| Line | |
|---|
| 1 | #!/bin/bash |
|---|
| 2 | |
|---|
| 3 | PATH=/usr/sbin:/usr/bin:/sbin:/bin |
|---|
| 4 | export PATH |
|---|
| 5 | |
|---|
| 6 | set -x |
|---|
| 7 | |
|---|
| 8 | mount /proc |
|---|
| 9 | |
|---|
| 10 | booturl=http://10.33.0.1:8000 |
|---|
| 11 | insturl=http://10.33.0.1/profiles |
|---|
| 12 | |
|---|
| 13 | eval `cat /proc/cmdline | tr " " "\n" | grep booturl=` |
|---|
| 14 | eval `cat /proc/cmdline | tr " " "\n" | grep insturl=` |
|---|
| 15 | |
|---|
| 16 | # usb setup |
|---|
| 17 | if grep -q ' usb' /proc/cmdline; then |
|---|
| 18 | modprobe ohci-hcd |
|---|
| 19 | modprobe ehci-hcd |
|---|
| 20 | modprobe usbhid |
|---|
| 21 | fi |
|---|
| 22 | |
|---|
| 23 | # setup network |
|---|
| 24 | pciids=`lspci -n|grep ' 0200: '|sed 's/.*\([0-9a-f]\{4\}\):\([0-9a-f]\{4\}\).*/0x0000\1 0x0000\2/'|sort -u` |
|---|
| 25 | kver=`uname -r` |
|---|
| 26 | |
|---|
| 27 | for pciid in $pciids; do |
|---|
| 28 | modules=`grep "$pciid" /lib/modules/$kver/modules.pcimap |cut -f1 -d' '|sort -u` |
|---|
| 29 | |
|---|
| 30 | for module in $modules; do |
|---|
| 31 | modprobe $module && break |
|---|
| 32 | done |
|---|
| 33 | done |
|---|
| 34 | |
|---|
| 35 | dhclient eth0 |
|---|
| 36 | |
|---|
| 37 | # request install script from the server |
|---|
| 38 | mac=`ifconfig |grep HWaddr|sed -e 's/.*HWaddr //' -e 's/-/:/' -e 's/ *//g' |head -1` |
|---|
| 39 | profile=`wget -q -O- $booturl/profile/` |
|---|
| 40 | wget -q $insturl/$profile/install.script || wget -q $insturl/install.script |
|---|
| 41 | export profile |
|---|
| 42 | chmod +x install.script |
|---|
| 43 | ./install.script 2>&1 | tee log |
|---|
| 44 | |
|---|
| 45 | # request localboot if the install script exited with a good status |
|---|
| 46 | if [ $? = 0 ]; then |
|---|
| 47 | wget -q $booturl/localboot/ |
|---|
| 48 | else |
|---|
| 49 | echo "failed install" |
|---|
| 50 | fi |
|---|
| 51 | |
|---|
| 52 | # if debug is passed on the cmdline of the kernel, launch a shell else reboot |
|---|
| 53 | if grep -q ' debug' /proc/cmdline; then |
|---|
| 54 | exec /bin/bash |
|---|
| 55 | else |
|---|
| 56 | reboot -f |
|---|
| 57 | fi |
|---|
| 58 | |
|---|
| 59 | # init ends here |
|---|