Kod: Markera allt
#! /bin/bash
#
if [[ -z $1 ]]; then
SMBCONF="/etc/samba/smb.conf"
else
SMBCONF="$1"
fi
#
MODIFIED=false
if [[ -z $(grep "server signing" $SMBCONF) ]]; then
MODIFIED=true
#server signing = auto
vim -c ':set shortmess=a' -c ':set cmdheight=2' -c ':set noignorecase' -c '/workgroup =' -c 'call append(line("."), " server signing = auto")' -c 'wq!' $SMBCONF
fi
if [[ -z $(grep "client signing" $SMBCONF) ]]; then
MODIFIED=true
#client signing = auto
vim -c ':set shortmess=a' -c ':set cmdheight=2' -c ':set noignorecase' -c '/workgroup =' -c 'call append(line("."), " client signing = auto")' -c 'wq!' $SMBCONF
fi
##if [[ -z $(grep "client schannel" $SMBCONF) ]]; then
## - I do not think this is necessary anymore, but it remains as a note...
##MODIFIED=true
##client schannel = auto
##vim -c ':set shortmess=a' -c ':set cmdheight=2' -c ':set noignorecase' -c '/workgroup =' -c 'call append(line("."), " client schannel = auto")' -c 'wq!' $SMBCONF
##fi
if [[ -z $(grep "client use spnego" $SMBCONF) ]]; then
# - spnego is deprecated now and is going to be "yes" for standard....
MODIFIED=true
#client use spnego = yes
vim -c ':set shortmess=a' -c ':set cmdheight=2' -c ':set noignorecase' -c '/workgroup =' -c 'call append(line("."), " client use spnego = yes")' -c 'wq!' $SMBCONF
fi
if [[ -z $(grep "server min protocol" $SMBCONF) ]]; then
MODIFIED=true
#server min protocol = NT1
vim -c ':set shortmess=a' -c ':set cmdheight=2' -c ':set noignorecase' -c '/workgroup =' -c 'call append(line("."), " server min protocol = NT1")' -c 'wq!' $SMBCONF
fi
if [[ -z $(grep "client min protocol" $SMBCONF) ]]; then
MODIFIED=true
#client min protocol = NT1
vim -c ':set shortmess=a' -c ':set cmdheight=2' -c ':set noignorecase' -c '/workgroup =' -c 'call append(line("."), " client min protocol = NT1")' -c 'wq!' $SMBCONF
fi
echo
if [[ $MODIFIED == true ]]; then
echo "$SMBCONF modified..."
vim $SMBCONF
echo
read -p "_Restart Samba? [Y/n]: " IN
if [[ -z $IN || $IN == "y" || $IN == "Y" ]]; then
echo "-Reastarting Samba..."
service smbd restart
service nmbd restart
fi
else
echo "$SMBCONF NOT modified..."
fi
echo