updates
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
alias mount_all='sudo $HOME/.config/fish/scripts/mount.sh'
|
alias mount_all='sudo $HOME/.config/fish/scripts/mount.sh'
|
||||||
|
alias umount_all='sudo $HOME/.config/fish/scripts/umount.sh'
|
||||||
|
|
||||||
################ COMMON ALIASES ################################################
|
################ COMMON ALIASES ################################################
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -27,7 +27,7 @@ if ping -c 1 -W 1 "$HOST" >/dev/null 2>&1; then
|
|||||||
"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
|
||||||
|
|
||||||
if ping -c 1 -W 1 "100.64.0.3" >/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)
|
# Mount Data (from fstab line 2)
|
||||||
mount_cifs "//100.64.0.3/Data" \
|
mount_cifs "//100.64.0.3/Data" \
|
||||||
"/home/honney/mount/Data" \
|
"/home/honney/mount/Data" \
|
||||||
@@ -48,7 +48,7 @@ if ping -c 1 -W 1 "100.64.0.3" >/dev/null 2>&1; then
|
|||||||
"/home/honney/mount/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"
|
||||||
|
|
||||||
elif ping -c 1 -W 1 "192.168.188.122" >/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)
|
# Mount Data (from fstab line 2)
|
||||||
mount_cifs "//192.168.188.122/Data" \
|
mount_cifs "//192.168.188.122/Data" \
|
||||||
"/home/honney/mount/Data" \
|
"/home/honney/mount/Data" \
|
||||||
|
|||||||
+43
-25
@@ -1,35 +1,53 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Source the functions file
|
function is_mounted() {
|
||||||
source "$HOME/.config/function_helper.sh"
|
mountpoint -q "$1"
|
||||||
|
}
|
||||||
|
|
||||||
# Define mount points
|
function unmount() {
|
||||||
MOUNT_POINT_RAID="$HOME/Raid/"
|
if is_mounted "$1"; then
|
||||||
MOUNT_POINT_SSD="$HOME/Server-SSD/"
|
if ! sudo umount -l "$1"; then
|
||||||
|
notify-send -u critical "Unmount failed" "$1"
|
||||||
PASSWORD_FILE="$HOME/.cred/credentials.txt"
|
return 1
|
||||||
PASSWORD=$(<"$PASSWORD_FILE")
|
|
||||||
|
|
||||||
# Unmount RAID
|
|
||||||
if is_mounted "$MOUNT_POINT_RAID"; then
|
|
||||||
if echo "$PASSWORD" | sudo -S umount "$MOUNT_POINT_RAID"; then
|
|
||||||
send_notification "low" "Unmount Successful" "Unmounted $MOUNT_POINT_RAID successfully." "$HOME/.icons/BeautyLine-Garuda/devices/scalable/drive-harddisk-encrypted-symbolic.svg"
|
|
||||||
else
|
else
|
||||||
send_notification "high" "Unmount Failed" "Failed to unmount $MOUNT_POINT_RAID." "$HOME/.icons/BeautyLine-Garuda/devices/scalable/drive-harddisk-symbolic.svg"
|
notify-send -u low "Unmount completed" "$1"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function force_unmount() {
|
||||||
|
if is_mounted "$1"; then
|
||||||
|
if ! sudo umount -fl "$1"; then
|
||||||
|
notify-send -u critical "Unmount failed" "$1"
|
||||||
|
return 1
|
||||||
else
|
else
|
||||||
send_notification "low" "Not Mounted" "$MOUNT_POINT_RAID is not mounted." "$HOME/.icons/BeautyLine-Garuda/devices/scalable/drive-harddisk.svg"
|
notify-send -u low "Unmount completed" "$1"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function has_connection() {
|
||||||
|
if ping -c 1 -W 1 "$1" &>/dev/null; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
mounts=("/home/honney/mount/Data" "/home/honney/mount/Media" "/home/honney/mount/Ripping" "/home/honney/mount/Apps")
|
||||||
|
|
||||||
|
if has_connection "100.64.0.3" || has_connection "192.168.188.122"; then
|
||||||
|
for mount in "${mounts[@]}"; do
|
||||||
|
unmount "$mount"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
for mount in "${mounts[@]}"; do
|
||||||
|
force_unmount "$mount"
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Unmount SSD
|
if has_connection "192.168.1.1"; then
|
||||||
if is_mounted "$MOUNT_POINT_SSD"; then
|
unmount "/home/honney/mount/fritzNAS"
|
||||||
if echo "$PASSWORD" | sudo -S umount "$MOUNT_POINT_SSD"; then
|
|
||||||
send_notification "low" "Unmount Successful" "Unmounted $MOUNT_POINT_SSD successfully." "$HOME/.icons/BeautyLine-Garuda/devices/scalable/drive-harddisk-encrypted-symbolic.svg"
|
|
||||||
else
|
else
|
||||||
send_notification "high" "Unmount Failed" "Failed to unmount $MOUNT_POINT_SSD." "$HOME/.icons/BeautyLine-Garuda/devices/scalable/drive-harddisk-symbolic.svg"
|
force_unmount "/home/honney/mount/fritzNAS"
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
send_notification "low" "Not Mounted" "$MOUNT_POINT_SSD is not mounted." "$HOME/.icons/BeautyLine-Garuda/devices/scalable/drive-harddisk.svg"
|
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user