shell command Ubuntu client

Asked by SMarty

Hello,

I read everything i found about configuring ubuntu client for using shell command. (server and client v1.6)

I want to schedule shutdown.

Here what i have so far :
- shell module enabled in server
- created a script in /home/mysuser/halt.sh
- in this script i have "sudo shutdown -h now"
- i gave execution permission to the script : chmod +x halt.sh
- i granted the user "myuser" root access without password to this script : did "sudo visudo" and added line "myuser ALL=NOPASSWD: /home/myuser/halt.sh"
- in server i add shell command "/usr/bin/sudo /home/myuser/halt.sh

Can't get the command to work

did i miss something ?

thanks a lot

Question information

Language:
English Edit question
Status:
Solved
For:
Xibo Edit question
Assignee:
No assignee Edit question
Solved by:
SMarty
Solved:
Last query:
Last reply:
Revision history for this message
Alex Harrington (alexharrington) said :
#1

Did you enable shell commands in the client config and whitelist your
command?

Why the double call to sudo by the way?

Revision history for this message
SMarty (bopieds) said :
#2

Thanks for the quick answer.

you mean i don't need sudo in server command ? just call the script "/home/mysuser/halt.sh" ?

didn't enable shell command in client nor whitelist ! should i do it in site.cfg ? i don't see any key for that purpose in site.cfg.default

speaking about whitelisting : do i need to whitelist the shutdown command or just the script ?

thanks

Revision history for this message
Alex Harrington (alexharrington) said :
#3

http://bazaar.launchpad.net/~xibo-maintainers/xibo/ponswinnecke/view/head:/client/python/defaults.cfg#L196

The section you need is in defaults.cfg (you copy it in to your site.cfg to
override the defaults).

You already have sudo in your script, so you just need to call
/home/myuser/halt.sh
You need to whitelist /home/myuser/halt.sh in the client configuration

In your sudo configuration you need to allow your user to call shutdown -
not your script.

Revision history for this message
SMarty (bopieds) said :
#4

ok thanks.

Simplified a bit and tried :

- added to site.cfg

[ShellCommands]
enabled=true
whitelist=/usr/bin/sudo /etc/init.d/reboot

- did a "sudo visudo" and added

myuser ALL=NOPASSWD: /etc/init.d/reboot

- in server i create a layout and add an Linux command

/usr/bin/sudo /etc/init.d/reboot

- in server i schedule this layout today and actual hour + 5 minutes

- in client press "i" and "r" to make sure it updates changes

...no luck, client doesn't reboot...

Revision history for this message
Alex Harrington (alexharrington) said :
#5

Please do exactly what I said before. That will work

Revision history for this message
SMarty (bopieds) said :
#6

yes i did it and followed your advice word for word but with no luck, so i tried to simplify it a bit.

Anyway my bad for this one, "reboot" as i tried it won't work as it is a service and not a command.

I rolled back to your solution : same problem.

when i open a terminal and type /home/myuser/reboot.sh it reboots without asking for a password.

I checked date and time just in case, but server date and time matches client one

Revision history for this message
Alex Harrington (alexharrington) said :
#7

What does the client log. It will log if the command line isn't matching.
Also check you've used full paths everywhere

Revision history for this message
SMarty (bopieds) said :
#8

for the record, just in case there is something wrong i did, here what i have :

in /home/myuser/reboot.sh :

#!/bin/bash
/usr/bin/sudo /sbin/shutdown -h now

in sudoers i added the line :

myuser ALL=NOPASSWD: /sbin/shutdown

in /opt/xibo/pyclient/client/python/site.cfg :

[ShellCommands]
enabled=true
whitelist=/home/myuser/reboot.sh

And in the server i create a layout with the linux shell command : /home/myuser/reboot.sh

Now concerning logs, where can i find them ?
I had a look into /opt/xibo/pyclient/client/python/data/log but there are no files in here

thanks a lot for your assistance

Revision history for this message
Alex Harrington (alexharrington) said :
#9

That all looks correct to me.

You need to enable logging to screen or file. Again defaults.cfg shows you
the options

Revision history for this message
SMarty (bopieds) said :
#10

Sorry but logging options in default.cfg are not clear. I don't really understand what option to choose.

I copied the logging options as follow :

[Logging]
logWriter=XiboLogXmds
splitLogWriter1=XiboLogXmds
splitLogWriter2=XiboLogScreen
logLevel=0

I tried to change logWriter to XiboLogFile or XiboLogScreen and logLevel up to 10

I can't find any log info in the client.

Revision history for this message
SMarty (bopieds) said :
#11

ok i found run.log....

which logLevel should i chose ?

Revision history for this message
SMarty (bopieds) said :
#12

Can i send you the log file ?

Revision history for this message
Alex Harrington (alexharrington) said :
#13

10 will give you the most output

Revision history for this message
Alex Harrington (alexharrington) said :
#14

Just look in there for the section on the shell command running and paste
in a few lines either side.

Alex

Revision history for this message
SMarty (bopieds) said :
#15

My last try worked !

I just changed the schedule to 15 minutes after creation instead of 10 minutes.
So i think the problem was the client wasn't synchronized.
I thought it could be synchronized manually by pressing "i" and then "r" to refresh but it seem it doesn't... can you confirm ?

thanks

Revision history for this message
Alex Harrington (alexharrington) said :
#16

I then r will cause the client to download new content but it won't trigger
the layout to reload. You'd need to press r for that

Revision history for this message
Alex Harrington (alexharrington) said :
#17

I mean n

Revision history for this message
SMarty (bopieds) said :
#18

ah ok ! thanks for the information and thank you for your help.
Have a nice week-end