From de90ac3ad51909de82fcdb039e739713241fcf21 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Fri, 29 Jul 2022 21:51:18 -0500 Subject: [PATCH] Add new script push_script_to.sh --- push_script_to.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 push_script_to.sh diff --git a/push_script_to.sh b/push_script_to.sh new file mode 100644 index 0000000..b47f0e5 --- /dev/null +++ b/push_script_to.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +# this is a script to push scripts from the folder with git +# to actual locations where I use them + +if [ -z "$1" ]; then + echo "Provide a script or pass --help to see syntax" + exit +elif [ "$1" == "--help" ];then + echo "The syntax is as follows:"$'\n'"push_script_to (additional destinations separated by space)" + exit +elif ! [ -f "$1" ]; then + echo "The given script doesn't exist" + exit +fi + +[ -z "$2" ] && echo "Provide destination(s) or pass --help to see syntax" && exit + +for i in "${@:2}" +do + if [ "$i" == "local_script_dir" ]; then + cp "$1" "/home/sintan/.local/bin/personal/" + chmod +x "/home/sintan/.local/bin/personal/$(basename "$1")" + + elif [ "$i" == "cron_daily" ]; then + sudo cp "$1" "/etc/cron.daily/" + sudo chmod +x "/etc/cron.daily/$(basename "$1")" + + elif [ "$i" == "cron_weeky" ]; then + sudo cp "$1" "/etc/cron.weekly/" + sudo chmod +x "/etc/cron.weekly/$(basename "$1")" + + else echo "Unrecognized destination: $i" + fi +done \ No newline at end of file