nfs: add cluster-shared-nfs replacement in ensure_nfs
Some checks are pending
continuous-integration/laminar-eldarion Build failed with exit code 123 after 2 seconds
Some checks are pending
continuous-integration/laminar-eldarion Build failed with exit code 123 after 2 seconds
This commit is contained in:
parent
612dbf96b7
commit
6a3f5612f4
1 changed files with 31 additions and 2 deletions
|
@ -1,10 +1,37 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# $1 The path to ensure is mounted after a network interface comes up.
|
||||
ensure_nfs() {
|
||||
local dirpath="${1}";
|
||||
local target_script="/etc/network/if-up.d/ensure-nfs";
|
||||
#/etc/network/if-up.d/
|
||||
|
||||
task_begin "ensure_nfs: registering ${dirpath}";
|
||||
# 1: Ensure the target script exists
|
||||
if [[ ! -d "$(dirname "${target_script}")" ]]; then
|
||||
mkdir -p "$(dirname "${target_script}")";
|
||||
fi
|
||||
if [[ ! -r "${target_script}" ]]; then
|
||||
echo "#!/usr/bin/env bash" >>"${target_script}";
|
||||
chmod +x "${target_script}";
|
||||
fi
|
||||
|
||||
if grep -q "${dirpath}; then" "${target_script}"; then
|
||||
echo "ensure_nfs: ${dirpath} is already registered.";
|
||||
task_end 0;
|
||||
return 0;
|
||||
fi
|
||||
|
||||
echo "if ! mountpoint -q '${dirpath}'; then mount '${dirpath}'; fi" >>"${target_script}";
|
||||
|
||||
task_end "$?" "ensure_nfs: error registering ${dirpath} in ${target_script}";
|
||||
}
|
||||
|
||||
# $1 Thing to mount
|
||||
# $2 Path to mount it to
|
||||
add_nfs_mount() {
|
||||
source="${1}";
|
||||
target="${2}";
|
||||
local source="${1}";
|
||||
local target="${2}";
|
||||
|
||||
task_begin "NFS mount ${source} → ${target}";
|
||||
# 1: Remove any old entries from /etc/fstab
|
||||
|
@ -18,6 +45,8 @@ add_nfs_mount() {
|
|||
mount "${target}";
|
||||
|
||||
task_end "$?";
|
||||
|
||||
ensure_nfs "${target}";
|
||||
}
|
||||
|
||||
add_nfs_mount "magicbag.node.mooncarrot.space:/mnt/elfstone2/cluster" "/mnt/shared";
|
||||
|
|
Loading…
Reference in a new issue