mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-30 22:05:13 +08:00
🎉 Sync 2026-03-30 23:55:08
This commit is contained in:
1 parent
9283298b33
commit
2bd051c664
84 files changed
+3097
-3780
No files matched your search
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Copyright (C) 2017-2019 Chen Minqiang <ptpt52@gmail.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI Support for wizard
|
||||
LUCI_DEPENDS:=
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_NAME:=luci-app-wizard
|
||||
|
||||
PKG_MAINTAINER:=Chen Minqiang <ptpt52@gmail.com>
|
||||
PKG_LICENSE:=GPLv3
|
||||
|
||||
define Package/luci-app-wizard/conffiles
|
||||
/etc/config/wizard
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
@@ -0,0 +1,3 @@
|
||||
# luci-app-wizard
|
||||
|
||||
修改自 https://github.com/x-wrt/com.x-wrt/tree/master/luci-app-wizard
|
||||
@@ -0,0 +1,160 @@
|
||||
'use strict';
|
||||
'require view';
|
||||
'require dom';
|
||||
'require poll';
|
||||
'require uci';
|
||||
'require rpc';
|
||||
'require form';
|
||||
'require fs';
|
||||
|
||||
return view.extend({
|
||||
load: async function () {
|
||||
const promises = await Promise.all([
|
||||
fs.exec('/etc/init.d/wizard', ['reconfig']),
|
||||
uci.changes(),
|
||||
L.resolveDefault(uci.load('wireless')),
|
||||
uci.load('wizard'),
|
||||
L.resolveDefault(fs.stat('/www/luci-static/istorex/style.css'), null),
|
||||
L.resolveDefault(fs.stat('/www/luci-static/routerdog/style.css'), null),
|
||||
L.resolveDefault(fs.stat('/usr/sbin/nginx'), null)
|
||||
]);
|
||||
const data = {
|
||||
istorex: promises[4],
|
||||
routerdog: promises[5],
|
||||
nginx: promises[6]
|
||||
};
|
||||
return data;
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
var m, s, o;
|
||||
var has_wifi = false;
|
||||
|
||||
if (uci.sections('wireless', 'wifi-device').length > 0) {
|
||||
has_wifi = true;
|
||||
}
|
||||
|
||||
m = new form.Map('wizard', [_('Initial Router Setup')],
|
||||
_('If you are using this router for the first time, please configure it here.'));
|
||||
|
||||
s = m.section(form.NamedSection, 'default', 'wizard');
|
||||
s.addremove = false;
|
||||
s.tab('netsetup', _('Net Settings'), _('Three different ways to access the Internet, please choose according to your own situation.'));
|
||||
|
||||
o = s.taboption('netsetup', form.ListValue, 'wan_proto', _('Protocol'));
|
||||
o.rmempty = false;
|
||||
o.value('dhcp', _('DHCP client'));
|
||||
o.value('pppoe', _('PPPoE'));
|
||||
|
||||
o = s.taboption('netsetup', form.Value, 'wan_pppoe_user', _('PAP/CHAP username'));
|
||||
o.depends('wan_proto', 'pppoe');
|
||||
|
||||
o = s.taboption('netsetup', form.Value, 'wan_pppoe_pass', _('PAP/CHAP password'));
|
||||
o.depends('wan_proto', 'pppoe');
|
||||
o.password = true;
|
||||
|
||||
o = s.taboption('netsetup', form.Value, 'lan_ipaddr', _('IPv4 address'));
|
||||
o.datatype = 'ip4addr';
|
||||
|
||||
o = s.taboption('netsetup', form.Value, 'lan_netmask', _('IPv4 netmask'));
|
||||
o.datatype = 'ip4addr';
|
||||
o.value('255.255.255.0');
|
||||
o.value('255.255.0.0');
|
||||
o.value('255.0.0.0');
|
||||
o.default = '255.255.255.0';
|
||||
|
||||
o = s.taboption('netsetup', form.DynamicList, 'lan_dns', _('Use custom DNS servers'), _('Leave empty to use ISP DNS'));
|
||||
o.datatype = 'ip4addr';
|
||||
o.cast = 'string';
|
||||
|
||||
o = s.taboption('netsetup', form.Flag, 'siderouter', _('Siderouter'),
|
||||
_('Use as downstream router i.e. it will work like a switch'));
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.taboption('netsetup', form.Value, 'lan_gateway', _('IPv4 gateway'));
|
||||
o.depends('siderouter', '1');
|
||||
o.datatype = 'ip4addr';
|
||||
o.placeholder = _('Enter the main router IP');
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.taboption('netsetup', form.Flag, 'dhcp', _('DHCP Server'),
|
||||
_('To turn on this DHCP, you need to turn off the DHCP of the main router, and to turn off this DHCP, you need to manually change the gateway and DNS of all Internet devices to the IP of this bypass router'));
|
||||
o.depends('siderouter', '1');
|
||||
o.default = o.enabled;
|
||||
|
||||
o = s.taboption('netsetup', form.Flag, 'ipv6', _('Enable IPv6'), _('Enable/Disable IPv6'));
|
||||
o.default = o.enabled;
|
||||
|
||||
s.tab('firmware', _('Firmware Settings'));
|
||||
|
||||
// o = s.taboption('firmware', form.Flag, 'autoupgrade_pkg', _('Packages Auto Upgrade'),_('谨慎开启'));
|
||||
// o.rmempty = false;
|
||||
|
||||
o = s.taboption('firmware', form.Flag, 'autoupgrade_fm', _('Firmware Upgrade Notice'));
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.taboption('firmware', form.Flag, 'coremark', _('CoreMark'), _('第一次开机后是否运行CPU跑分测试'));
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.taboption('firmware', form.Flag, 'cookie_p', _('Persistent cookies'),
|
||||
_('Keep the background login state to avoid the need to log in again every time the browser is closed'));
|
||||
o.default = o.enabled;
|
||||
|
||||
o = s.taboption('firmware', form.Flag, 'https', _('Force the use of HTTPS in the backend.'));
|
||||
|
||||
if (data.istorex || data.routerdog){
|
||||
o = s.taboption('firmware', form.ListValue, 'landing_page', _('主题模式'));
|
||||
o.value('default', _('默认'));
|
||||
if (data.routerdog){
|
||||
o.value('routerdog', _('路由狗(专业NAS模式)'));
|
||||
}
|
||||
if (data.istorex){
|
||||
o.value('nas', _('NAS模式'));
|
||||
o.value('next-nas', _('NEXT-NAS模式'));
|
||||
o.value('router', _('路由模式'));
|
||||
}
|
||||
o.default = 'default';
|
||||
}
|
||||
|
||||
if (has_wifi) {
|
||||
s.tab('wifisetup', _('Wireless Settings'), _('Set the router\'s wireless name and password. For more advanced settings, please go to the Network-Wireless page.'));
|
||||
o = s.taboption('wifisetup', form.Value, 'wifi_ssid', _('<abbr title=\"Extended Service Set Identifier\">ESSID</abbr>'));
|
||||
o.datatype = 'maxlength(32)';
|
||||
|
||||
o = s.taboption("wifisetup", form.Value, "wifi_key", _("Key"));
|
||||
o.datatype = 'wpakey';
|
||||
o.password = true;
|
||||
}
|
||||
|
||||
if (data.nginx) {
|
||||
s.tab('shortcuts', _('Shortcuts'), _('比如设置google.com的快捷方式为字母g,则在此路由器网络的任何浏览器中输入g/即可访问google.com'));
|
||||
|
||||
o = s.taboption('shortcuts', form.SectionValue, 'shortcuts', form.GridSection, 'shortcuts', null,
|
||||
_('Shortcuts'));
|
||||
|
||||
s = o.subsection;
|
||||
s.addremove = true;
|
||||
s.anonymous = true;
|
||||
|
||||
o = s.option(form.Value, 'shortcut', _('Shortcut'));
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Value, 'to_url', _('Target URL'));
|
||||
o.rmempty = false;
|
||||
o.placeholder = 'https://example.com';
|
||||
o.validate = function(section_id, value) {
|
||||
if (value.match(/^https?:\/\/.+/i)) {
|
||||
return true;
|
||||
}
|
||||
return _('Please enter a valid URL starting with http:// or https://');
|
||||
};
|
||||
|
||||
o = s.option(form.Value, 'comments', _('Comments'));
|
||||
o.optional = true;
|
||||
}
|
||||
|
||||
setTimeout("document.getElementsByClassName('cbi-button-apply')[0].children[3].children[0].value='1'", 1000)
|
||||
|
||||
return m.render();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
module("luci.controller.wizard", package.seeall)
|
||||
|
||||
local uci = luci.model.uci.cursor()
|
||||
local http = require "luci.http"
|
||||
|
||||
function index()
|
||||
entry({"admin", "index"}, call("landing_page"), _("Home") , 1).dependent = false
|
||||
end
|
||||
|
||||
function landing_page()
|
||||
local landing_page = uci:get("wizard", "default", "landing_page")
|
||||
if (luci.sys.call("pgrep routergo >/dev/null") == 0 and landing_page == "routerdog") then
|
||||
http.redirect(luci.dispatcher.build_url("admin","routerdog"));
|
||||
elseif luci.sys.call("pgrep quickstart >/dev/null") == 0 then
|
||||
if landing_page == "nas" then
|
||||
http.redirect(luci.dispatcher.build_url("admin","istorex","nas"));
|
||||
elseif landing_page == "next-nas" then
|
||||
http.redirect(luci.dispatcher.build_url("admin","istorex","next-nas"));
|
||||
elseif landing_page == "router" then
|
||||
http.redirect(luci.dispatcher.build_url("admin","istorex","router"));
|
||||
else
|
||||
http.redirect(luci.dispatcher.build_url("admin","quickstart"));
|
||||
end
|
||||
else
|
||||
http.redirect(luci.dispatcher.build_url("admin","status"))
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,44 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8\n"
|
||||
|
||||
msgid "Wizard"
|
||||
msgstr "Мастер настройки"
|
||||
|
||||
msgid "Initial Router Setup"
|
||||
msgstr "Мастер настройки маршрутизатора"
|
||||
|
||||
msgid "Net Settings"
|
||||
msgstr "Сетевые настройки"
|
||||
|
||||
msgid "Wireless Settings"
|
||||
msgstr "Настройки беспроводной связи"
|
||||
|
||||
msgid "If you are using this router for the first time, please configure it here."
|
||||
msgstr "Если вы используете этот маршрутизатор в первый раз, пожалуйста, просто настройте его здесь."
|
||||
|
||||
msgid "Three different ways to access the Internet, please choose according to your own situation."
|
||||
msgstr "Существует два различных способа серфинга в Интернете, пожалуйста, выбирайте в соответствии с вашей собственной ситуацией."
|
||||
|
||||
msgid "Set the router's wireless name and password. For more advanced settings, please go to the Network-Wireless page."
|
||||
msgstr "Задайте имя беспроводной сети и пароль маршрутизатора. для получения более подробных настроек, пожалуйста, перейдите на страницу Cеть-Беспроводная связь."
|
||||
|
||||
msgid "Siderouter"
|
||||
msgstr "Вторичный роутер"
|
||||
|
||||
msgid "Enable IPv6"
|
||||
msgstr "Включить IPv6"
|
||||
|
||||
msgid "Enable/Disable IPv6"
|
||||
msgstr "Включение/Отключение IPv6"
|
||||
|
||||
msgid "Firmware Settings"
|
||||
msgstr "Настройки встроенного ПО"
|
||||
|
||||
msgid "Packages Auto Upgrade"
|
||||
msgstr "Автоматическое обновление пакета"
|
||||
|
||||
msgid "Firmware Upgrade Notice"
|
||||
msgstr "Напоминание об обновлении прошивки"
|
||||
|
||||
msgid "Persistent cookies"
|
||||
msgstr "Постоянный вход в систему"
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
zh_Hans
|
||||
@@ -0,0 +1,75 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8\n"
|
||||
|
||||
msgid "Wizard"
|
||||
msgstr "设置向导"
|
||||
|
||||
msgid "Initial Router Setup"
|
||||
msgstr "路由器设置向导"
|
||||
|
||||
msgid "Net Settings"
|
||||
msgstr "网络设置"
|
||||
|
||||
msgid "Wireless Settings"
|
||||
msgstr "无线设置"
|
||||
|
||||
msgid "If you are using this router for the first time, please configure it here."
|
||||
msgstr "如果你首次使用这个路由器,请在这里简单设置。"
|
||||
|
||||
msgid "Three different ways to access the Internet, please choose according to your own situation."
|
||||
msgstr "二种不同的上网方式,请您根据自身情况进行选择。"
|
||||
|
||||
msgid "Set the router's wireless name and password. For more advanced settings, please go to the Network-Wireless page."
|
||||
msgstr "设置路由器的无线名字和密码,更多高级设置请进入 网络-无线 页面。"
|
||||
|
||||
msgid "Leave empty to use ISP DNS"
|
||||
msgstr "留空则使用阿里DNS"
|
||||
|
||||
msgid "Enter the main router IP"
|
||||
msgstr "请输入主路由IP"
|
||||
|
||||
msgid "Siderouter"
|
||||
msgstr "旁路由模式"
|
||||
|
||||
msgid "To turn on this DHCP, you need to turn off the DHCP of the main router, and to turn off this DHCP, you need to manually change the gateway and DNS of all Internet devices to the IP of this bypass router"
|
||||
msgstr "开启此DHCP则需要关闭主路由的DHCP, 关闭此DHCP则需要手动将所有上网设备的网关和DNS改为此旁路由的IP"
|
||||
|
||||
msgid "Enable IPv6"
|
||||
msgstr "启用IPv6"
|
||||
|
||||
msgid "Enable/Disable IPv6"
|
||||
msgstr "一键开启/关闭 IPv6"
|
||||
|
||||
msgid "Firmware Settings"
|
||||
msgstr "固件设置"
|
||||
|
||||
msgid "Packages Auto Upgrade"
|
||||
msgstr "软件包自动更新"
|
||||
|
||||
msgid "Firmware Upgrade Notice"
|
||||
msgstr "固件更新提醒"
|
||||
|
||||
msgid "Persistent cookies"
|
||||
msgstr "持久化登录"
|
||||
|
||||
msgid "Keep the background login state to avoid the need to log in again every time the browser is closed"
|
||||
msgstr "保持后台登录状态,避免每次关闭浏览器后都需要重新登录"
|
||||
|
||||
msgid "Home"
|
||||
msgstr "首页"
|
||||
|
||||
msgid "Shortcuts"
|
||||
msgstr "快捷访问"
|
||||
|
||||
msgid "Shortcut"
|
||||
msgstr "快捷方式"
|
||||
|
||||
msgid "Target URL"
|
||||
msgstr "目标URL"
|
||||
|
||||
msgid "Please enter a valid URL starting with http:// or https://"
|
||||
msgstr "URL需以http:// 或 https://开头"
|
||||
|
||||
msgid "Force the use of HTTPS in the backend."
|
||||
msgstr "后台强制使用https"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
config wizard 'default'
|
||||
Executable
+263
@@ -0,0 +1,263 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=19
|
||||
|
||||
extra_command "reconfig" ""
|
||||
|
||||
boot() {
|
||||
exit 0;
|
||||
}
|
||||
|
||||
add_wizard() {
|
||||
local cfg="$1"
|
||||
local wan_proto wan_pppoe_user wan_pppoe_pass
|
||||
local lan_ipaddr lan_netmask lan_dns lan_gateway dhcp
|
||||
local device ipv6 old_ipv6 wifi_ssid wifi_key old_wifi_ssid old_wifi_key
|
||||
|
||||
config_get wan_proto "$cfg" wan_proto
|
||||
|
||||
device=$(uci get network.wan.device 2>/dev/null)
|
||||
case "${wan_proto}" in
|
||||
dhcp)
|
||||
uci delete network.wan
|
||||
uci set network.wan=interface
|
||||
uci set network.wan.device="$device"
|
||||
uci set network.wan.proto='dhcp'
|
||||
;;
|
||||
pppoe)
|
||||
config_get wan_pppoe_user "$cfg" wan_pppoe_user
|
||||
config_get wan_pppoe_pass "$cfg" wan_pppoe_pass
|
||||
[[ "${wan_pppoe_user} != $(uci -q get network.wan.username)" || "${wan_pppoe_pass} != $(uci -q get network.wan.password)" ]] && {
|
||||
uci delete network.wan
|
||||
uci set network.wan=interface
|
||||
uci set network.wan.proto='pppoe'
|
||||
uci set network.wan.device="$device"
|
||||
uci set network.wan.username="${wan_pppoe_user}"
|
||||
uci set network.wan.password="${wan_pppoe_pass}"
|
||||
[ -n "${ipv6}" ] && {
|
||||
uci -q set network.wan.ipv6='0'
|
||||
uci -q set network.wan.delegate='0'
|
||||
}
|
||||
}
|
||||
;;
|
||||
esac
|
||||
|
||||
config_get lan_ipaddr "$cfg" lan_ipaddr
|
||||
config_get lan_netmask "$cfg" lan_netmask
|
||||
test -n "${lan_ipaddr}" && test -n "${lan_netmask}" && {
|
||||
uci set network.lan.ipaddr="${lan_ipaddr}"
|
||||
uci set network.lan.netmask="${lan_netmask}"
|
||||
}
|
||||
|
||||
config_get siderouter "$cfg" siderouter
|
||||
config_get old_siderouter "$cfg" old_siderouter
|
||||
config_get lan_gateway "$cfg" lan_gateway
|
||||
config_get dhcp "$cfg" dhcp
|
||||
config_get lan_dns "$cfg" lan_dns
|
||||
config_get ipv6 "$cfg" ipv6
|
||||
config_get old_ipv6 "$cfg" old_ipv6
|
||||
config_get autoupgrade_pkg "$cfg" autoupgrade_pkg
|
||||
|
||||
[ "$dhcp" == "0" ] && dhcp="1"
|
||||
if [[ "${lan_gateway}" != "$(uci -q get network.lan.gateway)" || "${dhcp}" != "$(uci -q get dhcp.lan.ignore)" ]]; then
|
||||
if [ "${siderouter}" == "1" ]; then
|
||||
uci -q set network.lan.gateway="${lan_gateway}"
|
||||
[ -n "$lan_dns" ] || lan_dns='223.5.5.5'
|
||||
[ -n "$dhcp" ] && uci -q set dhcp.lan.ignore="1" || uci -q del dhcp.lan.ignore
|
||||
uci -q set firewall.@zone[0].masq='1'
|
||||
uci -q set network.wan.proto='none'
|
||||
elif [ "${siderouter}" == "0" ]; then
|
||||
uci -q del network.lan.gateway
|
||||
uci -q del dhcp.lan.ignore
|
||||
uci -q del network.lan.dns
|
||||
uci -q del firewall.@zone[0].masq
|
||||
uci -q set network.wan.proto='dhcp'
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -n "$lan_dns" ] && {
|
||||
[ "$(uci -q get dhcp.@dnsmasq[0].noresolv)" == 1 ] && {
|
||||
uci -q del dhcp.@dnsmasq[0].noresolv
|
||||
}
|
||||
uci -q set network.wan.peerdns='0'
|
||||
uci -q set network.lan.dns="${lan_dns}"
|
||||
} || {
|
||||
uci -q del network.wan.peerdns
|
||||
uci -q del network.lan.dns
|
||||
}
|
||||
|
||||
if [ "${ipv6}" != "${old_ipv6}" ]; then
|
||||
if [ -n "${ipv6}" ]; then
|
||||
uci -q delete dhcp.lan.ra
|
||||
uci -q delete dhcp.lan.dhcpv6
|
||||
uci -q set network.lan.delegate='0'
|
||||
uci -q set network.wan.ipv6='0'
|
||||
uci -q set network.wan.delegate='0'
|
||||
uci -q delete network.globals.ula_prefix
|
||||
else
|
||||
uci -q set dhcp.lan.ra='hybrid'
|
||||
uci -q set dhcp.lan.dhcpv6='hybrid'
|
||||
uci -q del network.lan.delegate
|
||||
uci -q set network.wan.ipv6='auto'
|
||||
uci -q del network.wan.delegate
|
||||
fi
|
||||
uci -q set wizard.default.old_ipv6="${ipv6}"
|
||||
fi
|
||||
|
||||
wifi_setup_radio(){
|
||||
local radio=$1
|
||||
uci -q get wireless.${radio} >/dev/null 2>&1 && {
|
||||
if [ "$(uci -q get wireless.${radio}.band)" = "5g" ]; then
|
||||
uci -q set wireless.default_${radio}.ssid="${wifi_ssid}_5G"
|
||||
elif [ "$(uci -q get wireless.${radio}.band)" = "2g" ]; then
|
||||
uci -q set wireless.default_${radio}.ssid="${wifi_ssid}_2.4G"
|
||||
fi
|
||||
uci -q set wireless.default_${radio}.device="${radio}"
|
||||
if [ "${wifi_key}" ]; then
|
||||
uci -q set wireless.default_${radio}.encryption='psk2'
|
||||
uci -q set wireless.default_${radio}.key="${wifi_key}"
|
||||
else
|
||||
uci -q set wireless.default_${radio}.encryption='none'
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
config_get wifi_ssid "$cfg" wifi_ssid
|
||||
config_get wifi_key "$cfg" wifi_key
|
||||
config_get old_wifi_ssid "$cfg" old_wifi_ssid
|
||||
config_get old_wifi_key "$cfg" old_wifi_key
|
||||
|
||||
if [[ "${wifi_ssid}" != "${old_wifi_ssid}" || "${wifi_key}" != "${old_wifi_key}" ]]; then
|
||||
test -n "${wifi_ssid}" && {
|
||||
for radio in radio0 radio1 radio2 radio3; do
|
||||
wifi_setup_radio ${radio}
|
||||
done
|
||||
uci commit wireless
|
||||
uci -q set wizard.default.old_wifi_ssid="${wifi_ssid}"
|
||||
uci -q set wizard.default.old_wifi_key="${wifi_key}"
|
||||
}
|
||||
fi
|
||||
|
||||
sethttps
|
||||
|
||||
uci commit wizard
|
||||
uci commit dhcp
|
||||
uci commit firewall
|
||||
uci commit network
|
||||
|
||||
if [ "${autoupgrade_pkg}" != "1" ]; then
|
||||
sed -i '/opkg-upgrade/d' /etc/crontabs/root
|
||||
else
|
||||
grep -q "opkg-upgrade" /etc/crontabs/root || {
|
||||
hour="$(grep -m1 -ao '[4-6]' /dev/urandom | head -n1)"
|
||||
min="$(grep -m1 -ao '[0-5][0-9]' /dev/urandom | head -n1)"
|
||||
echo "$min $hour * * * . /etc/hotplug.d/online/51-opkg-upgrade >/dev/null 2>&1" >> /etc/crontabs/root
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
reconfig() {
|
||||
uci -q set wizard.default.wan_proto="$(uci -q get network.wan.proto)"
|
||||
uci -q set wizard.default.wan_pppoe_user="$(uci -q get network.wan.username)"
|
||||
uci -q set wizard.default.wan_pppoe_pass="$(uci -q get network.wan.password)"
|
||||
uci -q set wizard.default.lan_ipaddr="$(uci -q get network.lan.ipaddr)"
|
||||
uci -q set wizard.default.lan_netmask="$(uci -q get network.lan.netmask)"
|
||||
uci -q set wizard.default.lan_gateway="$(uci -q get network.lan.gateway)"
|
||||
uci -q set wizard.default.lan_dns="$(uci -q get network.lan.dns)"
|
||||
[ "$(uci -q get dhcp.lan.ignore)" ] && uci -q set wizard.default.dhcp="0" || uci -q del wizard.default.dhcp
|
||||
uci commit wizard
|
||||
}
|
||||
|
||||
sethttps() {
|
||||
config_get https "$cfg" https
|
||||
if [ -n "$(command -v nginx)" ]; then
|
||||
if [ -z "`uci -q get nginx._redirect2ssl`" ]; then
|
||||
uci -q set nginx._redirect2ssl=server
|
||||
uci -q set nginx._redirect2ssl.server_name='_redirect2ssl'
|
||||
uci -q set nginx._redirect2ssl.return='302 https://$host$request_uri'
|
||||
uci -q set nginx._redirect2ssl.access_log='off; # logd openwrt'
|
||||
fi
|
||||
if [ "x${https}" = "x1" ] ; then
|
||||
uci -q del nginx.default_server.listen
|
||||
uci -q add_list nginx.default_server.listen='80'
|
||||
uci -q add_list nginx.default_server.listen='[::]:80'
|
||||
uci -q del nginx._redirect2ssl.listen
|
||||
uci -q add_list nginx._redirect2ssl.listen='80 default_server'
|
||||
uci -q add_list nginx._redirect2ssl.listen='[::]:80 default_server'
|
||||
else
|
||||
uci -q del nginx._redirect2ssl.listen
|
||||
uci -q add_list nginx._redirect2ssl.listen='80'
|
||||
uci -q add_list nginx._redirect2ssl.listen='[::]:80'
|
||||
uci -q del nginx.default_server.listen
|
||||
uci -q add_list nginx.default_server.listen='80 default_server'
|
||||
uci -q add_list nginx.default_server.listen='[::]:80 default_server'
|
||||
fi
|
||||
uci commit nginx
|
||||
/etc/init.d/nginx reload
|
||||
elif [ -n "$(command -v lighttpd)" ]; then
|
||||
if [ "x${https}" = "x1" ] ; then
|
||||
sed -i "s/ # url.redirect =/ url.redirect =/" /etc/lighttpd/conf.d/82-https.conf
|
||||
else
|
||||
sed -i "s/ url.redirect =/ # url.redirect =/" /etc/lighttpd/conf.d/82-https.conf
|
||||
fi
|
||||
/etc/init.d/lighttpd reload
|
||||
else
|
||||
if [ "x${https}" = "x1" ] ; then
|
||||
uci -q set uhttpd.main.redirect_https='1'
|
||||
else
|
||||
uci -q set uhttpd.main.redirect_https='0'
|
||||
fi
|
||||
uci commit uhttpd
|
||||
/etc/init.d/uhttpd reload
|
||||
fi
|
||||
}
|
||||
|
||||
process_shortcut() {
|
||||
local shortcut to_url comments lanaddr
|
||||
local cfg="$1"
|
||||
lanaddr="$(uci get network.lan.ipaddr)"
|
||||
[ -n $lanaddr ] && lanaddr="$(echo "$lanaddr" | sed -e "s/\/2\+//")"
|
||||
|
||||
config_get shortcut "$cfg" shortcut
|
||||
config_get to_url "$cfg" to_url
|
||||
config_get comments "$cfg" comments
|
||||
|
||||
uci -q set nginx._sc_$shortcut=server
|
||||
uci -q set nginx._sc_$shortcut.server_name="$shortcut"
|
||||
uci -q add_list nginx._sc_$shortcut.listen="80"
|
||||
uci -q add_list nginx._sc_$shortcut.listen="443"
|
||||
uci -q set nginx._sc_$shortcut.return="302 $to_url"
|
||||
|
||||
uci -q set dhcp._sc_$shortcut=domain
|
||||
uci -q set dhcp._sc_$shortcut.name="$shortcut"
|
||||
uci -q set dhcp._sc_$shortcut.ip="$lanaddr"
|
||||
uci -q set dhcp._sc_$shortcut.comments="$comments"
|
||||
}
|
||||
|
||||
start() {
|
||||
config_load wizard
|
||||
config_foreach add_wizard wizard
|
||||
if [ -n "$(command -v nginx)" ]; then
|
||||
for server in $(uci show nginx | grep '_sc_' | grep '=server' | cut -d. -f2 | cut -d= -f1); do
|
||||
uci delete nginx.$server
|
||||
done
|
||||
for server in $(uci show dhcp | grep '_sc_' | grep '=domain' | cut -d. -f2 | cut -d= -f1); do
|
||||
uci delete dhcp.$server
|
||||
done
|
||||
config_foreach process_shortcut shortcuts
|
||||
uci commit nginx
|
||||
uci commit dhcp
|
||||
/etc/init.d/nginx reload
|
||||
fi
|
||||
(
|
||||
/etc/init.d/network restart
|
||||
/etc/init.d/firewall reload
|
||||
/etc/init.d/dnsmasq reload
|
||||
|
||||
)&
|
||||
}
|
||||
|
||||
restart() {
|
||||
start
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-wizard.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-wizard.json << EEOF
|
||||
{
|
||||
"config": "wizard",
|
||||
"init": "wizard"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
touch /etc/config/wizard
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@wizard[-1]
|
||||
add ucitrack wizard
|
||||
set ucitrack.@wizard[-1].init=wizard
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
chmod +x /etc/init.d/wizard 2>/dev/null
|
||||
rm -f /tmp/luci-indexcache
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"admin/system/initsetup": {
|
||||
"title": "Wizard",
|
||||
"order": 1,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "wizard/initsetup"
|
||||
},
|
||||
"depends": {
|
||||
"acl": [ "luci-app-wizard" ],
|
||||
"uci": { "wizard": true }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"luci-app-wizard": {
|
||||
"description": "Grant UCI access for luci-app-wizard",
|
||||
"read": {
|
||||
"file": {
|
||||
"/etc/init.d/wizard reconfig": [ "exec" ]
|
||||
},
|
||||
"uci": [ "wizard", "wireless" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "wizard" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"config": "wizard",
|
||||
"init": "wizard"
|
||||
}
|
||||
Reference in new issue
Block a user