1
0
forked from finn/tinyboard

no user systemd it's stupid

This commit is contained in:
2026-04-13 14:04:48 -07:00
parent 85df138d10
commit 56dff3f22b
2 changed files with 60 additions and 68 deletions

View File

@@ -1,25 +0,0 @@
#~/.config/systemd/user/rclone-mount@.service
[Unit]
Description=Rclone mount of %i
After=network-online.target
Wants=network-online.target
[Service]
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 \
--vfs-cache-mode writes \
--vfs-cache-max-size 256M \
--allow-other \
--log-level INFO \
--log-file %h/.local/share/rclone-%i.log
ExecStop=/bin/fusermount -u %h/mnt/%i
Restart=on-failure
RestartSec=10
StartLimitInterval=60
StartLimitBurst=3
[Install]
WantedBy=default.target

View File

@@ -2,7 +2,7 @@
#
# hubspoke-helper.sh - Manage hub/spoke rclone mounts
# Assumes spoke Docker files exist in ~/autossh-tunnel/
# Assumes hub rclone service template is manually placed (or not needed)
# Simplified hub mount uses direct rclone commands (no systemd services)
set -euo pipefail
@@ -30,11 +30,11 @@ SPOKE ACTIONS (docker-based, no systemd):
logs Show container logs
show-cmd Show manual autossh command (non-docker)
HUB ACTIONS (systemd user service for rclone mount):
install Install the rclone user service (needs service file)
start Start the rclone mount service
stop Stop the rclone mount service
status Show service status
HUB ACTIONS (simplified rclone mount - no systemd):
install Show simplified setup instructions
start Start rclone mount in background
stop Stop rclone mount
status Check mount status
mount Manual foreground mount (testing)
unmount Unmount manually
@@ -96,55 +96,72 @@ EOF
}
# ------------------------------------------------------------
# Hub actions (rclone user service)
# Hub actions (simplified - no systemd templates)
# ------------------------------------------------------------
hub_install() {
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 "Simplified hub setup:"
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"
echo "1. Ensure /etc/fuse.conf has 'user_allow_other' uncommented:"
echo " sudo sed -i 's/^#user_allow_other/user_allow_other/' /etc/fuse.conf"
echo ""
echo "2. Ensure you're in the 'fuse' group:"
echo " sudo usermod -aG fuse $USER"
echo " (You may need to log out and back in for this to take effect)"
echo ""
echo "3. Create mount point directory:"
echo " mkdir -p \"$MOUNT_POINT\""
echo ""
echo "4. Test manual mount:"
echo " $0 hub mount"
echo ""
echo "5. For auto-start, consider adding to crontab with @reboot:"
echo " crontab -e"
echo " Add: @reboot $0 hub start-background"
echo ""
echo "Note: This simplified version doesn't use systemd services."
}
hub_start() {
systemctl --user start "rclone-mount@${RCLONE_REMOTE}.service"
echo "Starting rclone mount in background..."
mkdir -p "$MOUNT_POINT"
nohup rclone mount "${RCLONE_REMOTE}:" "$MOUNT_POINT" \
--config "${HOME}/.config/rclone/rclone.conf" \
--vfs-cache-mode writes \
--allow-other \
--daemon >/dev/null 2>&1 &
echo "Mount started in background (PID: $!)"
echo "Check status with: $0 hub status"
}
hub_start_background() {
# Internal function for crontab/auto-start
mkdir -p "$MOUNT_POINT"
rclone mount "${RCLONE_REMOTE}:" "$MOUNT_POINT" \
--config "${HOME}/.config/rclone/rclone.conf" \
--vfs-cache-mode writes \
--allow-other \
--daemon
}
hub_stop() {
systemctl --user stop "rclone-mount@${RCLONE_REMOTE}.service"
echo "Stopping rclone mount..."
if hub_unmount; then
echo "Mount stopped."
else
echo "Could not unmount. Trying force unmount..."
fusermount -uz "$MOUNT_POINT" 2>/dev/null && echo "Force unmounted." || echo "Still could not unmount."
fi
}
hub_status() {
systemctl --user status "rclone-mount@${RCLONE_REMOTE}.service" --no-pager
if mountpoint -q "$MOUNT_POINT" 2>/dev/null; then
echo "Mount point $MOUNT_POINT is mounted."
mount | grep "$MOUNT_POINT"
else
echo "Mount point $MOUNT_POINT is NOT mounted."
echo "Check if rclone process is running:"
pgrep -af rclone || echo "No rclone mount processes found."
fi
}
hub_mount() {