[v3,08/17] scripts: spfs-change-mode.sh added

Submitted by Stanislav Kinsburskiy on May 19, 2016, 10:57 a.m.

Details

Message ID 20160519105756.15506.30435.stgit@skinsbursky-vz7-gold.qa.sw.ru
State Rejected
Series "NFS migration support"
Headers show

Commit Message

Stanislav Kinsburskiy May 19, 2016, 10:57 a.m.
This scripts can be used on restore to switch all the spfs mounts to Stub mode
when all files have been reopened.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 scripts/spfs-change-mode.sh |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100755 scripts/spfs-change-mode.sh

Patch hide | download patch | download mbox

diff --git a/scripts/spfs-change-mode.sh b/scripts/spfs-change-mode.sh
new file mode 100755
index 0000000..0b91669
--- /dev/null
+++ b/scripts/spfs-change-mode.sh
@@ -0,0 +1,32 @@ 
+#!/bin/bash
+
+[[ "post-restore" == "$CRTOOLS_SCRIPT_ACTION" ]] || exit 0
+
+set -o pipefail
+
+if [ -z "$SPFS_MANAGER_SOCK" ]; then
+	echo "SPFS_MANAGER_SOCK environment variable is not set"
+	exit 1
+fi
+
+if [ -z "$SPFS_MODE" ]; then
+	echo "SPFS_MODE environment variable is not set"
+	exit 1
+fi
+
+[ -e $SPFS_MANAGER_SOCK ] || exit 0
+
+if [ ! -S "$SPFS_MANAGER_SOCK" ]; then
+	echo "$SPFS_MANAGER_SOCK is not a socket"
+	exit 1
+fi
+
+SPFS_CLIENT="/usr/sbin/spfs-client"
+
+if [ ! -x "$SPFS_CLIENT" ]; then
+	echo "Filed to find executable /usr/sbin/spfs-client"
+	exit 1
+fi
+
+$SPFS_CLIENT manage "mode;all;mode=$SPFS_MODE" --socket-path $SPFS_MANAGER_SOCK > /dev/null
+exit $?