WizardKit/archlive/airootfs/usr/local/bin/mount-backup-shares
Alan Mason d8952ed26f 2017-01: Retroactive Updates
* Disabled gputest
  * The package is failing to install.

* Now using Midori GTK3 build
  * GTK2 was pulled from main repos for security reasons

* Removed warnings about missing UFD
  * For use with live sessions

* Wallpaper updated for live sessions
  * Wallpaper is now set at startup
  * Checks for UFD source but defaults to included file
  * Bugfix: Wallpaper is now set for multiple monitor/workspace setups

* Disabled choose-mirror service

* Better permission handling
  * build-wk now checks if running as root
  * build-wk now sets permissions before calling build.sh
    * Should prevent build failues as build.sh expects files to be owned by root
    * build-wk sets ownership back to builduser.builduser during cleanup

* Better menu for HW-Diags
  * The script now returns to the menu after running a selection
    * Unless the mode was set directly by passing a valid argument
    * NOTE: This allows for easier use in CLI mode

* Add delay before removing /media/wktech

* Adjusted TMP_DIR in build-wk

* Fixed path to custom repo

* Trimming the fat
  * hostname / hosts now configured by customize_airootfs.sh
  * removed files from etc that were at default settings
  * removed grml zsh config since oh-my-zsh/lean is used

* Defined a LOG_DIR for build-wk

* Introducing libinput
  * Switched to libinput over synaptics as it has been deprecated.
    * Should restore touchpad functionality going forward.
* Full mount path SHOULD now be displayed for mount-all-volumes.

* Added CLI Screensavers

* diag-network works now
  * network connection tests now passes all ipv4 private ip ranges
    * 10.0.0.0/8, 172.16.0.0/12, & 192.168.0.0/24
    * need to add ipv6 at some point
  * hw-diag menu flow adjusted

* New hostname and more bugfixes
  * hostname switched to wk-arch
  * ufw package is now installed
  * adjusted upload section of hw-diags

* Added alias for start-wifi

* Booting to CLI mode will autologin wktech
  * When booting to the CLI the motd shows some avail commands
  * Adjusted HW-Diags menu for use in CLI mode
2017-12-06 17:56:10 -08:00

67 lines
1.9 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: WK_ARCH media may be damaged. Please reboot or try another UFD"
else
source "/usr/local/bin/arch.conf" || \
die "ERROR: WK_ARCH media may be damaged. Please reboot or try another UFD"
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