Social security for getting on a large amount Beat The Cycle Of Debt Beat The Cycle Of Debt for an approved in addition questions.

Safe1405 – Automated or Interactive Asterisk backup solution -with auto FTP upload

Posted: April 27th, 2009 | Author: | Filed under: Asterisk VoIP, Linux, Tech, Uncategorized | Tags: , , , , , , , , , , , , , , , , , , , , , , , , , | 6 Comments »

Summary:

Safe1405 is a bash script that will backup the popular Asterisk directories and place them in a tar.gz file. The script can be used in 1 of 2 modes.
The first mode is interactive, with a menu to choose:

  • Backup Everything (/etc/asterisk, Voicemail, Recordings, Sounds)
  • Just VM
  • Just Recordings
  • Just Sounds

After the file is created, it will prompt to upload to a remote FTP server.

The second mode is silent, and is best suited for automated execution via cron or at.
Just enable the UNATTENDED and PUT_FTP variables by setting them to “1″.  You can directly edit the paths to each directory if yours are non-standard.

The script can be directly downloaded here: Safe1405 Download Link

Code:

#!/bin/bash
# Safe1405
# Author: Gregg Hansen - www.thiscoolsite.com
# Safely tar and gzip Asterisk files

# Version 1.0 20090427
#-Backs up all important Asterisk files - Tar/Gz
#-Choose the file name, or Date by default
#-GUI-like. Able to be silent for cron, or interactive

#EDIT the below ABSOLUTE paths to match your directory structure:
VAR_LIB="/var/lib/asterisk"
ETC_AST="/etc/asterisk"
VM="/var/spool/asterisk/voicemail"
MON="/var/spool/asterisk/monitor"

#Date Var
FILEDATE="$(date +%Y%m%d)"
#Your ServerName
#Filename is FILEDATE-SERVERNAME.tar.gz
SERVERNAME="Chicago-Ast01"

#Enable unattended mode/Remote FTP put (useful for Cron):
# Backup of /etc/asterisk ONLY (default)
# 1 = On, 0 = Off
UNATTENDED="0"
PUT_FTP="0"

#FTP Credentials
FTP_IP="127.0.0.1"
FTP_USER="admin"
FTP_PASS="secret"

###--START CODE---###

### Interactive Mode Functions ###
prompt()
{
cat <<EOF

Safe1405 Backup

1) Everything
2) /etc/asterisk
3) Voicemail
4) Recordings
5) Sounds
Q) Quit

EOF

echo -n "Prompt> "
read INPUT
case $INPUT in
1) everything;;
2) etc-ast;;
3) vm;;
4) recordings;;
5) sounds;;
q) exit;;
Q) exit;;
esac

}
everything()
{
FILENAME="$FILEDATE-$SERVERNAME-FULL.tar.gz"
tar cfvz $FILENAME $ETC_AST $VM $MON $VAR_LIB
ftpprompt
}
etc-ast()
{
FILENAME="$FILEDATE-$SERVERNAME-ETC_AST.tar.gz"
tar cfvz $FILENAME $ETC_AST
ftpprompt
}
vm()
{
FILENAME="$FILEDATE-$SERVERNAME-VM.tar.gz"
tar cfvz $FILENAME $VM
ftpprompt
}
recordings()
{
FILENAME="$FILEDATE-$SERVERNAME-REC.tar.gz"
tar cfvz $FILENAME $MON
ftpprompt
}
sounds()
{
FILENAME="$FILEDATE-$SERVERNAME-SOUNDS.tar.gz"
tar cfvz $FILENAME $VAR_LIB
ftpprompt
}
ftpprompt()
{
echo -en "Upload $FILENAME to FTP? (y or n) "
read INPUT
if [ "$INPUT" == "y" ]; then
quietftp
fi
}

### Unattended Mode Functions ###
silent()
{
tar cfvz $FILEDATE-$SERVERNAME-ETC-AST.tar.gz $ETC_AST ##Uncomment##$VM #$MON #$VAR_LIB
FILENAME="$FILEDATE-$SERVERNAME-ETC-AST.tar.gz"
}

quietftp()
{
ftp -ivn <<EOF
open $FTP_IP

user $FTP_USER $FTP_PASS
binary
put $FILENAME
bye
EOF
}
#### Start Program Flow ###
clear
#Unattended Function Call(s)
if [ "$UNATTENDED" == "1" ]; then
silent
if [ "$PUT_FTP" == "1" ]; then
quietftp
exit
fi
exit
fi
#Interactive Function Calls
prompt
exit

###–END CODE—###
Leave a comment if you have questions/suggestions or would like help setting up the script.
-Gregg


Fastest Route to Single Booting Linux on the new 2009 Mac Mini

Posted: March 30th, 2009 | Author: | Filed under: Linux, Mac, Tech | Tags: , , , , , , , , , , , , , , , | 3 Comments »

See IMPORTANT NOTES section below… there’s currently a catch with rebooting….
If you find a fix for the reboot issue, please leave a comment (that will email me)..

Special thanks to Victor Costan http://blog.costan.us

Step 1 – Get your linux on the HD
-Power On / Insert Linux Install Disk With Kernel 2.6.26 or higher / Power Off
-Power On / Wait 4 Seconds / Hold “c” key to boot from DVD drive
-I couldn’t get linux to work after deleting the EFI partition, so don’t.
-Get to your distro’s partitioning utility and delete the main MAC partition
-After deleting the big partition, create your linux partitions
-If you delete the EFI partition on accident, the Leopard install will fix it
-Direct the installer to put GRUB on the first sector of your /boot partition
-Install whatever other options you want and let installer run
-Remove Linux Install Disk / Insert MAC OSX Install Disk / Reboot

Step 2 – Tell MAC‘s Open Firmware What To Do
-Power On / Wait 4 Seconds / Hold “c” key to boot from DVD drive
-Get to “Terminal” under “Utilities” on MAC Installation Setup
-Type the following command to determine how your /boot partition was identified
diskutil list
-Type the following command to set that partition as bootable (mine was disk0s2)
bless –device /dev/disk0s2 –setboot –legacy –verbose

IMPORTANT NOTES
-After these steps, linux will boots fine but when trying to reload it will hangs (more likely the shutdown process hangs).  It appears to require a hard reset at this time…bummer.
-Earlier Kernels (Such as 2.6.18 in Centos 5.2 and lower) may install successfully but do not properly load drivers for all the hardware once installed.

WINDOWS KEYBOARD NOTES
Hold “c” key to boot from DVD drive
Hold “F12″ key to eject the DVD drive
Hold “ALT” to emulate the option key (not used in this procedure)

SOURCES

Debian Success Documented here (by Thomas Glanzmann): http://lkml.indiana.edu/hypermail/linux/kernel/0903.1/01828.html

Discussion and bless command from Veiho in Ubuntuforums :  http://ubuntuforums.org/archive/index.php/t-493393.html

Status on reload problem being worked by ubuntu developers: https://bugs.launchpad.net/ubuntu/+source/linux


Linux Software RAID

Posted: January 19th, 2009 | Author: | Filed under: Linux, Tech | Tags: , , , , , , , , , , , , , , , | 1 Comment »

I have always wanted to setup a NAS to house all of my data in one location, and now the price/GB is affordable enough for me to live the dream.  Christmas Day I was sitting on the computer thinking that a  NAS would be a good project to close out 08′, so I purchased the following:

7 – Western Digital 1TB Hard drvies
2 – PCI Sata Controllers with 4x internal SataII ports each
3 GB RAM

I decided to use my 2nd desktop computer that I’ve owned.
Purchased in 03′ here are the specs:

AMD Athlon XP 2200+ 1.8GHz
3GB Ram
4 PCI Slots
ASUS MB

That’s all you need to know about that PC.  So I get all of the hard drives setup in the new case and create a rat’s nest of sata and molex connectors.
Most geeks will tell you that you should definitely go with hardware raid controllers because it takes the load off of the CPU and the performance is much better.  I decided to go with software RAID6 because I am not a conformist. :)

Just kidding here are my reasons for software RAID over Hardware:
-Most modern CPUs can handle the RAID operations with ease
-Hardware RAID controller failure results in you having to obtain the exact model and firmware ver. for your data to come back
-My application is not write or read intensive.  The highest load I can see on the NAS will be burning a DVD image over the network while having several other users in the house stream high-def media, while VPN users access the data.  So a max of 40MB/s-ish.  Should be nothing for the gigabit network here.

