root/oscgroups/trunk/OscGroupServerStartStop.sh

Revision 7, 2.1 kB (checked in by ross, 3 years ago)

import oscgroups project

Line 
1 #! /bin/sh
2 #
3 # This is a start/stop script to be used with the Linux init.d mechanism
4 # so that the OSCgroups server is restarted when Linux is restarted.
5 # To use this script, first edit the lines below so that OSCGROUPSERVER
6 # is the path to the OscGroupServer binary and LOGFILE is the path to
7 # a file where the server will write log messages. The PORT, MAXUSERS,
8 # MAXGROUPS and TIMEOUTSECONDS variables map to the corresponding 
9 # OscGroupServer parameters. You can also edit the USER variable to 
10 # execute the server as a different Unix user.
11 #
12 # to install this script place it in /etc/init.d (or link it using ln -s)
13 #
14 # then add it to the global startup/shutdown scripts using:
15 #
16 # $ update-rc.d OscGroupServerStartStop.sh defaults
17 #
18 # you can also run it manually using:
19 #
20 # $ OscGroupServerStartStop.sh start
21 #
22 # for more info see:
23 # man start-stop-daemon
24 # man update-rc.d
25 # cat /etc/init.d/skeleton
26 #
27
28 OSCGROUPSERVER=/root/oscgroups/OSCgroups/bin/OscGroupServer
29 LOGFILE=/root/logs/oscgroupserver.log
30 PORT=22242
31 TIMEOUTSECONDS=60
32 MAXUSERS=500
33 MAXGROUPS=500
34
35 PATH=/sbin:/bin:/usr/sbin:/usr/bin
36 DAEMON=$OSCGROUPSERVER
37 NAME="OscGroupServer"
38 DESC="OscGroupServer: OSCgroups NAT traversal daemon"
39 OPTIONS="-l $LOGFILE";
40 USER=root
41 PIDFILE=/var/run/$NAME.pid
42 STOPSIGNAL=INT
43
44 test -x $DAEMON || echo Error: $DAEMON missing or not executable
45 test -x $DEAMON || exit 0
46
47 set -e
48
49
50 d_start() {
51         start-stop-daemon --start --background --make-pidfile --pidfile $PIDFILE \
52                 --chuid $USER --exec $DAEMON -- $OPTIONS
53 }
54
55 d_stop() {
56         start-stop-daemon --stop --pidfile $PIDFILE \
57                 --signal $STOPSIGNAL
58 }
59
60 case "$1" in
61   start)
62         echo -n "Starting $DESC: $NAME"
63         d_start
64         echo "."
65         ;;
66   stop)
67         echo -n "Stopping $DESC: $NAME"
68         d_stop
69         echo "."
70         ;;
71  
72   restart|force-reload)
73         echo -n "Restarting $DESC: $NAME"
74         d_stop
75         sleep 1
76         d_start
77         echo "."
78         ;;
79   *)
80         echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
81         exit 1
82         ;;
83 esac
84
85 exit 0
86
Note: See TracBrowser for help on using the browser.