From a5b870ddef360d50b672a8372374624666f12849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sat, 14 Jan 2017 14:48:01 +0100 Subject: Add some initial support for syncthing configuration Syncthing expects that we are using gui, but I said NO! --- utils/syncthing | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100755 utils/syncthing (limited to 'utils/syncthing') diff --git a/utils/syncthing b/utils/syncthing new file mode 100755 index 0000000..fe23586 --- /dev/null +++ b/utils/syncthing @@ -0,0 +1,99 @@ +#!/bin/sh +set -e + +[ -d syncthing ] || (echo "There is no configuration directory" >&2; exit 1) +HOST="$(hostname)" +[ -f syncthing/"$HOST" ] || (echo "Host $HOST seems to be unconfigured" >&2; exit 1) + +TMPCNF="/tmp/syncthing.conf.xml" +[ -f $TMPCNF ] && rm $TMPCNF + +# Begin configuration +echo "" >$TMPCNF + +for h in syncthing/*; do + # Source host + . "$h" + + # Set to configuration + echo " " >>$TMPCNF + echo "
$ADDRESS
" >>$TMPCNF + echo "
" >>$TMPCNF + + # Parse DIRS of this host + eval `echo "$DIRS" | sed -ne 's/^\([^:]*\):.*$/ST_DIR_HOSTS_\1="$ST_DIR_HOSTS_\1 $ID"/p'` +done + +# Now again source target host +. syncthing/"$HOST" + + +while read -r d; do + # Get name of the directory + NM="$(echo "$d" | sed 's/:.*$//')" + # Get target path + PTH="$(echo "$d" | sed 's/^[^:]*://')" + # Write folder init + echo " " >>$TMPCNF + # Specify every all devices + for dev in eval `echo \$ST_DIR_HOSTS_$NM`; do + echo " " >>$TMPCNF + done + # Write common configs (TODO do we want to have chance to change it?) + echo " 1 + + 0 + 0 + 0 + random + false + 0 + 0 + 0 + 10 + false + false + true" >>$TMPCNF + # Write folder end + echo " " >>$TMPCNF +done <<<"$DIRS" + +# Some defaults (TODO again do we care about those on various hosts) +echo " +
127.0.0.1:8384
+ $APIKEY + dark +
+ + default + default + true + true + 21027 + [ff12::8384]:21027 + 0 + 0 + 60 + true + 10 + true + true + 60 + 30 + 10 + 1800 + true + 12 + 24 + false + 5 + true + false + 1 + https://upgrades.syncthing.net/meta.json + false + 10 + " >>$TMPCNF + +# End configuration +echo "
" >>$TMPCNF -- cgit v1.2.3