PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : lircd bei Neustart automatisch starten



mowses
31.08.04, 13:36
Hallo

Ich habe es endlich geschafft lirc auf meinem Rechner (Debian, 2.6.8) ans laufen zu bekommen. Es hat gedauert aber dafür ist die Freude nun um so größer.

Jetzt aber zu meinem Anliegen.

Ich möchte natürlich, dass der lircd bei jedem Start automatisch gestartet wird und alle nötigen Einstellungen automatisch ausgeführt werden.

Damit er lauscht muss ich folgendes machen.


setserial /dev/ttySx uart none
depmod -a
modprobe lirc_serial
lircd


Das depmod -a ist dabei denke ich mittlerweile nicht mehr nötig aber ohne die anderen klappt es nicht. Das feste installieren von lirc_serial in den Kernel mittels modconf oder insmod klappt nicht, da das Device immer busy ist.

Am liebsten hätte ich ein init-Script welches all das macht, allerdings kenn ich mich mit dem schreiben eines solchen nicht aus und wollte daher fragen ob einer von euch vielleicht schon eins hat, oder mir eine Quelle außer des Beispielscripts in /etc/init.d/ nennen kann.

mowses
31.08.04, 19:17
Na dann werde ich mir wohl selber mal die Antworten geben... ;-)

In der /etc/init.d/README gab es einen Link zum Debian Policy Manual (http://www.debian.org/doc/debian-policy/) dort unter 9.3 System run levels and init.d scripts (http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit) gab es so einiges Interessantes zu lesen. Ich hab dann aus der /etc/init.d/skeleton mal ein Script für den lircd gebaut.

Ich hoffe das ist halbwegs anständig und brauchbar. Wenn jemand böses darin findet bitte sagen! Ich habe es eignetlich so ziemlich komplett übernommen bist auf ein paar geänderte Pfadangaben und die Einträge bei case start.



#! /bin/sh
# Author: Andrej v. Schilling <mowses AT gmx DOT net>
#
# Version: @(#)skeleton 2.85-23 28-Jul-2004 miquels@cistron.nl
#
# manage lircd

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Linux Infrared Remote Control"
NAME=lircd
DAEMON=/usr/local/sbin/$NAME
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

# Read config file if it is present.
#if [ -r /etc/default/$NAME ]
#then
# . /etc/default/$NAME
#fi

#
# Function that starts the daemon/service.
#
d_start() {
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--exec $DAEMON
}

#
# Function that stops the daemon/service.
#
d_stop() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
--name $NAME
}

#
# 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"
setserial /dev/ttyS0 uart none
modprobe lirc_serial
d_start
irexec -d /etc/lircrc
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
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


Dazu dann noch die Links in meinem Standardrunlevel per ln -s ../init.d/lircd S99lircd und in /etc/rc6.d und /etc/rc0.d per ln -s ../init.d/lircd K16lircd angelegt und das ganze funktioniert eigentlich ganz gut.

Ich hoffe es ist ein wenig brauchbar und wie gesagt wenn böse Fehler drin sind bitte melden. Das wird dann mir und vielleicht anderen helfen.