-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrc.local
More file actions
executable file
·29 lines (23 loc) · 894 Bytes
/
rc.local
File metadata and controls
executable file
·29 lines (23 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
set -ex
function echo_red {
echo -e "\033[0;31m$1\033[0m"
}
function error_handler () {
set +ex
echo_red "An error occured while bootstrapping CoreOS."
while true; do sleep 1; done
exit 1
}
trap error_handler ERR
# create coreos cloud-config
PUBLIC_IP=$(/sbin/ip -4 -o addr show dev eth0 | awk '{ print $4; }')
PRIVATE_IP=$(/sbin/ip -4 -o addr show dev eth1 | awk '{ print $4; }')
GATEWAY=$(/sbin/ip route | awk '/default/ { print $3 }')
SSH_KEY="$(cat /root/.ssh/authorized_keys | head -n1)"
sed "s,HOSTNAME,$HOSTNAME,;s,PUBLIC_IP,$PUBLIC_IP,;s,PRIVATE_IP,$PRIVATE_IP,;s,GATEWAY,$GATEWAY,;s,SSH_KEY,$SSH_KEY," /usr/share/oem/cloud-config.yml.template > /usr/share/oem/cloud-config.yml
# download coreos, kernel and create initrd
/usr/sbin/update-coreos
# run CoreOS kernel
/sbin/kexec --load /boot/coreos/vmlinuz --initrd /boot/coreos/initrd.cpio.gz
/sbin/kexec --exec