Score:0

Unpacking a .tar only persists if left for 30+ seconds

my flag

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?

galexite avatar
pk flag
You should not be keeping software in `/var`. `/opt` or `/usr/local` is a much better place to keep non-apt managed software.
mondotofu avatar
cn flag
From an architectural standpoint, these Ubuntu servers would be better off as virtual machines in the cloud.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.