Daniel J Walsh | d6848ea | 2010-06-10 16:35:55 -0400 | [diff] [blame] | 1 | #!/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 Paris | f37a6a7 | 2011-08-08 15:47:43 -0400 | [diff] [blame] | 13 | # 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 Walsh | 7a653ef | 2011-09-14 08:54:06 -0400 | [diff] [blame] | 16 | # / to be shared by any app that starts a separate namespace |
Eric Paris | f37a6a7 | 2011-08-08 15:47:43 -0400 | [diff] [blame] | 17 | # If you do not use sandbox, xguest or pam_namespace you can turn \ |
| 18 | # this service off.\ |
Daniel J Walsh | d6848ea | 2010-06-10 16:35:55 -0400 | [diff] [blame] | 19 | # |
| 20 | |
| 21 | # Source function library. |
Dan Walsh | 17fc79a | 2011-10-24 14:34:34 -0400 | [diff] [blame] | 22 | . /etc/init.d/functions |
Daniel J Walsh | d6848ea | 2010-06-10 16:35:55 -0400 | [diff] [blame] | 23 | |
| 24 | LOCKFILE=/var/lock/subsys/sandbox |
| 25 | |
| 26 | base=${0##*/} |
| 27 | |
Steve Lawrence | 582fd00 | 2010-06-10 16:37:59 -0400 | [diff] [blame] | 28 | start() { |
| 29 | echo -n "Starting sandbox" |
| 30 | |
Dan Walsh | c00affc | 2011-11-10 12:16:07 -0500 | [diff] [blame] | 31 | [ -f "$LOCKFILE" ] && return 0 |
Daniel J Walsh | d6848ea | 2010-06-10 16:35:55 -0400 | [diff] [blame] | 32 | |
| 33 | touch $LOCKFILE |
Steve Lawrence | 582fd00 | 2010-06-10 16:37:59 -0400 | [diff] [blame] | 34 | mount --make-rshared / || return $? |
Steve Lawrence | 582fd00 | 2010-06-10 16:37:59 -0400 | [diff] [blame] | 35 | return 0 |
| 36 | } |
Daniel J Walsh | d6848ea | 2010-06-10 16:35:55 -0400 | [diff] [blame] | 37 | |
Steve Lawrence | 582fd00 | 2010-06-10 16:37:59 -0400 | [diff] [blame] | 38 | stop() { |
| 39 | echo -n "Stopping sandbox" |
| 40 | |
| 41 | [ -f "$LOCKFILE" ] || return 1 |
| 42 | } |
| 43 | |
| 44 | status() { |
Daniel J Walsh | d6848ea | 2010-06-10 16:35:55 -0400 | [diff] [blame] | 45 | if [ -f "$LOCKFILE" ]; then |
| 46 | echo "$base is running" |
| 47 | else |
| 48 | echo "$base is stopped" |
| 49 | fi |
| 50 | exit 0 |
Steve Lawrence | 582fd00 | 2010-06-10 16:37:59 -0400 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | case "$1" in |
| 54 | restart) |
| 55 | start && success || failure |
| 56 | ;; |
| 57 | |
| 58 | start) |
| 59 | start && success || failure |
| 60 | echo |
Daniel J Walsh | d6848ea | 2010-06-10 16:35:55 -0400 | [diff] [blame] | 61 | ;; |
| 62 | |
| 63 | stop) |
Steve Lawrence | 582fd00 | 2010-06-10 16:37:59 -0400 | [diff] [blame] | 64 | stop && success || failure |
| 65 | echo |
| 66 | ;; |
| 67 | |
| 68 | status) |
| 69 | status |
Daniel J Walsh | d6848ea | 2010-06-10 16:35:55 -0400 | [diff] [blame] | 70 | ;; |
| 71 | |
| 72 | *) |
| 73 | echo $"Usage: $0 {start|stop|status|restart}" |
| 74 | exit 3 |
| 75 | ;; |
| 76 | esac |