opnsense-core/+POST_INSTALL
Franco Fichtner ae63623233 system: better wwwonly bootstrap
This also has an issue with the post-update rc.syshook if
the wwwonly is not found.  But: after a boot it is ensured
and should not be missing thereafter.

The package post-install would ensure it previously, but
we don't want to also chain the php bootstrap through this
just to get the call stack in the right order.

May need further adjusting but also no need to rush this
into a stable release at the moment.
2025-07-29 13:16:04 +02:00

36 lines
1.1 KiB
Text

echo "Updating /etc/shells"
cp /etc/shells /etc/shells.bak
(grep -v /usr/local/sbin/opnsense-shell /etc/shells.bak; \
echo /usr/local/sbin/opnsense-shell) > /etc/shells
rm -f /etc/shells.bak
cp /etc/shells /etc/shells.bak
(grep -v /usr/local/sbin/opnsense-installer /etc/shells.bak; \
echo /usr/local/sbin/opnsense-installer) > /etc/shells
rm -f /etc/shells.bak
echo "Registering root shell"
pw usermod -n root -s /usr/local/sbin/opnsense-shell
echo "Hooking into /etc/rc"
cp /etc/rc /etc/rc.bak
cat > /etc/rc <<EOF
#!/bin/sh
# OPNsense rc(8) hook was automatically installed:
if [ -f /usr/local/etc/rc ]; then exec /usr/local/etc/rc; fi
EOF
cat /etc/rc.bak >> /etc/rc
rm -f /etc/rc.bak
echo "Hooking into /etc/rc.shutdown"
cp /etc/rc.shutdown /etc/rc.shutdown.bak
cat > /etc/rc.shutdown <<EOF
#!/bin/sh
# OPNsense rc(8) hook was automatically installed:
if [ -f /usr/local/etc/rc.shutdown ]; then exec /usr/local/etc/rc.shutdown; fi
EOF
cat /etc/rc.shutdown.bak >> /etc/rc.shutdown
rm -f /etc/rc.shutdown.bak
/usr/local/etc/rc.d/configd start
/usr/local/etc/rc.syshook update