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

62 lines
1.8 KiB
Bash
Raw Normal View History

2023-05-29 20:08:48 -05:00
#!/bin/bash
2022-07-29 21:51:18 -05:00
# 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
2023-05-29 20:08:48 -05:00
elif [ "$1" == "--help" ]; then
2022-07-29 21:51:18 -05:00
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
2023-05-29 20:08:48 -05:00
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")"
2023-05-29 20:08:48 -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-10-13 19:50:10 -05:00
elif [ "$i" == "root_scripts" ]; then
dest="/usr/local/bin/"
echo Copying to "$dest"...
sudo cp "$1" "$dest"
echo Making it executable...
sudo chmod +x "$dest$(basename "$1")"
2023-05-29 20:08:48 -05:00
else
echo "Unrecognized destination: $i"
echo "Available destinations are: personal_script_dir, cron_daily, cron_weekly, cron_monthly, root_scripts"
2022-07-29 21:51:18 -05:00
fi
2023-05-29 20:08:48 -05:00
done