#!/bin/sh # Dawnline first-run / upgrade housekeeping. # Locations are off by default since 0.5.2 (lookups send addresses to a third # party); a router that had them on by the old default keeps them on. if [ -f /etc/config/dawnline ] && [ -z "$(uci -q get dawnline.settings.geo_enabled)" ]; then uci -q set dawnline.settings.geo_enabled=1 uci -q commit dawnline fi [ -f /etc/config/dawnline ] || cat > /etc/config/dawnline <<'CFG' config settings 'settings' option portal_enabled '0' option portal_port '8443' option default_device_limit '3' option hostnames '1' CFG chmod 600 /etc/config/dawnline mkdir -p /etc/dawnline && chmod 700 /etc/dawnline # Webhook alerts were removed. uci -q delete dawnline.settings.webhook_url uci -q delete dawnline.settings.alert uci -q commit dawnline rm -f /etc/dawnline/alerts.json # Backups moved into Settings. rm -f /www/luci-static/resources/view/dawnline/backups.js # "Pause everyone" is gone: turning a server off does the same, so a # router left paused keeps its servers off instead of letting everyone in. if [ "$(uci -q get dawnline.settings.paused_all)" = 1 ]; then for s in $(uci -q show dawnline | sed -n 's/^dawnline\.\([^.=]*\)=server$/\1/p'); do uci -q set "dawnline.$s.enabled=0"; done fi uci -q delete dawnline.settings.paused_all uci -q commit dawnline # Portal assets moved out of the web root (served only with a valid code). rm -rf /usr/share/dawnline/portal/www/assets # "Find home devices" (0.3.0) is gone: its option and dnsmasq records too. for s in $(uci -q show dawnline | sed -n 's/^dawnline\.\([^.]*\)\.bonjour=.*/\1/p'); do uci -q delete "dawnline.$s.bonjour"; done uci -q commit dawnline if ls /tmp/dnsmasq*.d/dawnline-bonjour.conf >/dev/null 2>&1; then rm -f /tmp/dnsmasq*.d/dawnline-bonjour.conf /var/run/dawnline/bonjour.json /etc/init.d/dnsmasq restart 2>/dev/null fi # LuCI caches: menu index, and module URLs (?v= follows the opkg status time). rm -f /tmp/luci-indexcache* /tmp/luci-modulecache/* 2>/dev/null touch /usr/lib/opkg/status 2>/dev/null # Cron restarts the agent when it stops ticking (Health → Watchdog). mkdir -p /etc/crontabs grep -qs /usr/libexec/dawnline/heartbeat /etc/crontabs/root || { echo '*/5 * * * * /usr/libexec/dawnline/heartbeat' >> /etc/crontabs/root /etc/init.d/cron restart 2>/dev/null } /etc/init.d/rpcd reload # A reload keeps LuCI logins but sometimes misses the plugin; restart only then. sleep 2 ubus list luci.dawnline >/dev/null 2>&1 || { /etc/init.d/rpcd restart; sleep 2; } # A fresh install starts the service; an upgrade restarts it only where the # admin had it on (a disabled Dawnline stays that way). if [ "$PKG_UPGRADE" = 1 ]; then /etc/init.d/dawnline enabled && /etc/init.d/dawnline restart else /etc/init.d/dawnline enable /etc/init.d/dawnline restart fi exit 0