| 1 | #! /bin/sh |
|---|
| 2 | |
|---|
| 3 | ### BEGIN INIT INFO |
|---|
| 4 | # Provides: openct |
|---|
| 5 | # Required-Start: $syslog |
|---|
| 6 | # Required-Stop: $syslog |
|---|
| 7 | # Should-Start: $local_fs |
|---|
| 8 | # Should-Stop: $local_fs |
|---|
| 9 | # Default-Start: 2 3 4 5 |
|---|
| 10 | # Default-Stop: 0 1 6 |
|---|
| 11 | # Short-Description: smart card terminal framework |
|---|
| 12 | # Description: Initialize the OpenCT smart card terminal |
|---|
| 13 | # framework. |
|---|
| 14 | ### END INIT INFO |
|---|
| 15 | |
|---|
| 16 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin |
|---|
| 17 | DAEMON=@sbindir@/openct-control |
|---|
| 18 | STATUS_DIR="@OPENCT_SOCKET_PATH@" |
|---|
| 19 | STATUS_FILE="$STATUS_DIR/status" |
|---|
| 20 | NAME=OpenCT |
|---|
| 21 | DESC="smart card terminal framework" |
|---|
| 22 | |
|---|
| 23 | test -x $DAEMON || exit 0 |
|---|
| 24 | |
|---|
| 25 | # create the directory for our status and socket files, |
|---|
| 26 | # if it does not exist. |
|---|
| 27 | if ! test -e "$STATUS_DIR" |
|---|
| 28 | then |
|---|
| 29 | mkdir "$STATUS_DIR" |
|---|
| 30 | |
|---|
| 31 | # maybe you also want to set owner ship and permissions here. |
|---|
| 32 | # this example would assign the directory to a group "scard" |
|---|
| 33 | # and set permissions so only users in that group can access |
|---|
| 34 | # smart card readers via openct. |
|---|
| 35 | #chown root:scard "$STATUS_DIR" |
|---|
| 36 | #chmod 0750 "$STATUS_DIR" |
|---|
| 37 | fi |
|---|
| 38 | |
|---|
| 39 | set -e |
|---|
| 40 | |
|---|
| 41 | case "$1" in |
|---|
| 42 | start) |
|---|
| 43 | echo -n "Starting $DESC: $NAME" |
|---|
| 44 | $DAEMON init |
|---|
| 45 | echo "." |
|---|
| 46 | ;; |
|---|
| 47 | stop) |
|---|
| 48 | echo -n "Stopping $DESC: $NAME " |
|---|
| 49 | if [ -f $STATUS_FILE ]; then |
|---|
| 50 | $DAEMON shutdown |
|---|
| 51 | rm -f $STATUS_FILE |
|---|
| 52 | fi |
|---|
| 53 | echo "." |
|---|
| 54 | ;; |
|---|
| 55 | #reload) |
|---|
| 56 | # |
|---|
| 57 | # If the daemon can reload its config files on the fly |
|---|
| 58 | # for example by sending it SIGHUP, do it here. |
|---|
| 59 | # |
|---|
| 60 | # If the daemon responds to changes in its config file |
|---|
| 61 | # directly anyway, make this a do-nothing entry. |
|---|
| 62 | # |
|---|
| 63 | # echo -n "Reloading $DESC configuration..." |
|---|
| 64 | # start-stop-daemon --stop --signal 1 --quiet --pidfile \ |
|---|
| 65 | # @localstatedir@/run/$NAME.pid --exec $DAEMON |
|---|
| 66 | # echo "done." |
|---|
| 67 | #;; |
|---|
| 68 | restart|force-reload) |
|---|
| 69 | # |
|---|
| 70 | # If the "reload" option is implemented, move the "force-reload" |
|---|
| 71 | # option to the "reload" entry above. If not, "force-reload" is |
|---|
| 72 | # just the same as "restart". |
|---|
| 73 | # |
|---|
| 74 | echo -n "Restarting $DESC: $NAME" |
|---|
| 75 | if [ -f $STATUS_FILE ]; then |
|---|
| 76 | $DAEMON shutdown |
|---|
| 77 | rm -f $STATUS_FILE |
|---|
| 78 | fi |
|---|
| 79 | sleep 0.1 |
|---|
| 80 | $DAEMON init |
|---|
| 81 | echo "." |
|---|
| 82 | ;; |
|---|
| 83 | *) |
|---|
| 84 | N=/etc/init.d/$NAME |
|---|
| 85 | # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 |
|---|
| 86 | echo "Usage: $N {start|stop|restart|force-reload}" >&2 |
|---|
| 87 | exit 1 |
|---|
| 88 | ;; |
|---|
| 89 | esac |
|---|
| 90 | |
|---|
| 91 | exit 0 |
|---|