start.sh 1.2 KB

12345678910111213141516171819202122232425262728
  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. 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. /app/data/config/config.xml
  13. fi
  14. # Set the listenAddress and the gui enabled to make sure user doesnt lock themselves out by accident.
  15. sed -e "s,<listenAddress>.*</listenAddress>,<listenAddress>tcp://:${SYNC_PORT}</listenAddress>," -i /app/data/config/config.xml
  16. sed -e 's,<gui .*>,<gui enabled="true" tls="false" debugging="false">,' -i /app/data/config/config.xml
  17. chown -R cloudron:cloudron /app/data/config /app/data
  18. # -no-browser opens up the browser (for desktop app preumably)
  19. echo "=> Starting syncthing"
  20. 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