Add init script from #924
authorFlorian Fainelli <florian@openwrt.org>
Wed, 10 Oct 2007 13:28:25 +0000 (13:28 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Wed, 10 Oct 2007 13:28:25 +0000 (13:28 +0000)
SVN-Revision: 9242

net/dhcp/Makefile
net/dhcp/files/dhcpd.init [new file with mode: 0644]

index 039bf2c..0b10a4c 100644 (file)
@@ -71,6 +71,8 @@ endef
 define Package/dhcp-server/install
        $(INSTALL_DIR) $(1)/usr/sbin
        $(CP) $(PKG_INSTALL_DIR)/usr/sbin/dhcpd $(1)/usr/sbin/
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/dhcpd.init $(1)/etc/init.d/dhcpd
 endef
 
 $(eval $(call BuildPackage,dhcp-relay))
diff --git a/net/dhcp/files/dhcpd.init b/net/dhcp/files/dhcpd.init
new file mode 100644 (file)
index 0000000..25f8466
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/sh /etc/rc.common
+START=60
+
+lease_file=/tmp/dhcpd.leases
+config_file=/etc/dhcpd.conf
+pid_file=/var/run/dhcpd.pid
+
+start() {
+       echo Starting isc-dhcpd
+
+       if [ ! -e $lease_file ]; then
+               echo "  Creating $lease_file"
+               touch $lease_file
+       fi
+       
+       /usr/sbin/dhcpd -cf $config_file -lf $lease_file
+       
+       if [ $$ -eq 0 ]; then
+               echo "  isc-dhcpd failed to start"
+       fi
+}
+
+stop() {
+       echo "Stopping isc-dhcpd"
+       if [ -e $pid_file ]; then
+               kill `cat $pid_file`
+
+               if [ $$ -eq 0 ]; then
+                       echo "  PID " `cat $pid_file` not found
+                       echo "  Is the DHCP server running?"
+               fi
+       
+               rm $pid_file
+       else
+               echo "  $pid_file not found"
+       fi
+}