core/+POST_INSTALL
Franco Fichtner 90296833f9 firmware: firmware-product, src/opnsense/version/opnsense, etc.
Now that we have metadata injection at build time read it instead
of its auxiliary files.  Allow live-mount to snoop the metadata and
afterwards we can start to marry the version and firmware-product
file.

Last puzzle piece will be a tool called "opnsense-version" to read
the JSON metadata and return it in a piecemeal fashion of a part
of the system requires that info, especially from the shell.
2018-09-16 20:38:15 +02:00

43 lines
1.3 KiB
Plaintext

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
echo "Writing package metadata"
mkdir -p /usr/local/opnsense/version
echo "%%CORE_COMMIT%%" > /usr/local/opnsense/version/opnsense
echo "%%CORE_NAME%%" > /usr/local/opnsense/version/opnsense.name
echo "%%CORE_ABI%%" > /usr/local/opnsense/version/opnsense.abi
/usr/local/etc/rc.d/configd start
/usr/local/etc/rc.configure_firmware