I work for a company that has several Ubuntu 18.04 Server units scattered across the USA running our own software. The units are used by our clients a few days a week and the rest of the time sit idle and (normally) powered off. Since its release, we've run into this rare issue in which a unit will boot up to a blank screen. Fortunately we can manually fix this remotely, but it's been a nuisance. I finally tracked it down to this software update script:
wget -O /home/user/update.tar.gz.gpg www.website.com/001001002.tar.gz.gpg
gpg --batch --passphrase SecretPassword -o /home/user/update.tar.gz -d /home/user/update.tar.gz.gpg
cp /var/softwareName/etc/config.cfg /home/user/config.backup
rm -r /var/softwareName/bin
rm -r /var/softwareName/etc
rm -r /var/softwareName/setup
rm -r /var/softwareName/static
tar -C /var/softwareName/ -zxvf /home/user/update.tar.gz
cp /home/user/config.backup /var/softwareName/etc/config.cfg
rm /home/user/update.tar.gz.gpg
rm /home/user/update.tar.gz
rm /home/user/config.backup
systemctl restart softwareName.service
systemctl restart kiosk.service
If an update is installed, and then the power cable is pulled on the unit within ~30 seconds all the files within the "bin", "etc", "setup", and "static" directories are completely empty. All of the files that should be there are there, they're just empty.
What makes it really confusing to me is the updated software loads immediately after the script runs, and it works fine.
I've done some testing by running individual sections of the script at a time, and I think I have it narrowed down to
tar -C /var/softwareName/ -zxvf /home/user/update.tar.gz
Does anyone have any idea how the contents of the files are getting removed?