forked from lutris/buildbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-container.sh
executable file
·46 lines (40 loc) · 1.22 KB
/
setup-container.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
#!/bin/bash
set -x
container=$1
user='ubuntu'
InstallDependencies() {
sudo lxc file push setup-buildbot.sh $container/home/$user/
sudo lxc exec $container -- sudo bash -c /home/$user/setup-buildbot.sh
}
SetupSSH() {
sudo lxc exec $container -- mkdir -p /home/$user/.ssh
sudo lxc exec $container -- chown $user /home/$user/.ssh
sudo lxc file push ~/.ssh/config $container/home/$user/.ssh/
}
SetupUserspace() {
sudo lxc exec $container -- git clone https://github.com/lutris/buildbot.git /home/$user/buildbot
sudo lxc exec $container -- chown -R ubuntu:ubuntu /home/$user/buildbot
}
SetupHost() {
if [[ $container == *"64"* ]]; then
other_container="${container%amd64}i386"
other_hostname="buildbot32"
else
other_container="${container%i386}amd64"
other_hostname="buildbot64"
fi
other_ip=$(sudo lxc list $other_container -c 4 | grep eth0 | cut -d" " -f 2)
if [[ "$other_ip" = "" ]]; then
echo "Other container $other_container is not reachable"
exit 2
fi
sudo lxc exec $container -- bash -c "echo $other_ip $other_hostname >> /etc/hosts"
}
if [ $2 ]; then
$2
else
InstallDependencies
SetupHost
SetupSSH
SetupUserspace
fi