Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
vernesong committed Dec 2, 2023
1 parent a646b47 commit 1891cc6
Showing 1 changed file with 40 additions and 48 deletions.
88 changes: 40 additions & 48 deletions luci-app-openclash/root/etc/uci-defaults/luci-openclash
Original file line number Diff line number Diff line change
Expand Up @@ -45,56 +45,14 @@ cat > "/lib/upgrade/keep.d/luci-app-openclash" <<-EOF
EOF

#Set Dashboard Secret
if [ "$(uci -q get openclash.config.dashboard_password)" == "123456" ]; then
uci -q set openclash.config.dashboard_password="$(tr -cd 'a-zA-Z0-9' </dev/urandom 2>/dev/null| head -c8 || date +%N| md5sum |head -c8)"
fi
uci -q set openclash.config.dashboard_password="$(tr -cd 'a-zA-Z0-9' </dev/urandom 2>/dev/null| head -c8 || date +%N| md5sum |head -c8)"

#Set authentication
if [ -n "$(uci -q get openclash.@authentication[0].enabled)" ]; then
auth_cfg=false
else
auth_cfg=true
fi

if $auth_cfg; then
uci_name_tmp=$(uci add openclash authentication)
uci_set="uci -q set openclash.$uci_name_tmp."
${uci_set}enabled="1"
${uci_set}username="Clash"
${uci_set}password="$(tr -cd 'a-zA-Z0-9' </dev/urandom 2>/dev/null| head -c8 || date +%N| md5sum |head -c8)"
fi

#Restore
if [ -f "/tmp/openclash.bak" ]; then
mv -f "/tmp/openclash.bak" "/etc/config/openclash" >/dev/null 2>&1
cp -rf "/tmp/openclash/." "/etc/openclash/" >/dev/null 2>&1
cp -rf "/tmp/openclash_config/." "/etc/openclash/config/" >/dev/null 2>&1
cp -rf "/tmp/openclash_core/." "/etc/openclash/core/" >/dev/null 2>&1
cp -rf "/tmp/openclash_history/." "/etc/openclash/history/" >/dev/null 2>&1
cp -rf "/tmp/openclash_proxy_provider/." "/etc/openclash/proxy_provider/" >/dev/null 2>&1
cp -rf "/tmp/openclash_rule_provider/." "/etc/openclash/rule_provider/" >/dev/null 2>&1
cp -rf "/tmp/openclash_game_rules/." "/etc/openclash/game_rules/" >/dev/null 2>&1
mv -f "/tmp/openclash_custom_rules.list.bak" "/etc/openclash/custom/openclash_custom_rules.list" >/dev/null 2>&1
mv -f "/tmp/openclash_custom_rules_2.list.bak" "/etc/openclash/custom/openclash_custom_rules_2.list" >/dev/null 2>&1
mv -f "/tmp/openclash_custom_hosts.list.bak" "/etc/openclash/custom/openclash_custom_hosts.list" >/dev/null 2>&1
mv -f "/tmp/openclash_custom_fake_filter.list.bak" "/etc/openclash/custom/openclash_custom_fake_filter.list" >/dev/null 2>&1
mv -f "/tmp/openclash_custom_domain_dns.list.bak" "/etc/openclash/custom/openclash_custom_domain_dns.list" >/dev/null 2>&1
if [ -d "/tmp/openclash_dashboard/" ]; then
rm -rf "/usr/share/openclash/ui/dashboard/" >/dev/null 2>&1
cp -rf "/tmp/openclash_dashboard/." "/usr/share/openclash/ui/dashboard/" >/dev/null 2>&1
rm -rf "/tmp/openclash_dashboard/" >/dev/null 2>&1
fi
if [ -d "/tmp/openclash_yacd/" ]; then
rm -rf "/usr/share/openclash/ui/yacd/" >/dev/null 2>&1
cp -rf "/tmp/openclash_yacd/." "/usr/share/openclash/ui/yacd/" >/dev/null 2>&1
rm -rf "/tmp/openclash_yacd/" >/dev/null 2>&1
fi
rm -rf "/etc/openclash/openclash" >/dev/null 2>&1
rm -rf "/etc/openclash/fake_filter.list" >/dev/null 2>&1
rm -rf "/etc/openclash/openclash_servers_fake_filter.conf" >/dev/null 2>&1
rm -rf "/tmp/openclash" >/dev/null 2>&1
rm -rf "/tmp/openclash.bak" >/dev/null 2>&1
fi
uci_name_tmp=$(uci add openclash authentication)
uci_set="uci -q set openclash.$uci_name_tmp."
${uci_set}enabled="1"
${uci_set}username="Clash"
${uci_set}password="$(tr -cd 'a-zA-Z0-9' </dev/urandom 2>/dev/null| head -c8 || date +%N| md5sum |head -c8)"

#Set Core Model
source "/etc/openwrt_release"
Expand Down Expand Up @@ -137,6 +95,40 @@ if [ -n "$(uci -q get dhcp.@dnsmasq[0].resolvfile)" ]; then
uci -q set openclash.config.default_resolvfile=$(uci -q get dhcp.@dnsmasq[0].resolvfile)
fi

uci -q commit openclash

#Restore
if [ -f "/tmp/openclash.bak" ]; then
mv -f "/tmp/openclash.bak" "/etc/config/openclash" >/dev/null 2>&1
cp -rf "/tmp/openclash/." "/etc/openclash/" >/dev/null 2>&1
cp -rf "/tmp/openclash_config/." "/etc/openclash/config/" >/dev/null 2>&1
cp -rf "/tmp/openclash_core/." "/etc/openclash/core/" >/dev/null 2>&1
cp -rf "/tmp/openclash_history/." "/etc/openclash/history/" >/dev/null 2>&1
cp -rf "/tmp/openclash_proxy_provider/." "/etc/openclash/proxy_provider/" >/dev/null 2>&1
cp -rf "/tmp/openclash_rule_provider/." "/etc/openclash/rule_provider/" >/dev/null 2>&1
cp -rf "/tmp/openclash_game_rules/." "/etc/openclash/game_rules/" >/dev/null 2>&1
mv -f "/tmp/openclash_custom_rules.list.bak" "/etc/openclash/custom/openclash_custom_rules.list" >/dev/null 2>&1
mv -f "/tmp/openclash_custom_rules_2.list.bak" "/etc/openclash/custom/openclash_custom_rules_2.list" >/dev/null 2>&1
mv -f "/tmp/openclash_custom_hosts.list.bak" "/etc/openclash/custom/openclash_custom_hosts.list" >/dev/null 2>&1
mv -f "/tmp/openclash_custom_fake_filter.list.bak" "/etc/openclash/custom/openclash_custom_fake_filter.list" >/dev/null 2>&1
mv -f "/tmp/openclash_custom_domain_dns.list.bak" "/etc/openclash/custom/openclash_custom_domain_dns.list" >/dev/null 2>&1
if [ -d "/tmp/openclash_dashboard/" ]; then
rm -rf "/usr/share/openclash/ui/dashboard/" >/dev/null 2>&1
cp -rf "/tmp/openclash_dashboard/." "/usr/share/openclash/ui/dashboard/" >/dev/null 2>&1
rm -rf "/tmp/openclash_dashboard/" >/dev/null 2>&1
fi
if [ -d "/tmp/openclash_yacd/" ]; then
rm -rf "/usr/share/openclash/ui/yacd/" >/dev/null 2>&1
cp -rf "/tmp/openclash_yacd/." "/usr/share/openclash/ui/yacd/" >/dev/null 2>&1
rm -rf "/tmp/openclash_yacd/" >/dev/null 2>&1
fi
rm -rf "/etc/openclash/openclash" >/dev/null 2>&1
rm -rf "/etc/openclash/fake_filter.list" >/dev/null 2>&1
rm -rf "/etc/openclash/openclash_servers_fake_filter.conf" >/dev/null 2>&1
rm -rf "/tmp/openclash" >/dev/null 2>&1
rm -rf "/tmp/openclash.bak" >/dev/null 2>&1
fi

uci -q set openclash.config.enable=0
uci -q commit openclash

Expand Down

0 comments on commit 1891cc6

Please sign in to comment.