Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions git_sync
Original file line number Diff line number Diff line change
@@ -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


8 changes: 6 additions & 2 deletions p
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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
Expand Down