summaryrefslogtreecommitdiffstats
path: root/scripts/mount-store
diff options
context:
space:
mode:
authorSimon Rettberg2015-09-05 20:48:22 +0200
committerSimon Rettberg2015-09-05 20:48:22 +0200
commit8edc84bb2fd77c40b4e47fc64d1c6045b6b4aa5f (patch)
tree0763b3f42876f207cea5aeb741cb063578f7d5f7 /scripts/mount-store
parent[tmlite-bwlp] mount-store script: corr. var $RANDOM (diff)
downloadtmlite-bwlp-8edc84bb2fd77c40b4e47fc64d1c6045b6b4aa5f.tar.gz
tmlite-bwlp-8edc84bb2fd77c40b4e47fc64d1c6045b6b4aa5f.tar.xz
tmlite-bwlp-8edc84bb2fd77c40b4e47fc64d1c6045b6b4aa5f.zip
Refine mount script, updater backup/restore to handle new dozmod db
Diffstat (limited to 'scripts/mount-store')
-rwxr-xr-xscripts/mount-store34
1 files changed, 27 insertions, 7 deletions
diff --git a/scripts/mount-store b/scripts/mount-store
index 51080fa..cd777a8 100755
--- a/scripts/mount-store
+++ b/scripts/mount-store
@@ -23,6 +23,9 @@ images)
;;
esac
+FLAG="${DEST}/.notmounted"
+SUBDIR="${DEST}/bwlehrpool_store"
+
# Sanity checks: Destination exists?
if [ ! -d "$DEST" ]; then
mkdir -p "$DEST"
@@ -44,24 +47,26 @@ if awk '{print $2}' "/proc/mounts" | grep -q "^${DEST}\$"; then
RET=$?
if [ "$RET" -ne "0" ]; then
echo "Cannot unmount '$DEST'!" >&2
+ echo "Storage might be in use (running VM upload etc.)" >&2
+ echo "Try stopping DMSD first" >&2
exit "$RET"
fi
fi
# Unmount and not requested to mount (local mode)
if [[ "${SOURCE}" == "null" ]]; then
- rm -f "${DEST}/.notmounted"
+ rm -f "${FLAG}"
exit 0
fi
-touch "${DEST}/.notmounted"
+touch "${FLAG}"
# Mount!
if grep -E -q '^[^/].+:.+' <<<$SOURCE; then
# seems to be NFS
- for i in 1 2 3; do
- mount -v -t nfs -o rw,async,nolock,vers=3,fg,ac,retry=1,timeo=100,sec=sys "$SOURCE" "$DEST"
+ for opt in vers=4 vers=3; do
+ mount -v -t nfs -o rw,noatime,noexec,nodev,async,nolock,$opt,fg,ac,retry=1,timeo=150,sec=sys "$SOURCE" "$DEST"
RET=$?
[ "$RET" -eq "0" ] && break
done
@@ -84,10 +89,25 @@ else
exit 1
fi
+echo "----------------------------------"
+
if [ "$RET" == "0" ]; then
- chgrp -R images "$DEST" 2>/dev/null
- chmod -R ug+rwX "$DEST" 2>/dev/null
- TEST="$DEST/.test-$RANDOM-$RANDOM"
+ rm -f "${FLAG}"
+ if [ -e "${FLAG}" ]; then
+ echo "Error: File '.notmounted' exists on remote storage. Delete first!" >&2
+ umount -v "$DEST"
+ exit 5
+ fi
+ chgrp images "${DEST}" 2>/dev/null
+ mkdir -p "${SUBDIR}"
+ if [ ! -d "${SUBDIR}" ]; then
+ echo "Error: Could not create $(basename "$SUBDIR")! Storage not writable!" >&2
+ umount -v "$DEST"
+ exit 6
+ fi
+ chgrp -R images "${SUBDIR}" 2>/dev/null &
+ chmod -R ug+rwX "${SUBDIR}" 2>/dev/null &
+ TEST="${SUBDIR}/.deleteme-$RANDOM-$RANDOM"
sudo -n -u dmsd touch "$TEST"
RET=$?
if [ -e "$TEST" ]; then