Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Windowsの共有フォルダをマウントする。
#!/bin/sh
WINDOWS_SHARE='//192.168.XXX.XXX/share'
SHARE_USER='user'
SHARE_PASS='pass'
MOUNT_POINT='/mnt/windows_share'
MOUNT_TEST_FILE="${MOUNT_POINT}/mount_test.txt"
TEST_LOCAL_USER='shizm'
/usr/bin/sudo -u $TEST_LOCAL_USER /bin/touch $MOUNT_TEST_FILE > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo "${WINDOWS_SHARE} is not mounted."
echo "try mount ..."
/bin/mount -t cifs -o user=$SHARE_USER,password=$SHARE_PASS $WINDOWS_SHARE $MOUNT_POINT
if [ $? -ne 0 ]
then
echo "mount ${WINDOWS_SHARE} faield!" >&2
else
echo "mount ${WINDOWS_SHARE} succeeded."
fi
else
echo "${WINDOWS_SHARE} is already mounted."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment