~ubuntu-branches/ubuntu/feisty/laptop-mode-tools/feisty

« back to all changes in this revision

Viewing changes to etc/init.d/laptop-mode

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-12-06 12:53:23 UTC
  • mfrom: (1.1.3 upstream) (2.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20061206125323-6mx5dyxog2n8xxlc
Tags: 1.32-1ubuntu1
Merge from debian unstable; remaining Ubuntu changes:

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
test -f /usr/sbin/laptop_mode || exit 0
10
10
 
 
11
. /lib/lsb/init-functions
 
12
 
11
13
if [ -f /etc/default/laptop-mode ]; then
12
14
        . /etc/default/laptop-mode;
13
15
fi
23
25
 
24
26
case $1 in
25
27
  start)
26
 
    echo -n "Enabling laptop mode: "
 
28
    log_action_begin_msg "Enabling laptop mode"
27
29
    touch /var/run/laptop-mode-enabled        
28
 
    /usr/sbin/laptop_mode auto init
29
 
    exit 0
 
30
    RESULT=$(/usr/sbin/laptop_mode auto init)
 
31
    log_action_end_msg 0 "$RESULT"
30
32
    ;;
31
33
 
32
34
  restart|reload|force-reload)
33
35
    set -e
34
 
    echo -n "Restarting laptop mode: "    
35
 
    /usr/sbin/laptop_mode auto init force
36
 
    exit 0
 
36
    log_action_begin_msg "Stopping laptop mode"
 
37
    
 
38
    # Full restart: first stop laptop mode completely (to restore default mount options etc.)
 
39
    rm -f /var/run/laptop-mode-enabled
 
40
    RESULT=$(/usr/sbin/laptop_mode stop init)
 
41
    log_action_end_msg 0 "$RESULT"
 
42
    
 
43
    # Now remove files containing stored status, re-enable, and start it up again.
 
44
    rm -f /var/run/laptop-mode-*
 
45
    touch /var/run/laptop-mode-enabled
 
46
    log_action_begin_msg "Starting laptop mode"
 
47
    RESULT=$(/usr/sbin/laptop_mode auto init force)
 
48
    log_action_end_msg 0 "$RESULT"
37
49
    ;;
38
50
 
39
51
  stop)
40
52
    rm -f /var/run/laptop-mode-enabled
41
 
    echo -n "Disabling laptop mode: "
42
 
    if ! ( /usr/sbin/laptop_mode stop init ) ; then
43
 
        echo " (failed)."
 
53
    log_action_begin_msg "Disabling laptop mode"
 
54
    RESULT=$(/usr/sbin/laptop_mode stop init)
 
55
    if [ $? -ne 0 ]; then
 
56
        log_action_end_msg 1 "$RESULT"
44
57
        exit 1
45
58
    fi
46
 
    exit 0
 
59
    log_action_end_msg 0
47
60
    ;;
48
61
 
49
62
  status)
50
63
    echo "Laptop mode status:"
51
64
    echo
52
65
    /usr/sbin/laptop_mode status
53
 
    exit 0
54
66
    ;;
55
67
    
56
68
  *)
57
 
      echo "Usage: $0 {stop|start|restart|reload|force-reload|status}" >&2
58
 
      exit 1
 
69
    echo "Usage: $0 {stop|start|restart|reload|force-reload|status}" >&2
 
70
    exit 2
59
71
    ;;
60
72
esac
61
 
 
 
73
exit 0