Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 445  / 3 Years ago, fri, may 14, 2021, 8:49:06

I have looked everywhere for a solution that lets me run CIFS automount script after login with around 20 second delay.
What I have tried.
Added the script to visudo:



rait ALL=(ALL) NOPASSWD: /home/rait/Downloads/Testing/mount.sh, /bin/mount


After that added the script to Startup applications, but it does not work.
Also I tried adding it to .bash_profile and rc.d. In rc.d it works but that does not run it after login. I need it after login because it will ask people for their AD user and password via GUI.
The script itself looks like this:



    #!/bin/bash
MOUNTDIR=Public
DIRNAME=Avalik
DOMAIN=Domain
SERVER=server_adr
SHARE=shares

if [ ! -d ${HOME}/Documents/${DIRNAME} ]; then
mkdir ${HOME}/Documents/${DIRNAME}
fi

# get the windows username
wUsername=`zenity --entry --width=300 --title="Mount $MOUNTDIR" --text="Kasutaja
nimi:"`
if [ $? -ne 0 ]; then
exit 1
fi

# get the windows password
wPassword=`zenity --entry --width=300 --title="Mount $MOUNTDIR" --text="Parool:"
--hide-text`
if [ $? -ne 0 ]; then
exit 1
fi

mount -t cifs //$SERVER/$SHARE ${HOME}/Documents/${DIRNAME} -o username=${wUsern
ame},password=${wPassword},domain=${DOMAIN}

if [ $? -eq 0 ]; then
zenity --info --title="Mount OK!" --text="Mount OK!"
else
zenity --error --title="Mount Failed!" --text="Mount Failed!"
fi


I hope that someone knows how to do it.



PS: After I edited the visudo now it asks for root password after I open terminal. So terminal asks me for sudo password when ever I open it after login. Once I remove the line that should run the script in visudo it does not ask for password anymore.



Please help :)


More From » mount

 Answers
6

Fixed it by adding this to sudoers:



%sudo   ALL=(ALL) NOPASSWD: /bin/mount, /bin/umount


And the Startup Applications command was edited so it was /home/user/script/path/script.sh and it started to work. Also added sudo infront of the mount command in the script as well.



Thanks for you help guys :)


[#25229] Saturday, May 15, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hreadsoplet

Total Points: 220
Total Questions: 108
Total Answers: 105

Location: Serbia
Member since Fri, Jun 3, 2022
2 Years ago
;