[kernel] r7739 - people/jurij/ipw3945-daemon/debian
Jurij Smakov
jurij-guest at alioth.debian.org
Fri Nov 10 22:38:23 UTC 2006
Author: jurij-guest
Date: Fri Nov 10 23:38:23 2006
New Revision: 7739
Added:
people/jurij/ipw3945-daemon/debian/init (contents, props changed)
Modified:
people/jurij/ipw3945-daemon/debian/start
Log:
Restore the init script, add modprobe-start and modprobe-stop
targets.
Added: people/jurij/ipw3945-daemon/debian/init
==============================================================================
--- (empty file)
+++ people/jurij/ipw3945-daemon/debian/init Fri Nov 10 23:38:23 2006
@@ -0,0 +1,119 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides: ipw3945-daemon
+# Required-Start: mountkernfs $local_fs
+# Required-Stop: $local_fs
+# Default-Start: S
+# Default-Stop: 0 6
+# Short-Description: Starts Intel regulatory daemon (ipw3945d)
+# Description: Starts the binary userspace regulatory daemon, required
+# for operation of Intel/PRO Wireless 3945ABG cards
+### END INIT INFO
+
+. /lib/lsb/init-functions
+
+DAEMON_OWNER="Debian-ipw3945d:Debian-ipw3945d"
+DAEMON_BINARY="/sbin/ipw3945d"
+SYS_CMD_PERM="744"
+DAEMON_PID_DIR="/var/run/ipw3945-daemon"
+DAEMON_PID_FILE="${DAEMON_PID_DIR}/ipw3945d"
+
+# Occasionally we will be started by a modprobe hook very early,
+# when the filesystem might not be mounted rw yet. In this case
+# daemon will fail to start, as it will be unable to write its
+# pid file. This function may be used to check for it.
+can_write_pid() {
+ check="${DAEMON_PID_DIR}/can_write"
+ rm -f "${check}" > /dev/null 2>&1 || true
+ if touch "${check}" > /dev/null 2>&1; then
+ res=0
+ rm -f "${check}"
+ else
+ res=1
+ fi
+ return "${res}"
+}
+
+# If the driver is loaded, some entries in the /sys tree should
+# appear. If we are run by a modprobe hook, it might be that we
+# need to wait a bit for them to appear and then adjust their
+# permissions and ownership appropriately.
+have_sys_entries() {
+ res=1
+ for delay in 1 2 4
+ do
+ cmd="$(echo /sys/bus/pci/drivers/ipw3945/*/cmd)"
+ if test -n "${cmd}"; then
+ chown "${DAEMON_OWNER}" ${cmd}
+ chmod "${SYS_CMD_PERM}" ${cmd}
+ break
+ res=0
+ 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
+}
+
+start_daemon() {
+ if have_sys_entries; then
+ log_daemon_msg "Starting ipw3945 regulatory daemon" "ipw3945d"
+ fire_it_up
+ code=$?
+ log_end_msg ${code}
+ else
+ log_warning_msg "Not starting ipw3945 regulatory daemon, driver not loaded."
+ fi
+}
+
+stop_daemon () {
+ log_daemon_msg "Stopping ipw3945 regulatory daemon" "ipw3945d"
+ shut_it_down
+ log_end_msg 0
+}
+
+test -x "${DAEMON_BINARY}" || exit 0
+
+case "$1" in
+ start)
+ start_daemon
+ ;;
+ stop)
+ stop_daemon
+ ;;
+ restart|force-reload)
+ stop_daemon
+ start_daemon
+ ;;
+ # The modprobe-* targets are supposed to be used
+ # from modprobe hooks only.
+ modprobe-start)
+ can_write_pid || exit 0
+ have_sys_entries || exit 0
+ fire_it_up
+ ;;
+ modprobe-stop)
+ shut_it_down
+ # This target must exit with code 1 due to the way
+ # it is called from the modprobe hook.
+ exit 1
+ ;;
+ *)
+ echo "Usage: ${0} {start|stop|restart|force-reload}"
+ exit 1
+ ;;
+esac
+exit 0
Modified: people/jurij/ipw3945-daemon/debian/start
==============================================================================
--- people/jurij/ipw3945-daemon/debian/start (original)
+++ people/jurij/ipw3945-daemon/debian/start Fri Nov 10 23:38:23 2006
@@ -1,10 +1,5 @@
#!/bin/sh
-DAEMON_PID='/var/run/ipw3945-daemon/ipw3945d.pid'
-DAEMON_LOG='/var/log/ipw3945-daemon/ipw3945d.log'
-
-test -x /sbin/ipw3945d || exit 0
-
# Wait for the devices to come up
for delay in 1 2 4
do
@@ -21,17 +16,5 @@
chmod 744 ${cmd}
# If we are started early, the fs might be not mounted rw yet,
-# so we wait for it to become writable.
-while true
-do
- if touch "${DAEMON_PID}"; then
- rm -f "${DAEMON_PID}"
- break
- fi
- sleep 1
-done
-
-# Launch the daemon
-su -s /bin/sh -c /sbin/ipw3945d "${DAEMON_USER}" -- --pid-file=${DAEMON_PID}" \
- --log-file=${DAEMON_LOG}" \
- --quiet
+# so we wait for it to become writable (in the background).
+/usr/lib/ipw3945-daemon/deferred-start &
More information about the Kernel-svn-changes
mailing list