From 8bf069af2ff559d77eaec56be0843daee3b37bb5 Mon Sep 17 00:00:00 2001 From: Stefan Ravn van Overeem Date: Tue, 3 Nov 2015 07:48:01 +0100 Subject: [PATCH 01/14] Add aliases to .bashrc instead of .bash_profile. .bash_profile only runs at login shells, while .bashrc runs at every shell session --- p | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 p diff --git a/p b/p old mode 100644 new mode 100755 index 5fc322f..2f4c8b1 --- a/p +++ b/p @@ -1,7 +1,7 @@ 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 # check if the pacman database exists pacdb=/var/lib/pacman/db.lck From 3b5047803bb3dcedf548e609b0f904699efbfa65 Mon Sep 17 00:00:00 2001 From: Stefan Ravn van Overeem Date: Tue, 3 Nov 2015 08:21:27 +0100 Subject: [PATCH 02/14] First attempt at git autosync. --- git_sync | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 git_sync diff --git a/git_sync b/git_sync new file mode 100644 index 0000000..6b290b6 --- /dev/null +++ b/git_sync @@ -0,0 +1,55 @@ +#!/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=$HOME/scripts +SYNC_SCRIPT=/usr/bin/git_sync.sh + +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 +git clone $GIT_URL $GIT_DIR + + +#make a script that does the syncing +echo" +#!/bin/sh + +#Sync the git repo +git -C $GIT_DIR +" > $SYNC_SCRIPT + +#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 + +[Service] +Type=simple +ExecStart=$SYNC_SCRIPT" > /etc/systemd/system/git_sync.service + From 15ecffee3436ccbe4ddd6c82456a5e3c85607166 Mon Sep 17 00:00:00 2001 From: Stefan Ravn van Overeem Date: Tue, 3 Nov 2015 08:29:07 +0100 Subject: [PATCH 03/14] small fixes --- git_sync | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/git_sync b/git_sync index 6b290b6..2797d78 100644 --- a/git_sync +++ b/git_sync @@ -4,7 +4,7 @@ #add the repo to $path (should be done in p) #install git -GIT_URL=https://github.com/twial/scripts.git +GIT_URL=https://github.com/StefanRvO/scripts.git GIT_DIR=$HOME/scripts SYNC_SCRIPT=/usr/bin/git_sync.sh @@ -19,7 +19,7 @@ if [ -n "$x" ] fi #clone the repo -git clone $GIT_URL $GIT_DIR +git clone $GIT_URL $GIT_DIR || true #make a script that does the syncing @@ -27,8 +27,8 @@ echo" #!/bin/sh #Sync the git repo -git -C $GIT_DIR -" > $SYNC_SCRIPT +git -C $GIT_DIR" > $SYNC_SCRIPT + #set up a systemd timer to sync once every 5 minutes echo " From 885ae5a5445a3b992d83d909dc6aafa66921c535 Mon Sep 17 00:00:00 2001 From: Stefan Ravn van Overeem Date: Tue, 3 Nov 2015 08:30:28 +0100 Subject: [PATCH 04/14] set sync script exec bit --- git_sync | 1 + 1 file changed, 1 insertion(+) diff --git a/git_sync b/git_sync index 2797d78..49fcf2c 100644 --- a/git_sync +++ b/git_sync @@ -28,6 +28,7 @@ echo" #Sync the git repo git -C $GIT_DIR" > $SYNC_SCRIPT +chmod +x $SYNC_SCRIPT #set up a systemd timer to sync once every 5 minutes From 9acbdcd8f9df85bee690f981050dc17697533ea4 Mon Sep 17 00:00:00 2001 From: Stefan Ravn van Overeem Date: Tue, 3 Nov 2015 08:31:56 +0100 Subject: [PATCH 05/14] fixes. --- git_sync | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/git_sync b/git_sync index 49fcf2c..78771cc 100644 --- a/git_sync +++ b/git_sync @@ -19,11 +19,12 @@ if [ -n "$x" ] fi #clone the repo +rm $GIT_DIR -p git clone $GIT_URL $GIT_DIR || true #make a script that does the syncing -echo" +echo " #!/bin/sh #Sync the git repo From e29322f2d7c58cb694ade0c9ec9e014c58bf92ac Mon Sep 17 00:00:00 2001 From: Stefan Ravn van Overeem Date: Tue, 3 Nov 2015 08:36:54 +0100 Subject: [PATCH 06/14] changed to single quotes --- git_sync | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/git_sync b/git_sync index 78771cc..cf23b2f 100644 --- a/git_sync +++ b/git_sync @@ -24,16 +24,16 @@ git clone $GIT_URL $GIT_DIR || true #make a script that does the syncing -echo " +echo ' #!/bin/sh #Sync the git repo -git -C $GIT_DIR" > $SYNC_SCRIPT +git -C $GIT_DIR' > $SYNC_SCRIPT chmod +x $SYNC_SCRIPT #set up a systemd timer to sync once every 5 minutes -echo " +echo ' [Unit] Description=sync the repo every 5 minutes @@ -43,15 +43,15 @@ Persistent=true Unit=git_sync.service [Install] -WantedBy=timers.target" > /etc/systemd/system/git_sync.timer +WantedBy=timers.target' > /etc/systemd/system/git_sync.timer #set up the service for the timer -echo " +echo ' [Unit] Description=sync the repo [Service] Type=simple -ExecStart=$SYNC_SCRIPT" > /etc/systemd/system/git_sync.service +ExecStart=$SYNC_SCRIPT' > /etc/systemd/system/git_sync.service From 157787f508f22c8eb3f58c91369d942e4007e565 Mon Sep 17 00:00:00 2001 From: Stefan Ravn van Overeem Date: Tue, 3 Nov 2015 08:40:52 +0100 Subject: [PATCH 07/14] Added stuff for actually starting the service --- git_sync | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/git_sync b/git_sync index cf23b2f..44fcf81 100644 --- a/git_sync +++ b/git_sync @@ -19,7 +19,7 @@ if [ -n "$x" ] fi #clone the repo -rm $GIT_DIR -p +rm $GIT_DIR -Rf git clone $GIT_URL $GIT_DIR || true @@ -55,3 +55,9 @@ Description=sync the repo Type=simple ExecStart=$SYNC_SCRIPT' > /etc/systemd/system/git_sync.service +#Start systemd services + +systemctl enable git_sync.timer +systemctl start git_sync.timer + + From 1737b81c879d8039fab64447e5913664eb546b87 Mon Sep 17 00:00:00 2001 From: Stefan Ravn van Overeem Date: Tue, 3 Nov 2015 08:48:04 +0100 Subject: [PATCH 08/14] small edits. this is a bit hard to debug.. --- git_sync | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/git_sync b/git_sync index 44fcf81..fe249ec 100644 --- a/git_sync +++ b/git_sync @@ -33,8 +33,7 @@ chmod +x $SYNC_SCRIPT #set up a systemd timer to sync once every 5 minutes -echo ' -[Unit] +echo '[Unit] Description=sync the repo every 5 minutes [Timer] @@ -47,13 +46,12 @@ WantedBy=timers.target' > /etc/systemd/system/git_sync.timer #set up the service for the timer -echo ' -[Unit] +echo '[Unit] Description=sync the repo [Service] Type=simple -ExecStart=$SYNC_SCRIPT' > /etc/systemd/system/git_sync.service +ExecStart=/usr/bin/git_sync.sh' > /etc/systemd/system/git_sync.service #Start systemd services From 8c9a85512f0b2edb9997441cc4340ef214e6e381 Mon Sep 17 00:00:00 2001 From: Stefan Ravn van Overeem Date: Tue, 3 Nov 2015 08:59:47 +0100 Subject: [PATCH 09/14] changed sync script --- git_sync | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git_sync b/git_sync index fe249ec..23cfdc8 100644 --- a/git_sync +++ b/git_sync @@ -5,7 +5,7 @@ #install git GIT_URL=https://github.com/StefanRvO/scripts.git -GIT_DIR=$HOME/scripts +GIT_DIR=/root/scripts SYNC_SCRIPT=/usr/bin/git_sync.sh x=`pacman -Qs git` @@ -28,7 +28,7 @@ echo ' #!/bin/sh #Sync the git repo -git -C $GIT_DIR' > $SYNC_SCRIPT +git -C /root/scripts pull' > $SYNC_SCRIPT chmod +x $SYNC_SCRIPT From 6716064aeb71985cf58fa98a3932c24accae9963 Mon Sep 17 00:00:00 2001 From: Stefan Ravn van Overeem Date: Tue, 3 Nov 2015 09:13:56 +0100 Subject: [PATCH 10/14] try to fix bug in service --- git_sync | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/git_sync b/git_sync index 23cfdc8..895bb8c 100644 --- a/git_sync +++ b/git_sync @@ -6,7 +6,6 @@ #install git GIT_URL=https://github.com/StefanRvO/scripts.git GIT_DIR=/root/scripts -SYNC_SCRIPT=/usr/bin/git_sync.sh x=`pacman -Qs git` @@ -23,14 +22,6 @@ rm $GIT_DIR -Rf git clone $GIT_URL $GIT_DIR || true -#make a script that does the syncing -echo ' -#!/bin/sh - -#Sync the git repo -git -C /root/scripts pull' > $SYNC_SCRIPT -chmod +x $SYNC_SCRIPT - #set up a systemd timer to sync once every 5 minutes echo '[Unit] @@ -48,10 +39,10 @@ WantedBy=timers.target' > /etc/systemd/system/git_sync.timer echo '[Unit] Description=sync the repo +Wants=git_sync.timer [Service] -Type=simple -ExecStart=/usr/bin/git_sync.sh' > /etc/systemd/system/git_sync.service +ExecStart=/usr/bin/git -C /root/scripts pull' > /etc/systemd/system/git_sync.service #Start systemd services From 3a4f9ced7b0a8ab4e0ebe028f4645cbc2ed391dd Mon Sep 17 00:00:00 2001 From: Stefan Ravn van Overeem Date: Tue, 3 Nov 2015 09:28:45 +0100 Subject: [PATCH 11/14] Added updating of path to p --- p | 3 +++ 1 file changed, 3 insertions(+) diff --git a/p b/p index 2f4c8b1..5f9682b 100755 --- a/p +++ b/p @@ -3,6 +3,9 @@ chmod u+x ~/.run echo "alias p='curl -L https://raw.githubusercontent.com/twial/scripts/master/p | sh'" > ~/.bashrc echo "alias r='~/.run'" >> ~/.bashrc +#Add scripts to path +echo 'PATH=/root/scripts:$PATH' > ~/.profile + # check if the pacman database exists pacdb=/var/lib/pacman/db.lck if [ -e $pacdb ] From c696e6ed85c73bcc59b09daaf658f2a5b796f451 Mon Sep 17 00:00:00 2001 From: Stefan Ravn van Overeem Date: Tue, 3 Nov 2015 09:41:36 +0100 Subject: [PATCH 12/14] Pretty sure git sync works now. --- git_sync | 2 +- p | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/git_sync b/git_sync index 895bb8c..4417d82 100644 --- a/git_sync +++ b/git_sync @@ -4,7 +4,7 @@ #add the repo to $path (should be done in p) #install git -GIT_URL=https://github.com/StefanRvO/scripts.git +GIT_URL=https://github.com/twial/scripts.git GIT_DIR=/root/scripts x=`pacman -Qs git` diff --git a/p b/p index 5f9682b..df1abf6 100755 --- a/p +++ b/p @@ -4,7 +4,7 @@ echo "alias p='curl -L https://raw.githubusercontent.com/twial/scripts/master/p echo "alias r='~/.run'" >> ~/.bashrc #Add scripts to path -echo 'PATH=/root/scripts:$PATH' > ~/.profile +echo 'PATH=/root/scripts:$PATH' > ~/.bashrc # check if the pacman database exists pacdb=/var/lib/pacman/db.lck From e91b9990125ead66e8af824e007e01e769339fce Mon Sep 17 00:00:00 2001 From: Stefan Ravn van Overeem Date: Tue, 3 Nov 2015 10:28:16 +0100 Subject: [PATCH 13/14] added /bin/bash to .bash_profile to get alias support in login shells --- p | 1 + 1 file changed, 1 insertion(+) diff --git a/p b/p index 2f4c8b1..9f6c1e4 100755 --- a/p +++ b/p @@ -2,6 +2,7 @@ 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'" > ~/.bashrc echo "alias r='~/.run'" >> ~/.bashrc +echo "/bin/bash" >> ~/.bash_profile # check if the pacman database exists pacdb=/var/lib/pacman/db.lck From 2322f44f85bb7c83b702a5286522a36618f4e9cc Mon Sep 17 00:00:00 2001 From: Stefan Ravn van Overeem Date: Tue, 3 Nov 2015 10:32:05 +0100 Subject: [PATCH 14/14] single arrow instead of double --- p | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/p b/p index 9f6c1e4..a0620ac 100755 --- a/p +++ b/p @@ -2,7 +2,7 @@ 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'" > ~/.bashrc echo "alias r='~/.run'" >> ~/.bashrc -echo "/bin/bash" >> ~/.bash_profile +echo "/bin/bash" > ~/.bash_profile # check if the pacman database exists pacdb=/var/lib/pacman/db.lck