Here is the breakdown to setup a raid.
1. Install all hardware and confirm it is recognized by the cards/bios
2. Boot to your favorite .NUX distro
3. Setup your main boot drive with the common partitioning scheme.  1x 100MB /Boot, 2x RAM Swap, / with rest of HD space on OS drive
4. Boot up, yum -y update
5. Remote in and fdisk -l to verify that everything is there, then dmesg to make sure there are no issues.
6. fdisk /dev/sda,  specify type (Linux RAID Autodetect), type n for new, primary partition, enter, enter…Wait for the inode goodness
7. yum install mdadm
8. man mdadm and read
9. Setup your raid with the mdadm command, specify spare drives, block size (64k or 128k shoud do), and RAID level.  I went with RAID6 for dual redundancy.  So my 7 drives ended up being ~4.5TB of usuable space.
10. After you run the mdadm command the RAID will sync up and initialize.  You can use the drives while they are syncing, but they will operate in a degradated state.
11. Wait about 15 hours in my case for the RAID to initialize, then check dmesg to see if you have any errors.  Also ‘cat /proc/mdstat’ to see the status of your RAID.
12. Setup Samba, nfs, ftp, whatever you want to give your (l)users access to the data.

If you have any issues with RAID, leave a comment and I’ll email you to help.  I had many issues over the course of this RAID fiasco that I’ve learned from.

Final Say:  If you must go software RAID, use at least a P4 Core 2 Duo processor.


Kickstart GNUDialer Install – Made Easy

Posted: October 24th, 2008 | Author: | Filed under: Asterisk VoIP, Linux, Tech | Tags: , , , , , , , , , , | 11 Comments »

I’ve had the task of installing GNUDialer for testing and call-centers tend want dialers all the time.  Many dialer platforms are extremely bloated and their support fees are enormous! I like GNUDialer because they decided to make an open-source dialer platform that is minimal and functional.

Disclaimer:  I am not responsible for any loss of data, server explosions, recessions, depressions, or anything negative that may arise from you running the dialer kickstart script.  It was meant with good intentions, but I am not going to be liable for any of your actions.
:) Glad that is out of the way.

You can read through each script that runs and know exactly how the install was done.  Make sure you watch the console throughout the install to catch any possible errors that may be thrown out (2)stderr.

Instructions:
–Prerequisites (Have your server connected to a DHCP-enabled network with internet access)

1. Download and Burn CentOS 4.5 or 4.6 ISO CD1 Here or Here.

2. Start the server with the CD and set the BIOS to boot from CD first

3. You will see this screen if it booted from the CD properly. At the prompt type ‘linux ks=http://www.thiscoolsite.com/scripts/ks_dialer/ks.cfg’ just like it did in the screenshot.  Then hit enter.

4. If you typed the command incorrectly you will see this screen asking you to ‘test your media’.  If you see this screen reboot your server and try typing the command again, but correctly.


5. After a minute you should see a screen that looks like this.  That means you typed the ‘linux ks’ command correctly and it is installing in txt mode.  It will take at least 10 minutes, then it will look like it is paused at the end of the install.  Don’t worry, it is using yum to install all the latest packages you need to run Asterisk and Gnudialer.  The install will reboot itselft, so don’t mess with it.


Upon first boot, the main script runs that will be doing the MySQL databse config, Asterisk install, astcrm, and GNUDialer installs.  The script will exit and you will be prompted with a login screen.  The default user is ‘root’ and password is ‘star1405′.

Change your root password immediately with the ‘passwd’ command.

Once you are logged in you can check to see that Asterisk is running by typing Asterisk -r and getting in to the console.  You can then start the gnudialer daemon for the first time by typing ‘gnudialer –safe’.  You should be up and running now! Good Job.

Navigate to http://InternalIPAddress/gnudialer to login to the management interface.  Password is ‘gnudialer’.

Make sure you read all of the readme and install files in /usr/src/gnudialer so you can actually setup working campaigns and use the settings properly.  Also, a few people are always available for live help in IRC.freenode.net’s #gnudialer channel.  Be aware, ignorance is not allowed.  If you didn’t attempt to troubleshoot the issue yourself or read everything available to you on the internet, you will be chastised and humiliated in front of your peers. <G>

As always, leave a comment with your email and I will try to help in any way that I can.
Happy automated-dialing trails…to you!
-Gregg


Flip1405 – The Failover Asterisk Solution

Posted: July 12th, 2008 | Author: | Filed under: Asterisk VoIP, Linux, Mac, Tech | Tags: , , , , , , , , , , , , , , , , , , | 57 Comments »

Flip1405 is an Asterisk Failover solution that was created in early 2008. I found the need to create an easy to install failover solution for Asterisk servers. After a couple hours on a Sunday night, I had the first version completed. In 2009 someone who came across this script reworked the code to add new features, and I updated the site. Now, in 2011 I am glad to announce that there is a new version that has many new features and improvements over my existing code. Many thanks to Jonathan Bayer for updating the script again. His site is http://linuxnotes.us

Excerpt taken from his site:
Congratulations! You have now set up your first Asterisk-based VOIP server.

