[kernel] r7740 - people/jurij/ipw3945-daemon/debian
Jurij Smakov
jurij-guest at alioth.debian.org
Sat Nov 11 01:08:12 UTC 2006
Author: jurij-guest
Date: Sat Nov 11 02:08:11 2006
New Revision: 7740
Removed:
people/jurij/ipw3945-daemon/debian/start
people/jurij/ipw3945-daemon/debian/stop
Modified:
people/jurij/ipw3945-daemon/debian/README.Debian
people/jurij/ipw3945-daemon/debian/control
people/jurij/ipw3945-daemon/debian/init
people/jurij/ipw3945-daemon/debian/rules
Log:
Update to adapt to the scheme in which we can
be started both from modprobe hooks and during
the normal bootup process.
Modified: people/jurij/ipw3945-daemon/debian/README.Debian
==============================================================================
--- people/jurij/ipw3945-daemon/debian/README.Debian (original)
+++ people/jurij/ipw3945-daemon/debian/README.Debian Sat Nov 11 02:08:11 2006
@@ -1,31 +1,18 @@
-As the ipw3945d daemon requires the ipw3945 driver module to be loaded, it is
-started not through the usual /etc/init.d mechanism, but whenever the ipw394
-module is loaded by 'modprobe' (and, correspondingly, stopped just before the
-module is unloaded). This is implemented by installing the modprobe
-configuration file /etc/modprobe.d/ipw3945-daemon, which calls the scripts in
-/usr/lib/ipw3945-daemon on suitable occasions. Normally, the ipw3945 module
-will be automatically loaded by udev during system startup if available,
-causing the daemon to be started.
+There are two ways the ipw3945 daemon may be started/stopped in Debian.
+By implementing modprobe hooks, the daemon is made to start every time
+the ipw3945 kernel module is loaded, and removed right before the kernel
+module is removed. So you can use the commands
-In Debian the ipw3945d is set up to run as non-root user, which will be created
-during installation of the package. To operate successfully, daemon needs
-access to some files in /sys directory tree. The /usr/lib/ipw3945-daemon/start
-script will correctly set the permissions and ownership for these entries each
-time before starting the daemon. Note, that changes to this script will *not*
-be preserved on upgrades. In order to control its behavior, adjust the values
-of the following variables in /etc/default/ipw3945-daemon (default values are
-shown):
+ modprobe ipw3945
+ modprobe -r ipw3945
-DAEMON_BINARY='/sbin/ipw3945d'
- The location of the daemon binary
-DAEMON_USER='Debian-ipw3945d'
-DAEMON_GROUP='Debian-ipw3945d'
- User and group id the daemon will run under. Also, those values will
- be used to set the ownership of the /sys entries, which daemon needs
- access to. If you change those, you have to make sure that the
- specified user/group exists and has sufficient permissions to write the
- process id (PID) file specified by DAEMON_PID variable
-SYS_CMD_PERM='744'
- Permissions for the entries in /sys tree.
-DAEMON_PID='/var/run/ipw3945d.pid'
- Location of the daemon's process id (PID) file.
+to insert/remove ipw3945 kernel module, which will cause automatic
+starting/stopping of the ipw3945d daemon. However, when insertion of the
+module is triggered by udev early in the boot process, the daemon cannot
+be started, as at that point the file system is still mounted read-only,
+so the daemon cannot write its pid file. To overcome this problem, a
+regular /etc/init.d/ipw3945-daemon script is installed to start the
+daemon at the right time in the boot process (and shut it down on halt
+or reboot).
+
+ -- Jurij Smakov <jurij at debian.org> Fri, 10 Nov 2006 15:16:43 -0800
Modified: people/jurij/ipw3945-daemon/debian/control
==============================================================================
--- people/jurij/ipw3945-daemon/debian/control (original)
+++ people/jurij/ipw3945-daemon/debian/control Sat Nov 11 02:08:11 2006
@@ -8,7 +8,7 @@
Package: ipw3945-daemon
Architecture: i386 amd64
-Depends: adduser, ${shlibs:Depends}
+Depends: adduser, lsb-base (>= 3.1), ${shlibs:Depends}
Description: Binary userspace regulatory daemon for Intel PRO/Wireless 3945ABG cards
The regulatory daemon is responsible for controlling and configuring
aspects of the hardware required to operate the device within
Modified: people/jurij/ipw3945-daemon/debian/init
==============================================================================
--- people/jurij/ipw3945-daemon/debian/init (original)
+++ people/jurij/ipw3945-daemon/debian/init Sat Nov 11 02:08:11 2006
@@ -17,7 +17,7 @@
DAEMON_BINARY="/sbin/ipw3945d"
SYS_CMD_PERM="744"
DAEMON_PID_DIR="/var/run/ipw3945-daemon"
-DAEMON_PID_FILE="${DAEMON_PID_DIR}/ipw3945d"
+DAEMON_PID_FILE="${DAEMON_PID_DIR}/ipw3945d.pid"
# Occasionally we will be started by a modprobe hook very early,
# when the filesystem might not be mounted rw yet. In this case
@@ -41,37 +41,40 @@
# permissions and ownership appropriately.
have_sys_entries() {
res=1
- for delay in 1 2 4
+ for delay in 0 1 2 4
do
+ sleep "${delay}"
cmd="$(echo /sys/bus/pci/drivers/ipw3945/*/cmd)"
- if test -n "${cmd}"; then
+ if test -e "${cmd}"; then
chown "${DAEMON_OWNER}" ${cmd}
chmod "${SYS_CMD_PERM}" ${cmd}
- break
res=0
+ break
fi
- sleep "${delay}"
done
- echo "${res}"
-}
-
-fire_it_up() {
- start-stop-daemon --start --quiet --chuid "${DAEMON_OWNER}" \
- --exec "${DAEMON_BINARY}" --pidfile "${DAEMON_PID_FILE}" \
- --oknodo -- --pid-file=${DAEMON_PID_FILE} --quiet > /dev/null 2>&1
- res=$?
return "${res}"
}
-shut_it_down {
- start-stop-daemon --stop --quiet --pidfile "${DAEMON_PID_FILE}" \
- --signal HUP > /dev/null 2>&1
+# Check for a stale pid file and remove it, if present. If there is
+# a non-zero argument, the removal is silent (no warning emitted)
+remove_stale_pid() {
+ if test -e "${DAEMON_PID_FILE}"; then
+ pid=$(cat "${DAEMON_PID_FILE}")
+ msg="Removing stale pid file ${DAEMON_PID_FILE} (pid ${pid} not running)."
+ if ! kill -0 "${pid}" > /dev/null 2>&1; then
+ test -n "${1}" || log_warning_msg "${msg}"
+ rm -f "${DAEMON_PID_FILE}"
+ fi
+ fi
}
start_daemon() {
if have_sys_entries; then
+ remove_stale_pid
log_daemon_msg "Starting ipw3945 regulatory daemon" "ipw3945d"
- fire_it_up
+ start-stop-daemon --start --quiet --chuid "${DAEMON_OWNER}" \
+ --exec "${DAEMON_BINARY}" --pidfile "${DAEMON_PID_FILE}" \
+ --oknodo -- --pid-file=${DAEMON_PID_FILE} --quiet > /dev/null 2>&1
code=$?
log_end_msg ${code}
else
@@ -81,7 +84,10 @@
stop_daemon () {
log_daemon_msg "Stopping ipw3945 regulatory daemon" "ipw3945d"
- shut_it_down
+ start-stop-daemon --stop --quiet --pidfile "${DAEMON_PID_FILE}" \
+ --signal HUP > /dev/null 2>&1
+ # Daemon does not clean up its pid file when exiting on the signal
+ remove_stale_pid quietly
log_end_msg 0
}
@@ -102,11 +108,10 @@
# from modprobe hooks only.
modprobe-start)
can_write_pid || exit 0
- have_sys_entries || exit 0
- fire_it_up
+ start_daemon
;;
modprobe-stop)
- shut_it_down
+ stop_daemon
# This target must exit with code 1 due to the way
# it is called from the modprobe hook.
exit 1
Modified: people/jurij/ipw3945-daemon/debian/rules
==============================================================================
--- people/jurij/ipw3945-daemon/debian/rules (original)
+++ people/jurij/ipw3945-daemon/debian/rules Sat Nov 11 02:08:11 2006
@@ -29,7 +29,7 @@
dh_installdocs README.ipw3945d
dh_installchangelogs
dh_installdirs
- dh_installinit
+ dh_installinit -- start 39 S . start 36 0 6 .
dh_installmodules
dh_installman debian/ipw3945d.8
dh_installlogrotate
More information about the Kernel-svn-changes
mailing list