WizardKit/archlive/airootfs/usr/local/bin/mount-backup-shares
Alan Mason 3bf0f54b1a 2016-09: Retroactive Updates
* Display Manager
  * nodm removed due to a dbus issue
    * Hopefully if Xorg can’t be run it will default to CLI
  * XFCE is now started by .zlogin
    * Removed the "Save Session" checkbox

* Networking
  * Replaced NetworkManager with systemd-networkd
    * networkd had a 33% faster boot time than NetworkManager (-10s)
    * It also more directly prioritizes wired connections
    * NOTES: This removed the ability to easily connect to new networks
      * This is okay as the WiFi changes very infrequently
      * The WiFi settings are loaded from the UFD directly
  * Added linux-firmware to support more network devices
  * broadcom-wl wouldn't compile under i686 so it's x64 only ATM
  * Removed the udev rule forcing the dhcp delay during boot
  * Server IPs updated

* Config files and wallpapers moved to <UFD>/config

* Fixed an issue where SMART was misreporting drives as bad
  * When a drive failed SMART, subsequent drives would always report "NS"
2017-12-06 17:53:59 -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/config/arch.conf" ]]; then
source "/run/archiso/bootmnt/config/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