-
Notifications
You must be signed in to change notification settings - Fork 1
/
load.sh
executable file
·56 lines (47 loc) · 1.37 KB
/
load.sh
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# stubbing out networking detection for vlans and static ips
# ip=dhcp
# address=1.2.3.4 netmask=255.255.255.0 gateway=1.2.3.1 vlan=212 BOOTIF=${netX/mac} dns=1.1.1.1
# determine interface from given mac on kernel command-line
# modprobe 8021q
# vconfig add eth0 212
#ifconfig eth0.212 1.2.3.4 netmask 255.255.255.0 up
#route add default gw 192.168.254.1
#set dns resolve.conf
# if dhcp use dhclient <interface>
#
core_update()
{
if grep -qs "core_sha=" /proc/cmdline
then
echo "[core] SHA specified... checking out core to specified SHA..."
CORE_SHA=`cat /proc/cmdline | grep -o 'core_sha=[^ ,]\+' | awk -F'=' {'print $2'}`
mv /opt/core /opt/core.orig
git clone --branch ${CORE_SHA} [email protected]:netbootxyz/core.git /opt/core
fi
}
core_check()
{
if ! grep -qs "playbook=" /proc/cmdline
then
echo "[core] Playbook not set... not doing anything..."
exit 0
fi
echo "[core] Playbook set... linking playbook to run on boot..."
PLAYBOOK=`cat /proc/cmdline | grep -o 'playbook=[^ ,]\+' | awk -F'=' {'print $2'}`
ln -s /opt/core/$PLAYBOOK.yml /opt/core/playbook.yml
}
run_playbook()
{
cd /opt/core
ansible-playbook -i localhost playbook.yml
}
main()
{
core_update
core_check
run_playbook
# keep container open for debug... maybe we make this adjustable via cmdline
sleep 1200
}
main