[asterisk-users] restart system from extension

Steve Edwards asterisk.org at sedwards.com
Thu Apr 6 13:58:08 CDT 2017

Please don't top post.

> On Thu, Apr 06, 2017 at 08:16:34PM +0300, Atux Atux wrote:

> hi. i would like to be able to reboot the system from my extension. is 
> that possible? if yes, how?

> Στις 6 Απρ 2017 8:25 μ.μ., ο χρήστης "Tzafrir Cohen" 
> <tzafrir.cohen at xorcom.com> έγραψε:

> System('sudo /sbin/reboot')

On Thu, 6 Apr 2017, Atux Atux wrote:

> Could you give some more details please?

While there may be many ways, sudo is the most obvious. I'd suggest 
sticking with it and learning it before researching other methods if you 
find a use case that sudo can't handle.

Sudo allows a user to run specific (or any) commands as another user. For 
example, allow the asterisk user to run a command as apache or root. This 
ability can be configured to run with or without a password.

If you're running Asterisk as root, which you shouldn't do, you don't need 
sudo since root can do almost everything.

If you're running Asterisk as asterisk, you can create a file named 
asterisk in /etc/sudoers.d/ that tells sudo what commands you want sudo to 
allow the user named asterisk, what user that command will be executed as, 
and if a password is needed. And more -- wade through 'man sudoers' for 
all the gory details.

In it's simplest form, which is not the most secure, this file would look 

 	asterisk ALL=(ALL) NOPASSWD: ALL

This means the user asterisk can run all commands as any user on any host 
without needing a password. Kind of scary, right?

The best way to edit this file is with the 'visudo' command because it 
will help prevent you from creating an invalid file. This can be very 
important when you are editing your file (for your login) remotely.

You should take the time to create a 'sudoers' file for the asterisk user 
that allows the single '/sbin/reboot' command. Do as I say, not as I've 
done :)

Thanks in advance,
Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867 PST

More information about the asterisk-users mailing list