mirror of
https://github.com/rancher/os.git
synced 2025-08-01 23:17:50 +00:00
Merge pull request #1270 from joshwget/new-packet-installation-script
New Packet installation script
This commit is contained in:
commit
897cbb9e9f
@ -1,10 +0,0 @@
|
||||
# Packet Support
|
||||
|
||||
Launch a Type-0, Type-1 or Type-3 Ubuntu 14.04 server and use the below cloud config. You can add any additional RancherOS configuration to it, but below is the bare minimum you need to provision RancherOS.
|
||||
|
||||
```yaml
|
||||
#cloud-config
|
||||
runcmd:
|
||||
- wget -O /tmp/cc https://raw.githubusercontent.com/rancher/os/master/scripts/hosting/packet/packet.sh
|
||||
- bash -x /tmp/cc
|
||||
```
|
@ -1,4 +0,0 @@
|
||||
#cloud-config
|
||||
runcmd:
|
||||
- wget -O /tmp/cc https://raw.githubusercontent.com/rancher/os/master/scripts/hosting/packet/packet.sh
|
||||
- bash -x /tmp/cc
|
@ -1,96 +1,124 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if ros version >/dev/null 2>&1; then
|
||||
exit 0
|
||||
TINKERBELL_URL=$(cat /proc/cmdline | sed -e 's/^.*tinkerbell=//' -e 's/ .*$//')
|
||||
INSTALLER_IMAGE=rancher/os:v0.7.0-rc1
|
||||
|
||||
tinkerbell_post()
|
||||
{
|
||||
docker run rancher/curl -X POST -H "Content-Type: application/json" -d "{'type':'provisioning.$1'}" ${TINKERBELL_URL}
|
||||
}
|
||||
|
||||
tinkerbell_post 104
|
||||
|
||||
DEV_PREFIX=/dev/sd
|
||||
if [ -e /dev/vda ]; then
|
||||
DEV_PREFIX=/dev/vd
|
||||
fi
|
||||
|
||||
apt-get install -y jq curl
|
||||
BOOT=${DEV_PREFIX}a1
|
||||
BOOT_TYPE=83
|
||||
SWAP=${DEV_PREFIX}a5
|
||||
SWAP_TYPE=82
|
||||
OEM=${DEV_PREFIX}a6
|
||||
OEM_TYPE=83
|
||||
ROOT=${DEV_PREFIX}a7
|
||||
ROOT_TYPE=83
|
||||
RAID=false
|
||||
|
||||
mkdir -p /boot/ros
|
||||
|
||||
URL_BASE=https://releases.rancher.com/os/latest
|
||||
curl -L $URL_BASE/vmlinuz > /boot/ros/vmlinuz
|
||||
curl -L $URL_BASE/initrd > /boot/ros/initrd
|
||||
|
||||
eval $(curl -sL https://metadata.packet.net/metadata | jq -r '.network.addresses[] | select(.address_family == 4 and .public) | "ADDRESS=\(.address)/\(.cidr)\nGATEWAY=\(.gateway)"')
|
||||
eval $(curl -sL https://metadata.packet.net/metadata | jq -r '.network.interfaces[0] | "MAC=\(.mac)"')
|
||||
|
||||
cat > /etc/default/grub << "EOF"
|
||||
# If you change this file, run 'update-grub' afterwards to update
|
||||
# /boot/grub/grub.cfg.
|
||||
# For full documentation of the options in this file, see:
|
||||
# info -f grub -n 'Simple configuration'
|
||||
|
||||
GRUB_DEFAULT=ROS
|
||||
GRUB_HIDDEN_TIMEOUT=15
|
||||
GRUB_HIDDEN_TIMEOUT_QUIET=false
|
||||
GRUB_TIMEOUT=10
|
||||
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
|
||||
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS1,115200n8"
|
||||
GRUB_CMDLINE_LINUX=""
|
||||
|
||||
# Uncomment to enable BadRAM filtering, modify to suit your needs
|
||||
# This works with Linux (no patch required) and with any kernel that obtains
|
||||
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
|
||||
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
|
||||
|
||||
# Uncomment to disable graphical terminal (grub-pc only)
|
||||
GRUB_TERMINAL=console
|
||||
|
||||
# The resolution used on graphical terminal
|
||||
# note that you can use only modes which your graphic card supports via VBE
|
||||
# you can see them in real GRUB with the command `vbeinfo'
|
||||
#GRUB_GFXMODE=640x480
|
||||
|
||||
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
|
||||
#GRUB_DISABLE_LINUX_UUID=true
|
||||
|
||||
# Uncomment to disable generation of recovery mode menu entries
|
||||
#GRUB_DISABLE_RECOVERY="true"
|
||||
|
||||
# Uncomment to get a beep at grub start
|
||||
#GRUB_INIT_TUNE="480 440 1"
|
||||
GRUB_TERMINAL=serial
|
||||
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=1 --word=8 --parity=no --stop=1"
|
||||
EOF
|
||||
|
||||
cat > /etc/grub.d/50ros << EOF
|
||||
#!/bin/sh
|
||||
exec tail -n +3 \$0
|
||||
# This file provides an easy way to add custom menu entries. Simply type the
|
||||
# menu entries you want to add after this comment. Be careful not to change
|
||||
# the 'exec tail' line above.
|
||||
menuentry 'ROS' {
|
||||
recordfail
|
||||
load_video
|
||||
insmod gzio
|
||||
insmod part_msdos
|
||||
insmod part_msdos
|
||||
insmod diskfilter
|
||||
insmod mdraid1x
|
||||
insmod ext2
|
||||
linux /ros/vmlinuz rancher.state.mdadm_scan rancher.state.directory=ros rancher.network.interfaces.bond0.address=$ADDRESS rancher.network.interfaces.bond0.gateway=$GATEWAY rancher.network.interfaces.mac:${MAC}.bond=bond0 rancher.cloud_init.datasources=[packet] rancher.rm_usr console=tty0 console=ttyS1,115200n8
|
||||
initrd /ros/initrd
|
||||
}
|
||||
menuentry 'ROS Debug' {
|
||||
recordfail
|
||||
load_video
|
||||
insmod gzio
|
||||
insmod part_msdos
|
||||
insmod part_msdos
|
||||
insmod diskfilter
|
||||
insmod mdraid1x
|
||||
insmod ext2
|
||||
linux /ros/vmlinuz rancher.state.mdadm_scan rancher.state.directory=ros rancher.network.interfaces.bond0.address=$ADDRESS rancher.network.interfaces.bond0.gateway=$GATEWAY rancher.network.interfaces.mac:${MAC}.bond=bond0 rancher.cloud_init.datasources=[packet] rancher.rm_usr rancher.network.interfaces.eth*.dhcp=false console=tty0 console=ttyS1,115200n8 rancher.debug rancher.log
|
||||
initrd /ros/initrd
|
||||
wait_for_dev()
|
||||
{
|
||||
for DEV; do
|
||||
for ((i=0;i<10;i++)); do
|
||||
if [ ! -e $DEV ]; then
|
||||
partprobe || true
|
||||
sleep 1
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
modprobe md || true
|
||||
|
||||
dd if=/dev/zero of=${DEV_PREFIX}a bs=1M count=1
|
||||
|
||||
if [ -e ${DEV_PREFIX}b ]; then
|
||||
dd if=/dev/zero of=${DEV_PREFIX}b bs=1M count=1
|
||||
RAID=true
|
||||
BOOT=/dev/md1
|
||||
BOOT_TYPE=fd
|
||||
SWAP=/dev/md5
|
||||
SWAP_TYPE=fd
|
||||
OEM=/dev/md6
|
||||
OEM_TYPE=fd
|
||||
ROOT=/dev/md7
|
||||
ROOT_TYPE=fd
|
||||
fi
|
||||
|
||||
|
||||
# Partition BOOT
|
||||
echo -e "n\np\n1\n\n+2G\nt\n${BOOT_TYPE}\nw" | fdisk ${DEV_PREFIX}a || true
|
||||
partprobe || true
|
||||
# Partition Extended
|
||||
echo -e "n\ne\n\n\n\nw" | fdisk ${DEV_PREFIX}a || true
|
||||
partprobe || true
|
||||
# Partition SWAP
|
||||
echo -e "n\nl\n\n+2G\n\nt\n5\n${SWAP_TYPE}\nw" | fdisk ${DEV_PREFIX}a || true
|
||||
partprobe || true
|
||||
# Partition OEM
|
||||
echo -e "n\nl\n\n+100M\n\nt\n6\n${OEM_TYPE}\nw" | fdisk ${DEV_PREFIX}a || true
|
||||
partprobe || true
|
||||
# Partition ROOT
|
||||
echo -e "n\nl\n\n\n\nt\n7\n${ROOT_TYPE}\nw" | fdisk ${DEV_PREFIX}a || true
|
||||
partprobe || true
|
||||
# Make boot active
|
||||
echo -e "a\n1\nw" | fdisk ${DEV_PREFIX}a || true
|
||||
partprobe || true
|
||||
|
||||
if [ "$RAID" = "true" ]; then
|
||||
sfdisk --dump ${DEV_PREFIX}a | sfdisk --no-reread ${DEV_PREFIX}b
|
||||
|
||||
wait_for_dev ${DEV_PREFIX}b1 ${DEV_PREFIX}b5 ${DEV_PREFIX}b6 ${DEV_PREFIX}b7 ${DEV_PREFIX}a1 ${DEV_PREFIX}a5 ${DEV_PREFIX}a6 ${DEV_PREFIX}a7
|
||||
|
||||
mdadm --create $BOOT --level=1 --metadata=1.0 --raid-devices=2 ${DEV_PREFIX}a1 ${DEV_PREFIX}b1
|
||||
mdadm --create $SWAP --level=1 --metadata=1.2 --raid-devices=2 ${DEV_PREFIX}a5 ${DEV_PREFIX}b5
|
||||
mdadm --create $OEM --level=1 --metadata=1.2 --raid-devices=2 ${DEV_PREFIX}a6 ${DEV_PREFIX}b6
|
||||
mdadm --create $ROOT --level=1 --metadata=1.2 --raid-devices=2 ${DEV_PREFIX}a7 ${DEV_PREFIX}b7
|
||||
fi
|
||||
|
||||
mkswap -L RANCHER_SWAP $SWAP
|
||||
system-docker run --privileged --entrypoint /bin/bash ${INSTALLER_IMAGE} -c "mkfs.ext4 -L RANCHER_BOOT $BOOT"
|
||||
system-docker run --privileged --entrypoint /bin/bash ${INSTALLER_IMAGE} -c "mkfs.ext4 -L RANCHER_STATE $ROOT"
|
||||
system-docker run --privileged --entrypoint /bin/bash ${INSTALLER_IMAGE} -c "mkfs.ext4 -L RANCHER_OEM $OEM"
|
||||
|
||||
tinkerbell_post 105
|
||||
|
||||
mkdir -p /mnt/oem
|
||||
mount $(ros dev LABEL=RANCHER_OEM) /mnt/oem
|
||||
cat > /mnt/oem/oem-config.yml << EOF
|
||||
#cloud-config
|
||||
mounts:
|
||||
- [ LABEL=RANCHER_SWAP, "", swap, "" ]
|
||||
EOF
|
||||
umount /mnt/oem
|
||||
|
||||
chmod +x /etc/grub.d/50ros
|
||||
tinkerbell_post 106
|
||||
|
||||
update-grub2
|
||||
METADATA=$(docker run rancher/curl -sL https://metadata.packet.net/metadata)
|
||||
eval $(echo ${METADATA} | jq -r '.network.addresses[] | select(.address_family == 4 and .public) | "ADDRESS=\(.address)/\(.cidr)\nGATEWAY=\(.gateway)"')
|
||||
eval $(echo ${METADATA} | jq -r '.network.interfaces[0] | "MAC=\(.mac)"')
|
||||
NETWORK_ARGS="rancher.network.interfaces.bond0.address=$ADDRESS rancher.network.interfaces.bond0.gateway=$GATEWAY rancher.network.interfaces.mac:${MAC}.bond=bond0"
|
||||
|
||||
tune2fs -L RANCHER_STATE $(df -h / | sed 1d | awk '{print $1}')
|
||||
tinkerbell_post 107
|
||||
|
||||
COMMON_ARGS="console=ttyS1,115200n8 rancher.cloud_init.datasources=[packet] ${NETWORK_ARGS}"
|
||||
if [ "$RAID" = "true" ]; then
|
||||
ros install -f -t raid -i ${INSTALLER_IMAGE} -d ${DEV_PREFIX}a -a "rancher.state.mdadm_scan ${COMMON_ARGS}" --no-reboot
|
||||
else
|
||||
ros install -f -t noformat -i ${INSTALLER_IMAGE} -d ${DEV_PREFIX}a -a "${COMMON_ARGS}" --no-reboot
|
||||
fi
|
||||
|
||||
tinkerbell_post 108
|
||||
reboot
|
||||
|
Loading…
Reference in New Issue
Block a user