From dcc085f8261ed358f86dcce69c9730c7b034cb60 Mon Sep 17 00:00:00 2001 From: z3rOR0ne Date: Sun, 4 Sep 2022 02:02:50 -0700 Subject: [PATCH] :sparkles: Updated scripts --- scripts/bgit | 14 ++++++++++++-- scripts/dependencycheck | 37 +++++++++++++++++++++++++++++++++++++ scripts/pyalarm | 2 +- scripts/python/pyalarm | 9 +++++---- 4 files changed, 55 insertions(+), 7 deletions(-) create mode 100755 scripts/dependencycheck diff --git a/scripts/bgit b/scripts/bgit index 0aa43bce..57ea3d1e 100755 --- a/scripts/bgit +++ b/scripts/bgit @@ -245,6 +245,8 @@ if [ $numrepos -eq 0 ] ; then # Otherwise, if there already is a .git directory... else + # creates a list of repos and puts them in an array + remotearray=($(git remote)) # Grabs all new files newfiles=$(git status --short | grep '??' | awk '{print $2}' | tr '\n' ' ') # Grabs all modified files @@ -252,6 +254,7 @@ else # Grabs all deleted files deleted=$(git status | grep deleted | awk '{print $2}' | tr '\n' ' ') + # getopts loop for flag -r that reverts back changes in git repo while getopts "r" opt; do case $opt in @@ -290,7 +293,11 @@ else git reset --hard ${commitarray[$version]} # and pushes it to remote repository - git remote | xargs -L1 git push --all + for ((i = 0; i < numrepos; i++)) ; do + git push --force ${remotearray[i]} ; + done + + # git remote | xargs -L1 git push --all echo "${txtblue}bgit script has completed! goodbye!${txtwhite}" exit 0 @@ -391,7 +398,10 @@ else git commit -m "$gitmoji $cmessage" ; # pushes the commit to each repository - git remote | xargs -L1 git push --all + for ((i = 0; i < numrepos; i++)) ; do + git push --force ${remotearray[i]} ; + done + # git remote | xargs -L1 git push --all echo "${txtblue}bgit script has completed! goodbye!${txtwhite}" exit 0 diff --git a/scripts/dependencycheck b/scripts/dependencycheck new file mode 100755 index 00000000..b255ac75 --- /dev/null +++ b/scripts/dependencycheck @@ -0,0 +1,37 @@ +#!/bin/bash + +# Error handling +set -e + +# For styling/colorizing output +txtbld=$(tput bold) +# txtblue=${txtbld}$(tput setaf 4) +# txtgreen=${txtbld}$(tput setaf 2) +txtred=${txtbld}$(tput setaf 1) +# txtyellow=${txtbld}$(tput setaf 3) +txtwhite=${txtbld}$(tput setaf 7) + + +# Dependency check +function dependencycheck() +{ + numdependencies="$#" + dependencies=("$@") + missingdependencies=0 + for ((i = 0; i < numdependencies; i++)) ; + do + if ! command -v "${dependencies[$i]}" &> /dev/null + then + echo "${txtred}dependency not met: ${dependencies[$i]}${txtwhite}" + missingdependencies=$((missingdependencies+1)) + fi + done +} + +#invoke function +dependencycheck "$@" + +if [ $missingdependencies -gt 0 ] ; then + echo "${txtred}Please install needed dependencies${txtwhite}" + exit 1 +fi diff --git a/scripts/pyalarm b/scripts/pyalarm index c6e50233..f24ee2f6 100755 --- a/scripts/pyalarm +++ b/scripts/pyalarm @@ -1,3 +1,3 @@ #!/bin/bash -$HOME/scripts/python/pyalarm $1 &> /dev/null 2>&1 & +$HOME/scripts/python/pyalarm $1 $2 &> /dev/null 2>&1 & diff --git a/scripts/python/pyalarm b/scripts/python/pyalarm index af956708..19926f43 100755 --- a/scripts/python/pyalarm +++ b/scripts/python/pyalarm @@ -1,13 +1,14 @@ #!/bin/python # https://realpython.com/python-subprocess/ - import subprocess from argparse import ArgumentParser from time import sleep parser = ArgumentParser() -parser.add_argument("time", type=int) +# parser.add_argument("time", type=int) +parser.add_argument("-t", type=int) args = parser.parse_args() -sleep(args.time) -subprocess.call(["notify-send", "Time's Up!!",]) +sleep(args.t) +# sleep(args.time) +subprocess.call(["notify-send", "Time's Up!!"])