| #!/bin/bash |
| |
| function psg() { |
| ps awwux | grep -v grep | grep $1 |
| } |
| function botdo() { |
| sudo -u buildbot $* |
| } |
| |
| if [[ $UID != 0 ]]; then |
| echo "Not root? Run 'sudo $0'" |
| exit 1 |
| fi |
| |
| mounted=`mount | grep external` |
| if [[ $mounted = '' ]]; then |
| echo "Mounting /external" |
| in_fstab=`grep external /etc/fstab` |
| if [[ $in_fstab != '' ]]; then |
| mount /external |
| else |
| mount -t ext4 /dev/sda1 /external |
| fi |
| fi |
| |
| running=`/etc/init.d/ssh status | grep 'is running'` |
| if [[ $running = '' ]]; then |
| echo "Starting SSH daemon" |
| iptables -P INPUT ACCEPT |
| /etc/init.d/ssh start |
| fi |
| |
| running=`psg powerd` |
| if [[ $running != '' ]]; then |
| echo "Stopping powerd" |
| stop powerd |
| fi |
| |
| buildbot_root=/external/buildbot |
| running=`psg buildslave` |
| if [[ $running = '' ]]; then |
| echo "Starting buildbot" |
| if [ -f $buildbot_root/twistd.pid ]; then |
| botdo buildslave stop $buildbot_root |
| fi |
| botdo buildslave start $buildbot_root |
| fi |
| |
| echo "System initialized correctly" |