Converter um arquivo .sh (Centos) para .sh (Ubuntu)

1. Converter um arquivo .sh (Centos) para .sh (Ubuntu)

daniel
danfra

(usa Ubuntu)

Enviado em 18/04/2013 - 12:13h

Boa tarde pessoal,
tenho um scrip install.sh para rodar no centos, porem preciso modifica-lo para ubuntu, nao tenho ideia o que diferencia um do outro neste arquivo. Alguma dica?

Segue o script


#!/bin/bash

clear
echo
echo "----------- Install MagnusBilling Server: ----------"
echo "-------------- www.magnusbilling.com ---------------"
echo "------------- info@magnusbilling.com ---------------"
echo
sleep 2


service asterisk status | grep pid > /dev/null
if [ $? = 0 ];then
echo Asterisk is running
else
echo
echo "ASTERISK Error: please check install Asterisk and try again!"
echo
exit
fi


echo
echo "----------- Checking MySQL connection: ----------"
echo

dbaccess="denied"
until [[ $dbaccess = "success" ]]; do
mysql --user="$1" --password="$2" -e exit 2>/dev/null
dbstatus=`echo $?`
if [ $dbstatus -ne 0 ]; then
echo
echo "MYSQL Error: please check the user access and try again!"
echo
exit
else
dbaccess="success"
echo "Connect Mysl Success!"
fi
done


VERSION=$(awk '{print $3}' /etc/redhat-release)
if [[ "$VERSION" =~ ^6 ]]; then
VERSION='6'
else
VERSION='5'
fi;

cat /etc/selinux/config | grep SELINUX=enforcing > /dev/null

if [ $? = 0 ]
then
echo "Disabling SELINUX and iptables..."
sed 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config > borra && mv -f borra /etc/selinux/config
chkconfig iptables off
else

echo "Oops, looks like SELINUX is disabled..."
chkconfig iptables off
fi


if [[ $VERSION = '5' ]]; then

rpm --import http://yum.jasonlitka.com/RPM-GPG-KEY-jlitka

touch /etc/yum.repos.d/utterramblings.repo
echo '[utterramblings]
name=Jasons Utter Ramblings Repo
baseurl=http://yum.jasonlitka.com/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://yum.jasonlitka.com/RPM-GPG-KEY-jlitka
' > /etc/yum.repos.d/utterramblings.repo
fi


if [[ `uname -m` = 'x86_64' ]]; then

yum -y install kernel-devel.x86_64
yum -y install gcc.x86_64 gcc-c++.x86_64 bison.x86_64 openssl-devel.x86_64 libtermcap-devel.x86_64 ncurses-devel.x86_64 doxygen.x86_64 curl-devel.x86_64 newt-devel.x86_64 mlocate.x86_64 lynx.x86_64 tar.x86_64 wget.x86_64 nmap.x86_64 bzip2.x86_64 mod_ssl.x86_64 crontabs.x86_64 vixie-cron.x86_64 speex.x86_64 speex-devel.x86_64 unixODBC.x86_64 unixODBC-devel.x86_64 libtool-ltdl.x86_64 libtool-ltdl-devel.x86_64 mysql-connector-odbc.x86_64 mysql.x86_64 mysql-devel.x86_64 mysql-server.x86_64 flex.x86_64 screen.x86_64 autoconf automake libxml2.x86_64 libxml2-devel.x86_64 sqlite* subversion
yum -y install php.x86_64 php-cli.x86_64 php-posix.x86_64 php-devel.x86_64 php-gd.x86_64 php-mbstring.x86_64 php-mysql.x86_64 php-pdo.x86_64 php-xml.x86_64 php-xmlrpc.x86_64 php-pear.x86_64 crontabs.x86_64
else
yum -y install kernel-devel
yum -y install --skip-broken gcc gcc-c++ make openssl-devel newt-devel ncurses-devel libtermcap-devel libxml2-devel perl curl curl-devel bison bison-devel doxygen mlocate lynx nmap mod_ssl crontabs vixie-cron speex speex-devel libtool-ltdl unixODBC unixODBC-devel libtool-ltdl-devel mysql-connector-odbc mysql mysql-devel mysql-server flex screen audiofile-devel libogg-devel perl-DateManip sendmail-cf sox autoconf automake libxml2 libxml2-devel sqlite* subversion
yum -y install php php-cli php-devel php-gd php-posix php-mbstring php-mysql php-pdo php-xml php-xmlrpc php-pear crontabs
fi;

/sbin/chkconfig httpd on && /sbin/chkconfig mysqld on && /sbin/chkconfig --add mysqld && chkconfig crond on && /etc/init.d/crond start


echo "
<IfModule mime_module>
AddType application/octet-stream .csv
</IfModule>
" >> /etc/httpd/conf/httpd.conf