Next question (probably the first your boss will ask you): What happens when the server crashes, or loses power, or needs to be upgraded, or…….; well, you get the idea. If you only have a single server, you lose your phones until it is rebooted. Given that you probably installed this on a cheap, inexpensive piece of hardware, these questions are not out of the question, especially for a business.

We had the same questions, and have implemented a failover solution. I started with a script I got from this web page, but was dissatisfied with it. It seemed to be a bit of a kludge, in that it wasn’t a true HA solution, but was only a backup solution.

I did a massive reworking of the script, and the result downloadable from here:

flip1405.sh

This script is used to synchronize the /tftpboot with the /var/ftp/ directory:

syncftp.sh

The only dependencies for Flip1405.sh are nmap and arping

To use, first get your primary Asterisk server running smoothly. When ready, you can either clone it using Clonezilla (or some other utility) or just install Asterisk on the second box. Then follow these steps:

Setup shared-keys so the servers can copy between each other without user intervention. Setup Login without password
Set up ftp (I use vsftp), if needed. We use it to download the configurations for the Aastra phones. Usually we would use tftp, but since we have some phones outside our office we simply use ftp for everything.
Install this script into /usr/local/sbin on the primary/active system.
Run the script with the -s option:
/usr/local/sbin/flip1405.sh -s
The second script: syncftp.sh, is used to synchronize the /tftpboot directory with the /var/ftp directory. If you need it, install the syncftp.sh script into /usr/local/sbin
Open up the flip1405.sh in an editor, and check the various settings. I would recommend that if you need to change them, to use a config file (/etc/sysconfig/flip1405) rather than editing each file. The config file is NOT sync’d between the systems, so you can have system specific options in the file.
There is no need to specify the device, or whether the system is a master or slave. The script determines this at run time. The most important lines to set are the first three variables: MASTERIP, SLAVEIP, and FLOAT. These are:
MASTERIP IP address of the master system (arbitrary name)
SLAVEIP IP address of the slave system
FLOAT IP address that will float between the Master and Slave, and which your phones will access
All other variables are set for an Elastix system. Elastix is based on the following:
Asterisk 1.6
Centos 5.5
FreePBX 2.6
Make sure to set the bindaddr to the virtual IP address in /etc/asterisk/sip.conf or
/etc/asterisk/sip_general_custom.conf
bindaddr=192.168.1.12 ;IP of Virtual interface
Add the following line(s) to the root crontab (only install the syncftp.sh line if you are using it):
* * * * * /usr/local/sbin/flip1405.sh
*/5 * * * * /usr/local/sbin/syncftp.sh
If you like, you can add the following lines to /etc/crontab instead:

* * * * * root /usr/local/sbin/flip1405.sh
*/5 * * * * root /usr/local/sbin/syncftp.sh
If you have phones outside your network, you will need to configure your firewall to direct the following ports to the FLOAT address:

tcp 21 (if you are using ftp)
tcp 3000
udp 3000
tcp 5060-5082
tcp 10000-20000
tcp 5800-5900
udp 5060-5082
udp 1000-20000
udp 5800-5900

Click below to see previous versions (20090327)
Old Versions


Asterisk as a Virtual Machine – On a Mac

Posted: July 11th, 2008 | Author: | Filed under: Asterisk VoIP, Linux, Mac, Tech | Tags: , , , , , , , , , , , | 2 Comments »

I know a few people that would like to run their small home-office phones with Asterisk, but don’t want to dedicate a server just for Linux/Asterisk. The answer to their problems is Asterisk running as a virtual machine! I was running VMWare Server on my Mac Mini with CentOS as the host os. But that got me thinking, I have a sweet Mac just sitting there running 2 linux OS’s and it’s pretty idle. I proceeded to back up my Asterisk config files and installed Leopard on the Mac Mini.

Now for those that aren’t familiar, VMWare can run with either Windows or Linux as the Host OS. Linux is usually the better option due to uptime, security, memory usage, etc. I simply acquired Parallels for Mac (VMWare equivalent, but for Mac) and installed CentOS as the client OS. Within 15 minutes I had my new server up and running. Upon boot, I had an issue. The box would hang when it was “booting Kernel”. I looked around and sure enough, it was trying to boot the EL-SMP kernel. One reboot later, hit esc. at the OS kernel page, and selected the EL kernel (not SMP) and I was up and running with Asterisk virtual with a Mac host OS. Opa!

Once you are logged into your Asterisk/Linux OS:
Edit /boot/grub/menu.lst and comment out the EL-SMP kernel, then you will auto-boot the working kernel.

Happy virtualization.