start.sh 1.4 KB

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