rufengsuixing / luci-app-adguardhome

maybe the best AdGuardHome luci for openwrt
1.31k stars 484 forks source link

awk: /etc/AdGuardHome.yaml: No such file or directory #130

Open zhangguanzhang opened 2 years ago

zhangguanzhang commented 2 years ago
root@OpenWrt:~# opkg list | grep -i adg
kmod-usb-gadget - 5.4.162-1 - Kernel support for USB Gadget mode
luci-app-adguardhome - git-22.007.21624-d880280-1 - LuCI support for AdGuardHome
luci-i18n-adguardhome-zh-cn - git-22.007.21624-d880280-1 - Translation for luci-app-adguardhome - 简体中文 (Simplified Chinese)

root@OpenWrt:~# opkg install luci-app-adguardhome
Installing luci-app-adguardhome (git-22.007.21624-d880280-1) to root...
Downloading file:///local_feed/luci-app-adguardhome_git-22.007.21624-d880280-1_all.ipk
Configuring luci-app-adguardhome.
awk: /etc/AdGuardHome.yaml: No such file or directory

root@OpenWrt:~# opkg files luci-app-adguardhome
Package luci-app-adguardhome (git-22.007.21624-d880280-1) is installed on root and has the following files:
/usr/lib/lua/luci/view/AdGuardHome/AdGuardHome_check.htm
/usr/lib/lua/luci/view/AdGuardHome/yamleditor.htm
/usr/lib/lua/luci/view/AdGuardHome/AdGuardHome_chpass.htm
/usr/share/AdGuardHome/watchconfig.sh
/usr/lib/lua/luci/view/AdGuardHome/log.htm
/usr/share/AdGuardHome/AdGuardHome_template.yaml
/usr/lib/lua/luci/view/AdGuardHome/AdGuardHome_status.htm
/lib/upgrade/keep.d/luci-app-adguardhome
/etc/config/AdGuardHome
/etc/uci-defaults/40_luci-AdGuardHome
/usr/lib/lua/luci/model/cbi/AdGuardHome/base.lua
/usr/lib/lua/luci/controller/AdGuardHome.lua
/usr/share/AdGuardHome/update_core.sh
/www/luci-static/resources/codemirror/lib/codemirror.js
/www/luci-static/resources/codemirror/addon/fold/foldgutter.css
/usr/share/rpcd/acl.d/luci-app-adguardhome.json
/www/luci-static/resources/codemirror/lib/codemirror.css
/usr/share/AdGuardHome/getsyslog.sh
/usr/lib/lua/luci/model/cbi/AdGuardHome/log.lua
/www/luci-static/resources/codemirror/theme/dracula.css
/usr/share/AdGuardHome/links.txt
/www/luci-static/resources/codemirror/addon/fold/indent-fold.js
/etc/init.d/AdGuardHome
/www/luci-static/resources/codemirror/addon/fold/foldcode.js
/www/luci-static/resources/codemirror/mode/yaml/yaml.js
/usr/share/AdGuardHome/firewall.start
/usr/lib/lua/luci/model/cbi/AdGuardHome/manual.lua
/usr/share/AdGuardHome/gfw2adg.sh
/usr/share/AdGuardHome/tailto.sh
/usr/share/AdGuardHome/waitnet.sh
/www/luci-static/resources/twin-bcrypt.min.js
/usr/share/AdGuardHome/addhost.sh
/www/luci-static/resources/codemirror/addon/fold/foldgutter.js
zhangguanzhang commented 2 years ago

开调试是执行 /etc/init.d/AdGuardHome reload 报的错 hack下后,编译出来的ipk文件就能解决

    if [ -d feeds/others/luci-app-adguardhome ];then
        sed -i '/configpath/s#/etc/AdGuardHome.yaml#/etc/config/AdGuardHome.yaml#' feeds/others/luci-app-adguardhome/root/etc/config/AdGuardHome
    fi
    # https://github.com/rufengsuixing/luci-app-adguardhome/issues/130
    SED_NUM=$(awk '/^start_service/,/configpath/{a=NR}END{print a}' feeds/others/luci-app-adguardhome/root/etc/init.d/AdGuardHome)
    sed -i "$SED_NUM"'a [ ! -f "${configpath}" ] && cp /usr/share/AdGuardHome/AdGuardHome_template.yaml ${configpath}' feeds/others/luci-app-adguardhome/root/etc/init.d/AdGuardHome
zhangguanzhang commented 2 years ago

卸载也会报错 Command failed: Not found

root@OpenWrt:~# opkg remove luci-app-adguardhome
Removing package luci-app-adguardhome from root...
AdGuardHome service disabled
AdGuardHome service disabled

Not deleting modified conffile /etc/config/AdGuardHome.
karnadii commented 2 years ago

do you find solution? I also have the same problem

zhangguanzhang commented 2 years ago

sed -i '/configpath/s#/etc/AdGuardHome.yaml#/etc/config/AdGuardHome.yaml#' feeds/others/luci-app-adguardhome/root/etc/config/AdGuardHome

try this command

SED_NUM=$(awk '/^start_service/,/configpath/{a=NR}END{print a}' /etc/init.d/AdGuardHome)
sed -i "$SED_NUM"'a [ ! -f "${configpath}" ] && cp /usr/share/AdGuardHome/AdGuardHome_template.yaml ${configpath}' /etc/init.d/AdGuardHome