theomolenaar
Dabbler
- Joined
- Jun 12, 2016
- Messages
- 43
I have two bash scripts: backup-plex.sh and update-plex.sh
update-plex.sh looks like this:
The first if statement checks if the backup completes without errors. If no errors then the update script should start. Unfortunately my code doesn't start the update part inside the if. The backing up part works as it should. I'm guessing something is wrong with
update-plex.sh looks like this:
Code:
#!/bin/bash
JAIL_NAME=plex
#MAKE BACKUP of plex jail before updating
#https://stackoverflow.com/questions/38978650/run-a-script-in-the-same-directory-as-the-current-script
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source ${__dir}/backup-plex.sh
if [$? -eq 0]; then
echo "Backup $JAIL_NAME succeeded" >> /mnt/pool1/media/logs/mediajail.log
#After backup is finished, update plex
echo "---Starting updating jail: ${JAIL_NAME} ---" $(date) >> /mnt/pool1/media/logs/mediajail.log
#https://github.com/mstinaff/PMS_Updater.git
iocage exec $JAIL_NAME 'sh /usr/local/PMS_Updater/PMS_Updater.sh -v -a'
if [$? -eq 0]; then
echo "Update Completed" $(date) >> /mnt/pool1/media/logs/mediajail.log
#email notification
Plex updated to latest version | /usr/bin/mail -s "Software Update Completed" jowandijkhuis@gmail.com
else
echo "Update $JAIL_NAME failed" >> /mnt/pool1/media/logs/mediajail.log
fi
else
echo "Backup $JAIL_NAME failed" >> /mnt/pool1/media/logs/mediajail.log
fiThe first if statement checks if the backup completes without errors. If no errors then the update script should start. Unfortunately my code doesn't start the update part inside the if. The backing up part works as it should. I'm guessing something is wrong with
$? -eq 0. Any ideas on how to fix this?
Last edited: