OSDN Git Service

d957100c9eecd1b022c9aced7dea667cfe0aca0c
[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=`cat $SLOTOSDIR/slot/$SNUM/fulcon`
43         if [ x"$NAME" == x"-" -o x"$NAME" == x"" ]; then
44                 printf "error: slot%2d has not a container\n" $SNUM
45                 RCODE=-1
46                 continue
47         fi
48
49         rm -rf $SLOTOSDIR/slot/$SNUM/net
50         cp -pr $FULCONDIR/container/$NAME/net $SLOTOSDIR/slot/$SNUM/
51
52         fulcon start $NAME >& /dev/null &
53
54         echo start $NAME
55 done
56
57 exit $RCODE
58