#! /bin/sh # # fichier /etc/init.d/sound_basile ## voir http://sourceforge.net/mailarchive/forum.php?thread_id=8072079&forum_id=1752 set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="sound_basile script" NAME=sound_basile DAEMON=/usr/sbin/$NAME PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # Read config file if it is present. if [ -r /etc/default/$NAME ] then . /etc/default/$NAME fi # the magic register for sound sound_basile_regs="/proc/asound/card0/codec97#0/ac97#0-0+regs" # the command to put it on sound_basile_on_cmd="7a 2090" # the command to put it off sound_basile_off_cmd="7a 2092" # # Function that starts the daemon/service. # d_start() { logger -i sound_basile start regs= $sound_basile_regs if [ ! -r $sound_basile_regs ]; then logger -s no sound_basile_regs $sound_basile_regs exit 1 fi echo $sound_basile_on_cmd > $sound_basile_regs } # # Function that stops the daemon/service. # d_stop() { logger -i sound_basile start regs= $sound_basile_regs if [ ! -r $sound_basile_regs ]; then logger -s no sound_basile_regs $sound_basile_regs exit 1 fi echo $sound_basile_off_cmd > $sound_basile_regs } # # Function that sends a SIGHUP to the daemon/service. # d_reload() { start-stop-daemon --stop --quiet --pidfile $PIDFILE \ --name $NAME --signal 1 } case "$1" in start) echo -n "Starting $DESC: $NAME" d_start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" d_stop echo "." ;; #reload) # # If the daemon can reload its configuration without # restarting (for example, when it is sent a SIGHUP), # then implement that here. # # If the daemon responds to changes in its config file # directly anyway, make this an "exit 0". # # echo -n "Reloading $DESC configuration..." # d_reload # echo "done." #;; restart|force-reload) # # If the "reload" option is implemented, move the "force-reload" # option to the "reload" entry above. If not, "force-reload" is # just the same as "restart". # echo -n "Restarting $DESC: $NAME" d_stop # One second might not be time enough for a daemon to stop, # if this happens, d_start will fail (and dpkg will break if # the package is being upgraded). Change the timeout if needed # be, or change d_stop to have start-stop-daemon use --retry. # Notice that using --retry slows down the shutdown process somewhat. sleep 1 d_start echo "." ;; *) # echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0