Summary:Until there is an update to allow updating I have created the following script. I have not tested it as is but have tested individual parts. Figured I would post it anyways since I cannot truly test it until there is an update. Also, it would be better to get a larger testing audience.
Prerequisites:zenity
unzip
Code:Code:
#!/bin/sh
#Version 1.4
#Script can be found at http://ss.deviatenow.com/viewtopic.php?f=3&p=543#p543
if [ ! -d "UpdaterLogs" ]; then
mkdir UpdaterLogs
fi
UP_DATE=`date +%Y-%m-%d_%I:%M%p`
echo "*****************************************" >> UpdaterLogs/$UP_DATE.log
echo "Starting SexScripts, checking for update first" >> UpdaterLogs/$UP_DATE.log
echo `date` >> UpdaterLogs/$UP_DATE.log
echo "*****************************************" >> UpdaterLogs/$UP_DATE.log
#Checks the old sexscripts.zip filedate
ORGDATE=`date -r sexscripts.zip +%s`
if [ ! -e sexscripts.zip ]; then
ORGDATE=1
fi
#Downloads the new sexscripts.zip only if newer
zenity --info --text 'Please wait while I check for an update. Click OK to begin the check.'
wget -N http://ss.deviatenow.com/files/sexscripts.zip 2>&1 | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloading at \2\/s, ETA \3/' | zenity --progress --title="Downloading" --auto-close
#Checks the sexscripts.zip date
NEWDATE=`date -r sexscripts.zip +%s`
#States the new and old filedate (debugging purposes can be commented out)
echo "NewDate = $NEWDATE and OrgDate = $ORGDATE" >> UpdaterLogs/$UP_DATE.log
#If sexscripts has beed updated on server then asks if you want to update
if [ "$ORGDATE" -lt "$NEWDATE" ] >> UpdaterLogs/$UP_DATE.log
then
if zenity --question --text="Update available, would you like to update?"; then
echo "*****************************************" >> UpdaterLogs/$UP_DATE.log
echo "Updating..." >> UpdaterLogs/$UP_DATE.log
echo "*****************************************" >> UpdaterLogs/$UP_DATE.log
# Backs up your scripts
cp -rv scripts oldscripts >> UpdaterLogs/$UP_DATE.log
echo "*****************************************" >> UpdaterLogs/$UP_DATE.log
# Applies the update, only updates newer files and creates new files
unzip -uo sexscripts.zip >> UpdaterLogs/$UP_DATE.log
echo "*****************************************" >> UpdaterLogs/$UP_DATE.log
# Uncomment the next line to remove the scripts folder completely before coping your old scripts back, I don't do this by default in case an update is made to the default scripts
# rm -Rv scripts
# Restores your old scripts
cp -rvf oldscripts/* scripts >> UpdaterLogs/$UP_DATE.log
echo "*****************************************" >> UpdaterLogs/$UP_DATE.log
# Deletes the backup of your scripts
rm -Rv oldscripts >> UpdaterLogs/$UP_DATE.log
echo "*****************************************" >> UpdaterLogs/$UP_DATE.log
# Changes the last modified date for your scripts (useful for if you have changed the default scripts)
find scripts -exec touch {} \; >> UpdaterLogs/$UP_DATE.log
LOGDIR=`pwd`
zenity --info --text 'Update Successfull! Check '$LOGDIR'/UpdaterLogs/'$UP_DATE' for the update log.'
echo "SexScripts has been updated!" >> UpdaterLogs/$UP_DATE.log
else
zenity --info --text 'Skipping update, you will be propted next time you start the program.'
# Deletes the updated sexscripts.zip to force prompt of update
echo "*****************************************" >> UpdaterLogs/$UP_DATE.log
echo "Skipping Update..." >> UpdaterLogs/$UP_DATE.log
rm sexscripts.zip >> UpdaterLogs/$UP_DATE.log
echo "*****************************************" >> UpdaterLogs/$UP_DATE.log
fi
else
zenity --info --text 'No update found, starting SexScripts.'
echo "*****************************************" >> UpdaterLogs/$UP_DATE.log
echo "No Update Found" >> UpdaterLogs/$UP_DATE.log
echo "*****************************************" >> UpdaterLogs/$UP_DATE.log
fi
echo "Starting SexScripts..." >> UpdaterLogs/$UP_DATE.log
exec java -Djava.ext.dirs=lib -Dfile.encoding=UTF-8 -jar sexscripts.jar
Notes:Save as update.sh
Mark the executable bit
ex. chmod +x update.sh or chmod 700 update.sh
It will run SexScripts once it has completed so you no longer need to use the old sexscripts.sh
If you have changed any of the default scripts ex. SexScripts_Enhanced-Setup_v1.0 please run the following command in a terminal window in your sexscripts folder
find scripts -exec touch {} \;If you have a problem or suggestion I am welcome to all, I will try to fix/add as soon as possible.
Changelog:1.0 - Initial script: Includes backing up your scripts and prompting for update.
1.1 - Bug Fix: If you apply a new intro script ex. SexScripts_Enhanced-Setup_v1.0 the intro scripts are older than the current update file and get overwritten, this has been fixed.
1.2 - Bug Fix: Upon restoring scripts it copied the oldscripts folder and placed the folder under script, this has been fixed.
1.3 - Uploaded 12/7/11 11:47pm CST
1.3 - Bug Fix: If you delete the old sexscripts.zip it would fail and not update to the new one.
1.3 - New Feature: Added logging, useful if you encounter errors in the update process, makes troubleshooting much easier.
1.4 - Uploaded 12/11/11 2:57am CST
1.4 - Added progress bar for download so you don't think it's not working when it is downloading an update.