#!/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