2016-01-20 29 views
0

我一直在嘗試使用Linode StackScript來安裝FreePBX,但是當我使用./install_amp --installdb時,我一直在遇到提示。我正在使用FreePBX 12和CentOS 6.5進行安裝。我基本上將wiki中的安裝命令複製到腳本中。Linode StackScript自動安裝FreePBX ./install_amp

我遇到的問題是,當./install_amp --installdb在此腳本中出現時,會彈出提示輸入用戶名,密碼和所有默認選項。有沒有辦法讓這個更自動化?就像在更換amportal.conf文件到達該部分之前一樣?或者發送一個模擬的「輸入」?

#!/bin/bash 

# Disable selinux and update system 
sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/sysconfig/selinux 
yum -y update 
yum -y groupinstall core 
yum -y groupinstall base 

# Install required dependencies 
yum -y install gcc gcc-c++ lynx bison mysql-devel mysql-server php php-mysql php-pear php-mbstring tftp-server httpd make ncurses-devel libtermcap-devel sendmail sendmail-cf caching-nameserver sox newt-devel libxml2-devel libtiff-devel audiofile-devel gtk2-devel subversion kernel-devel git subversion kernel-devel php-process crontabs cronie cronie-anacron wget vim php-xml uuid-devel libtool sqlite-devel 

# Turn off iptables and turn on mysql/httpd 
chkconfig --leveliptables off 
service iptables stop 
chkconfig --level 345 mysqld on 
service mysqld start 
chkconfig --level 345 httpd on 
service httpd start 

# Install PearDB 
pear channel-update pear.php.net 
pear install db-1.7.14 

# Google voice dependencies 
cd /usr/src 
wget https://iksemel.googlecode.com/files/iksemel-1.4.tar.gz 
tar xf iksemel-*.tar.gz 
cd iksemel-* 
./configure 
make 
make install 

# Add asterisk user 
adduser asterisk -M -c "Asterisk User" 

# Download asterisk source files 
cd /usr/src 
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz 
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz 
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz 
git clone https://github.com/akheron/jansson.git 
wget http://www.pjsip.org/release/2.2.1/pjproject-2.2.1.tar.bz2 

# Compile and install pjproject 
cd /usr/src 
tar -xjvf pjproject-2.2.1.tar.bz2 
cd pjproject-2.2.1 
CFLAGS='-DPJ_HAS_IPV6=1' ./configure --prefix=/usr --enable-shared --disable-sound\ 
    --disable-resample --disable-video --disable-opencore-amr --libdir=/usr/lib64 
make dep 
make 
make install 

# Compile and Install jansson 
cd /usr/src/jansson 
autoreconf -i 
./configure --libdir=/usr/lib64 
make 
make install 

# Compile and install Asterisk 
cd /usr/src 
tar xvfz asterisk-13-current.tar.gz 
rm -f asterisk-13-current.tar.gz 
cd asterisk-* 
contrib/scripts/install_prereq install 
./configure --libdir=/usr/lib64 
contrib/scripts/get_mp3_source.sh 

make 
make install 
make config 
ldconfig 

# Install asterisk-extra-sounds 
mkdir -p /var/lib/asterisk/sounds 
cd /var/lib/asterisk/sounds 
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz 
tar xfz asterisk-extra-sounds-en-wav-current.tar.gz 
rm -f asterisk-extra-sounds-en-wav-current.tar.gz 
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722-current.tar.gz 
tar xfz asterisk-extra-sounds-en-g722-current.tar.gz 
rm -f asterisk-extra-sounds-en-g722-current.tar.gz 

# Install and configure FreePBX 
cd /usr/src 
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-12.0-latest.tgz 
tar vxfz freepbx-12.0-latest.tgz 

# Change ownership 
chown asterisk. /var/run/asterisk 
chown -R asterisk. /etc/asterisk 
chown -R asterisk. /var/{lib,log,spool}/asterisk 
mkdir /usr/lib/asterisk 
chown -R asterisk. /usr/lib/asterisk 
chown -R asterisk. /usr/lib64/asterisk 
mkdir /var/www/html 
chown -R asterisk. /var/www/ 

# Modifications to apache 
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php.ini 
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf_orig 
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/httpd/conf/httpd.conf 
service httpd restart 

#Configure asterisk db 
cd /usr/src/freepbx 
export ASTERISK_DB_PW=amp109 
mysqladmin -u root create asterisk 
mysqladmin -u root create asteriskcdrdb 
mysql -u root -e "GRANT ALL PRIVILEGES ON asterisk.* TO [email protected] IDENTIFIED BY '*********';" 
mysql -u root -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO [email protected] IDENTIFIED BY '********';" 
mysql -u root -e "flush privileges;" 

#Restart asterisk and install FreePBX 
cd /usr/src/freepbx 
./start_asterisk start 
./install_amp --installdb --username=asterisk --password=******* 
amportal chown 
amportal a ma installall 
amportal a reload 
amportal a ma refreshsignatures 
amportal chown 

#Start FreePBX 
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3 
amportal restart 

# Install and setup commercial modules 
wget -P /etc/yum.repos.d/ -N http://yum.schmoozecom.net/schmooze-commercial/schmooze-commercial.repo 
yum clean all 
yum -y install php-5.3-zend-guard-loader sysadmin fail2ban incron ImageMagick 

# Restart Apache and install sysadmin 
service httpd restart 
amportal a ma download sysadmin 
amportal a ma install sysadmin 

sed -i '338d' /etc/httpd/conf/httpd.conf 
sed -i '338i AllowOveride ALL' /etc/httpd/conf/httpd.conf 

amportal chown 
amportal a ma refreshsignatures 
amportal a reload 

回答

0

快速瀏覽一下amp_install --help會告訴你--scripted選項應該防止它要求任何東西。

如果您不使用默認的用戶名或密碼,您還需要設置--username--password

這是我在2.11中使用的;我相信這是相同的。13是一個重寫,應該更可靠。語法爲:

install --dbuser asteriskuser --dbpass xxxx --no-interaction