install.fairie/dotfiles/.local/share/chezmoi/system/usr/local/bin/executable_rclone-mount
Brian Zalewski e0677a246f Update dotfiles/.local/share/chezmoi/home/.chezmoiexternal.toml, dotfiles/.local/share/chezmoi/home/.chezmoidata.yaml, dotfiles/.local/share/chezmoi/home/private_dot_config/environments/desktop, dotfiles/.local/share/chezmoi/home/private_dot_config/environments/terminal, dotfiles/.local/share/chezmoi/home/private_dot_config/environments/development, dotfiles/.local/share/chezmoi/home/private_dot_config/environments/work, dotfiles/.local/share/chezmoi/system/Applications/Firefox.app/Contents/Resources/distribution/policies.json, dotfiles/.local/share/chezmoi/system/etc/fonts/local.conf, dotfiles/.local/share/chezmoi/system/etc/grub.d/31_hold-shift, dotfiles/.local/share/chezmoi/system/etc/keybase/config.json, dotfiles/.local/share/chezmoi/system/etc/opt/chrome/policies/managed/policies.json, dotfiles/.local/share/chezmoi/system/etc/systemd/system/r2-docker.service, dotfiles/.local/share/chezmoi/system/etc/systemd/system/r2-{{ .user.username }}.service.tmpl, dotfiles/.local/share/chezmoi/system/etc/rcloneignore, dotfiles/.local/share/chezmoi/system/mnt/private_r2-docker/remove_dot_gitkeep, dotfiles/.local/share/chezmoi/system/usr/lib/firefox/distribution/policies.json, dotfiles/.local/share/chezmoi/system/usr/lib/firefox-esr/distribution/policies.json, dotfiles/.local/share/chezmoi/system/usr/local/bin/executable_rclone-mount, dotfiles/.local/share/chezmoi/system/var/cache/rclone/remove_dot_gitkeep, dotfiles/.local/share/chezmoi/system/var/log/user/run_onchange_after-symlink-user-logs, dotfiles/.local/share/chezmoi/system/.chezmoiexternal.toml
2022-11-27 08:32:41 +00:00

64 lines
1.6 KiB
Bash

#!/usr/bin/env sh
### Variables
TYPE="$1"
USER="$2"
MOUNT="$3"
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"
elif [ "$TYPE" = 'docker' ]; then
CACHE_FOLDER="/var/cache/rclone/$MOUNT"
CONFIG_FOLDER="/etc"
LOG_FOLDER="/var/log/rclone"
LOG_FILE="$LOG_FOLDER/$MOUNT.log"
MOUNT_PATH="/mnt/$MOUNT"
else
CACHE_FOLDER="/var/cache/rclone"
CONFIG_FOLDER="/etc"
LOG_FOLDER="/var/log/rclone"
LOG_FILE="$LOG_FOLDER/$MOUNT.log"
MOUNT_PATH="/mnt/$MOUNT"
fi
### Ensure directories created
if [ ! -d "$CACHE_FOLDER" ]; then
mkdir -p "$CACHE_FOLDER"
fi
if [ ! -d "$CONFIG_FOLDER" ]; then
mkdir -p "$CONFIG_FOLDER"
fi
if [ ! -d "$LOG_FOLDER" ]; then
mkdir -p "$LOG_FOLDER"
fi
if [ ! -d "$MOUNT_PATH" ]; then
mkdir -p "$MOUNT_PATH"
fi
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"