mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Disable pihole at boot and set ip of shadowsocks and vpn from vps
This commit is contained in:
parent
6f21253f0a
commit
df496aea2b
2 changed files with 46 additions and 3 deletions
22
openmptcprouter/files/etc/init.d/disablepihole
Executable file
22
openmptcprouter/files/etc/init.d/disablepihole
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
START=10
|
||||||
|
|
||||||
|
disable_pihole() {
|
||||||
|
local server=$1
|
||||||
|
if [ "$(uci -q get openmptcprouter.${server}.pihole)" = "1" ] && [ "$(uci -q get dhcp.@dnsmasq[0].server)" != "127.0.0.1#5353" ]; then
|
||||||
|
_log "Disable Pi-Hole for boot..."
|
||||||
|
uci -q batch <<-EOF >/dev/null
|
||||||
|
delete dhcp.@dnsmasq[0].server
|
||||||
|
add_list dhcp.@dnsmasq[0].server='127.0.0.1#5353'
|
||||||
|
commit dhcp
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
start()
|
||||||
|
{
|
||||||
|
config_load openmptcprouter
|
||||||
|
config_foreach disable_pihole_status server
|
||||||
|
}
|
|
@ -463,6 +463,10 @@ _set_config_from_vps() {
|
||||||
[ -z "$vps_config" ] && vps_config=$(_get_json "config")
|
[ -z "$vps_config" ] && vps_config=$(_get_json "config")
|
||||||
[ -z "$vps_config" ] && return
|
[ -z "$vps_config" ] && return
|
||||||
|
|
||||||
|
# get VPS ip
|
||||||
|
vpsip="$(uci -q get openmptcprouter.${servername}.ip)"
|
||||||
|
vps_lastchange="$(echo "$vps_config" | jsonfilter -q -e '@.vps.lastchange')"
|
||||||
|
|
||||||
# Set current VPN
|
# Set current VPN
|
||||||
current_vpn="$(uci -q get openmptcprouter.settings.vpn)"
|
current_vpn="$(uci -q get openmptcprouter.settings.vpn)"
|
||||||
if [ -z "$current_vpn" ] || [ -n "$vps_lastchange" ]; then
|
if [ -z "$current_vpn" ] || [ -n "$vps_lastchange" ]; then
|
||||||
|
@ -513,8 +517,11 @@ _set_config_from_vps() {
|
||||||
set shadowsocks-libev.sss0.obfs_plugin=$ss_obfs_plugin
|
set shadowsocks-libev.sss0.obfs_plugin=$ss_obfs_plugin
|
||||||
set shadowsocks-libev.sss0.obfs_type=$ss_obfs_type
|
set shadowsocks-libev.sss0.obfs_type=$ss_obfs_type
|
||||||
set shadowsocks-libev.sss0.obfs_host=$ss_obfs_host
|
set shadowsocks-libev.sss0.obfs_host=$ss_obfs_host
|
||||||
commit shadowsocks-libev
|
|
||||||
EOF
|
EOF
|
||||||
|
if [ "$(uci -q get shadowsocks-libev.sss0.server)" != "127.0.0.1" ]; then
|
||||||
|
uci -q set shadowsocks-libev.sss0.server="$vpsip"
|
||||||
|
fi
|
||||||
|
uci -q commit shadowsocks-libev.sss0
|
||||||
logger -t "OMR-VPS" "Shadowsocks restart..."
|
logger -t "OMR-VPS" "Shadowsocks restart..."
|
||||||
/etc/init.d/shadowsocks-libev restart >/dev/null 2>&1
|
/etc/init.d/shadowsocks-libev restart >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
@ -540,8 +547,11 @@ _set_config_from_vps() {
|
||||||
set glorytun.vpn.key=$glorytun_key
|
set glorytun.vpn.key=$glorytun_key
|
||||||
set glorytun.vpn.enable=$glorytun_state
|
set glorytun.vpn.enable=$glorytun_state
|
||||||
set glorytun.vpn.chacha20=$glorytun_chacha
|
set glorytun.vpn.chacha20=$glorytun_chacha
|
||||||
commit glorytun
|
|
||||||
EOF
|
EOF
|
||||||
|
if [ "$(uci -q get glorytun.vpn.host)" != "127.0.0.1" ]; then
|
||||||
|
uci -q set glorytun.vpn.host="$vpsip"
|
||||||
|
fi
|
||||||
|
uci -q commit glorytun
|
||||||
logger -t "OMR-VPS" "Glorytun restart..."
|
logger -t "OMR-VPS" "Glorytun restart..."
|
||||||
/etc/init.d/glorytun restart >/dev/null 2>&1
|
/etc/init.d/glorytun restart >/dev/null 2>&1
|
||||||
/etc/init.d/glorytun-udp restart >/dev/null 2>&1
|
/etc/init.d/glorytun-udp restart >/dev/null 2>&1
|
||||||
|
@ -562,8 +572,11 @@ _set_config_from_vps() {
|
||||||
set openvpn.omr.port=$openvpn_port
|
set openvpn.omr.port=$openvpn_port
|
||||||
set openvpn.omr.secret="/etc/luci-uploads/openvpn.key"
|
set openvpn.omr.secret="/etc/luci-uploads/openvpn.key"
|
||||||
set openvpn.omr.enabled=$openvpn_state
|
set openvpn.omr.enabled=$openvpn_state
|
||||||
commit openvpn
|
|
||||||
EOF
|
EOF
|
||||||
|
if [ "$(uci -q get openvpn.omr.remote)" != "127.0.0.1" ]; then
|
||||||
|
uci -q set openvpn.omr.remote="$vpsip"
|
||||||
|
fi
|
||||||
|
uci -q commit openvpn
|
||||||
logger -t "OMR-VPS" "OpenVPN restart..."
|
logger -t "OMR-VPS" "OpenVPN restart..."
|
||||||
/etc/init.d/openvpn restart
|
/etc/init.d/openvpn restart
|
||||||
}
|
}
|
||||||
|
@ -581,6 +594,10 @@ _set_config_from_vps() {
|
||||||
set mlvpn.general.enable=$mlvpn_state
|
set mlvpn.general.enable=$mlvpn_state
|
||||||
commit mlvpn
|
commit mlvpn
|
||||||
EOF
|
EOF
|
||||||
|
if [ "$(uci -q get mlvpn.general.host)" != "127.0.0.1" ]; then
|
||||||
|
uci -q set mlvpn.general.host="$vpsip"
|
||||||
|
fi
|
||||||
|
uci -q commit mlvpn
|
||||||
logger -t "OMR-VPS" "MLVPN restart..."
|
logger -t "OMR-VPS" "MLVPN restart..."
|
||||||
/etc/init.d/mlvpn restart
|
/etc/init.d/mlvpn restart
|
||||||
fi
|
fi
|
||||||
|
@ -597,6 +614,10 @@ _set_config_from_vps() {
|
||||||
set dsvpn.vpn.enable=$dsvpn_state
|
set dsvpn.vpn.enable=$dsvpn_state
|
||||||
commit dsvpn
|
commit dsvpn
|
||||||
EOF
|
EOF
|
||||||
|
if [ "$(uci -q get dsvpn.vpn.host)" != "127.0.0.1" ]; then
|
||||||
|
uci -q set dsvpn.vpn.host="$vpsip"
|
||||||
|
fi
|
||||||
|
uci -q commit dsvpn
|
||||||
logger -t "OMR-VPS" "DSVPN restart..."
|
logger -t "OMR-VPS" "DSVPN restart..."
|
||||||
/etc/init.d/dsvpn restart
|
/etc/init.d/dsvpn restart
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue