diff --git a/git_sync b/git_sync new file mode 100644 index 0000000..4417d82 --- /dev/null +++ b/git_sync @@ -0,0 +1,52 @@ +#!/bin/sh + +#create a local copy of the git repo, and create a systemd timer to sync it once every 5 minute. +#add the repo to $path (should be done in p) + +#install git +GIT_URL=https://github.com/twial/scripts.git +GIT_DIR=/root/scripts + +x=`pacman -Qs git` + +if [ -n "$x" ] + then + echo "git is installed!" + else + echo "git is not installed! installing.." + pacman -S git --noconfirm +fi + +#clone the repo +rm $GIT_DIR -Rf +git clone $GIT_URL $GIT_DIR || true + + + +#set up a systemd timer to sync once every 5 minutes +echo '[Unit] +Description=sync the repo every 5 minutes + +[Timer] +OnCalendar=*:0/5 +Persistent=true +Unit=git_sync.service + +[Install] +WantedBy=timers.target' > /etc/systemd/system/git_sync.timer + +#set up the service for the timer + +echo '[Unit] +Description=sync the repo +Wants=git_sync.timer + +[Service] +ExecStart=/usr/bin/git -C /root/scripts pull' > /etc/systemd/system/git_sync.service + +#Start systemd services + +systemctl enable git_sync.timer +systemctl start git_sync.timer + + diff --git a/p b/p old mode 100644 new mode 100755 index 5fc322f..5843f9d --- a/p +++ b/p @@ -1,7 +1,11 @@ curl -L https://raw.githubusercontent.com/twial/scripts/master/run > ~/.run chmod u+x ~/.run -echo "alias p='curl -L https://raw.githubusercontent.com/twial/scripts/master/p | sh'" > ~/.bash_profile -echo "alias r='~/.run'" >> ~/.bash_profile +echo "alias p='curl -L https://raw.githubusercontent.com/twial/scripts/master/p | sh'" > ~/.bashrc +echo "alias r='~/.run'" >> ~/.bashrc +echo "/bin/bash" > ~/.bash_profile + +#Add scripts to path +echo 'PATH=/root/scripts:$PATH' > ~/.bashrc # check if the pacman database exists pacdb=/var/lib/pacman/db.lck