Fix captive portal detection and restore MOTD

This commit is contained in:
v3d 2026-06-29 17:29:00 +02:00
parent 3b7a16564b
commit 34b4c4b036
9 changed files with 153 additions and 59 deletions

View file

@ -112,27 +112,13 @@ if ! shopt -oq posix; then
fi
fi
# info on login
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`
# get the load averages
read one five fifteen rest < /proc/loadavg
echo "
@@@@@@@@@@@@@@@@@@@ `date +"%A, %e %B %Y, %r"`
@@@@@@, &@& *@@@@@@ `uname -srnmo`
@@@@@@@. .@@@@@@@ Uptime.............: ${UPTIME}
@@@@ .@@@. @@@@ Memory.............: `cat /proc/meminfo | grep MemFree | awk {'print $2'}`kB (Free) / `cat /proc/meminfo | grep MemTotal | awk {'print $2'}`kB (Total)
@ &@@@@.@@@@# @ Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min)
@ @ . #@@@# . @ @ Running Processes..: `ps ax | wc -l | tr -d " "`
@ @@@, # ,@@@ @ Manual / more info.: pivilion.net
@@, @ ,@@ Onion Address......: `cat /home/pi/pivilion/torname`
@@@@@#@@@@@@@#@@@@@ Run "pivilion" for inital setup! / Running in `cat /home/pi/pivilion/mode` mode
"
# Pivilion login banner. The modern installer deploys the same hook through
# /etc/profile.d; this fallback keeps the legacy filesystem overlay usable.
if [ "${PIVILION_MOTD_SHOWN:-0}" != 1 ] && [ -r /usr/local/lib/pivilion/common.sh ]; then
. /usr/local/lib/pivilion/common.sh
if pivilion_load_config >/dev/null 2>&1 && [ "$(id -un)" = "$PIVILION_USER" ]; then
pivilion_print_motd
export PIVILION_MOTD_SHOWN=1
fi
fi
export LC_ALL=C

View file

@ -1,17 +1,11 @@
RewriteEngine on
RewriteCond %{REQUEST_URI} !(\/index\.php)$
RewriteCond %{REQUEST_URI} !(\/pi-logo_128\.png)$
RewriteCond %{REQUEST_URI} !(\/content\/.*)$
RewriteCond %{REQUEST_URI} !(\/index\.php)$
RewriteCond %{REQUEST_URI} !(\/pi-logo_128\.png)$
RewriteCond %{REQUEST_URI} !(\/content\/.*)$
RewriteCond %{REQUEST_URI} !(\/css\/.*)$
RewriteCond %{REQUEST_URI} !(\/doc\/.*)$
RewriteCond %{REQUEST_URI} !(\/docker\/.*)$
RewriteCond %{REQUEST_URI} !(\/img\/.*)$
RewriteCond %{REQUEST_URI} !(\/js\/.*)$
RewriteCond %{REQUEST_URI} !(\/modules\/.*)$
RewriteCond %{REQUEST_URI} !(\/tests\/.*)$
RewriteCond %{REQUEST_URI} !(\/*.php)$
RewriteCond %{REQUEST_URI} !(\/*.head.*)$
RewriteRule ^(.*)$ http://10.1.1.1/index.php [L,R=301]
# Captive-network probes use otherwise unknown paths such as /generate_204,
# /hotspot-detect.html, and /connecttest.txt. Redirect those temporarily so
# clients open their login assistant, but let the gallery serve its own PHP and
# asset paths without a loop.
RewriteCond %{REQUEST_URI} !\.php$ [NC]
RewriteCond %{REQUEST_URI} !\.head(?:\.|$) [NC]
RewriteCond %{REQUEST_URI} !^/(?:content|css|doc|docker|img|images|js|modules|tests|upload)(?:/|$) [NC]
RewriteCond %{REQUEST_URI} !^/pi-logo_128\.png$ [NC]
RewriteRule ^ http://10.1.1.1/index.php [L,R=302,NE]