Created
July 7, 2014 19:39
-
-
Save nickrobinson/9c6adec65dc6c6cc5923 to your computer and use it in GitHub Desktop.
mount_vm_old_web.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
CODE_SUCCESS=0 | |
CODE_FAILURE=10 | |
CODE_FAILURE_ARG=11 | |
RETVAL=${CODE_FAILURE_ARG} | |
VM= | |
if [ $# -eq 1 ] && [ -n "$1" ]; then | |
VM="$1" | |
RETVAL=${CODE_SUCCESS} | |
fi | |
if [ ${RETVAL} -eq ${CODE_SUCCESS} ]; then | |
SCRIPT_PATH=`dirname "$0" 2>/dev/null` | |
if [ -z "${SCRIPT_PATH}" ]; then | |
SCRIPT_PATH='.' | |
fi | |
RETVAL=${CODE_FAILURE} | |
if [ -f "${SCRIPT_PATH}/unmount_vm_old_web.sh" ]; then | |
"${SCRIPT_PATH}/unmount_vm_old_web.sh" &>/dev/null | |
if [ $? -eq 0 ]; then | |
RETVAL=${CODE_SUCCESS} | |
fi | |
fi | |
if [ ${RETVAL} -eq ${CODE_SUCCESS} ]; then | |
RETVAL=${CODE_FAILURE} | |
if [ -f "/media/mmcblk0p1/bin/mount.nfs" ]; then | |
echo -n "virtual machine [${VM}] status: " | |
PKT_COUNT=`/bin/ping -c 2 "${VM}" 2>/dev/null | /bin/grep 'received' 2>/dev/null | /usr/bin/cut -d ',' -f2 2>/dev/null | /usr/bin/cut -d ' ' -f2 2>/dev/null` | |
if [ -n "${PKT_COUNT}" ] && [ "${PKT_COUNT}" != '0' ]; then | |
echo "available" | |
/bin/mkdir -p /flash/nonvol/main &>/dev/null | |
/media/mmcblk0p1/bin/mount.nfs "${VM}:/data/nrobinso.lnx.dev/aos/dev/uca/ambassador-R6/source/NEWeb/NEWebImpl/content/main" /flash/nonvol/main -v -o 'nfsvers=3,nolock' &>/dev/null | |
if [ $? -eq 0 ]; then | |
/bin/ip netns exec "vrf0" apachectl stop &>/dev/null | |
sleep 3 | |
/bin/ip netns exec "vrf0" apachectl start &>/dev/null | |
RETVAL=${CODE_SUCCESS} | |
else | |
echo "failed to mount virtual machine [${VM}] directories" >&2 | |
fi | |
else | |
echo "unavailable" | |
echo "virtual machine [${VM}] not available" >&2 | |
fi | |
else | |
echo '/media/mmcblk0p1/bin/mount.nfs not found' >&2 | |
fi | |
else | |
echo "${SCRIPT_PATH}/unmount_vm_old_web.sh failed" | |
fi | |
if [ $RETVAL -eq ${CODE_SUCCESS} ]; then | |
echo "mounted virtual machine [${VM}] directories" | |
fi | |
else | |
echo 'invalid arguments' >&2 | |
fi | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment