blob: 19346ce093b3850e305a788a7abf21a7f555df83 [file] [log] [blame]
Renato Golin94cc1042016-04-26 11:02:23 +01001#!/bin/bash
2
3function psg() {
4 ps awwux | grep -v grep | grep $1
5}
6function botdo() {
7 sudo -u buildbot $*
8}
9
10if [[ $UID != 0 ]]; then
11 echo "Not root? Run 'sudo $0'"
12 exit 1
13fi
14
15mounted=`mount | grep external`
16if [[ $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
24fi
25
26running=`/etc/init.d/ssh status | grep 'is running'`
27if [[ $running = '' ]]; then
28 echo "Starting SSH daemon"
29 iptables -P INPUT ACCEPT
30 /etc/init.d/ssh start
31fi
32
33running=`psg powerd`
34if [[ $running != '' ]]; then
35 echo "Stopping powerd"
36 stop powerd
37fi
38
39buildbot_root=/external/buildbot
40running=`psg buildslave`
41if [[ $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
47fi
48
49echo "System initialized correctly"