Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | function psg() { |
| 4 | ps awwux | grep -v grep | grep $1 |
| 5 | } |
| 6 | function botdo() { |
| 7 | sudo -u buildbot $* |
| 8 | } |
| 9 | |
| 10 | if [[ $UID != 0 ]]; then |
| 11 | echo "Not root? Run 'sudo $0'" |
| 12 | exit 1 |
| 13 | fi |
| 14 | |
| 15 | mounted=`mount | grep external` |
| 16 | if [[ $mounted = '' ]]; then |
| 17 | echo "Mounting /external" |
| 18 | in_fstab=`grep external /etc/fstab` |
| 19 | if [[ $in_fstab != '' ]]; then |
| 20 | mount /external |
| 21 | else |
| 22 | mount -t ext4 /dev/sda1 /external |
| 23 | fi |
| 24 | fi |
| 25 | |
| 26 | running=`/etc/init.d/ssh status | grep 'is running'` |
| 27 | if [[ $running = '' ]]; then |
| 28 | echo "Starting SSH daemon" |
| 29 | iptables -P INPUT ACCEPT |
| 30 | /etc/init.d/ssh start |
| 31 | fi |
| 32 | |
| 33 | running=`psg powerd` |
| 34 | if [[ $running != '' ]]; then |
| 35 | echo "Stopping powerd" |
| 36 | stop powerd |
| 37 | fi |
| 38 | |
| 39 | buildbot_root=/external/buildbot |
| 40 | running=`psg buildslave` |
| 41 | if [[ $running = '' ]]; then |
| 42 | echo "Starting buildbot" |
| 43 | if [ -f $buildbot_root/twistd.pid ]; then |
| 44 | botdo buildslave stop $buildbot_root |
| 45 | fi |
| 46 | botdo buildslave start $buildbot_root |
| 47 | fi |
| 48 | |
| 49 | echo "System initialized correctly" |