2017-05-05 11:19:38 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
2017-05-08 05:56:55 +00:00
|
|
|
mkdir -p /app/data/config
|
2017-05-05 11:19:38 +00:00
|
|
|
|
2017-05-26 02:19:46 +00:00
|
|
|
# if this if the first run, generate a useful config
|
|
|
|
if [ ! -f /app/data/config/config.xml ]; then
|
2018-02-26 22:39:33 +00:00
|
|
|
echo "=> Generating config"
|
|
|
|
/app/code/syncthing --generate="/app/data/config"
|
|
|
|
|
|
|
|
# The password value was determined by reading config.xml and setting value in the GUI
|
|
|
|
xmlstarlet ed --inplace \
|
|
|
|
--subnode "//configuration/gui" -t elem -n user -v "admin" \
|
|
|
|
--subnode "//configuration/gui" -t elem -n password -v '$2a$10$93OsgwAMD4NcPFTpGDnuTORMMbj5dc1ZlYUPrQCcy1N/Bsy9scUvK' \
|
|
|
|
/app/data/config/config.xml
|
2017-05-05 11:19:38 +00:00
|
|
|
fi
|
|
|
|
|
2017-06-07 22:26:33 +00:00
|
|
|
# Set the listenAddress and the gui enabled to make sure user doesnt lock themselves out by accident.
|
2018-02-26 22:07:43 +00:00
|
|
|
sed -e "s,<listenAddress>.*</listenAddress>,<listenAddress>tcp://:${SYNCER_PORT}</listenAddress>," -i /app/data/config/config.xml
|
2017-06-07 22:26:33 +00:00
|
|
|
sed -e 's,<gui .*>,<gui enabled="true" tls="false" debugging="false">,' -i /app/data/config/config.xml
|
|
|
|
|
2017-06-10 09:25:07 +00:00
|
|
|
chown -R cloudron:cloudron /app/data/config /app/data
|
|
|
|
|
2018-02-26 22:39:33 +00:00
|
|
|
# -no-browser opens up the browser (for desktop app preumably)
|
2018-02-26 18:30:48 +00:00
|
|
|
echo "=> Starting syncthing"
|
2018-02-26 22:39:33 +00:00
|
|
|
STNODEFAULTFOLDER=1 STNOUPGRADE=1 exec /usr/local/bin/gosu cloudron:cloudron /app/code/syncthing -gui-address=0.0.0.0:3000 -home=/app/data/config -no-browser
|
2017-05-05 11:19:38 +00:00
|
|
|
|