Merge pull request #25 from basvandewiel/21-re-introduce-ini-file-management
21 re introduce ini file management
This commit is contained in:
commit
72ae6c250b
24
nfs_mount.sh
24
nfs_mount.sh
|
@ -76,6 +76,16 @@ function run_once() {
|
|||
}
|
||||
|
||||
|
||||
# Load script configuration from an INI file.
|
||||
# ..which isn't really an INI file but just a list of Bash vars
|
||||
function load_ini() {
|
||||
local SCRIPT_PATH="$(realpath "$0")"
|
||||
local INI_FILE=${SCRIPT_PATH%.*}.ini
|
||||
if [ -e "$INI_FILE" ]; then
|
||||
eval "$(cat $INI_FILE | tr -d '\r')"
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if we have an IPv4 address on any of the interfaces that is
|
||||
# not a local loopback (127.0.0.0/8) or link-local (169.254.0.0/16) adddress.
|
||||
|
||||
|
@ -186,7 +196,6 @@ function install_mount_at_boot() {
|
|||
|
||||
# NET_UP_SCRIPT is finished so we make it executable
|
||||
chmod 755 "${NET_UP_SCRIPT}"
|
||||
echo "Installed $NET_UP_SCRIPT."
|
||||
|
||||
echo -e "#!/bin/bash"$'\n'"umount -a -t nfs4" > "${NET_DOWN_SCRIPT}"
|
||||
chmod 755 "${NET_DOWN_SCRIPT}"
|
||||
|
@ -226,13 +235,6 @@ function remove_mount_at_boot() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Remount the root filesystem if it's currently mounted read-only
|
||||
|
||||
function remount_rootfs() {
|
||||
mount | grep "on / .*[(,]ro[,$]" -q && RO_ROOT="yes"
|
||||
[ "${RO_ROOT}" == "yes" ] && mount / -o remount,rw
|
||||
}
|
||||
|
||||
#=========BUSINESS LOGIC================================
|
||||
#
|
||||
# This part just calls the functions we define above
|
||||
|
@ -250,6 +252,9 @@ as_root
|
|||
# ..and that the script shall run only once per session.
|
||||
run_once
|
||||
|
||||
# Load configuration from the .ini file if we have one.
|
||||
load_ini
|
||||
|
||||
# Only cause changes if the configuration is viable.
|
||||
viable_config
|
||||
|
||||
|
@ -259,9 +264,6 @@ wake_up_nfs
|
|||
# ..and give it time to actually get dressed.
|
||||
wait_for_nfs
|
||||
|
||||
# Ensure the root filesystem is writable
|
||||
remount_rootfs
|
||||
|
||||
# Install/update the scripts to run at every reboot
|
||||
install_mount_at_boot
|
||||
|
||||
|
|
Loading…
Reference in New Issue