added Vector_zeroEnd() function
[util-vserver.git] / util-vserver / sysv / vprocunhide
1 #!/bin/bash
2 #
3 # vprocunhide  sets vserver related attributes for /proc
4 #
5 # chkconfig: 2345 26 74
6 # description: Makes some /proc entries visibly for vservers
7
8 : ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
9 test -e "$UTIL_VSERVER_VARS" || {
10     echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
11     exit 1
12 }
13 . "$UTIL_VSERVER_VARS"
14
15 f=/etc/rc.d/init.d/functions
16 if test -e "$f"; then
17     . "$f"
18     lockfile=/var/lock/subsys/vprocunhide
19 else
20     success() { echo .; }
21     passed()  { echo .; }
22     failure() { echo ERROR; }
23     lockfile=/var/run/vprocunhide
24 fi
25
26
27 function start()
28 {
29     echo -n $"Fixing /proc entries visibility..."
30     $_VPROCUNHIDE
31     retval=$?
32     case "$retval" in
33         0)      success;;
34         2)      passed; retval=0;;
35         *)      failure;
36     esac
37     echo
38     test "$retval" -ne 0 || touch "$lockfile"
39     return $retval
40 }
41
42 function stop()
43 {
44     rm -f "$lockfile"
45 }
46
47 function restart()
48 {
49     stop
50     start
51 }
52
53 case "$1" in
54     start|stop|restart) $1;;
55     reload)             ;;
56     condrestart)
57         test -f $lockfile && restart || :
58         ;;
59     status)
60         test -f $lockfile && {
61             echo $"/proc entries were fixed"
62             exit 0
63         }
64         echo $"/proc entries are not fixed"
65         exit 1
66         ;;
67     *)
68         echo "Usage: $0 {start|stop|reload|restart|condrestart|status}"
69         exit 2
70         ;;
71 esac