diff --git a/.src/gitupdate.sh b/.src/gitupdate.sh index 960339c..37042c8 100755 --- a/.src/gitupdate.sh +++ b/.src/gitupdate.sh @@ -1,11 +1,48 @@ #!/bin/bash +# ──────────────────────────────────────< VARIABLES >──────────────────────────────────── +# ─< define the git-directory >─────────────────────────────────────────────────────────── gitdir=$(pwd) + +# ─< define the branch to be pulled >───────────────────────────────────────────────────── branch="main" -if ! command -v git >/dev/null 2>&1; then - echo "Error" -else +# ─< define the format for the date >───────────────────────────────────────────────────── +date=$(date '+%d/%m/%Y %H:%M:%S') + +# ─< log dir and file >─────────────────────────────────────────────────────────────────── +l_dir="$HOME/logs/" +l_file="$HOME/logs/gitupdate.log" +# ────────────────────────────────────< VARIABLES END >────────────────────────────────── + +g_pull () +{ cd $gitdir - git pull origin $branch + git pull origin $branch >>$l_file +} + +l_date () +{ + echo " + _____ + $date + _____ + " >>$l_file +} + +main () +{ +if ! command -v git >/dev/null 2>&1; then + echo "-- Error, git was not found --" +else + if [ -d $HOME/logs/ ]; then + l_date + g_pull + else + mkdir $l_dir + echo "--- Created logs folder under $l_dir ---" + sleep 1 + g_pull + fi fi +}