~ubuntu-branches/ubuntu/karmic/trousers/karmic

« back to all changes in this revision

Viewing changes to debian/trousers.init

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-01-23 22:03:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080123220300-fhtqja3c0oq0gp6z
Tags: 0.3.1-4
* Added patch from Aaron M. Ucko <ucko@debian.org> to allow trousers to
  build successfully on amd64, and presumably also other 64-bit
  architectures (Closes: #457400).
* Including udev rule for /dev/tpm from William Lima
  <wlima.amadeus@gmail.com> as suggested by David Smith <dds@google.com>
  (Closes: #459682).
* Added lintian overrides.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash
 
1
#!/bin/sh
 
2
 
2
3
### BEGIN INIT INFO
3
 
# Provides:          trousers
4
 
# Required-Start:    $local_fs $network
5
 
# Required-Stop:
6
 
# Should-Start:      udev
 
4
# Provides:             tcsd
 
5
# Required-Start:       $local_fs
 
6
# Required-Stop:        $local_fs
 
7
# Should-Start:
7
8
# Should-Stop:
8
 
# Default-Start:     2 3 4 5
9
 
# Default-Stop:      S 0 1 6
10
 
# Short-Description: Start or stop TrouSerS tcsd daemon.
11
 
# Description:
 
9
# Default-Start:        2 3 4 5
 
10
# Default-Stop:         0 1 6
 
11
# Short-Description:    starts tcsd
 
12
# Description:          tcsd belongs to the TrouSerS TCG Software Stack
12
13
### END INIT INFO
13
14
 
 
15
PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
16
DAEMON=/usr/sbin/tcsd
 
17
NAME=tcsd
 
18
DESC="Trusted Computing daemon"
 
19
 
 
20
test -x $DAEMON || exit 0
 
21
 
14
22
set -e
15
23
 
16
 
DESC="TrouSerS TCS daemon"
17
 
NAME=tcsd
18
 
DAEMON=/usr/sbin/tcsd
19
 
DEFAULTFILE=/etc/default/trousers
20
 
 
21
 
[ -x $DAEMON ] || exit 0
22
 
 
23
 
[ -f $DEFAULTFILE ] && . $DEFAULTFILE
24
 
 
25
 
. /lib/lsb/init-functions
26
 
. /etc/default/rcS
27
 
 
28
 
case "$TROUSERS_ENABLE" in
29
 
  [Nn]*)
30
 
    log_warning_msg "To enable $NAME, edit $DEFAULTFILE and set TROUSERS_ENABLE=yes"
31
 
    exit 0
32
 
    ;;
33
 
esac
34
 
 
35
 
load_modules() {
36
 
        if [ -n "${TPM_MODULES}" ]; then
37
 
            for d in ${TPM_MODULES}; do
38
 
                if echo `/sbin/lsmod` | grep -q -w "$d"; then
39
 
                    [ "$VERBOSE" != no ] && log_success_msg "Module already loaded: $d"
40
 
                    continue
 
24
case "${1}" in
 
25
        start)
 
26
                echo -n "Starting $DESC: "
 
27
                if [ ! -e /dev/tpm* ]
 
28
                then
 
29
                        echo "device driver not loaded, aborting."
 
30
                        exit 0
 
31
                fi
 
32
 
 
33
                start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
 
34
                echo "$NAME."
 
35
                ;;
 
36
 
 
37
        stop)
 
38
                echo -n "Stopping $DESC: "
 
39
                start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid --oknodo --exec $DAEMON
 
40
                echo "$NAME."
 
41
                ;;
 
42
 
 
43
        restart|force-reload)
 
44
                echo -n "Restarting $DESC: "
 
45
                start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid --oknodo --exec $DAEMON
 
46
                sleep 1
 
47
                if [ ! -e /dev/tpm* ]
 
48
                then
 
49
                        echo "device driver not loaded, aborting."
 
50
                        exit 0
 
51
                fi
 
52
                start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
 
53
                echo "$NAME."
 
54
                ;;
 
55
 
 
56
        status)
 
57
                if [ -f /var/run/$NAME.pid ]
 
58
                then
 
59
                        echo "$NAME is running."
41
60
                else
42
 
                    if modprobe -q $d $MODULE_OPTS 2>/dev/null; then
43
 
                        [ "$VERBOSE" != no ] && log_success_msg "Loaded module: $d"
44
 
                        continue
45
 
                    else
46
 
                        if [ "$VERBOSE" != no ]; then
47
 
                            log_warning_msg "Unable to load module: $d"
48
 
                            continue
49
 
                        fi
50
 
                    fi
 
61
                        echo "$NAME is not running."
 
62
                        exit 1
51
63
                fi
52
 
            done
53
 
        fi
54
 
}
55
 
 
56
 
check_modules() {
57
 
        if [ ! -c /dev/tpm ] && [ ! -c /dev/tpm0 ]; then
58
 
            log_warning_msg "Not starting $DESC ($NAME); no TPM device found."
59
 
            exit 0
60
 
        fi
61
 
}
62
 
 
63
 
tcsd_start() {
64
 
        load_modules
65
 
        check_modules
66
 
        log_daemon_msg "Starting $DESC" "$NAME"
67
 
        start-stop-daemon --start --quiet --chuid tpm --exec $DAEMON
68
 
        log_end_msg $?
69
 
}
70
 
 
71
 
tcsd_stop() {
72
 
        log_daemon_msg "Stopping $DESC" "$NAME"
73
 
        start-stop-daemon --stop --quiet --oknodo --exec $DAEMON --user tpm
74
 
        log_end_msg $?
75
 
}
76
 
 
77
 
case "$1" in
78
 
  start)
79
 
    tcsd_start
80
 
    ;;
81
 
  stop)
82
 
    tcsd_stop
83
 
    ;;
84
 
  restart|reload|force-reload)
85
 
    tcsd_stop
86
 
    tcsd_start
87
 
    ;;
88
 
  *)
89
 
    log_success_msg "Usage: $0 {start|stop|restart|reload|force-reload}"
90
 
    exit 1
91
 
  ;;
 
64
                ;;
 
65
 
 
66
        *)
 
67
                N=/etc/init.d/$NAME
 
68
                echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
 
69
                exit 1
 
70
                ;;
92
71
esac
93
72
 
94
73
exit 0