diff --git a/hub/rclone-mount@.service b/hub/rclone-mount@.service index 2b14e9a..19dc0c8 100644 --- a/hub/rclone-mount@.service +++ b/hub/rclone-mount@.service @@ -6,7 +6,7 @@ After=network-online.target Wants=network-online.target [Service] -Type=notify +Type=simple ExecStartPre=/usr/bin/mkdir -p %h/mnt/%i ExecStart=/usr/bin/rclone mount %i: %h/mnt/%i \ --config=%h/.config/rclone/rclone.conf \ @@ -14,10 +14,12 @@ ExecStart=/usr/bin/rclone mount %i: %h/mnt/%i \ --vfs-cache-max-size 256M \ --allow-other \ --log-level INFO \ - --log-file /tmp/rclone-%i.log + --log-file %h/.local/share/rclone-%i.log ExecStop=/bin/fusermount -u %h/mnt/%i Restart=on-failure -RestartSec=5 +RestartSec=10 +StartLimitInterval=60 +StartLimitBurst=3 [Install] WantedBy=default.target diff --git a/hubspoke-helper.sh b/hubspoke-helper.sh index 6edf08d..b3f6778 100755 --- a/hubspoke-helper.sh +++ b/hubspoke-helper.sh @@ -12,7 +12,7 @@ set -euo pipefail TUNNEL_DIR="${TUNNEL_DIR:-$HOME/tinyboard/spoke}" COMPOSE_FILE="${COMPOSE_FILE:-$TUNNEL_DIR/compose.yaml}" RCLONE_REMOTE="${RCLONE_REMOTE:-brie-remote}" -MOUNT_POINT="${MOUNT_POINT:-$HOME/mnt/brie}" +MOUNT_POINT="${MOUNT_POINT:-$HOME/mnt/$RCLONE_REMOTE}" # ------------------------------------------------------------ # Usage @@ -99,10 +99,40 @@ EOF # Hub actions (rclone user service) # ------------------------------------------------------------ hub_install() { - echo "Assuming you have placed rclone-mount@.service in ~/.config/systemd/user/" - echo "Also, 'sudo loginctl enable-linger armbian' and a reboot may be necessary." - echo "If not, create it manually. Then run: systemctl --user daemon-reload" + local SERVICE_DIR="$HOME/.config/systemd/user" + local SERVICE_FILE="$SERVICE_DIR/rclone-mount@.service" + local TEMPLATE_FILE="$(dirname "$0")/hub/rclone-mount@.service" + + echo "Installing rclone mount systemd user service..." + + # Create service directory if it doesn't exist + mkdir -p "$SERVICE_DIR" + + # Check if template exists + if [ ! -f "$TEMPLATE_FILE" ]; then + die "Service template not found at $TEMPLATE_FILE" + fi + + # Copy service template + cp "$TEMPLATE_FILE" "$SERVICE_FILE" + echo "Copied service template to $SERVICE_FILE" + + # Check if user linger is enabled + if ! systemctl --user is-enabled --quiet user@$(id -u).service 2>/dev/null; then + echo "WARNING: User linger may not be enabled. Run: sudo loginctl enable-linger $USER" + echo "You may need to reboot for user services to start automatically." + fi + + # Reload systemd systemctl --user daemon-reload + echo "Systemd user daemon reloaded." + + echo "" + echo "Next steps:" + echo "1. Ensure /etc/fuse.conf has 'user_allow_other' uncommented" + echo "2. Ensure you're in the 'fuse' group: sudo usermod -aG fuse $USER" + echo "3. Start the service: $0 hub start" + echo "4. Enable auto-start: systemctl --user enable rclone-mount@${RCLONE_REMOTE}.service" } hub_start() {