Skip to content

Commit 83bf45d

Browse files
committed
Added option to change read-only for rclone and plexdrive
1 parent 7a22e76 commit 83bf45d

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ RUN \
4949
# Encryption
5050
ENV ENCRYPT_MEDIA "1"
5151

52+
ENV READONLY "1"
53+
5254
# Rclone
5355
ENV BUFFER_SIZE "500M"
5456
ENV MAX_READ_AHEAD "30G"

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Environment variables:
6868
* `-e REMOVE_LOCAL_FILES_WHEN_SPACE_EXCEEDS_GB` - Remove local files when local storage exceeds this value in GB (default **100**) - this is ignored if `REMOVE_LOCAL_FILES_BASED_ON` is set to time
6969
* `-e FREEUP_ATLEAST_GB` - Remove atleast this value in GB on removal (default **80**) - this is ignored if `REMOVE_LOCAL_FILES_BASED_ON` is set to time
7070
* `-e REMOVE_LOCAL_FILES_AFTER_DAYS` Remove local files older than this value in days (default **10**) - this is ignored if `REMOVE_LOCAL_FILES_BASED_ON` is set to space
71+
* `-e READ_ONLY` If Rclone and Plexdrive should be read only or not. 0 means writeable and 1 means read only (default **1**)
7172
* `-e PGID` Group id
7273
* `-e PUID` User id
7374

@@ -156,7 +157,7 @@ When using encryption this gives us a total of 5 directories:
156157
- /local-decrypt: Local data decrypted that is yet to be uploaded to the cloud
157158
- /chunks: Plexdrive temporary files and caching
158159
- /local-media: Union of decrypted cloud data and local data (Mounted with Union-FS)
159-
160+
160161
When NOT using encryption this gives us a total of 4 directories:
161162
- /cloud-decrypt: Cloud data decrypted (Mounted with Plexdrive)
162163
- /local-decrypt: Local data decrypted that is yet to be uploaded to the cloud

scripts/mount.script

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ mount_gdrive () {
2929
# Mount GD if not already mounted.
3030
if [ $(ps -ef | grep "plexdrive" | grep -v "grep" | wc -l) == "0" ]; then
3131
echo "[ $(date $(printenv DATE_FORMAT)) ] Mounting Google Drive mountpoint: ${cloud_dir}"
32+
echo "screen -dmS plexdrive plexdrive $mongo $plexdrive_options ${cloud_dir}"
3233
screen -dmS plexdrive plexdrive $mongo $plexdrive_options "${cloud_dir}"
3334
else
3435
echo "[ $(date $(printenv DATE_FORMAT)) ] Google Drive mountpoint: ${cloud_dir} already mounted."
@@ -52,6 +53,7 @@ mount_local_media () {
5253

5354
if [ $(ps -ef | grep "rclone" | grep -v "grep" | wc -l) == "0" ]; then
5455
echo "[ $(date $(printenv DATE_FORMAT)) ] Mounting decrypted Google Drive: ${cloud_decrypt_dir}"
56+
echo "rclone mount $rclone_mount_options $@ $(printenv RCLONE_LOCAL_ENDPOINT) ${cloud_decrypt_dir}"
5557
rclone mount $rclone_mount_options "$@" "$(printenv RCLONE_LOCAL_ENDPOINT)" "${cloud_decrypt_dir}" &
5658
else
5759
echo "[ $(date $(printenv DATE_FORMAT)) ] Decrypted Google Drive mountpoint: ${cloud_decrypt_dir} already mounted."
@@ -82,6 +84,8 @@ mount_union () {
8284

8385
ufs_mounts="${local_decrypt_dir}=RW:${cloud_decrypt_dir}=RO"
8486

87+
echo "[ $(date $(printenv DATE_FORMAT)) ] Mounting union of ${local_decrypt_dir} and ${cloud_decrypt_dir}: ${local_media_dir}"
88+
echo "unionfs $ufs_options ${ufs_mounts} ${local_media_dir}"
8589
unionfs $ufs_options "${ufs_mounts}" "${local_media_dir}"
8690
else
8791
echo "[ $(date $(printenv DATE_FORMAT)) ] Plex library mountpoint: ${local_media_dir} already mounted."

scripts/variables

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@ local_media_dir="/local-media"
1111

1212
rclone_config="--config=/config/rclone.conf"
1313
rclone_options="${rclone_config} --buffer-size $(printenv BUFFER_SIZE) --checkers $(printenv CHECKERS)"
14-
rclone_mount_options="${rclone_options} --read-only --allow-non-empty --allow-other --max-read-ahead $(printenv MAX_READ_AHEAD) --uid ${_puid:-911} --gid ${_pgid:-911}"
14+
rclone_mount_options="${rclone_options} --allow-non-empty --allow-other --max-read-ahead $(printenv MAX_READ_AHEAD) --uid ${_puid:-911} --gid ${_pgid:-911}"
1515

1616
plexdrive_temp_dir="/chunks"
17-
plexdrive_options="--config=/config --temp=${plexdrive_temp_dir} --chunk-size=$(printenv CHUNK_SIZE) --clear-chunk-age=$(printenv CLEAR_CHUNK_AGE) --uid=${_puid:-911} --gid=${_pgid:-911} -o allow_other,read_only"
17+
plexdrive_options="--config=/config --temp=${plexdrive_temp_dir} --chunk-size=$(printenv CHUNK_SIZE) --clear-chunk-age=$(printenv CLEAR_CHUNK_AGE) --uid=${_puid:-911} --gid=${_pgid:-911} -o allow_other"
18+
19+
if [ "$(printenv READ_ONLY)" != "0" ]; then
20+
plexdrive_options="$plexdrive_options -o read_only"
21+
rclone_mount_options="$rclone_mount_options --read-only"
22+
fi
1823
if [ ! -z $(printenv CLEAR_CHUNK_MAX_SIZE) ]; then
1924
plexdrive_options="${plexdrive_options} --clear-chunk-max-size=$(printenv CLEAR_CHUNK_MAX_SIZE)"
2025
fi
2126

27+
2228
mongo="--mongo-database=$(printenv MONGO_DATABASE) --mongo-host=localhost"
2329

2430
ufs_options="-o uid=${_puid:-911} -o gid=${_pgid:-911} -o cow,allow_other,direct_io,nonempty,auto_cache,sync_read"

0 commit comments

Comments
 (0)