WizardKit/archlive/airootfs/usr/local/bin/mount-backup-shares
Alan Mason f67cd37a38 2016-08: Retroactive Updates
* Added arch.conf file which is loaded from the UFD
  * Allows configuration without rebuilding the ISO
* Added connect-to-network script that uses arch.conf
  * Available for manual execution from the command line
  * Used by mount-backup-shares
* Added hardinfo with Conky hint and keyboard shortcut (Super+i)
* Avoid deleting a newly created iso right after building
* Conky
  * Settings can now be stored on the UFD
  * Transparancy fixed
* mount-all-volumes doesn't print the mountpoint for ARCH_HH
* NetworkManager should no longer hold up the boot time
* Prime95
  * Adjusted default length due to the summer heat
  * Fixed bug where hw-diags would let it run forever
* Removed extra themes to try and reduce the overall size
* Switching to nodm over lightdm
2017-12-06 17:52:21 -08:00

74 lines
2 KiB
Bash

#!/bin/bash
#
## Mount NAS backup shares
die () {
echo "$0:" "$@" >&2
exit 1
}
# Load settings
if [[ -f "/run/archiso/bootmnt/arch/arch.conf" ]]; then
source "/run/archiso/bootmnt/arch/arch.conf" || \
die "ERROR: ARCH_WK media may be damaged. Please reboot or try another UFD"
else
source "/usr/local/bin/arch.conf" || \
die "ERROR: ARCH_WK media may be damaged. Please reboot or try another UFD"
echo -n "ERROR: Settings file on ARCH_WK media missing. Using build version for now"
sleep 1s
echo -n "."
sleep 1s
echo -n "."
sleep 1s
echo "."
fi
# Connect to a network
connect-to-network
# Mount loop
echo "Mounting NAS backup shares"
for x in {1..4}; do
_skip="False"
# Load Backup share info
eval "declare -a _backup=(\${BACKUP_$x[@]})"
_name="${_backup[0]}"
_ip="${_backup[1]}"
_share="${_backup[2]}"
_user="${_backup[3]}"
_pass="${_backup[4]}"
# Check backup share info
if echo "$_name" | grep -Eq '^\s*$'; then
_skip="True";
fi
if echo "$_ip" | grep -Eq '^\s*$'; then
_skip="True";
fi
if echo "$_share" | grep -Eq '^\s*$'; then
_skip="True";
fi
if echo "$_user" | grep -Eq '^\s*$'; then
_skip="True";
fi
if echo "$_pass" | grep -Eq '^\s*$'; then
_skip="True";
fi
# Mount
if [[ "$_skip" == "False" ]]; then
sudo mkdir "/Backups/$_name" -p
if mountpoint -q "/Backups/$_name"; then
echo "$_name: (Already) mounted at /Backups/$_name ($(df -h "/Backups/$_name" | tail -1 | awk '{print $4}' | sed -r 's/([KMGT])/ \1b/') free)"
else
if sudo mount "//$_ip/$_share" "/Backups/$_name" -o username=$_user,password=$_pass 2>/dev/null; then
echo "$_name: Mounted at /Backups/$_name ($(df -h "/Backups/$_name" | tail -1 | awk '{print $4}' | sed -r 's/([KMGT])/ \1b/') free)"
else
rmdir "/Backups/$_name" -p 2>/dev/null
echo "$_name: Failed to mount"
fi
fi
fi
done