diff --git a/luci-app-passwall/root/etc/hotplug.d/iface/98-passwall b/luci-app-passwall/root/etc/hotplug.d/iface/98-passwall new file mode 100644 index 000000000..e34868b4a --- /dev/null +++ b/luci-app-passwall/root/etc/hotplug.d/iface/98-passwall @@ -0,0 +1,23 @@ +#!/bin/sh + +[[ "$ACTION" == "ifup" && $(uci get "passwall.@global[0].enabled") == "1" ]] && [ -f /var/lock/passwall_ready.lock ] && { + default_device=$(ip route | grep default | awk -F 'dev ' '{print $2}' | awk '{print $1}') + [ "$default_device" == "$DEVICE" ] && { + LOCK_FILE_DIR=/var/lock + [ ! -d ${LOCK_FILE_DIR} ] && mkdir -p ${LOCK_FILE_DIR} + LOCK_FILE="${LOCK_FILE_DIR}/passwall_ifup.lock" + if [ -s ${LOCK_FILE} ]; then + SPID=$(cat ${LOCK_FILE}) + if [ -e /proc/${SPID}/status ]; then + exit 1 + fi + cat /dev/null > ${LOCK_FILE} + fi + echo $$ > ${LOCK_FILE} + + /etc/init.d/passwall restart >/dev/null 2>&1 & + echo "passwall: restart when $INTERFACE ifup" > /dev/kmsg + + rm -rf ${LOCK_FILE} + } +} diff --git a/luci-app-passwall/root/etc/init.d/passwall b/luci-app-passwall/root/etc/init.d/passwall index 97de59cc3..c14fb8b5a 100755 --- a/luci-app-passwall/root/etc/init.d/passwall +++ b/luci-app-passwall/root/etc/init.d/passwall @@ -33,7 +33,13 @@ unlock() { } boot() { - $APP_FILE boot + local delay=$(uci -q get ${CONFIG}.@global_delay[0].start_delay || echo 1) + if [ "$delay" -gt 0 ]; then + $APP_FILE echolog "执行启动延时 $delay 秒后再启动!" + sleep $delay + fi + restart + touch ${LOCK_FILE_DIR}/${CONFIG}_ready.lock } start() { diff --git a/luci-app-passwall/root/usr/share/passwall/app.sh b/luci-app-passwall/root/usr/share/passwall/app.sh index 970bce36b..dfd9870c2 100755 --- a/luci-app-passwall/root/usr/share/passwall/app.sh +++ b/luci-app-passwall/root/usr/share/passwall/app.sh @@ -1576,16 +1576,6 @@ acl_app() { } } -boot() { - local delay=$(config_t_get global_delay start_delay 1) - if [ "$delay" -gt 0 ]; then - echolog "执行启动延时 $delay 秒后再启动!" - sleep $delay && start >/dev/null 2>&1 & - else - start - fi -} - start() { ulimit -n 65535 start_haproxy @@ -1753,7 +1743,4 @@ stop) start) start ;; -boot) - boot - ;; esac