Browse Source

Set default admin/password

Girish Ramakrishnan 7 năm trước cách đây
mục cha
commit
9cd9df2876
1 tập tin đã thay đổi với 10 bổ sung5 xóa
  1. 10 5
      start.sh

+ 10 - 5
start.sh

@@ -4,12 +4,16 @@ set -eu
 
 mkdir -p /app/data/config
 
-export STNODEFAULTFOLDER=1 STNOUPGRADE=1
-
 # if this if the first run, generate a useful config
 if [ ! -f /app/data/config/config.xml ]; then
-  echo "=> Generating config"
-  /app/code/syncthing --generate="/app/data/config"
+    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
 fi
 
 # Set the listenAddress and the gui enabled to make sure user doesnt lock themselves  out by accident.
@@ -18,6 +22,7 @@ sed -e 's,<gui .*>,<gui enabled="true" tls="false" debugging="false">,' -i /app/
 
 chown -R cloudron:cloudron /app/data/config /app/data
 
+# -no-browser opens up the browser (for desktop app preumably)
 echo "=> Starting syncthing"
-exec /usr/local/bin/gosu cloudron:cloudron /app/code/syncthing -gui-address=0.0.0.0:3000 -home=/app/data/config -no-browser
+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