Last active
July 13, 2026 14:26
-
-
Save wett1988/cdb9841e35c5c2321fab9746a0c2400e to your computer and use it in GitHub Desktop.
Bash script that checks if a specific rclone remote is mounted. If it is not mounted, it mounts the drive; if it is already mounted, it unmounts the drive.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # --- Configuration --- | |
| # Replace 'MyRemote:' with your rclone remote name | |
| REMOTE="MyRemote:" | |
| # Replace '/mnt/remote' with your desired local mount point | |
| MOUNT_POINT="/mnt/remote" | |
| # --- Logic --- | |
| # Check if the mount point is currently mounted | |
| if mount | grep -q "$REMOTE"; then | |
| echo "Drive is already mounted at $MOUNT_POINT. Unmounting..." | |
| if fusermount -uz $MOUNT_POINT; then | |
| notify-send "Rclone" "Unmounted $REMOTE successfully" -i dialogue-information | |
| echo "Unmount successful." | |
| else | |
| notify-send "Rclone" "Unmount failed for $REMOTE" -i dialogue-error | |
| echo "Unmount failed." | |
| fi | |
| else | |
| echo "Drive is not mounted. Mounting $REMOTE to $MOUNT_POINT..." | |
| # Mount in daemon mode | |
| if rclone mount $REMOTE $MOUNT_POINT --vfs-cache-mode full --daemon; then | |
| notify-send "Rclone" "Mounted $REMOTE successfully" -i dialogue-information | |
| echo "Mount successful." | |
| else | |
| notify-send "Rclone" "Mount failed for $REMOTE" -i dialogue-error | |
| echo "Mount failed." | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment