syncthing-app/start.sh

30 lines
1.3 KiB
Bash
Raw Normal View History

2017-05-05 11:19:38 +00:00
#!/bin/bash
set -eu
2018-02-27 00:28:45 +00:00
mkdir -p /app/data/config /app/data/folders /run/syncthing
2017-05-05 11:19:38 +00:00
# if this if the first run, generate a useful config
2020-04-08 16:43:15 +00:00
if [[ ! -f /app/data/config/config.xml ]]; then
2018-02-26 22:39:33 +00:00
echo "=> Generating config"
2018-02-26 22:51:26 +00:00
STNODEFAULTFOLDER=1 /app/code/syncthing --generate="/app/data/config"
2018-02-26 22:39:33 +00:00
2020-04-08 16:43:15 +00:00
# The password value (changeme) was determined by reading config.xml and setting value in the GUI
2018-02-27 00:56:42 +00:00
# urAccepted is 0 for not decided, -1 for no reporting
2018-02-26 22:39:33 +00:00
xmlstarlet ed --inplace \
--subnode "//configuration/gui" -t elem -n user -v "admin" \
--subnode "//configuration/gui" -t elem -n password -v '$2a$10$93OsgwAMD4NcPFTpGDnuTORMMbj5dc1ZlYUPrQCcy1N/Bsy9scUvK' \
2018-02-26 22:58:02 +00:00
--update "//configuration/options/defaultFolderPath" -v '/app/data/folders' \
2018-02-27 00:56:42 +00:00
--update "//configuration/options/urAccepted" -v '-1' \
2018-02-26 22:39:33 +00:00
/app/data/config/config.xml
2017-05-05 11:19:38 +00:00
fi
# Set the listenAddress and the gui enabled to make sure user doesnt lock themselves out by accident.
2018-02-26 22:46:02 +00:00
sed -e "s,<listenAddress>.*</listenAddress>,<listenAddress>tcp://:${SYNC_PORT}</listenAddress>," -i /app/data/config/config.xml
sed -e 's,<gui .*>,<gui enabled="true" tls="false" debugging="false">,' -i /app/data/config/config.xml
2018-02-27 00:28:45 +00:00
chown -R cloudron:cloudron /app/data /run/syncthing
2017-05-05 11:19:38 +00:00
2018-02-27 00:28:45 +00:00
echo "Starting supervisor"
2021-04-08 12:37:37 +00:00
exec /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i syncthing