1
0
Fork 0
mirror of https://github.com/SinTan1729/random.git synced 2024-12-26 21:18:36 -06:00
random/push_script_to.sh

53 lines
1.5 KiB
Bash
Raw Normal View History

2022-07-29 21:51:18 -05:00
#!/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
2022-07-30 02:26:09 -05:00
2022-07-29 21:51:18 -05:00
elif [ "$1" == "--help" ];then
echo "The syntax is as follows:"$'\n'"push_script_to <script-location> <destination> (additional destinations separated by space)"
exit
2022-07-30 02:26:09 -05:00
2022-07-29 21:51:18 -05:00
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
2022-07-30 02:26:09 -05:00
if [ "$i" == "personal_script_dir" ]; then
2022-07-30 03:02:57 -05:00
dest="/home/sintan/.local/bin/personal/"
echo Copying to "$dest"...
cp "$1" "$dest"
2022-07-31 00:29:52 -05:00
echo Making it executable...
2022-07-30 03:02:57 -05:00
chmod +x "$dest$(basename "$1")"
2022-07-29 21:51:18 -05:00
elif [ "$i" == "cron_daily" ]; then
2022-07-30 03:02:57 -05:00
dest="/etc/cron.daily/"
echo Copying to "$dest"...
sudo cp "$1" "$dest"
2022-07-31 00:29:52 -05:00
echo Making it executable...
2022-07-30 03:02:57 -05:00
sudo chmod +x "$dest$(basename "$1")"
2022-07-29 21:51:18 -05:00
2022-07-30 02:26:09 -05:00
elif [ "$i" == "cron_weekly" ]; then
2022-07-30 03:02:57 -05:00
dest="/etc/cron.weekly/"
echo Copying to "$dest"...
sudo cp "$1" "$dest"
2022-07-31 00:29:52 -05:00
echo Making it executable...
2022-07-30 03:02:57 -05:00
sudo chmod +x "$dest$(basename "$1")"
2022-07-29 21:51:18 -05:00
2022-07-30 02:26:09 -05:00
elif [ "$i" == "cron_monthly" ]; then
2022-07-30 03:02:57 -05:00
dest="/etc/cron.monthly/"
echo Copying to "$dest"...
sudo cp "$1" "$dest"
2022-07-31 00:29:52 -05:00
echo Making it executable...
2022-07-30 03:02:57 -05:00
sudo chmod +x "$dest$(basename "$1")"
2022-07-30 02:26:09 -05:00
2022-07-29 21:51:18 -05:00
else echo "Unrecognized destination: $i"
fi
done