setup google drive and dropbox as automounts on linux

 #!/bin/bash
set -e
# mount points
mkdir -p "$HOME/DropboxMount"
mkdir -p "$HOME/GDriveMount"
# ensure systemd user dir exists
mkdir -p "$HOME/.config/systemd/user"
# Dropbox service
cat > "$HOME/.config/systemd/user/rclone-dropbox.service" <<'EOF'
[Unit]
Description=Mount Dropbox via rclone
After=network-online.target
[Service]
Type=simple
ExecStartPre=/bin/mkdir -p %h/DropboxMount
ExecStart=/usr/bin/rclone mount dropbox: %h/DropboxMount --vfs-cache-mode writes
ExecStop=/bin/fusermount -u %h/DropboxMount
Restart=on-failure
[Install]
WantedBy=default.target
EOF
# Google Drive service
cat > "$HOME/.config/systemd/user/rclone-gdrive.service" <<'EOF'
[Unit]
Description=Mount Google Drive via rclone
After=network-online.target
[Service]
Type=simple
ExecStartPre=/bin/mkdir -p %h/GDriveMount
ExecStart=/usr/bin/rclone mount gdrive: %h/GDriveMount --vfs-cache-mode writes
ExecStop=/bin/fusermount -u %h/GDriveMount
Restart=on-failure
[Install]
WantedBy=default.target
EOF
# reload and enable
systemctl --user daemon-reload
systemctl --user enable rclone-dropbox.service
systemctl --user enable rclone-gdrive.service
# start now
systemctl --user start rclone-dropbox.service
systemctl --user start rclone-gdrive.service
x

Popular posts from this blog

Automatically Fix Song Metadata and Filenames on Linux with Beets

DropboxMount turns your Dropbox into a live, on-demand drive instead of a sync folder.

script to show all files with disk usage sizes