~ubuntu-branches/ubuntu/dapper/cpufreqd/dapper

« back to all changes in this revision

Viewing changes to debian/cpufreqd.init

  • Committer: Bazaar Package Importer
  • Author(s): Mattia Dongili
  • Date: 2005-11-27 18:47:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051127184742-9h26euwetr6kh1e6
Tags: 2.0.0-1

* New upstream release.
* cpufreqd.init: exit succesfully in case a stop is issued and
  cpufreqd is found running as requested by LSB thus making it
  possible to remove cpufreqd when cpufreqd itsef is stopped
  (closes: #340133)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /bin/sh
 
2
### BEGIN INIT INFO
 
3
# Required-Start: $local_fs $syslog
 
4
# Required-Stop:
 
5
# Default-Start:  2 3 4 5
 
6
# Default-Stop: 0 1 6
 
7
# Short-Description: start and stop cpufreqd
 
8
# Description: fully configurable daemon for dynamic frequency
 
9
#        and voltage scaling
 
10
### END INIT INFO
2
11
3
12
# Startup script for the cpufreqd daemon. It's been made using the
4
 
# skeleton      example file to build /etc/init.d/ scripts.
5
 
#               This file should be used to construct scripts for /etc/init.d.
6
 
#
7
 
#               Written by Miquel van Smoorenburg <miquels@cistron.nl>.
8
 
#               Modified for Debian GNU/Linux
9
 
#               by Ian Murdock <imurdock@gnu.ai.mit.edu>.
10
 
#
11
 
# Version:      @(#)skeleton  1.9.1  08-Apr-2002  miquels@cistron.nl
 
13
# skeleton example file to build /etc/init.d/ scripts.
 
14
# This file should be used to construct scripts for /etc/init.d.
 
15
#
 
16
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
 
17
# Modified for Debian GNU/Linux
 
18
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
 
19
#
 
20
# Version: @(#)skeleton  1.9.1  08-Apr-2002  miquels@cistron.nl
12
21
#
13
22
 
14
23
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
17
26
NAME=cpufreqd
18
27
DESC="CPU Frequency daemon"
19
28
 
 
29
# use lsb-base
 
30
. /lib/lsb/init-functions
 
31
 
20
32
# abort if no executable exists
21
33
test -x $DAEMON || exit 0
22
34
 
24
36
test -r $CPUFREQD_CONFFILE || exit 0
25
37
 
26
38
check_for_cpufreq_support() {
27
 
  # forget it if we're trying to start and no cpufreq found in kernel
28
 
  if !([ -d /sys/devices/system/cpu/cpu0/cpufreq ] || [ -f /proc/cpufreq ]) ; then
29
 
          echo "$DESC: no cpufreq interface found. "
30
 
          exit 0
31
 
  fi
 
39
        # forget it if we're trying to start and no cpufreq found in kernel
 
40
        if !([ -d /sys/devices/system/cpu/cpu0/cpufreq ] || [ -f /proc/cpufreq ]) ; then
 
41
#               log_failure_msg "no cpufreq interface found. "
 
42
                return 1
 
43
        fi
 
44
        return 0
32
45
}
33
46
 
34
47
check_for_pm_support() {
35
 
  # forget it if we're trying to start and no power management support is
36
 
  # included in kernel
37
 
  if !([ -d /proc/pmu ] || [ -f /proc/apm ] || [ -d /proc/acpi ]) ; then
38
 
          echo "$DESC: no supported power management interface found. "
39
 
          exit 0
40
 
  fi
 
48
        # forget it if we're trying to start and no power management support is
 
49
        # included in kernel
 
50
        if !([ -d /proc/pmu ] || [ -f /proc/apm ] || [ -d /proc/acpi ]) ; then
 
51
#               log_failure_msg "no supported power management interface found. "
 
52
                return 1
 
53
        fi
 
54
        return 0
41
55
}
42
56
 
43
57
set -e
44
58
 
 
59
retval=0
45
60
case "$1" in
46
 
  start)
47
 
      check_for_cpufreq_support
48
 
      check_for_pm_support
49
 
      echo -n "Starting $DESC: $NAME"
50
 
      start-stop-daemon --start --oknodo --exec $DAEMON -- -f $CPUFREQD_CONFFILE || retval=$?
51
 
      if [ "x$retval" != "x" ] ; then
52
 
        echo -n " Errors occurred starting cpufreqd"
53
 
      fi
54
 
      echo "."
55
 
      ;;
56
 
  stop)
57
 
      echo -n "Stopping $DESC: $NAME"
58
 
      start-stop-daemon --stop --oknodo --exec $DAEMON
59
 
      echo "."
60
 
      ;;
61
 
  reload|force-reload)
62
 
      check_for_cpufreq_support
63
 
      check_for_pm_support
64
 
      echo -n "Reloading $DESC configuration..."
65
 
      start-stop-daemon --stop --oknodo --signal 1 --exec $DAEMON -- -f $CPUFREQD_CONFFILE
66
 
      echo "done."
67
 
      ;;
68
 
  restart)
69
 
      echo -n "Restarting $DESC: $NAME"
70
 
      start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
71
 
      check_for_cpufreq_support
72
 
      check_for_pm_support
73
 
      sleep 1
74
 
      start-stop-daemon --start --oknodo --exec $DAEMON -- -f $CPUFREQD_CONFFILE || retval=$?
75
 
      if [ "x$retval" != "x" ] ; then
76
 
        echo -n " Errors occurred starting cpufreqd"
77
 
      fi
78
 
      echo "."
79
 
      ;;
80
 
  *)
81
 
      N=/etc/init.d/$NAME
82
 
      echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
83
 
      exit 1
84
 
      ;;
 
61
        start)
 
62
                log_daemon_msg "Starting $DESC" "$NAME"
 
63
                if ( check_for_cpufreq_support && check_for_pm_support ) ; then
 
64
                        start_daemon $DAEMON -f $CPUFREQD_CONFFILE
 
65
                else
 
66
#                       log_failure_msg " Errors occurred starting cpufreqd"
 
67
                        retval=1
 
68
                fi
 
69
                log_end_msg $retval;
 
70
        ;;
 
71
        stop)
 
72
                log_daemon_msg "Stopping $DESC" "$NAME"
 
73
                if ( pidofproc $DAEMON 2>&1 > /dev/null ) ; then
 
74
                        killproc $DAEMON 15
 
75
                fi
 
76
                log_end_msg $retval
 
77
        ;;
 
78
#  reload|force-reload)
 
79
#      check_for_cpufreq_support
 
80
#      check_for_pm_support
 
81
#      echo -n "Reloading $DESC configuration..."
 
82
#      start-stop-daemon --stop --oknodo --signal 1 --exec $DAEMON -- -f $CPUFREQD_CONFFILE
 
83
#      echo "done."
 
84
#      ;;
 
85
        reload|force-reload|restart)
 
86
                log_daemon_msg "Restarting $DESC" "$NAME"
 
87
                killproc $DAEMON
 
88
                sleep 1
 
89
                if ( check_for_cpufreq_support && check_for_pm_support ) ; then
 
90
                        start_daemon $DAEMON -f $CPUFREQD_CONFFILE
 
91
                else
 
92
#                       log_failure_msg " Errors occurred starting cpufreqd"
 
93
                        retval=1
 
94
                fi
 
95
                log_end_msg $retval;
 
96
        ;;
 
97
        *)
 
98
                N=/etc/init.d/$NAME
 
99
                echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
 
100
                retval=2
 
101
        ;;
85
102
esac
86
103
 
87
 
exit 0
 
104
exit $retval
 
105