entrypoint.sh 998 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/sh
  2. set -x
  3. # Force user and group because lighttpd runs as webdav
  4. USERNAME=webdav
  5. GROUP=webdav
  6. # Only allow read access by default
  7. READWRITE=${READWRITE:=false}
  8. # Add user if it does not exist
  9. if ! id -u "${USERNAME}" >/dev/null 2>&1; then
  10. addgroup -g ${USER_GID:=2222} ${GROUP}
  11. adduser -G ${GROUP} -D -H -u ${USER_UID:=2222} ${USERNAME}
  12. fi
  13. chown webdav /var/log/lighttpd
  14. if [ -n "$WHITELIST" ]; then
  15. sed -i "s/WHITELIST/${WHITELIST}/" /etc/lighttpd/webdav.conf
  16. fi
  17. if [ "$READWRITE" == "true" ]; then
  18. sed -i "s/is-readonly = \"\\w*\"/is-readonly = \"disable\"/" /etc/lighttpd/webdav.conf
  19. else
  20. sed -i "s/is-readonly = \"\\w*\"/is-readonly = \"enable\"/" /etc/lighttpd/webdav.conf
  21. fi
  22. if [ ! -f /config/htpasswd ]; then
  23. cp /etc/lighttpd/htpasswd /config/htpasswd
  24. fi
  25. if [ ! -f /config/webdav.conf ]; then
  26. cp /etc/lighttpd/webdav.conf /config/webdav.conf
  27. fi
  28. lighttpd -f /etc/lighttpd/lighttpd.conf
  29. # Hang on a bit while the server starts
  30. sleep 5
  31. tail -f /var/log/lighttpd/*.log