You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
590 B
Bash

#!/bin/bash
ssh_path=$1 # like kuba@192.168.1.90:/mnt/hdd
mount_path=$2 # like /var/mnt/hdd
service_name=$(echo "$mount_path" | sed 's/\//-/g');
service_name="${service_name:1}"
echo $service_name;
exit
sudo tee "/etc/systemd/system/${service_name}.mount" <<EOF
[Unit]
Description=SSHFS Mount for $ssh_path
After=network-online.target
Wants=network-online.target
[Mount]
What=$ssh_path
Where=$mount_path
Type=fuse.sshfs
Options=IdentityFile=/root/.ssh/id_ed25519,allow_other,reconnect,ServerAliveInterval=15,ServerAliveCountMax=3
TimeoutSec=30
[Install]
WantedBy=multi-user.target
EOF