install.fairie/home/dot_local/bin/executable_rclone-mount
Brian Zalewski d8769e8ad1 Update 16 files
- /home/dot_config/rclone/merge_rclone.conf
- /home/dot_config/rclone/s3-public.service.tmpl
- /home/dot_config/rclone/s3-private.service.tmpl
- /home/dot_config/rclone/s3-docker.service.tmpl
- /home/dot_config/gcp/gcp.json.TODO
- /home/dot_config/docker/plugins.json
- /home/.chezmoitemplates/secrets/key-cloudflare-r2-secret
- /home/.chezmoitemplates/secrets/key-cloudflare-r2-id
- /home/dot_local/bin/executable_rclone-mount
- /home/dot_local/bin/executable_install-program
- /home/.chezmoidata.yaml
- /home/.chezmoiscripts/_universal/run_onchange_before_11-install-docker.tmpl
- /home/.chezmoiscripts/universal/run_onchange_after_07-docker-plugins.tmpl
- /home/.chezmoi.yaml.tmpl
- /docs/TODO.md
- /software.yml
2023-01-30 03:09:02 +00:00

55 lines
1.4 KiB
Bash

#!/usr/bin/env sh
### Variables
TYPE="$1"
USER="$2"
MOUNT="$3"
### Path definitions
if [ "$TYPE" = 'user' ]; then
CACHE_FOLDER="/home/$USER/.cache/rclone"
CONFIG_FOLDER="/home/$USER/.config/rclone"
LOG_FOLDER="/home/$USER/.local/log"
LOG_FILE="$LOG_FOLDER/$MOUNT.log"
MOUNT_PATH="/home/{{ .user.username }}/.local/mnt/$MOUNT"
else
CACHE_FOLDER="/var/cache/rclone/$MOUNT"
CONFIG_FOLDER="/etc"
LOG_FOLDER="/var/log/rclone"
LOG_FILE="$LOG_FOLDER/$MOUNT.log"
MOUNT_PATH="/mnt/$MOUNT"
fi
### Ensure folders exist
for FOLDER in "$CACHE_FOLDER" "$CONFIG_FOLDER" "$LOG_FOLDER" "$MOUNT_PATH"; do
if [ ! -d "$FOLDER" ]; then
mkdir -p "$FOLDER" || echo "ERROR: Need permissions for $FOLDER"
fi
done
### Define rcloneignore location
RCLONE_IGNORE="$CONFIG_FOLDER/rcloneignore"
if [ ! -f "$RCLONE_IGNORE" ] && [ -f "/etc/rcloneignore" ]; then
RCLONE_IGNORE='etc/rcloneignore'
fi
### Mount
/usr/bin/rclone --config="$CONFIG_FOLDER/rclone.conf" \
mount \
--cache-tmp-upload-path="$CACHE_FOLDER/$MOUNT-upload" \
--cache-chunk-path="$CACHE_FOLDER/$MOUNT-chunks" \
--cache-workers=8 \
--cache-writes \
--cache-dir="$CACHE_FOLDER/$MOUNT-vfs" \
--cache-db-path="$CACHE_FOLDER/$MOUNT-db" \
--log-file="$LOG_FILE" \
--no-modtime \
--drive-use-trash \
--stats=0 \
--checkers=16 \
--bwlimit=40M \
--dir-cache-time=60m \
--vfs-cache-mode full \
--cache-info-age=60m \
--filter-from="$RCLONE_IGNORE"
"$MOUNT":/ "$MOUNT_PATH"