File: sandbox.init

package info (click to toggle)
android-platform-external-libselinux 8.1.0%2Br23-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 33,252 kB
  • sloc: ansic: 142,533; python: 23,929; makefile: 1,760; yacc: 1,367; sh: 1,108; lex: 448; xml: 176
file content (76 lines) | stat: -rw-r--r-- 1,370 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
## BEGIN INIT INFO
# Provides: sandbox
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 3 4 6
# Required-Start:
#              
## END INIT INFO
# sandbox:        Set up / mountpoint to be shared, /var/tmp, /tmp, /home/sandbox unshared
#
# chkconfig: 345 1 99
#
# description: sandbox, xguest and other apps that want to use pam_namespace \
#              require this script be run at boot.  This service script does \
#              not actually run any service but sets up: \
#              / to be shared by any app that starts a separate namespace
#              If you do not use sandbox, xguest or pam_namespace you can turn \
#              this service off.\
#

# Source function library.
. /etc/init.d/functions

LOCKFILE=/var/lock/subsys/sandbox

base=${0##*/}

start() {
	echo -n "Starting sandbox"

	[ -f "$LOCKFILE" ] && return 0

	touch $LOCKFILE
	mount --make-rshared / || return $? 
	return 0
}

stop() {
	echo -n "Stopping sandbox"

	[ -f "$LOCKFILE" ] || return 1
}

status() {
	if [ -f "$LOCKFILE" ]; then 
	    echo "$base is running"
	else
	    echo "$base is stopped"
	fi
	exit 0
}

case "$1" in
    restart)
	start && success || failure
	;;

    start)
	start && success || failure
	echo
	;;

    stop)
	stop && success || failure
	echo
	;;

    status)
	status
	;;

    *)
	echo $"Usage: $0 {start|stop|status|restart}"
	exit 3
	;;
esac