Creating menu for rebooting the computer


i have here some problem with my ppp connection and sometimes it is not answering, but asterisk is available.

So i want to insert a dialplan like i call a special number, asterisk take the call, is asking for a pin, is the pin is correct, calling a shellcommand like:

sudo reboot

Is this possible with asterisk?

That would be a very ugly solution! Linux isn’t windows, you know! Rebooting it is never necessary to solve problems like this. The most you should need to do should be to kill pppd - which is hopefully configured to restart again if it dies. If it’s not, you might have to restart it as well.

Have you tried setting up the PPP connection so it works properly? It’s outside the scope of this forum, but you should be able to get help with that on a linux newsgroup.

To start with, though, check out the pppd manual page:

man pppd

and, in particular, look at these options: lcp-echo-failure and lcp-echo-interval.

Don’t ask me to go into more detail, because it’s off-topic in this forum.

you are right, but dont discuss such thinks, i know exactly what i want and what i want to do. The first step is to be able to reboot the computer, in the second step i can extent the menu to press 1 for killing pppd etc.

I posted this question only, because i want to know if it is possible to execute shell commands from Asterisk and how to inplement a password or pin check with Asterisk.

What you’re looking for is the system() command: … cmd+System

A simple way to implement such a thing would be to make the pin number an extension - with, say, 6 or 8 digits. A long extension number is equal to a PIN, really. Dialling that extension would run your system(sudo reboot) command.

thx, that is one part i searched for.
The problem is, that i dial a external number to get access to my computer at home, this number is fixed, so i think an easy extension will not work here, but i will have a look into the voicemail system maybe i can copy some stuff from there to make the pin working like i want.

Thx for the Link, there is much more information, which helps me.

Ah, i found:
Maybe i can do it withit.

A simple way that i use to do similar things - well, definitely not reboot the system! :wink: - is like this:

exten => 2,1,Dial(SIP/budgetone,15,r)
exten => 2,2,Answer
exten => 2,3,Set(TIMEOUT(response)=1)
exten => 2,4,Background(will-unavail)
exten => 2,5,Background(vm-intro)
exten => 2,6,Voicemail(s2)
exten => 2,7,Hangup

extension 2 is the extension that incoming (SIP or IAX2) calls from my DID numbers come in to. I sort of hijacked the voicemail system so that when i dial in from outside, it plays my unavailable message, then the voicemail intro message and then goes into the recording the message part of voicemail.

Because i’ve used the Background() command to play the messages, i can dial a number while the message is playing and execution will switch to that extension (in the current context).

One of those extensions is a long extension number (in lieu of a PIN) which will get me into my voicemail. There are other short numbers, for echo test, etc, too.

I know i could do a more complicated authentication sytem, but i can’t really see the point on this particular server, as it’s probably more secure to have to dial an 8-digit extension number than to try and input an 8-digit PIN - because the first time you get it wrong, you’re disconnected, but with PINs it’s usual to allow, say, 3 attempts.

It’s not meant to be more secure though, just simpler - and no less secure.

thx for your help, now everthing is working perfect.
I recorded my own .gsm for the menu, here is the code i use now, maybe its helpful:

; the shutdown services on my server
exten => 99,1,SetLanguage(de)
exten => 99,2,Answer
exten => 99,3,DigitTimeout,5
exten => 99,4,ResponseTimeout,10
exten => 99,5,Wait(1)
exten => 99,6,Authenticate(${ADMINPW})
exten => 99,7,Goto(Administration,s,1)

exten => s,1,SetLanguage(de)
exten => s,2,DigitTimeout,5
exten => s,3,ResponseTimeout,10
exten => s,4,BackGround(admin-greetings)

exten => 1,1,BackGround(admin-restarting-ppp)
exten => 1,2,System(sudo /usr/bin/killall ppp)
exten => 1,3,Wait(2)
exten => 1,4,System(sudo /usr/bin/killall -9 ppp)
exten => 1,5,Wait(2)
exten => 1,6,System(sudo /etc/rc.d/ppp-user start)
exten => 1,7,Playback(admin-ppp-restart)
exten => 1,8,Goto(s,1)

exten => 2,1,System(sudo /sbin/reboot)
exten => 2,2,Playback(admin-reboot)
exten => 2,3,Hangup

Glad you’ve got it working! It’s nice to get a bit of feedback - it doesn’t happen often!

The concept of being able to do certain system things with a dial-in menu is a good one. It hadn’t occurred to me - but i’m sure i’ll find some applications for it! :wink: