firmware: cleanup prior to upgrade

squid package errors may manifest during major upgrade as well making
it necessary to run the cleanup in advance and not in background mode.

It would be nicer to avoid code duplication, but that can happen the
next time something needs to be adjusted in the actual cleanup routine.
This commit is contained in:
Franco Fichtner 2024-08-06 14:55:50 +02:00
parent 049c8724c2
commit 039ae3c198
3 changed files with 20 additions and 1 deletions

3
plist
View file

@ -149,8 +149,9 @@
/usr/local/etc/rc.syshook.d/stop/80-freebsd
/usr/local/etc/rc.syshook.d/stop/90-backup
/usr/local/etc/rc.syshook.d/stop/99-config
/usr/local/etc/rc.syshook.d/update/10-refresh
/usr/local/etc/rc.syshook.d/update/10-refresh.sh
/usr/local/etc/rc.syshook.d/upgrade/20-unbound-duckdb.py
/usr/local/etc/rc.syshook.d/upgrade/90-cleanup.sh
/usr/local/etc/ssl/opnsense.cnf
/usr/local/etc/strongswan.opnsense.d/README
/usr/local/etc/unbound.opnsense.d/README

View file

@ -3,6 +3,7 @@
# refresh relevant configuration files
/usr/local/etc/rc.configure_firmware
# a copy of this cleanup exists in 90-cleanup.sh
daemon /bin/sh -s << EOF
# remove our stale pyc files not handled by pkg
find /usr/local/opnsense -type f -name "*.pyc" -delete

View file

@ -0,0 +1,17 @@
#!/bin/sh
# a copy of this cleanup exists in 10-refresh.sh
/bin/sh -s << EOF
# remove our stale pyc files not handled by pkg
find /usr/local/opnsense -type f -name "*.pyc" -delete
for DIR in /boot /usr/libexec/bsdinstall /usr/local; do
# remove spurious files from pkg
find \${DIR} ! \( -type d \) -a \
\( -name "*.pkgsave" -o -name ".pkgtemp.*" \) -delete
# processs spurious directories from pkg
# (may not be empty so -delete does not work)
find \${DIR} -type d -name ".pkgtemp.*" -print0 | xargs -0 -n1 rm -r
done
EOF