aboutsummaryrefslogtreecommitdiffstats
path: root/package/network
diff options
context:
space:
mode:
authorJohn Crispin <john@openwrt.org>2013-09-17 21:45:30 +0000
committerJohn Crispin <john@openwrt.org>2013-09-17 21:45:30 +0000
commitf87409440298121ae1fbd718a17267cc180438e4 (patch)
tree2ceea2187fddf2c9fb21cb43a27d69afdd55e81f /package/network
parent4f62127dea854024116383c84fedb673baaae9cd (diff)
downloadupstream-f87409440298121ae1fbd718a17267cc180438e4.tar.gz
upstream-f87409440298121ae1fbd718a17267cc180438e4.tar.bz2
upstream-f87409440298121ae1fbd718a17267cc180438e4.zip
procd: convert various packages to procd style init.d scripts
Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 38023
Diffstat (limited to 'package/network')
-rwxr-xr-xpackage/network/config/netifd/files/etc/init.d/network43
-rw-r--r--package/network/services/dnsmasq/files/dnsmasq.init40
-rwxr-xr-xpackage/network/services/dropbear/files/dropbear.init2
-rwxr-xr-xpackage/network/services/ipset-dns/files/ipset-dns.init32
-rw-r--r--package/network/services/relayd/files/relay.init35
-rwxr-xr-xpackage/network/services/uhttpd/files/uhttpd.init38
6 files changed, 96 insertions, 94 deletions
diff --git a/package/network/config/netifd/files/etc/init.d/network b/package/network/config/netifd/files/etc/init.d/network
index 75586452f0..8031802e8d 100755
--- a/package/network/config/netifd/files/etc/init.d/network
+++ b/package/network/config/netifd/files/etc/init.d/network
@@ -3,17 +3,30 @@
START=20
STOP=90
-SERVICE_DAEMONIZE=1
-SERVICE_WRITE_PID=1
+USE_PROCD=1
-start() {
- stop
+start_service() {
[ -e /proc/sys/kernel/core_pattern ] && {
ulimit -c unlimited
echo '/tmp/%e.%p.%s.%t.core' > /proc/sys/kernel/core_pattern
}
- service_start /sbin/netifd
+ procd_open_instance
+ procd_set_param command /sbin/netifd
+ procd_set_param respawn
+ procd_close_instance
+}
+
+reload_service() {
+ ubus call network reload
+ /sbin/wifi down
+ /sbin/wifi up
+}
+
+stop_service() {
+ /sbin/wifi down
+}
+service_running() {
setup_switch() { return 0; }
include /lib/network
@@ -25,24 +38,20 @@ start() {
/sbin/wifi up
}
+service_triggers()
+{
+ procd_add_reload_trigger "network"
+}
+
restart() {
ifdown -a
sleep 1
- start
+ trap '' TERM
+ stop "$@"
+ start "$@"
}
shutdown() {
ifdown -a
stop
}
-
-stop() {
- /sbin/wifi down
- service_stop /sbin/netifd
-}
-
-reload() {
- ubus call network reload
- /sbin/wifi down
- /sbin/wifi up
-}
diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
index 630c07d1d8..a0aee8e02b 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -3,7 +3,8 @@
START=60
-SERVICE_USE_PID=1
+USE_PROCD=1
+PROG=/usr/sbin/dnsmasq
DNS_SERVERS=""
DOMAIN=""
@@ -479,7 +480,12 @@ dhcp_hostrecord_add() {
xappend "--host-record=$record"
}
-start() {
+service_triggers()
+{
+ procd_add_reload_trigger "dhcp"
+}
+
+start_service() {
include /lib/network
scan_interfaces
@@ -488,6 +494,10 @@ start() {
config_load dhcp
+ procd_open_instance
+ procd_set_param command $PROG -C $CONFIGFILE -k
+ procd_close_instance
+
# before we can call xappend
mkdir -p $(dirname $CONFIGFILE)
@@ -528,23 +538,19 @@ start() {
config_foreach dhcp_cname_add cname
echo >> $CONFIGFILE
- service_start /usr/sbin/dnsmasq -C $CONFIGFILE && {
- rm -f /tmp/resolv.conf
- [ $ADD_LOCAL_DOMAIN -eq 1 ] && [ -n "$DOMAIN" ] && {
- echo "search $DOMAIN" >> /tmp/resolv.conf
- }
- DNS_SERVERS="$DNS_SERVERS 127.0.0.1"
- for DNS_SERVER in $DNS_SERVERS ; do
- echo "nameserver $DNS_SERVER" >> /tmp/resolv.conf
- done
+ rm -f /tmp/resolv.conf
+ [ $ADD_LOCAL_DOMAIN -eq 1 ] && [ -n "$DOMAIN" ] && {
+ echo "search $DOMAIN" >> /tmp/resolv.conf
}
+ DNS_SERVERS="$DNS_SERVERS 127.0.0.1"
+ for DNS_SERVER in $DNS_SERVERS ; do
+ echo "nameserver $DNS_SERVER" >> /tmp/resolv.conf
+ done
}
-stop() {
- service_stop /usr/sbin/dnsmasq && {
- [ -f /tmp/resolv.conf ] && {
- rm -f /tmp/resolv.conf
- ln -s /tmp/resolv.conf.auto /tmp/resolv.conf
- }
+stop_service() {
+ [ -f /tmp/resolv.conf ] && {
+ rm -f /tmp/resolv.conf
+ ln -s /tmp/resolv.conf.auto /tmp/resolv.conf
}
}
diff --git a/package/network/services/dropbear/files/dropbear.init b/package/network/services/dropbear/files/dropbear.init
index 9390833d30..728767f030 100755
--- a/package/network/services/dropbear/files/dropbear.init
+++ b/package/network/services/dropbear/files/dropbear.init
@@ -123,7 +123,7 @@ start_service()
service_triggers()
{
- procd_add_config_trigger "dropbear" "/etc/init.d/dropbear" "restart"
+ procd_add_reload_trigger "dropbear"
}
killclients()
diff --git a/package/network/services/ipset-dns/files/ipset-dns.init b/package/network/services/ipset-dns/files/ipset-dns.init
index 7b732791ea..0a76fcc4cd 100755
--- a/package/network/services/ipset-dns/files/ipset-dns.init
+++ b/package/network/services/ipset-dns/files/ipset-dns.init
@@ -3,9 +3,7 @@
START=61
-SERVICE_DAEMONIZE=1
-SERVICE_WRITE_PID=1
-
+USE_PROCD=1
find_nameserver() {
. /lib/functions/network.sh
@@ -38,28 +36,22 @@ start_instance() {
config_get port "$cfg" port $((PORT++))
- SERVICE_PID_FILE="/var/run/ipset-dns-$port.pid" \
- service_start /usr/sbin/ipset-dns "$ipset" "$ipset6" "$port" "$dns"
+ procd_open_instance
+ procd_set_param command /usr/sbin/ipset-dns "$ipset" "$ipset6" "$port" "$dns"
+ procd_set_param env NO_DAEMONIZE=1
+ procd_set_param respawn
+ procd_close_instance
+}
+
+service_triggers()
+{
+ procd_add_reload_trigger "ipset-dns"
}
-start() {
+start_service() {
PORT=53001
DEFNS="$(find_nameserver)"
- # required by ipset-dns to not daemonize itself
- export NO_DAEMONIZE=1
-
config_load ipset-dns
config_foreach start_instance ipset-dns
}
-
-stop() {
- local pid
- for pid in /var/run/ipset-dns-*.pid; do
- [ -f "$pid" ] || continue
- SERVICE_PID_FILE="$pid" \
- service_stop /usr/sbin/ipset-dns
- rm -f "$pid"
- done
-}
-
diff --git a/package/network/services/relayd/files/relay.init b/package/network/services/relayd/files/relay.init
index 43ba6e10f4..edc419c0b9 100644
--- a/package/network/services/relayd/files/relay.init
+++ b/package/network/services/relayd/files/relay.init
@@ -2,9 +2,12 @@
# Copyright (c) 2011-2012 OpenWrt.org
START=80
+USE_PROCD=1
+PROG=/usr/sbin/relayd
+
resolve_ifname() {
grep -qs "^ *$1:" /proc/net/dev && {
- append args "-I $1"
+ procd_append_param command -I "$1"
append ifaces "$1"
}
}
@@ -37,6 +40,9 @@ start_relay() {
fi
}
+ procd_open_instance
+ procd_set_param command "$PROG"
+
local net networks
config_get networks "$cfg" network
for net in $networks; do
@@ -53,44 +59,41 @@ start_relay() {
local ipaddr
config_get ipaddr "$cfg" ipaddr
- [ -n "$ipaddr" ] && append args "-L $ipaddr"
+ [ -n "$ipaddr" ] && procd_append_param command -L "$ipaddr"
local gateway
config_get gateway "$cfg" gateway
- [ -n "$gateway" ] && append args "-G $gateway"
+ [ -n "$gateway" ] && procd_append_param command -G "$gateway"
local expiry # = 30
config_get expiry "$cfg" expiry
- [ -n "$expiry" ] && append args "-t $expiry"
+ [ -n "$expiry" ] && procd_append_param command "$expiry"
local retry # = 5
config_get retry "$cfg" retry
- [ -n "$retry" ] && append args "-p $retry"
+ [ -n "$retry" ] && procd_append_param command -p "$retry"
local table # = 16800
config_get table "$cfg" table
- [ -n "$table" ] && append args "-T $table"
+ [ -n "$table" ] && procd_append_param command -T "$table"
local fwd_bcast # = 1
config_get_bool fwd_bcast "$cfg" forward_bcast 1
- [ $fwd_bcast -eq 1 ] && append args "-B"
+ [ $fwd_bcast -eq 1 ] && procd_append_param command "-B"
local fwd_dhcp # = 1
config_get_bool fwd_dhcp "$cfg" forward_dhcp 1
- [ $fwd_dhcp -eq 1 ] && append args "-D"
+ [ $fwd_dhcp -eq 1 ] && procd_append_param command"-D"
- service_start /usr/sbin/relayd $args
+ procd_close_instance
}
-stop() {
- for pid in /var/run/relay-*.pid; do
- SERVICE_PID_FILE="$pid"
- service_stop /usr/sbin/relayd
- rm -f "$SERVICE_PID_FILE"
- done
+service_triggers()
+{
+ procd_add_reload_trigger "network"
}
-start() {
+start_service() {
include /lib/network
config_load network
config_foreach start_relay interface
diff --git a/package/network/services/uhttpd/files/uhttpd.init b/package/network/services/uhttpd/files/uhttpd.init
index 26fb0422a2..51f7547ca8 100755
--- a/package/network/services/uhttpd/files/uhttpd.init
+++ b/package/network/services/uhttpd/files/uhttpd.init
@@ -3,8 +3,7 @@
START=50
-SERVICE_DAEMONIZE=1
-SERVICE_WRITE_PID=1
+USE_PROCD=1
UHTTPD_BIN="/usr/sbin/uhttpd"
PX5G_BIN="/usr/sbin/px5g"
@@ -17,7 +16,7 @@ append_arg() {
local val
config_get val "$cfg" "$var"
- [ -n "$val" -o -n "$def" ] && append UHTTPD_ARGS "$opt ${val:-$def}"
+ [ -n "$val" -o -n "$def" ] && procd_append_param command "$opt" "${val:-$def}"
}
append_bool() {
@@ -28,7 +27,7 @@ append_bool() {
local val
config_get_bool val "$cfg" "$var" "$def"
- [ "$val" = 1 ] && append UHTTPD_ARGS "$opt"
+ [ "$val" = 1 ] && procd_append_param command "$opt"
}
generate_keys() {
@@ -53,7 +52,6 @@ generate_keys() {
start_instance()
{
- UHTTPD_ARGS=""
UHTTPD_CERT=""
UHTTPD_KEY=""
@@ -61,6 +59,9 @@ start_instance()
local realm="$(uci_get system.@system[0].hostname)"
local listen http https interpreter indexes path
+ procd_open_instance
+ procd_set_param command "$UHTTPD_BIN" -f
+
append_arg "$cfg" home "-h"
append_arg "$cfg" realm "-r" "${realm:-OpenWrt}"
append_arg "$cfg" config "-c"
@@ -84,17 +85,17 @@ start_instance()
config_get http "$cfg" listen_http
for listen in $http; do
- append UHTTPD_ARGS "-p $listen"
+ procd_append_param command -p "$listen"
done
config_get interpreter "$cfg" interpreter
for path in $interpreter; do
- append UHTTPD_ARGS "-i $path"
+ procd_append_param command -i "$path"
done
config_get indexes "$cfg" index_page
for path in $indexes; do
- append UHTTPD_ARGS "-I $path"
+ procd_append_param command -I "$path"
done
config_get https "$cfg" listen_https
@@ -116,29 +117,20 @@ start_instance()
}
}
- SERVICE_PID_FILE=/var/run/uhttpd_${cfg}.pid
- service_start $UHTTPD_BIN -f $UHTTPD_ARGS
+ procd_close_instance
# Check if daemon is running, if not then
# re-execute in foreground to display error.
- sleep 1 && service_check $UHTTPD_BIN || \
- $UHTTPD_BIN -f $UHTTPD_ARGS
+# sleep 1 && service_check $UHTTPD_BIN || \
+# $UHTTPD_BIN -f $UHTTPD_ARGS
}
-stop_instance()
+service_triggers()
{
- local cfg="$1"
-
- SERVICE_PID_FILE=/var/run/uhttpd_${cfg}.pid
- service_stop $UHTTPD_BIN
+ procd_add_reload_trigger "uhttpd"
}
-start() {
+start_service() {
config_load uhttpd
config_foreach start_instance uhttpd
}
-
-stop() {
- config_load uhttpd
- config_foreach stop_instance uhttpd
-}