Advertisement
AmourSpirit

site_gitrep.sh

Aug 11th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.17 KB | None | 0 0
  1. #!/bin/sh
  2. # version 1.2.0
  3. if [ -z "$1" ]
  4.   then
  5.     echo "No argument for user supplied! Exiting"
  6.     exit 1
  7. fi
  8. USER="$1"
  9. COMMIT_TIMESTAMP=`date +'%Y-%m-%d %H:%M:%S %Z'`
  10. DATELOG=`date +'%Y-%m-%d-%H-%M-%S'`
  11. LOG="/home/${USER}/logs/git_site.log"
  12. GIT="/usr/bin/git"
  13. REPO_DIR="/home/${USER}/"
  14. GIT_DIR=$REPO_DIR".git/"
  15. SYS_LOG="/var/log/git_site.log"
  16. if [ ! -d "$GIT_DIR" ]; then
  17.   # Control will enter here if $GIT_DIR doesn't exist.
  18.   echo "=========================================${DATELOG}=========================================" >> ${SYS_LOG}
  19.   echo "${DATELOG} .git not found check to see if '${REPO_DIR}' site still exist and that git is installed." >> ${SYS_LOG}
  20.   echo "=========================================${DATELOG}=========================================" >> ${SYS_LOG}
  21.   echo "" >> ${SYS_LOG}
  22.   exit 1
  23. fi
  24. echo "=========================================${DATELOG}=========================================" >> ${LOG}
  25. cd ${REPO_DIR}
  26. ${GIT} add --all .
  27. ${GIT} commit -m "Automated commit on ${COMMIT_TIMESTAMP}" >> ${LOG}
  28. ${GIT} push origin master
  29. echo "=========================================${DATELOG}=========================================" >> ${LOG}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement