add syncthing-keepalive service initial files
WIP - currently not fully functional
This commit is contained in:
16
syncthing-keepalive/README.org
Normal file
16
syncthing-keepalive/README.org
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
*** Syncthing keep alive servie
|
||||||
|
Very simple solution to make sure that syncthing is up and running
|
||||||
|
at most times, and also accessible via automatically started
|
||||||
|
screen session.
|
||||||
|
|
||||||
|
*** Prerequisites
|
||||||
|
* syncthing
|
||||||
|
* screen
|
||||||
|
* cron
|
||||||
|
|
||||||
|
*** Usage
|
||||||
|
Place ~check-syncthing.sh~ somewhere in you path, and add it's
|
||||||
|
invocation to your crontab.
|
||||||
|
|
||||||
|
*** Known limitations
|
||||||
|
* Doesn't clean pid file even after successfull shutdown.
|
||||||
26
syncthing-keepalive/check-syncthing.sh
Normal file
26
syncthing-keepalive/check-syncthing.sh
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#/bin/bash
|
||||||
|
|
||||||
|
pid_file=~/.syncthing-pid
|
||||||
|
screen_name="syncthing_screen"
|
||||||
|
|
||||||
|
is_syncthing_running() {
|
||||||
|
if [[ ! -f "${pid_file}" ]]; then
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
pid=$(<"${pid_file}")
|
||||||
|
if ! kill -0 "$pid" >/dev/null 2>&1; then
|
||||||
|
rm -f "${pid_file}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! is_syncthing_running; then
|
||||||
|
if screen -ls "${screen_name}" >/dev/null 2>&1; then
|
||||||
|
screen -S "${screen_name}" -X kill
|
||||||
|
fi
|
||||||
|
screen -DmS "${screen_name}" syncthing &
|
||||||
|
screen_pid=$!
|
||||||
|
# todo! find pid of syncthing and store it to pid file
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user