This is a static archive of the old Zorin Forum.

The information below may be outdated. Visit the new Zorin Forum here ›

If you have registered on the old forum, you will need to create an account on the new forum.

Logon script for user

sharky

Sun May 21, 2017 7:43:13 am

Hi,

I take advantage of this platform since it is the OS that I use by cons against my problem is more general under Linux.

I want to make a Logon script for mount remote share from NAS. 1 script for all.

I can't use FSTAB, because the NAS HOME folder is not same for each computer user.

What I did and my idea:
I use this line
Code:
sudo mount.cifs //NAS/home $LocalPathMountFolder -o credentials=/home/$USER/.$USER_cred


I create /home/$USER/.$USER_cred with user NAS credentials (user + pass)
When i start my script and give sudo password, it's work.

I have push my script in /etc/profile.d/mountnas.sh
Code:
Chmod 644 /etc/profile.d/mountnas.sh


With "sudo mount.cifs" i need to give the sudo password -> not good
So in visudo
add line
Code:
user ALL=(ALL:ALL) NOPASSWD:/etc/profile.d/mountnas.sh


But login not work !!
I must restart in recovery mod and delete my script.

Thanks for support.
Frank

Swarfendor437

Sun May 21, 2017 4:10:18 pm

This is worth reading through first methinks!:

https://support.plex.tv/hc/en-us/articl ... ions-Guide

sharky

Sun May 21, 2017 5:35:54 pm

Thanks for the return,

I understand the rights, I do not think it is there my problem directly

This is how to run the script with sudo without asking for a password!?
Maybe my script is not in the right folder, to do what I want to do !!?
I have already seen that in visudo, one must put the real name. I thought using user was all users.
Code:
realusername ALL=(ALL:ALL) NOPASSWD:/etc/profile.d/mountnas.sh


I can use * ? for all users ?
Code:
* ALL=(ALL:ALL) NOPASSWD:/etc/profile.d/mountnas.sh

I have not found a solution to impact all users in one line

Another question: under Linux, if the wifi settings are for all users, is the network connected before or after logon?

In my script, I added controls:
1. if the credentials file exists, otherwise exit script (new user)
2. if the NAS IP responds, otherwise exit script (not on the usual network or not connected)

Thanks to share your help

sharky

Sun May 21, 2017 5:43:32 pm

Swarfendor437

Sun May 21, 2017 5:55:51 pm

Hi, a couple of those articles were when Ubuntu used its own startup and shutdown routines using 'upstart' - this was dropped for system.d - I suspect with the release of Ubuntu 14.04:

http://www.zdnet.com/article/after-linu ... t-systemd/

Not only that, Ubuntu uses Unity - Zorin uses Gnome Shell.

And lastly ...

I am no scripting expert. ;) :D

sharky

Mon May 29, 2017 5:36:12 pm

Hi,

I have change sudoers
username ALL=(ALL:ALL) NOPASSWD:/sbin/mount.cifs

and it works

Swarfendor437

Mon May 29, 2017 7:29:34 pm

Great! Can we mark this post as [SOLVED] now? ;) :D