From 44c512226f33fb17ab41b2b60e06d88c22486e33 Mon Sep 17 00:00:00 2001 From: Andreas Date: Sat, 17 Sep 2016 23:31:09 +0200 Subject: [PATCH 1/3] make the script more general change the repo path to ~/ because the configs might as well lay in a different home directory. In addition I've add a variable which brings the user back to his starting point. --- general/update_dot_files/update_dot_files.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/general/update_dot_files/update_dot_files.sh b/general/update_dot_files/update_dot_files.sh index dc23d3c..79f8c5a 100755 --- a/general/update_dot_files/update_dot_files.sh +++ b/general/update_dot_files/update_dot_files.sh @@ -1,5 +1,7 @@ #! /bin/bash -cd /home/andreas/dot_files/ +directory=`pwd` +cd ~/git_repos/dot_files/ git add . git commit -m "update configs" git push +cd $directory From baaccf4049ea0d65035703d699673ed64e8d8a0a Mon Sep 17 00:00:00 2001 From: Andreas Date: Tue, 11 Oct 2016 11:54:05 +0200 Subject: [PATCH 2/3] rename update_dot_files.sh to config-update.sh I renamed the file because it's easier to call it this way. There are already lots of other commands which start with update* --- .../update_dot_files/{update_dot_files.sh => config-update.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename general/update_dot_files/{update_dot_files.sh => config-update.sh} (100%) diff --git a/general/update_dot_files/update_dot_files.sh b/general/update_dot_files/config-update.sh similarity index 100% rename from general/update_dot_files/update_dot_files.sh rename to general/update_dot_files/config-update.sh From ffe45b45b90af7664c1219e46db2cd42a2e505d3 Mon Sep 17 00:00:00 2001 From: Andreas Date: Wed, 26 Oct 2016 21:02:16 +0200 Subject: [PATCH 3/3] add a script to check if offlineimap is still working The script needs to run as a cronjob --- desktop/offlineimap/offlineimap.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 desktop/offlineimap/offlineimap.sh diff --git a/desktop/offlineimap/offlineimap.sh b/desktop/offlineimap/offlineimap.sh new file mode 100755 index 0000000..a76b9a2 --- /dev/null +++ b/desktop/offlineimap/offlineimap.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Check every ten seconds if the process identified as $1 is still +# running. After 5 checks (~60 seconds), kill it. Return non-zero to +# indicate something was killed. +monitor() { + local pid=$1 i=0 + + while ps $pid &>/dev/null; do + if (( i++ > 5 )); then + echo "Max checks reached. Sending SIGKILL to ${pid}..." >&2 + kill -9 $pid; return 1 + fi + + sleep 10 + done + + return 0 +} + +read -r pid < ~/.offlineimap/pid + +if ps $pid &>/dev/null; then + echo "Process $pid already running. Exiting..." >&2 + exit 1 +fi + +offlineimap -o -u quiet & monitor $!