Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # version 1.2.0
- if [ -z "$1" ]
- then
- echo "No argument for user supplied! Exiting"
- exit 1
- fi
- USER="$1"
- COMMIT_TIMESTAMP=`date +'%Y-%m-%d %H:%M:%S %Z'`
- DATELOG=`date +'%Y-%m-%d-%H-%M-%S'`
- LOG="/home/${USER}/logs/git_site.log"
- GIT="/usr/bin/git"
- REPO_DIR="/home/${USER}/"
- GIT_DIR=$REPO_DIR".git/"
- SYS_LOG="/var/log/git_site.log"
- if [ ! -d "$GIT_DIR" ]; then
- # Control will enter here if $GIT_DIR doesn't exist.
- echo "=========================================${DATELOG}=========================================" >> ${SYS_LOG}
- echo "${DATELOG} .git not found check to see if '${REPO_DIR}' site still exist and that git is installed." >> ${SYS_LOG}
- echo "=========================================${DATELOG}=========================================" >> ${SYS_LOG}
- echo "" >> ${SYS_LOG}
- exit 1
- fi
- echo "=========================================${DATELOG}=========================================" >> ${LOG}
- cd ${REPO_DIR}
- ${GIT} add --all .
- ${GIT} commit -m "Automated commit on ${COMMIT_TIMESTAMP}" >> ${LOG}
- ${GIT} push origin master
- echo "=========================================${DATELOG}=========================================" >> ${LOG}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement