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"
echo Setting proper permissions...
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"
echo Setting proper permissions...
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"
echo Setting proper permissions...
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"
echo Setting proper permissions...
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