diff options
author | Simon Rettberg | 2017-04-03 14:35:46 +0200 |
---|---|---|
committer | Simon Rettberg | 2017-04-03 14:35:46 +0200 |
commit | 55c67b2fc34e983861b7305e992bcd3cb54e63da (patch) | |
tree | bf2453ec6fb51e2eb3700dd8ea093f7d94d39dd7 | |
parent | [LighttpdHttps] Support setting HTTPS redirection (diff) | |
download | tmlite-bwlp-55c67b2fc34e983861b7305e992bcd3cb54e63da.tar.gz tmlite-bwlp-55c67b2fc34e983861b7305e992bcd3cb54e63da.tar.xz tmlite-bwlp-55c67b2fc34e983861b7305e992bcd3cb54e63da.zip |
[scripts/mount-store] Try more CIFS options, remember last working options
-rwxr-xr-x | scripts/mount-store | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/scripts/mount-store b/scripts/mount-store index e0ce839..715a8a4 100755 --- a/scripts/mount-store +++ b/scripts/mount-store @@ -6,6 +6,9 @@ if [ $# -lt 2 ]; then exit 1 fi +declare -rg CIFS_OPTS="/opt/openslx/cifs.opts" +declare -rg NFS_OPTS="/opt/openslx/nfs.opts" + WHAT="$1" SOURCE="$2" USERNAME="$3" @@ -130,17 +133,44 @@ elif grep -E -q '^//' <<<$SOURCE; then # seems to be SMB export USER="$USERNAME" export PASSWD="$PASSWORD" - for sec in ntlmv2 ntlm; do - echo " * Trying ${sec}..." - mount -v -t cifs -o rw,uid=0,gid=12345,forceuid,forcegid,nounix,file_mode=0664,dir_mode=0775,sec=$sec "$SOURCE" "$DEST" - RET=$? - [ "$RET" -ne "0" ] && continue - echo "Mount succeeded, checking write permissions...." - storage_test - RET=$? - [ "$RET" -eq "0" ] && break - umount -v "$DEST" || umount -v -f -l "$DEST" - done + RET=999 + OPTSTR= + if [ -f "$CIFS_OPTS" ]; then + OPTSTR=$(cat "$CIFS_OPTS") + fi + if [ -n "$OPTSTR" ]; then + echo " * Trying last successful mount options..." + if mount -v -t cifs -o "$OPTSTR" "$SOURCE" "$DEST"; then + echo "Mount succeeded, checking write permissions...." + storage_test + RET=$? + if [ "$RET" -ne "0" ]; then + umount -v "$DEST" || umount -v -f -l "$DEST" + fi + fi + fi + if [ "$RET" -ne "0" ]; then + for vers in "" "3.0" "2.1" "1.0" "2.0"; do + [ -n "$vers" ] && vers=",vers=${vers}" + for sec in "" "ntlmssp" "ntlmv2" "ntlm"; do + [ -n "$sec" ] && sec=",sec=${sec}" + echo " * Trying ...${vers}${sec}..." + OPTSTR="rw,uid=0,gid=12345,forceuid,forcegid,nounix,file_mode=0664,dir_mode=0775$vers$sec" + mount -v -t cifs -o "$OPTSTR" "$SOURCE" "$DEST" + RET=$? + [ "$RET" -ne "0" ] && continue + echo "Mount succeeded, checking write permissions...." + storage_test + RET=$? + [ "$RET" -eq "0" ] && break + umount -v "$DEST" || umount -v -f -l "$DEST" + done + [ "$RET" -eq "0" ] && break + done + if [ "$RET" -eq "0" ] && [ -n "$OPTSTR" ]; then + echo "$OPTSTR" > "$CIFS_OPTS" + fi + fi unset USER PASSWD else echo "Unknown mount type: $SOURCE" |