Thaw update script
Homepage
For this script to work for MacOS X users, you will need to install textutils for sha1sum... if you are using fink, execute this command:
sudo fink install textutils
#!/bin/bash
_help () {
echo "Thaw Update Script"
echo "$0 [testing|stable]";
exit 1
}
if test ! -x `which wget` -o ! -x `which sha1sum`; then
echo "You need wget and sha1sum command to perform this update."
exit 1
fi
if [ $# -gt 1 ]; then
_help
fi
if [ $# -eq 1 ]; then
if [ $1 = "-h" -o $1 = "--help" -o $1 = "-help" ]; then
_help
elif [ $1 = "stable" ]; then RELEASE="Thaw.jar";
elif [ $1 = "testing" ]; then
RELEASE="Thaw-testing.jar";
echo "testing update..."
else
_help
fi
else
RELEASE="Thaw.jar"
fi
echo "Checking for update..."
if ! wget "http://downloads.freenetproject.org/alpha/Thaw/$RELEASE.sha1" -O sha1.tmp 1>/dev/null 2>&1 ; then
echo "Sorry, can't contact the remote server"
exit 1
fi
if test ! -e $RELEASE; then
touch $RELEASE
fi
sha1_local=`sha1sum $RELEASE | awk '{print \$1}'`
sha1_remote=`cat sha1.tmp | awk '{print \$1}'`
rm sha1.tmp
echo "Current : $sha1_local"
echo "On server : $sha1_remote"
if test ! "$sha1_local" = "$sha1_remote"; then
echo -n "Update available. Updating..."
if ! wget "http://downloads.freenetproject.org/alpha/Thaw/$RELEASE" -O $RELEASE 1>/dev/null 2>&1 ; then
echo "Unable to connect to server."
exit 1
fi
echo "$RELEASE updated."
else
echo "$RELEASE uptodate, nothing done."
fi
exit 0
_help () {
echo "Thaw Update Script"
echo "$0 [testing|stable]";
exit 1
}
if test ! -x `which wget` -o ! -x `which sha1sum`; then
echo "You need wget and sha1sum command to perform this update."
exit 1
fi
if [ $# -gt 1 ]; then
_help
fi
if [ $# -eq 1 ]; then
if [ $1 = "-h" -o $1 = "--help" -o $1 = "-help" ]; then
_help
elif [ $1 = "stable" ]; then RELEASE="Thaw.jar";
elif [ $1 = "testing" ]; then
RELEASE="Thaw-testing.jar";
echo "testing update..."
else
_help
fi
else
RELEASE="Thaw.jar"
fi
echo "Checking for update..."
if ! wget "http://downloads.freenetproject.org/alpha/Thaw/$RELEASE.sha1" -O sha1.tmp 1>/dev/null 2>&1 ; then
echo "Sorry, can't contact the remote server"
exit 1
fi
if test ! -e $RELEASE; then
touch $RELEASE
fi
sha1_local=`sha1sum $RELEASE | awk '{print \$1}'`
sha1_remote=`cat sha1.tmp | awk '{print \$1}'`
rm sha1.tmp
echo "Current : $sha1_local"
echo "On server : $sha1_remote"
if test ! "$sha1_local" = "$sha1_remote"; then
echo -n "Update available. Updating..."
if ! wget "http://downloads.freenetproject.org/alpha/Thaw/$RELEASE" -O $RELEASE 1>/dev/null 2>&1 ; then
echo "Unable to connect to server."
exit 1
fi
echo "$RELEASE updated."
else
echo "$RELEASE uptodate, nothing done."
fi
exit 0
thanks to fridim :)