blob: b3979bf5437fcbf2ae48a3e5f23e7c6e5ed71a3c [file] [log] [blame]
Daniel J Walshd6848ea2010-06-10 16:35:55 -04001#!/bin/bash
2## BEGIN INIT INFO
3# Provides: sandbox
4# Default-Start: 3 4 5
5# Default-Stop: 0 1 2 3 4 6
6# Required-Start:
7#
8## END INIT INFO
9# sandbox: Set up / mountpoint to be shared, /var/tmp, /tmp, /home/sandbox unshared
10#
11# chkconfig: 345 1 99
12#
Eric Parisf37a6a72011-08-08 15:47:43 -040013# description: sandbox, xguest and other apps that want to use pam_namespace \
14# require this script be run at boot. This service script does \
15# not actually run any service but sets up: \
Dan Walsh7a653ef2011-09-14 08:54:06 -040016# / to be shared by any app that starts a separate namespace
Eric Parisf37a6a72011-08-08 15:47:43 -040017# If you do not use sandbox, xguest or pam_namespace you can turn \
18# this service off.\
Daniel J Walshd6848ea2010-06-10 16:35:55 -040019#
20
21# Source function library.
Dan Walsh17fc79a2011-10-24 14:34:34 -040022. /etc/init.d/functions
Daniel J Walshd6848ea2010-06-10 16:35:55 -040023
24LOCKFILE=/var/lock/subsys/sandbox
25
26base=${0##*/}
27
Steve Lawrence582fd002010-06-10 16:37:59 -040028start() {
29 echo -n "Starting sandbox"
30
Dan Walshc00affc2011-11-10 12:16:07 -050031 [ -f "$LOCKFILE" ] && return 0
Daniel J Walshd6848ea2010-06-10 16:35:55 -040032
33 touch $LOCKFILE
Steve Lawrence582fd002010-06-10 16:37:59 -040034 mount --make-rshared / || return $?
Steve Lawrence582fd002010-06-10 16:37:59 -040035 return 0
36}
Daniel J Walshd6848ea2010-06-10 16:35:55 -040037
Steve Lawrence582fd002010-06-10 16:37:59 -040038stop() {
39 echo -n "Stopping sandbox"
40
41 [ -f "$LOCKFILE" ] || return 1
42}
43
44status() {
Daniel J Walshd6848ea2010-06-10 16:35:55 -040045 if [ -f "$LOCKFILE" ]; then
46 echo "$base is running"
47 else
48 echo "$base is stopped"
49 fi
50 exit 0
Steve Lawrence582fd002010-06-10 16:37:59 -040051}
52
53case "$1" in
54 restart)
55 start && success || failure
56 ;;
57
58 start)
59 start && success || failure
60 echo
Daniel J Walshd6848ea2010-06-10 16:35:55 -040061 ;;
62
63 stop)
Steve Lawrence582fd002010-06-10 16:37:59 -040064 stop && success || failure
65 echo
66 ;;
67
68 status)
69 status
Daniel J Walshd6848ea2010-06-10 16:35:55 -040070 ;;
71
72 *)
73 echo $"Usage: $0 {start|stop|status|restart}"
74 exit 3
75 ;;
76esac