forked from artpol84/slxc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
slxc-run-machine.sh
executable file
·62 lines (50 loc) · 1.23 KB
/
slxc-run-machine.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
if [ -z "$1" ]; then
echo "Need machine name!"
exit 1
fi
mname="$1"
. ./slxc.conf
# Full path to BUILD
bkp=`pwd`
cd $BUILD
BUILD=`pwd`
cd $bkp
CONTAINERS_DIR="$BUILD/containers"
FSTAB="$BUILD/fstab"
MACHINE_INIT_SCRIPT="$BUILD/machine_init.sh"
CONFIG="$CONTAINERS_DIR/$mname.conf"
MACHINEFILE="$BUILD/machines"
DNSMASQFILE="$BUILD/dnsmasq.conf"
IPFILE="$BUILD/ipnumbering"
CHECK_DIRS="$CONTAINERS_DIR"
CHECK_FILES="$FSTAB $MACHINE_INIT_SCRIPT $CONFIG $MACHINEFILE $DNSMASQFILE $IPFILE"
# Find the machine
if [ ! -f "$MACHINEFILE" ]; then
echo "No mandatory file $i found. Check consistency!"
exit 1
fi
machine_ok=0
for i in `cat $MACHINEFILE`; do
if [ "$i" = "$mname" ]; then
machine_ok=1
fi
done
if [ "$machine_ok" = "0" ]; then
echo "Cannot start machine $mname. Create it first."
exit 0
fi
# Check other mandatory files
for i in $CHECK_DIRS; do
if [ ! -d "$i" ]; then
echo "No mandatory directory $i found. Check consistency!"
exit 1
fi
done
for i in $CHECK_FILES; do
if [ ! -f "$i" ]; then
echo "No mandatory file $i found. Check consistency!"
exit 1
fi
done
screen -d -m -S $mname -t $mname `which lxc-execute` -n $mname -f $CONFIG $MACHINE_INIT_SCRIPT