Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3f0b42353 | ||
|
|
318420eba6 |
+43
-37
@@ -20,52 +20,58 @@ mount_cifs() {
|
|||||||
echo "Successfully mounted: $mount_point"
|
echo "Successfully mounted: $mount_point"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function is_mounted() {
|
||||||
|
mountpoint -q "$1"
|
||||||
|
}
|
||||||
|
|
||||||
# Mount FRITZ.NAS (from fstab line 1)
|
# Mount FRITZ.NAS (from fstab line 1)
|
||||||
if ping -c 1 -W 1 "$HOST" >/dev/null 2>&1; then
|
if ! is_mounted "/home/honney/mount/fritzNAS"; then
|
||||||
|
if ping -c 1 -W 1 "192.168.1.1" >/dev/null 2>&1; then
|
||||||
mount_cifs "//192.168.1.1/FRITZ.NAS" \
|
mount_cifs "//192.168.1.1/FRITZ.NAS" \
|
||||||
"/home/honney/mount/fritzNAS" \
|
"/home/honney/mount/fritzNAS" \
|
||||||
"credentials=/home/honney/.cred/samba_credentials,uid=1000,gid=1000,vers=3.0,cache=none,nounix,noserverino,file_mode=0755,dir_mode=0755"
|
"credentials=/home/honney/.cred/samba_credentials,uid=1000,gid=1000,vers=3.0,cache=none,nounix,noserverino,file_mode=0755,dir_mode=0755"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
mount_points=("/home/honney/mount/Data" "/home/honney/mount/Media" "/home/honney/mount/Ripping" "/home/honney/mount/Apps")
|
||||||
|
|
||||||
if ping -c 1 -W 1 "192.168.188.122" >/dev/null 2>&1; then
|
if ping -c 1 -W 1 "192.168.188.122" >/dev/null 2>&1; then
|
||||||
# Mount Data (from fstab line 2)
|
echo "192.168.188.122, mounting shares..."
|
||||||
mount_cifs "//100.64.0.3/Data" \
|
echo ""
|
||||||
"/home/honney/mount/Data" \
|
mounts=("//192.168.188.122/Data" "//192.168.188.122/Media" "//192.168.188.122/Ripping" "//192.168.188.122/Apps")
|
||||||
"credentials=/home/honney/.cred/trueNAS_credentials,vers=3.1.1,iocharset=utf8,rw,uid=1000,gid=1000,nounix,noperm,file_mode=0660,dir_mode=0770,hard,intr,cache=loose"
|
for i in "${!mounts[@]}"; do
|
||||||
|
mount="${mounts[$i]}"
|
||||||
# Mount Media (from fstab line 3)
|
mount_point="${mount_points[$i]}"
|
||||||
mount_cifs "//100.64.0.3/Media" \
|
echo "Checking $mount_point"
|
||||||
"/home/honney/mount/Media" \
|
if ! is_mounted "$mount_point"; then
|
||||||
"credentials=/home/honney/.cred/trueNAS_credentials,vers=3.1.1,iocharset=utf8,rw,uid=1000,gid=1000,nounix,noperm,file_mode=0660,dir_mode=0770,hard,intr,cache=loose"
|
echo "$mount_point unmounted"
|
||||||
|
mount_cifs "$mount" \
|
||||||
# Mount Ripping (from fstab line 4)
|
"$mount_point" \
|
||||||
mount_cifs "//100.64.0.3/Ripping" \
|
|
||||||
"/home/honney/mount/Ripping" \
|
|
||||||
"credentials=/home/honney/.cred/trueNAS_credentials,vers=3.1.1,iocharset=utf8,rw,uid=1000,gid=1000,nounix,noperm,file_mode=0660,dir_mode=0770,hard,intr,cache=loose"
|
|
||||||
|
|
||||||
# Mount Apps (from fstab line 5)
|
|
||||||
mount_cifs "//100.64.0.3/Apps" \
|
|
||||||
"/home/honney/mount/Apps" \
|
|
||||||
"credentials=/home/honney/.cred/trueNAS_credentials,vers=3.1.1,iocharset=utf8,rw,uid=1000,gid=1000,nounix,noperm,file_mode=0660,dir_mode=0770,hard,intr,cache=loose"
|
"credentials=/home/honney/.cred/trueNAS_credentials,vers=3.1.1,iocharset=utf8,rw,uid=1000,gid=1000,nounix,noperm,file_mode=0660,dir_mode=0770,hard,intr,cache=loose"
|
||||||
|
else
|
||||||
|
echo "$mount_point already mounted"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
elif ping -c 1 -W 1 "100.64.0.3" >/dev/null 2>&1; then
|
elif ping -c 1 -W 1 "100.64.0.3" >/dev/null 2>&1; then
|
||||||
# Mount Data (from fstab line 2)
|
echo "192.168.188.122 unreachable"
|
||||||
mount_cifs "//192.168.188.122/Data" \
|
echo "100.64.0.3 reachable, mounting shares..."
|
||||||
"/home/honney/mount/Data" \
|
echo ""
|
||||||
"credentials=/home/honney/.cred/trueNAS_credentials,vers=3.1.1,iocharset=utf8,rw,uid=1000,gid=1000,nounix,noperm,file_mode=0660,dir_mode=0770,hard,intr,cache=loose"
|
mounts=("//100.64.0.3/Data" "//100.64.0.3/Media" "//100.64.0.3/Ripping" "//100.64.0.3/Apps")
|
||||||
|
for i in "${!mounts[@]}"; do
|
||||||
# Mount Media (from fstab line 3)
|
mount="${mounts[$i]}"
|
||||||
mount_cifs "//192.168.188.122/Media" \
|
mount_point="${mount_points[$i]}"
|
||||||
"/home/honney/mount/Media" \
|
echo "Checking $mount_point"
|
||||||
"credentials=/home/honney/.cred/trueNAS_credentials,vers=3.1.1,iocharset=utf8,rw,uid=1000,gid=1000,nounix,noperm,file_mode=0660,dir_mode=0770,hard,intr,cache=loose"
|
if ! is_mounted "$mount_point"; then
|
||||||
|
echo "$mount_point unmounted"
|
||||||
# Mount Ripping (from fstab line 4)
|
mount_cifs "$mount" \
|
||||||
mount_cifs "//192.168.188.122/Ripping" \
|
"$mount_point" \
|
||||||
"/home/honney/mount/Ripping" \
|
|
||||||
"credentials=/home/honney/.cred/trueNAS_credentials,vers=3.1.1,iocharset=utf8,rw,uid=1000,gid=1000,nounix,noperm,file_mode=0660,dir_mode=0770,hard,intr,cache=loose"
|
|
||||||
|
|
||||||
# Mount Apps (from fstab line 5)
|
|
||||||
mount_cifs "//192.168.188.122/Apps" \
|
|
||||||
"/home/honney/mount/Apps" \
|
|
||||||
"credentials=/home/honney/.cred/trueNAS_credentials,vers=3.1.1,iocharset=utf8,rw,uid=1000,gid=1000,nounix,noperm,file_mode=0660,dir_mode=0770,hard,intr,cache=loose"
|
"credentials=/home/honney/.cred/trueNAS_credentials,vers=3.1.1,iocharset=utf8,rw,uid=1000,gid=1000,nounix,noperm,file_mode=0660,dir_mode=0770,hard,intr,cache=loose"
|
||||||
|
else
|
||||||
|
echo "$mount_point already mounted"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|||||||
+4
-4
@@ -7,10 +7,10 @@ function is_mounted() {
|
|||||||
function unmount() {
|
function unmount() {
|
||||||
if is_mounted "$1"; then
|
if is_mounted "$1"; then
|
||||||
if ! sudo umount -l "$1"; then
|
if ! sudo umount -l "$1"; then
|
||||||
notify-send -u critical "Unmount failed" "$1"
|
echo "Unmount failed: $1"
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
notify-send -u low "Unmount completed" "$1"
|
echo "Unmount completed: $1"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -18,10 +18,10 @@ function unmount() {
|
|||||||
function force_unmount() {
|
function force_unmount() {
|
||||||
if is_mounted "$1"; then
|
if is_mounted "$1"; then
|
||||||
if ! sudo umount -fl "$1"; then
|
if ! sudo umount -fl "$1"; then
|
||||||
notify-send -u critical "Unmount failed" "$1"
|
echo "Unmount failed: $1"
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
notify-send -u low "Unmount completed" "$1"
|
echo "Unmount completed: $1"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user