Code:
#! /bin/bash
## This script is to automatate the updateing of the main
## website. Upload package should be an uncompressed tarball named upload.tar
## Drop it in the upload folder.
# Backup file
CONDOM=/home/ubuntu/backups/hartman-$(date +%Y%m%d).tar
# Upload loacation and file
UPLOAD=/home/ubuntu/Upload/
# Publishing location
FINAL=/var/www/html/
# Package Name
TARBALL=upload.tar
# internals. Leave alone.
HI=$UPLOAD$TARBALL
FI=$FINAL$TARBALL
if [[ $EUID -ne 0 ]];
then
echo "This script must be run as root"
exit 1
fi # close this if here; if not root, exit and end
# continue on if user is root
if [ -e $HI ]
then
echo "backing up Website"
tar -cf $CONDOM
echo "Moving Tarball"
mv $HI $FI
echo "Extracting Tarball"
tar -xf $FI
# echo "Deleting Tarball" #Commented out during testing
# rm $FI # Test this before going live.
echo "Congratulations! Your website has been updated"
else
echo "Your update is not present in the upload folder."
echo "Please check your update and try again."
fi
exit
Bookmarks