sed -i "s/memory_limit = 16M /memory_limit = 512M /" /etc/php.ini
sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 3M /" /etc/php.ini
sed -i "s/post_max_size = 8M/post_max_size = 20M/" /etc/php.ini
sed -i "s/max_execution_time = 30/max_execution_time = 90M/" /etc/php.ini
sed -i "s/max_input_time = 60/max_input_time = 120M/" /etc/php.ini
sed -i "s/User apache/User asterisk/" /etc/httpd/conf/httpd.conf
sed -i "s/Group apache/Group asterisk/" /etc/httpd/conf/httpd.conf
sed -i "s/\;date.timezone =/date.timezone = America\/Sao_Paulo/" /etc/php.ini

service httpd restart


echo
echo "----------- Install asterisk-addons : ----------"
echo
sleep 2
cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-addons-1.6.2.4.tar.gz
tar xzf asterisk-addons-1.6.2.4.tar.gz
cd /usr/src/asterisk-addons-1.6.2.4
make clean
./configure
make menuselect.makeopts
menuselect/menuselect --disable chan_ooh323 --disable format_mp3 menuselect.makeopts
make all
make install
make config
make samples

clear
echo
echo "----------- Installing the Web Interface ----------"
echo
sleep 2


svn checkout https://subversion.assembla.com/svn/billing_svn/ /var/www/html/billing
chown -R asterisk:asterisk /var/www/html/billing
touch /etc/asterisk/extensions_magnus.conf
touch /var/www/html/billing/resources/asterisk/sip_magnus.conf
touch /var/www/html/billing/resources/asterisk/sip_magnus_user.conf
touch /var/www/html/billing/resources/asterisk/sip_magnus_register.conf
ln -s /var/www/html/billing/resources/asterisk/sip_magnus_register.conf /etc/asterisk/sip_magnus_register.conf
ln -s /var/www/html/billing/resources/asterisk/sip_magnus.conf /etc/asterisk/sip_magnus.conf
ln -s /var/www/html/billing/resources/asterisk/sip_magnus_user.conf /etc/asterisk/sip_magnus_user.conf
ln -s /var/www/html/billing/lib/adodb /var/www/html/billing/resources/asterisk/adodb
ln -s /var/www/html/billing/lib/phpagi /var/www/html/billing/resources/asterisk/phpagi
ln -s /var/www/html/billing/resources/asterisk/magnus.php /var/lib/asterisk/agi-bin/magnus
rm -rf /etc/asterisk/res_config_mysql.conf
cp -rf /var/www/html/billing/doc/InstallFiles/* /var/www/html/billing/protected/config
ln -s /var/spool/cron/root /var/www/html/billing/protected/commands/cron
cd /var/www/html/billing/resources/asterisk/
tar xzvf magnus.tgz


echo "[billing]
switch => Realtime/billing@

[billing-2]
switch => Realtime/billing-2@

[billing3]
switch => Realtime/billing-3@
" > /etc/asterisk/extensions_magnus.conf

echo "
[general]
enabled = yes

port = 5038
bindaddr = 0.0.0.0

[magnus]
secret = magnussolution
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
read = system,call,log,verbose,agent,user,config,dtmf,reporting,cdr,dialplan
write = system,call,agent,user,config,command,reporting,originate
" > /etc/asterisk/manager.conf


echo "#include sip_magnus.conf" >> /etc/asterisk/sip.conf
echo "#include sip_magnus_user.conf" >> /etc/asterisk/sip.conf
echo "#include extensions_magnus.conf" >> /etc/asterisk/extensions.conf

echo "[settings]
sipusers => mysql,general,pkg_sip
sippeers => mysql,general,pkg_sip
voicemail => mysql,general,pkg_voicemail_users
extensions => mysql,general,pkg_extensions
" > /etc/asterisk/extconfig.conf


echo
echo "----------- Installing the new Database ----------"
echo
sleep 2

mysql -u $1 -p$2 -e "create database billing";
mysql billing -u $1 -p$2 < /var/www/html/billing/doc/table_defaul.sql

chown asterisk:asterisk /var/lib/asterisk/agi-bin/magnus
chmod +x /var/www/html/billing/resources/asterisk/magnus.php
chown -R asterisk:asterisk /var/lib/php/session/
chown -R asterisk:asterisk /etc/asterisk
chown -R asterisk:asterisk /var/www/html/billing


echo "[general]
dbhost = 127.0.0.1
dbname = billing
dbuser = $1
dbpass = $2
" > /etc/asterisk/res_mysql.conf


svn update https://subversion.assembla.com/svn/billing_svn/ /var/www/html/billing

echo "
1 * * * * php /var/www/html/billing/cron.php NotifyClient
1 22 * * * php /var/www/html/billing/cron.php DidCheck
1 23 * * * php /var/www/html/billing/cron.php PlanCheck
* * * * * php /var/www/html/billing/cron.php MasiveCall
* * * * * php /var/www/html/billing/cron.php Sms
0 2 * * * php /var/www/html/billing/cron.php Backup
1 * * * * php /var/www/html/billing/cron.php CuentaDigital
0,15,30,45 * * * * php /var/www/html/billing/cron.php Dineromail
2 * * * * php /var/www/html/billing/cron.php UpdateMysql
0 * * * * svn update https://subversion.assembla.com/svn/billing_svn/ /var/www/html/billing
" > /var/spool/cron/root

php /var/www/html/billing/cron.php UpdateMysql

echo "
[general]
bindaddr=0.0.0.0
bindport=5060
context = billing
dtmfmode=RFC2833
disallow=all
allow=g729
allow=g723
allow=ulaw
allow=alaw
allow=gsm
language=br
rtcachefriends=yes
srvlookup=yes
rtptimeout =10
rtpholdtimeout=30
allowsubscribe = no
alwaysauthreject=yes
rtupdate=yes

#include sip_magnus_register.conf
#include sip_magnus.conf
#include sip_magnus_user.conf
" > /etc/asterisk/sip.conf


echo
echo
echo ===============================================================
echo
echo Congratulations! You have installed Magnus Billing Server
echo
echo ===============================================================
echo
sleep 3



  


2. Re: Converter um arquivo .sh (Centos) para .sh (Ubuntu)

Estefanio Brunhara
stefaniobrunhara

(usa CentOS)

Enviado em 18/04/2013 - 12:31h

É grandinho este script kkk, Bom seria se alguém já tivesse feito isto mas, crie um ambiente de teste rode o script, e vai postando os erros, que a turma vai respondendo, mas você também precisa ter uma noção boa de script, se não só se alguém resolver fazer tudo do zero, ou se esta maquina vai ser dedicada somete para servidor voip, porque não instalar o centos?


3. Re: Converter um arquivo .sh (Centos) para .sh (Ubuntu)

daniel
danfra

(usa Ubuntu)

Enviado em 18/04/2013 - 14:52h

Realmente n quero isso dos amigos, mas como nao conheco mto bem o Centos fica dificil de saber o que mudar, eu sei que o yum trocarei p/ apt-get, mas o restante fico a ver navios...

Se ajuda em alguma coisa, quando eu dou o comando ./install.sh root senha ele dá esse erro:

ASTERISK Error: please check install Asterisk and try again!

acredito que tenha que mudar algo aqui "grep pid > /dev/null", talves no ubuntu seja dev/"alguma outra coisa"....


4. Re: Converter um arquivo .sh (Centos) para .sh (Ubuntu)

Alberto Federman Neto.
albfneto

(usa openSUSE)

Enviado em 18/04/2013 - 17:30h

de inicio, não mude nada.
tente executar e reporte os erros.

cd /
cd pasta onde está o install.sh
sudo chmod +x install.sh
./install.sh

e poste os erros quer aparecem


5. Re: Converter um arquivo .sh (Centos) para .sh (Ubuntu)

Estefanio Brunhara
stefaniobrunhara

(usa CentOS)

Enviado em 19/04/2013 - 14:12h

danfra escreveu:

ASTERISK Error: please check install Asterisk and try again!




Altere a linha "service asterisk status|grep pid > /dev/null" para "/etc/init.d/asterisk status | grep pid > /dev/null"

veja

/etc/init.d/asterisk status | grep pid > /dev/null
if [ $? = 0 ];then
echo Asterisk is running
else
echo
echo "ASTERISK Error: please check install Asterisk and try again!"
echo
exit
fi


A parte do script que esta abaixo, você pode apagar, ela testa a versão do centos desativa o selinux e busca o repositório para faze a instalação dos pacotes, como você esta usando o debiam, e você já deve ter instalado as mídias do debiam não vai fazer falta, e só um LUXO do script.

Não sei qual é o equivalente para o debiam do selinux, mas acredito que você não vai ter problemas.


VERSION=$(awk '{print $3}' /etc/redhat-release)
if [[ "$VERSION" =~ ^6 ]]; then
VERSION='6'
else
VERSION='5'
fi;

cat /etc/selinux/config | grep SELINUX=enforcing > /dev/null

if [ $? = 0 ]
then
echo "Disabling SELINUX and iptables..."
sed 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config > borra && mv -f borra /etc/selinux/config
chkconfig iptables off
else

echo "Oops, looks like SELINUX is disabled..."
chkconfig iptables off
fi


if [[ $VERSION = '5' ]]; then

rpm --import http://yum.jasonlitka.com/RPM-GPG-KEY-jlitka

touch /etc/yum.repos.d/utterramblings.repo
echo '[utterramblings]
name=Jasons Utter Ramblings Repo
baseurl=http://yum.jasonlitka.com/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://yum.jasonlitka.com/RPM-GPG-KEY-jlitka
' > /etc/yum.repos.d/utterramblings.repo
fi








Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts