Skip to content

Instantly share code, notes, and snippets.

@jeffposnick
Created December 19, 2018 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffposnick/354678f01118a1605d9c89abae85f4e3 to your computer and use it in GitHub Desktop.
Save jeffposnick/354678f01118a1605d9c89abae85f4e3 to your computer and use it in GitHub Desktop.
Shell script to automate nightly updates for the Camino browser (circa 2003?)
#!/bin/sh
echo "Beginning Camino Nightly Download: `date`" >> /Users/jeff/Documents/Camino/log.txt
echo "Changing to download folder" >> /Users/jeff/Documents/Camino/log.txt
cd ~/Documents/Camino
echo "pwd is: `pwd`" >> /Users/jeff/Documents/Camino/log.txt
echo "Downloading Camino: `date`" >> /Users/jeff/Documents/Camino/log.txt
curl -O http://ftp.mozilla.org/pub/mozilla.org/camino/nightly/latest/Camino.dmg.gz
if [ -f Camino.dmg.gz ]; then
gunzip Camino.dmg.gz
if [ $? -eq 0 ]; then
echo "Mounting Camino DMG: `date`" >> /Users/jeff/Documents/Camino/log.txt
thedisk=`hdid Camino.dmg | perl -e '$t = <>; $t =~ /^\/dev\/(\w+)/; print $1'`
else
echo "Problem unzipping file." >> /Users/jeff/Documents/Camino/log.txt
exit 1
fi
echo "Testing to see if Camino is running." >> /Users/jeff/Documents/Camino/log.txt
ps -xa | /usr/bin/grep Camino | /usr/bin/grep -v grep > /dev/null
if [ $? -eq 0 ]; then
echo "Getting Camino PID" >> /Users/jeff/Documents/Camino/log.txt
killme=`/bin/ps -xa | /usr/bin/grep Camino | /usr/bin/grep -v grep | /usr/bin/cut -c1-5`
echo "Killing Camino" >> /Users/jeff/Documents/Camino/log.txt
kill $killme
else
echo "Camino is not running" >> /Users/jeff/Documents/Camino/log.txt
fi
echo "Backing up old Camino" >> /Users/jeff/Documents/Camino/log.txt
tar -czf ~/Documents/Camino/CaminoOld.tar.gz /Applications/Camino.app
echo "Removing old Camino" >> /Users/jeff/Documents/Camino/log.txt
rm -rf /Applications/Camino.app
echo "Copying Camino Application: `date`" >> /Users/jeff/Documents/Camino/log.txt
ditto "/Volumes/Camino/Camino.app" "/Applications/Camino.app"
echo "Ejecting Camino DMG: `date`" >> /Users/jeff/Documents/Camino/log.txt
hdiutil eject $thedisk
echo "Renaming Camino DMG" >> /Users/jeff/Documents/Camino/log.txt
if [ -f "Camino.dmg" ]; then
thedate=`/bin/date +%D | /usr/bin/tr "/" "-"`
mv -f "Camino.dmg" "Camino.$thedate.dmg"
echo "Renamed to Camino.$thedate.dmg" >> /Users/jeff/Documents/Camino/log.txt
fi
back=`ls -1urt Camino.*`
backFile=`echo $back | awk '{ print $1 }'`
echo "Deleting old backup, $backFile" >> /Users/jeff/Documents/Camino/log.txt
rm $backFile
echo "End Camino download: `date`" >> /Users/jeff/Documents/Camino/log.txt
echo "---------------------------------" >> /Users/jeff/Documents/Camino/log.txt
echo >> /Users/jeff/Documents/Camino/log.txt
echo >> /Users/jeff/Documents/Camino/log.txt
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment