I'm trying to run the command
sleepd --sleep-command "/usr/bin/apm -S" -u 900
to conserve some energy, by putting my computer in standby after 15 minute of idling. This command works fine when I type it at a tcsh or sh prompt, but now I want to run it at boot time.
The Debian booting structure is guiding me to do this via a distro-provided script, /etc/rc5.d/S20sleepd (a symlink to somewhere else, IIRC.) I've appended the full text of this script below, but I think the crucial bits are
#! /bin/sh
DAEMON=/usr/sbin/sleepd NAME=sleepd
PARAMS="" if [ -e /etc/default/sleepd ]; then . /etc/default/sleepd fi
case "$1" in start) start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \ --exec $DAEMON -- $PARAMS ;;
esac
exit 0
I'm supposed to set things up the way I like them by editing a line in /etc/default/sleepd that says PARAMS=something-or-other. I've tried various permutations, all of which give error messages, e.g.
PARAMS=--sleep-command "apm -S" -u 900
-> /etc/rc5.d/S20sleepd: apm -S: command not found
PARAMS='--sleep-command "apm -S" -u 900'
-> /usr/sbin/sleepd: invalid option -- S /usr/sbin/sleepd: invalid option -- "
PARAMS=--sleep-command apm -S -u 900
-> usage: apm [-VvmMsSd] [--verbose] [--minutes] [--monitor] [--suspend] [--standby]
I suspect the problems result from my poor understanding of how the Bourne shell handles quotes. Any ideas, please?
Here's the full script:
#! /bin/sh
DAEMON=/usr/sbin/sleepd NAME=sleepd DESC="APM sleep daemon"
test -f $DAEMON || exit 0
set -e
# Source defaults file; edit that file to configure this script. PARAMS="" if [ -e /etc/default/sleepd ]; then . /etc/default/sleepd fi
case "$1" in start) # Ensure apm module is loaded. test -e /dev/apm_bios && touch /dev/apm_bios
echo -n "Starting $DESC: " start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \ --exec $DAEMON -- $PARAMS echo "$NAME." ;; stop) echo -n "Stopping $DESC: " start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/$NAME.pid \ --exec $DAEMON -- $PARAMS echo "$NAME." ;; restart|force-reload) echo -n "Restarting $DESC: " start-stop-daemon --stop --quiet --oknodo --pidfile \ /var/run/$NAME.pid --exec $DAEMON -- $PARAMS sleep 1 start-stop-daemon --start --quiet --pidfile \ /var/run/$NAME.pid --exec $DAEMON -- $PARAMS echo "$NAME." ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2 exit 1 ;; esac
exit 0