Added drive cleanup to the upgrade process

This commit is contained in:
David Carley
2021-03-07 23:57:24 -08:00
parent ae9e13ecad
commit 851ec31b0c
4 changed files with 44 additions and 1 deletions

View File

@@ -12,5 +12,6 @@ include scripts/bbctrl.service
include scripts/11-automount.rules include scripts/11-automount.rules
include scripts/resize_root_fs.sh include scripts/resize_root_fs.sh
include scripts/resize2fs_once include scripts/resize2fs_once
include scripts/bbctrl-logrotate
recursive-include src/py/camotics * recursive-include src/py/camotics *
global-exclude .gitignore global-exclude .gitignore

8
scripts/bbctrl-logrotate Normal file
View File

@@ -0,0 +1,8 @@
/var/log/bbctrl.log {
rotate 4
weekly
compress
missingok
notifempty
copytruncate
}

View File

@@ -142,6 +142,40 @@ if [ $? -eq 0 ]; then
REBOOT=true REBOOT=true
fi fi
# Install our logrotate config
cp ./scripts/bbctrl-logrotate /etc/logrotate.d/bbctrl
chown root:root /etc/logrotate.d/bbctrl
##########################################
# Begin one-time cleanup tasks for 1.0.7
##########################################
# Delete the entire local Chromium configuration. Start clean.
rm -rf /home/pi/.config/chromium
# Get rid of some old files that were left behind
rm -rf /home/pi/hostinfo.txt
rm -rf /home/pi/ssidinfo.txt
rm -rf /home/bbmc/bbctrl-1.0.0.tar.bz2
rm -rf /home/bbmc/hostinfo.sh
rm -rf /home/bbmc/index.html
rm -rf /home/bbmc/favicon.ico
# Force a logrotate to get everything into a known state
logrotate -f /etc/logrotate.conf
# Clean up the log directory - get rid of everything old
rm -rf /var/log/*.gz
rm -rf /var/log/*.1
rm -rf /var/log/*.old
rm -rf /var/log/bbctrl.2019*.install
rm -rf /var/log/bbctrl.2020*.install
rm -rf /var/log/bbctrl.log.*
##########################################
# End one-time cleanup tasks for 1.0.7
##########################################
sync sync
if $REBOOT; then if $REBOOT; then

View File

@@ -170,7 +170,7 @@ class Log(object):
if self.path is None: return if self.path is None: return
if self.f is not None: self.f.close() if self.f is not None: self.f.close()
self._rotate(self.path) self._rotate(self.path)
self.f = open(self.path, 'w') self.f = open(self.path, 'a')
self.bytes_written = 0 self.bytes_written = 0