mirror of
https://github.com/SinTan1729/random.git
synced 2024-12-26 13:18:35 -06:00
Add new script push_script_to.sh
This commit is contained in:
parent
b00ddfa0e3
commit
de90ac3ad5
1 changed files with 35 additions and 0 deletions
35
push_script_to.sh
Normal file
35
push_script_to.sh
Normal file
|
@ -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 <script-location> <destination> (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
|
Loading…
Reference in a new issue