addet some functionality and readability
This commit is contained in:
parent
fa0abf966a
commit
5bbcaaa096
1 changed files with 41 additions and 4 deletions
|
@ -1,11 +1,48 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# ──────────────────────────────────────< VARIABLES >────────────────────────────────────
|
||||||
|
# ─< define the git-directory >───────────────────────────────────────────────────────────
|
||||||
gitdir=$(pwd)
|
gitdir=$(pwd)
|
||||||
|
|
||||||
|
# ─< define the branch to be pulled >─────────────────────────────────────────────────────
|
||||||
branch="main"
|
branch="main"
|
||||||
|
|
||||||
if ! command -v git >/dev/null 2>&1; then
|
# ─< define the format for the date >─────────────────────────────────────────────────────
|
||||||
echo "Error"
|
date=$(date '+%d/%m/%Y %H:%M:%S')
|
||||||
else
|
|
||||||
|
# ─< log dir and file >───────────────────────────────────────────────────────────────────
|
||||||
|
l_dir="$HOME/logs/"
|
||||||
|
l_file="$HOME/logs/gitupdate.log"
|
||||||
|
# ────────────────────────────────────< VARIABLES END >──────────────────────────────────
|
||||||
|
|
||||||
|
g_pull ()
|
||||||
|
{
|
||||||
cd $gitdir
|
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
|
fi
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue