TIPS Reboot and Reset buttons

zigg.z

New Member
Joined
Feb 24, 2010
Messages
58
Reaction score
0
I think it would be helpful to reboot server or reset asterisk via the GUI rather than only with the shell commands.
 

zigg.z

New Member
Joined
Feb 24, 2010
Messages
58
Reaction score
0
There again, I found it in the Webmin....
Very useful, I just didn't look hard enough before.
 

blanchae

Guru
Joined
Mar 12, 2008
Messages
1,910
Reaction score
9
Don't stop the server in Webmin! You have to do an orderly shut-down of Asterisk and webmin doesn't do that. You must issue "amportal stop". This will close the mysql database and shut down the components of PiaF properly. If you skip this step, you can corrupt your database and the next time the server starts, Asterisk might not!

Then you issue "shutdown -h now" which will shut down the Linux part (this is what Webmin does).

You can make a bash script that has those two commands in it. Here's a webpage that talks about stopping Asterisk (little bit old but still relevant)
 

ou812

Guru
Joined
Oct 18, 2007
Messages
479
Reaction score
79
OK so I followed instruction on the stopping asterisk link.

pbx-reboot
I used my trusty text editor to create a file called pbx-reboot. Here's the two lines in it:

amportal stop
shutdown -r now

I saved it in /usr/sbin directory and made it executable for the root user only using the following command:

root@pbx:~ $ chmod 744 /usr/sbin/pbx-reboot
Now to stop PiaF, I just have to type:

root@pbx:~ $ pbx-reboot

Asterisk stops gracefully and then Linux shuts down and reboots the computer.

but this is what I get, I must be missing something.:crazy:

root@pbx:~ $ pbx-reboot
-bash: pbx-reboot: command not found

Gary.
 

darmock

PIAF Developer
Joined
Oct 18, 2007
Messages
2,892
Reaction score
98
#!/bin/sh
amportal stop
shutdown -r now

save it

chmod +x if 744 fails
 

bmore

Guru
Joined
Feb 12, 2009
Messages
118
Reaction score
1
Automatic Power down at night and Restart in Morning

If you do not need your pbx PC on at night and wish to automatically power it off to save power while having it restart automatically in the morning you can use the following method.

Create the following script.
Code:
#!/bin/sh
amportal stop
shutdown -h now

save it
Code:
/usr/sbin/pbx-stop

make it executable by root
Code:
chmod 744 /usr/sbin/pbx-stop

Add it to the crontab, Webmin makes it easy (experts can also use crontab -e)
In browser go to
http://<pbx-ip-address>:9001
Log in as root

Navigate to
Code:
Un-used Modules > Scheduled Cron Jobs

Click
Code:
Create a new scheduled cron job

Enter the following:
Execute cronjob as:
Code:
root
Command
Code:
/usr/sbin/pbx-stop
Select
Code:
Times and dates selected below ..

Select the Minutes, Hours, Days, Months, Weekdays that you want the pc to turn off. If you select a time and All days and All Months and All Weekdays. The pc will turn off each day at the same time. Or you can choose specific days.

Click
Code:
Save

You can also click Run Now to test it if you wish. It will immediately execute the command.

To make the PC automatically boot up each morning. Set the time in your bios. Enter the Bios settings during boot, often by pressing Delete, F1, F10 or some such.

Navigate to the setting named something like RTC timer. Enable it and Enter the time for the PC to automatically turn on. Choose every day of week.

That is it. The PC will automatically shutdown asterisk and then power off at the time set above and automatically power on each morning. In my case it powers off every night at 9:00pm and back on at 7:00am. You will save power and some money while conserving the environments resources.

Of course if this is a mission critical pbx you may not want to do this. For example you should have a cellphone or other means of contacting 911 or making emergency calls.
 

Twilight Sparkle

https://voip.ms/en/invite/MjM2MjQ4
Joined
Jul 21, 2013
Messages
448
Reaction score
57
not sure if this is a good place to ask this but

is there away?... to call the pbx enter in a long number and have the system trigger a SERVER REBOOT once the long number was dialed...

just incase i cant ssh into it from another ip or something and need to froce a reboot
 

Twilight Sparkle

https://voip.ms/en/invite/MjM2MjQ4
Joined
Jul 21, 2013
Messages
448
Reaction score
57
thanks for the help after you sent me this i started to google more info about it and i came a cross https://www.ukvoipforums.com/viewtopic.php?t=567 which i think is also on this site somewhere.

all i know is thanks this is fraking cool.
even more cooler then me being a Pony..... . .. . .^_^

as i post this i just tested it took about 10sec to issue the comment so total from Call to Re-loaded and live
4/5min
 

ostridge

Guru
Joined
Jan 22, 2015
Messages
1,618
Reaction score
517
after you sent me this i started to google more info about it and i came a cross https://www.ukvoipforums.com/viewtopic.php?t=567 which i think is also on this site somewhere.
You could better try the existing safe scripts for 'halt' and 'reboot' to be found in /usr/local/sbin/
They do a bit more than shutdown -r now - to ensure the other bits are first stopped

Code:
cat /usr/local/sbin/halt

cat /usr/local/sbin/reboot

Not having tested this but: would that make that "Edit /etc/asterisk/extensions_custom.conf and add: .... "
Code:
[macro-shutdown]
exten => s,1,Authenticate(1234)    
exten => s,1,NoOp(Looks like we're going to shutdown!)
exten => s,n,System(/usr/bin/sudo /usr/local/sbin/halt )

[macro-reboot]
exten => s,1,Authenticate(1234)    
exten => s,1,NoOp(Looks like we're going to reboot!)
exten => s,n,System(/usr/bin/sudo /usr/local/sbin/reboot )

I'm not sure if adding asterisk into sudo group or as a sudoer could be unsafe in some circumstance??
 
Last edited:

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,607
Reaction score
826
Your post is parochial, and in many scenarios just plain wrong :) There is no "safe" reboot or halt, if run with acceptable permissions, they will absolutely do exactly that. it depends on your OS but in any which way

which halt

and

which reboot

will identify the script appropriate to your installation, either Redhat, Debian or even arch . . . .

I agree that any elevated privilege is dangerous, if you added to your sudoers

which rm

then you could as the asterisk user

rm -rf /

which would seriously spoil your day ;-) It's just a linux thing you need to encompass.
And no, halt and reboot are just binaries that are called appropriately by shutdown -h now and shutdown -r now, if you know otherwise please let me know what I missed.

it is all documented in in

man shutdown

You seriously need to read that.
 
Last edited:

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
Problem was that in some flavors of Debian/Ubuntu, halt just halted... in a split second. It was fairly obvious that it wasn't shutting anything down gracefully. In the case of MySQL and Asterisk, that was obviously asking for trouble. And that's the reason we implemented the separate halt and reboot scripts in /usr/local/sbin.
 

Twilight Sparkle

https://voip.ms/en/invite/MjM2MjQ4
Joined
Jul 21, 2013
Messages
448
Reaction score
57
something to test when i get time thanks you guys this is cool to know i can issue commands though a phone call to be honest i never thought it was possible...

i do re-call a show called 24 on FOX where a lady named Nina, got her hands a cell phone and typed in a few numbers and next thing you know she locked CTU out of there servers...

i feel so bad a** being able to do this...

makes wounder how far can i go into what commands.... all i know is i require MORE INPUT... on this i wounder if there is a book for dummies... about thsi topic.

thanks guys this has been fantastic info

im using this on a pogoplug and i must say... not a fan at all... im going to switch to a Pie3...
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,607
Reaction score
826
Problem was that in some flavors of Debian/Ubuntu, halt just halted... in a split second. It was fairly obvious that it wasn't shutting anything down gracefully. In the case of MySQL and Asterisk, that was obviously asking for trouble. And that's the reason we implemented the separate halt and reboot scripts in /usr/local/sbin.


One would have to wonder which "flavor" did that, having used Debian form any many years I have never seen that behavior, both binaries orderly call either the sysViniyt scripts appropriately in /etc/init* pre jessie or the annoying systemd process, that either was ineffectual surprises me , look to:-

https://www.freedesktop.org/software/systemd/man/systemd-halt.service.html

for systemd and a badly formed /etc/inittab for older debain's
 

Members online

No members online now.

Forum statistics

Threads
25,779
Messages
167,505
Members
19,199
Latest member
leocipriano
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top