coova-chilli: switch to procd
Signed-off-by: Jaehoon You <teslamint@gmail.com>
This commit is contained in:
parent
69492e04f2
commit
258cbcdb89
2 changed files with 70 additions and 48 deletions
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007-2014 OpenWrt.org
|
# Copyright (C) 2007-2018 OpenWrt.org
|
||||||
#
|
#
|
||||||
# This is free software, licensed under the GNU General Public License v2.
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
# See /LICENSE for more information.
|
# See /LICENSE for more information.
|
||||||
|
@ -12,7 +12,7 @@ PKG_VERSION:=1.3.0+20141128
|
||||||
PKG_MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>
|
PKG_MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>
|
||||||
PKG_LICENSE:=GPL-2.0+
|
PKG_LICENSE:=GPL-2.0+
|
||||||
PKG_LICENSE_FILES:=COPYING
|
PKG_LICENSE_FILES:=COPYING
|
||||||
PKG_RELEASE:=5
|
PKG_RELEASE:=6
|
||||||
|
|
||||||
PKG_SOURCE_PROTO:=git
|
PKG_SOURCE_PROTO:=git
|
||||||
PKG_SOURCE_URL:=git://github.com/coova/coova-chilli
|
PKG_SOURCE_URL:=git://github.com/coova/coova-chilli
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
START=30
|
START=90
|
||||||
STOP=90
|
STOP=89
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger "chilli"
|
||||||
|
}
|
||||||
|
|
||||||
config_cb() {
|
config_cb() {
|
||||||
chilli_inst=$2
|
local chilli_inst="$2"
|
||||||
if [ "$chilli_inst" != "" ]
|
if [ "$chilli_inst" != "" ]; then
|
||||||
then
|
chilli_conf="/var/run/chilli_${chilli_inst}.conf"
|
||||||
rm -f /var/run/chilli_${chilli_inst}.*
|
if [ -e "$chilli_conf" ]; then
|
||||||
chilli_conf=/var/run/chilli_${chilli_inst}.conf
|
rm -f "$chilli_conf"
|
||||||
|
fi
|
||||||
eval "start_chilli_$chilli_inst=1"
|
eval "start_chilli_$chilli_inst=1"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -19,18 +25,18 @@ option_cb() {
|
||||||
network)
|
network)
|
||||||
. /lib/functions/network.sh
|
. /lib/functions/network.sh
|
||||||
local ifname
|
local ifname
|
||||||
network_get_device ifname $2
|
network_get_device ifname "$2"
|
||||||
echo "dhcpif=\"$ifname\"" >> $chilli_conf
|
echo "dhcpif=\"$ifname\"" >> "$chilli_conf"
|
||||||
;;
|
;;
|
||||||
disabled)
|
disabled)
|
||||||
eval "start_chilli_$chilli_inst=0"
|
[ "$(config_get_bool "$1")" = "1" ] && eval "start_chilli_$chilli_inst=0"
|
||||||
;;
|
;;
|
||||||
# boolean settings
|
# boolean settings
|
||||||
dhcpbroadcast|nodynip|vlanlocation|locationstopstart|locationcopycalled|locationimmediateupdate|locationopt82|coanoipcheck|noradallow|proxymacaccept|proxyonacct|dhcpmacset|dhcpradius|noc2c|eapolenable|uamanydns|uamanyip|uamnatanyip|nouamsuccess|nowispr1|nowispr2|domaindnslocal|radsec|macauth|macreauth|macauthdeny|macallowlocal|strictmacauth|strictdhcp|ieee8021q|only8021q|radiusoriginalurl|swapoctets|statusfilesave|wpaguests|openidauth|papalwaysok|mschapv2|chillixml|acctupdate|dnsparanoia|seskeepalive|usetap|noarpentries|framedservice|scalewin|redir|injectwispr|redirurl|routeonetone|nousergardendata|uamgardendata|uamotherdata|withunixipc|uamallowpost|redirssl|uamuissl|layer3|patricia|redirdnsreq|dhcpnotidle|ipv6|ipv6only)
|
debug|dhcpbroadcast|nodynip|vlanlocation|locationstopstart|locationcopycalled|locationimmediateupdate|locationopt82|coanoipcheck|noradallow|proxymacaccept|proxyonacct|dhcpmacset|dhcpradius|noc2c|eapolenable|uamanydns|uamanyip|uamnatanyip|nouamsuccess|nowispr1|nowispr2|domaindnslocal|radsec|macauth|macreauth|macauthdeny|macallowlocal|strictmacauth|strictdhcp|ieee8021q|only8021q|radiusoriginalurl|swapoctets|statusfilesave|wpaguests|openidauth|papalwaysok|mschapv2|chillixml|acctupdate|dnsparanoia|seskeepalive|usetap|noarpentries|framedservice|scalewin|redir|injectwispr|redirurl|routeonetone|nousergardendata|uamgardendata|uamotherdata|withunixipc|uamallowpost|redirssl|uamuissl|layer3|patricia|redirdnsreq|dhcpnotidle|ipv6|ipv6only)
|
||||||
[ "$2" = "true" -o "$2" = "1" ] && echo "$1" >> $chilli_conf
|
[ "$2" = "true" -o "$2" = "1" ] && echo "$1" >> "$chilli_conf"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "$1=\"$2\"" >> $chilli_conf
|
echo "$1=\"$2\"" >> "$chilli_conf"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -39,23 +45,39 @@ start_chilli() {
|
||||||
local cfg="$1"
|
local cfg="$1"
|
||||||
local start_chilli=$(eval "echo \$start_chilli_$cfg")
|
local start_chilli=$(eval "echo \$start_chilli_$cfg")
|
||||||
[ "$start_chilli" = "0" ] && return
|
[ "$start_chilli" = "0" ] && return
|
||||||
local base=/var/run/chilli_${cfg}
|
local base="/var/run/chilli_${cfg}"
|
||||||
chilli -c ${base}.conf \
|
|
||||||
--pidfile ${base}.pid \
|
procd_open_instance "$cfg"
|
||||||
--cmdsocket ${base}.sock \
|
procd_set_param command /usr/sbin/chilli
|
||||||
--unixipc ${base}.ipc &
|
procd_set_param file "${base}.conf"
|
||||||
|
procd_append_param command --fg --conf "${base}.conf" --pidfile "${base}.pid" --cmdsocket "${base}.sock" --unixipc "${base}.ipc"
|
||||||
|
procd_set_param respawn
|
||||||
|
procd_set_param stdout 1
|
||||||
|
procd_set_param stderr 1
|
||||||
|
procd_close_instance
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start_service() {
|
||||||
config_load chilli
|
config_load chilli
|
||||||
config_foreach start_chilli chilli
|
config_foreach start_chilli chilli
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop_service() {
|
||||||
ls /var/run/chilli*.pid 2>/dev/null && {
|
rm -f /var/run/chilli_*
|
||||||
kill $(cat /var/run/chilli*.pid)
|
}
|
||||||
sleep 1
|
|
||||||
killall -9 chilli
|
reload_chilli() {
|
||||||
rm -f /var/run/chilli*
|
local pid
|
||||||
}
|
local cfg="$1"
|
||||||
|
local base="/var/run/chilli_${cfg}"
|
||||||
|
if [ -f "${base}.pid" ]; then
|
||||||
|
pid="$(cat "${base}.pid")"
|
||||||
|
[ -f "/var/run/chilli.${pid}.cfg.bin" ] && rm -f "/var/run/chilli.${pid}.cfg.bin"
|
||||||
|
chilli_query -s "${base}.sock" reload
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
reload_service() {
|
||||||
|
config_load chilli
|
||||||
|
config_foreach reload_chilli chilli
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue