mount.sh 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. set -e
  3. ENCFS_SOURCE_CONFIG_PATH="$ENCFS_SOURCE_DIR/.encfs6.xml"
  4. if [ ! -f "$ENCFS_PASSWORD_PATH" ]; then
  5. echo generating encfs password at $ENCFS_PASSWORD_PATH
  6. (set -x;
  7. tr -dc "$ENCFS_PASSWORD_CHARSET" < /dev/random | head -c "$ENCFS_PASSWORD_LENGTH" > "$ENCFS_PASSWORD_PATH")
  8. [ -f "$ENCFS_SOURCE_CONFIG_PATH" ] && (set -x; rm "$ENCFS_SOURCE_CONFIG_PATH")
  9. fi
  10. # cave: when $ENCFS6_CONFIG is set, encfs excepts the config to already exist
  11. # ERROR fatal: config file specified by environment does not exist: /target/config/encfs6.xml [FileUtils.cpp:246]
  12. # https://github.com/vgough/encfs/issues/497
  13. function copy_config {
  14. sleep 4
  15. while [ ! -f "$ENCFS_SOURCE_CONFIG_PATH" ]; do
  16. echo waiting for encfs to create $ENCFS_SOURCE_CONFIG_PATH
  17. sleep 2
  18. done
  19. (set -x; cp "$ENCFS_SOURCE_CONFIG_PATH" "$ENCFS_CONFIG_COPY_PATH")
  20. }
  21. copy_config &
  22. set -x
  23. mkdir -p "$ENCFS_MOUNT_POINT"
  24. encfs -f -o allow_other --reverse --standard \
  25. --extpass="cat \"$ENCFS_PASSWORD_PATH\"" \
  26. "$ENCFS_SOURCE_DIR" "$ENCFS_MOUNT_POINT"