start.sh 1.3 KB

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. set -eu
  3. mkdir -p /app/data/config
  4. # if this if the first run, generate a useful config
  5. if [ ! -f /app/data/config/config.xml ]; then
  6. echo "=> Generating config"
  7. /app/code/syncthing --generate="/app/data/config"
  8. # The password value was determined by reading config.xml and setting value in the GUI
  9. # urAccepted is 0 for not decided, -1 for no reporting
  10. xmlstarlet ed --inplace \
  11. --subnode "//configuration/gui" -t elem -n user -v "admin" \
  12. --subnode "//configuration/gui" -t elem -n password -v '$2a$10$93OsgwAMD4NcPFTpGDnuTORMMbj5dc1ZlYUPrQCcy1N/Bsy9scUvK' \
  13. --update "//configuration/options/urAccepted" -v '-1' \
  14. /app/data/config/config.xml
  15. fi
  16. # Set the listenAddress and the gui enabled to make sure user doesnt lock themselves out by accident.
  17. sed -e "s,<listenAddress>.*</listenAddress>,<listenAddress>tcp://:${SYNCER_PORT}</listenAddress>," -i /app/data/config/config.xml
  18. sed -e 's,<gui .*>,<gui enabled="true" tls="false" debugging="false">,' -i /app/data/config/config.xml
  19. chown -R cloudron:cloudron /app/data/config /app/data
  20. # -no-browser opens up the browser (for desktop app preumably)
  21. echo "=> Starting syncthing"
  22. 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