You are not logged in.
Pages: 1
Hello,
I found this very usefull script /usr/local/bin/auto_share here in the Arch Wiki: https://wiki.archlinux.org/title/NFS#Au … t_handling
#!/bin/bash
function net_umount {
umount -l -f $1 &>/dev/null
}
function net_mount {
mountpoint -q $1 || mount $1
}
NET_MOUNTS=$(sed -e '/^.*#/d' -e '/^.*:/!d' -e 's/\t/ /g' /etc/fstab | tr -s " ")$'\n'b
printf %s "$NET_MOUNTS" | while IFS= read -r line
do
SERVER=$(echo $line | cut -f1 -d":")
MOUNT_POINT=$(echo $line | cut -f2 -d" ")
# Check if server already tested
if [[ "${server_ok[@]}" =~ "${SERVER}" ]]; then
# The server is up, make sure the share are mounted
net_mount $MOUNT_POINT
elif [[ "${server_notok[@]}" =~ "${SERVER}" ]]; then
# The server could not be reached, unmount the share
net_umount $MOUNT_POINT
else
# Check if the server is reachable
ping -c 1 "${SERVER}" &>/dev/null
if [ $? -ne 0 ]; then
server_notok[${#server_notok[@]}]=$SERVER
# The server could not be reached, unmount the share
net_umount $MOUNT_POINT
else
server_ok[${#server_ok[@]}]=$SERVER
# The server is up, make sure the share are mounted
net_mount $MOUNT_POINT
fi
fi
done
I am not the 'sed' guy, so I ask for help in extending this script to handle also CIFS and davfs shares. I have a fstab file like this with additional shares in it I want to automount at bootup:
//disk.lan.domain.com/media /mnt/disk/media cifs username=user1,password=password1,user,uid=1000,gid=1000,rw,x-systemd.device-timeout=8,x-systemd.idle-timeout=1min 0 0
https://file.webtux.de/seafdav /mnt/seafile davfs user,rw,auto 0 0
It would be very nice if someone could give me a solution howto do this.
Thank you!
Offline
Moved to Installation
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
Pages: 1