~clint-fewbar/ubuntu/oneiric/lxc/use-uec-for-natty

« back to all changes in this revision

Viewing changes to debian/lxc.init

  • Committer: Bazaar Package Importer
  • Author(s): Guido Trotter
  • Date: 2010-08-04 13:23:42 UTC
  • mfrom: (1.1.5 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100804132342-ds4lm3oaroeoxfxx
Tags: 0.7.2-1
* New upstream version
* Convert libcap dependency to versioned (closes: #571527)
* Bump up standards version to 3.9.0
* Fix too-deep /usr/lib/lxc/lxc path (closes: #587847)
* Add init script (closes: #573830)
  Thanks to Przemysław Knycz <pknycz@kolnet.eu> for the base example
* Bump up standards version (3.9.1)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# lxc containers starter script
 
3
# based on skeleton from Debian GNU/Linux
 
4
### BEGIN INIT INFO
 
5
# Provides:          lxc
 
6
# Required-Start:    $syslog $remote_fs
 
7
# Required-Stop:     $syslog $remote_fs
 
8
# Default-Start:     2 3 4 5
 
9
# Default-Stop:      0 1 6
 
10
# Short-Description: Linux Containers
 
11
# Description:       Linux Containers
 
12
### END INIT INFO
 
13
 
 
14
NAME=lxc
 
15
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
 
16
DESC="LXC containers"
 
17
 
 
18
SCRIPTNAME="/etc/init.d/lxc"
 
19
 
 
20
. /lib/lsb/init-functions
 
21
 
 
22
if [ -f /etc/default/$NAME ] ; then
 
23
  . /etc/default/$NAME
 
24
fi
 
25
 
 
26
if [ "x$RUN" != "xyes" ] ; then
 
27
  log_success_msg "$NAME init script disabled; edit /etc/default/$NAME"
 
28
  exit 0
 
29
fi
 
30
 
 
31
start_one() {
 
32
  name=$1
 
33
  if [ -f "$CONF_DIR/$name.conf" ]; then
 
34
    lxc-start -n $name -f $CONF_DIR/$name.conf -d
 
35
  else
 
36
    log_failure_msg "Can't find config file $CONF_DIR/$name.conf"
 
37
  fi
 
38
}
 
39
 
 
40
action_all() {
 
41
  action=$1
 
42
  nolog=$2
 
43
  for i in $CONTAINERS; do
 
44
    [ -n "$nolog" ] || log_progress_msg "$i"
 
45
    $action $i
 
46
  done
 
47
  [ -n "$nolog" ] || log_end_msg 0
 
48
}
 
49
 
 
50
case "$1" in
 
51
  start)
 
52
    log_daemon_msg "Starting $DESC"
 
53
    action_all start_one
 
54
    ;;
 
55
  stop)
 
56
    log_daemon_msg "Stopping $DESC"
 
57
    action_all "lxc-stop -n"
 
58
    ;;
 
59
  restart|force-reload)
 
60
    log_daemon_msg "Restarting $DESC"
 
61
    action_all start_one
 
62
    action_all "lxc-stop -n"
 
63
    ;;
 
64
  destroy)
 
65
    log_daemon_msg "Destroying $DESC"
 
66
    action_all "lxc-destroy -n"
 
67
    ;;
 
68
  freeze)
 
69
    log_daemon_msg "Freezing $DESC"
 
70
    action_all "lxc-freeze -n"
 
71
    ;;
 
72
  unfreeze)
 
73
    log_daemon_msg "Unfreezing $DESC"
 
74
    action_all "lxc-unfreeze -n"
 
75
    ;;
 
76
  info)
 
77
    log_daemon_msg "Info on $DESC" "$NAME"
 
78
    log_end_msg 0
 
79
    action_all "lxc-info -n" "nolog"
 
80
    ;;
 
81
  *)
 
82
    log_success_msg "Usage: $SCRIPTNAME {start|stop|force-reload|restart|destroy|freeze|unfreeze|info}"
 
83
    exit 1
 
84
    ;;
 
85
esac
 
86
 
 
87
exit 0