diff --git a/rclone/.config/systemd/user/rclone_ftp_mount.service b/rclone/.config/systemd/user/rclone_ftp_mount.service new file mode 100644 index 0000000..0b6ea9a --- /dev/null +++ b/rclone/.config/systemd/user/rclone_ftp_mount.service @@ -0,0 +1,16 @@ +[Unit] +Description=Mount Rclone FTP +After=network-online.target network.target +Wants=network-online.target + +[Service] +Type=simple +# Use Environment to explicitly set $HOME +Environment=HOME=%h +ExecStartPre=%h/.local/bin/rclone_mount_check.sh +ExecStart=/usr/bin/rclone mount tdnde_ftp: %h/mnt/tdnde_server --vfs-cache-mode full --vfs-cache-max-size 1G --ftp-concurrency 20 --timeout 60s --contimeout 30s --dir-cache-time 1h +ExecStop=/bin/fusermount -u %h/mnt/tdnde_server +Restart=on-failure + +[Install] +WantedBy=default.target diff --git a/rclone/.local/bin/rclone_mount_check.sh b/rclone/.local/bin/rclone_mount_check.sh new file mode 100755 index 0000000..68a5eea --- /dev/null +++ b/rclone/.local/bin/rclone_mount_check.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Define the network name (SSID) of your work network +WORK_SSID="BELL577" # Replace with your actual work network name + +# Get the current SSID (Wi-Fi network name) +# CURRENT_SSID=$(iwgetid -r) # If using iwgetid for Wi-Fi; you can also use nmcli for more flexibility + +# Alternatively, use nmcli to get the SSID +CURRENT_SSID=$(nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -d: -f2) + +# Check if the current SSID matches the work network +if [ "$CURRENT_SSID" == "$WORK_SSID" ]; then + exit 0 +else + echo "Not on the correct network (SSID: $CURRENT_SSID), skipping mount." + exit 1 +fi diff --git a/scripts/make_all.sh b/scripts/make_all.sh new file mode 100755 index 0000000..d0f8c4e --- /dev/null +++ b/scripts/make_all.sh @@ -0,0 +1,8 @@ +#!/bin/bash +cd ~/ExoKortex/2-Areas/IT/config +make all +if [ $? -eq 0 ]; then + notify-send "Dotfiles" "Configuration reloaded successfully!" +else + notify-send "Dotfiles" "Failed to reload configuration!" +fi diff --git a/scripts/rclone_post_install.sh b/scripts/rclone_post_install.sh new file mode 100644 index 0000000..36ad552 --- /dev/null +++ b/scripts/rclone_post_install.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Define paths +CHECK_SCRIPT="$HOME/.local/bin/rclone_mount_check.sh" +SERVICE_FILE="$HOME/.config/systemd/user/rclone_ftp_mount.service" + +# Ensure the check script is executable +if [ -f "$CHECK_SCRIPT" ] && [ ! -x "$CHECK_SCRIPT" ]; then + echo "Making the check script executable: $CHECK_SCRIPT" + chmod +x "$CHECK_SCRIPT" || { echo "Failed to make the script executable"; exit 1; } +else + echo "Check script already executable or doesn't exist." +fi + +# Reload user systemd to recognize the new unit +systemctl --user daemon-reload + +# Enable the service if not already enabled +if [ -f "$SERVICE_FILE" ]; then + if ! systemctl --user is-enabled --quiet rclone_ftp_mount.service; then + echo "Enabling the rclone service." + systemctl --user enable rclone_ftp_mount.service || { echo "Failed to enable the service"; exit 1; } + else + echo "Service already enabled." + fi +else + echo "Service file does not exist at $SERVICE_FILE." + exit 1 +fi + +# Start the service if not already running +if systemctl --user is-active --quiet rclone_ftp_mount.service; then + echo "Rclone service is already running." +else + echo "Starting the rclone service." + systemctl start rclone_ftp_mount.service || { echo "Failed to start the service"; exit 1; } +fi + +echo "Post-installation steps for rclone completed successfully."