addet some functionality and readability

This commit is contained in:
pika 2024-06-22 09:27:39 +02:00
parent fa0abf966a
commit 5bbcaaa096

View file

@ -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
}