-
Notifications
You must be signed in to change notification settings - Fork 11
/
initd_service.sh
52 lines (45 loc) · 1.38 KB
/
initd_service.sh
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
#!/bin/sh
#
# Wrapper to all scripts in /etc/init.d.
# Takes 3 args: start, stop and restart
#
INIT=/etc/init.d
PROGRAM=$1
ACTION=$2
usage () {
echo "$0 program { start | stop | restart }"
}
USERID=`id | awk '{print $1}'`
if [ "$USERID" != "uid=0(root)" ]; then
echo "You must be root to run this script"
exit 1
fi
if [ -x "${INIT}/$PROGRAM" ]; then
if [ "$ACTION" != "start" -a "$ACTION" != "stop" -a "$ACTION" !=
restart ]; then
usage
exit 1
fi
if [ "$ACTION" = restart ]; then
${INIT}/${PROGRAM} stop && echo "$PROGRAM stopped"
${INIT}/${PROGRAM} start && echo "$PROGRAM started"
else
${INIT}/${PROGRAM} ${ACTION} && echo "$PROGRAM
${ACTION}ed"
fi
else
echo "program $PROGRAM not found in $INIT"
usage
exit 1
fi
##############################################################################
### This script is submitted to BigAdmin by a user of the BigAdmin community.
### Sun Microsystems, Inc. is not responsible for the
### contents or the code enclosed.
###
###
### Copyright 2005 Sun Microsystems, Inc. ALL RIGHTS RESERVED
### Use of this software is authorized pursuant to the
### terms of the license found at
### http://www.sun.com/bigadmin/common/berkeley_license.html
##############################################################################