OSDN Git Service

PAUSED is changed to SUSPENDED.
[fulcon/Fulcon.git] / src / slot-os / start
1 #!/bin/bash
2
3 # Copyright (C) 2016 NIWA Hideyuki
4
5 FULCONDRIVER=`fulcon driver-name`
6 PATH=/usr/lib/slot-os/lib:/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
7
8 FULCONDIR=/var/lib/fulcon
9 SLOTOSDIR=/var/lib/slot-os
10
11 usage()
12 {
13         echo "usage: start NUMBER ..."
14         echo "usage: start all"
15 }
16
17 lsdir() {
18   ls -f --ind=none $1 | sed '/^\.\{1,2\}$/d'
19 }
20
21
22 if [ $# -lt 1 ]; then
23         usage
24         exit -1
25 fi
26
27 RCODE=0
28
29 SNUMS=$*
30 if [ x"$1" == x"all" ]; then
31         SNUMS=`ls $SLOTOSDIR/slot | sort -n`
32 fi
33
34 for SNUM in $SNUMS
35 do
36         if [ ! -x $SLOTOSDIR/slot/$SNUM ]; then
37                 printf "error: slot%2d is not exist\n" $SNUM
38                 RCODE=-1
39                 continue
40         fi
41
42         NAME=`printf "slot%02d" $SNUM`
43         if [ x"`fulcon status $NAME`" == x"SUSPENDED" ]; then
44                 fulcon resume $NAME
45         fi
46
47         rm -rf $SLOTOSDIR/slot/$SNUM/net
48         mkdir -p $FULCONDIR/container/$NAME/net
49         cp -pr $FULCONDIR/container/$NAME/net $SLOTOSDIR/slot/$SNUM/
50
51         fulcon start $NAME >& /dev/null 
52
53         echo start $NAME
54 done
55
56 exit $RCODE
57