#!/bin/sh
progress () {
C=0;
while test "`ps -p $2 | tail -n 1 | awk '{print $1}'`" = "$2"
do
case `expr $C % 4` in
0) char='[/]';;
1) char='[-]';;
2) char='[\]';;
3) char='[|]' ;;
esac
sleep .5
echo -n "\r$1...$char"
C=`expr $C + 1`
done
echo "\r$1...готово"
}
check_ec () {
if test -e /tmp/install.ec
then
if test "`cat /tmp/install.ec`" != "0"
then
echo 'Subprocess error'
exit 1
fi
else
echo 'Subprocess error'
exit 1
fi
rm /tmp/install.ec > /dev/null 2>&1
}
extract_files () {
for item in `tar xzf $1 info/files.list -O`;
do
if test "`echo $item | cut -c-1`" = "/"
then
prefix=''
else
prefix=$2/
fi
if test -e $prefix`echo $item | awk -F '@' '{print $1}'`
then
if test -e $prefix`echo $item | awk -F '@' '{print $1}'`'.old'
then
echo -n 'Backup of "'$prefix`echo $item | awk -F '@' '{print $1}'`'" exists, remove it? (y/n)[n]: '
if test -z $delete
then
read -r answear
else
answear=$delete
echo $answear
fi
case $answear in
'y') rm -rf $prefix`echo $item | awk -F '@' '{print $1}'`'.old';;
*) echo 'Ok, not touching...';;
esac
fi
echo $prefix`echo $item | awk -F '@' '{print $1}'`' exists, renaming to '$prefix`echo $item | awk -F '@' '{print $1}'`'.old...'
mv $prefix`echo $item | awk -F '@' '{print $1}'` $prefix`echo $item | awk -F '@' '{print $1}'`.old
fi
echo 'Extracting "'`echo $item | awk -F '@' '{print $2}'`'" to "'$prefix`echo $item | awk -F '@' '{print $1}'`'"...'
extract_dir=`echo $prefix$item | awk -F '@' '{print $1}' | tr '/' '\n' | head -n -1 | tr '\n' '/'`
mkdir -p $extract_dir
tar xzf $1 --strip-components=1 -C $extract_dir files/`echo $item | awk -F '@' '{print $2}'`
if test "`echo $item | awk -F '@' '{print $2}'`" != "`echo $item | awk -F '@' '{print $1}' | rev | cut -d'/' -f-1 | rev`"
then
echo 'Moving "'$extract_dir`echo $item | awk -F '@' '{print $2}'`'" to "'`echo $item | awk -F '@' '{print $1}'`'"'
mv $extract_dir`echo $item | awk -F '@' '{print $2}'` `echo $item | awk -F '@' '{print $1}'`
fi
done
}
change_permissions () {
for item in `tar xzf $1 info/perm -O`;
do
if test "`echo $item | awk -F'@' '{print $3}' | cut -c-1`" = "/"
then
chown -R `echo $item | awk -F'@' '{print $1}'` `echo $item | awk -F'@' '{print $3}'`
chmod -R `echo $item | awk -F'@' '{print $2}'` `echo $item | awk -F'@' '{print $3}'`
else
if test "`echo $item | awk -F'@' '{print $3}'`" = ""
then
for a in `tar xzf $1 info/files.list -O`
do
if test "`echo $a | awk -F'@' '{print $1}' | cut -c-1`" = "/"
then
chown -R `echo $item | awk -F'@' '{print $1}'` `echo $a | awk -F'@' '{print $1}'`
chmod -R `echo $item | awk -F'@' '{print $2}'` `echo $a | awk -F'@' '{print $1}'`
else
chown -R `echo $item | awk -F'@' '{print $1}'` $2/`echo $a | awk -F'@' '{print $1}'`
chmod -R `echo $item | awk -F'@' '{print $2}'` $2/`echo $a | awk -F'@' '{print $1}'`
fi
done
else
chown -R `echo $item | awk -F'@' '{print $1}'` $2/`echo $item | awk -F'@' '{print $3}'`
chmod -R `echo $item | awk -F'@' '{print $2}'` $2/`echo $item | awk -F'@' '{print $3}'`
fi
fi
done
}
make_symlinks () {
if tar xzf $1 info/links -O > /dev/null 2>&1
then
for item in `tar xzf $1 info/links -O`;
do
mkdir -p `echo $item | awk -F'@' '{print $2}' | rev | cut -d '/' -f2- | rev`
ln -s `echo $item | awk -F'@' '{print $1}'` `echo $item | awk -F'@' '{print $2}'`
done
fi
}
do_pg_query () {
if test "`echo $1 | rev | cut -d'.' -f-2 | rev`" = "tar.gz"
then
if tar xzf $1 info/pg.list -O > /dev/null 2>&1
then
for item in `tar xzf $1 info/pg.list -O`
do
echo "Выполняется запрос в PostgreSQL '$item'..."
export PGPASSWORD=$3
echo `tar xzf $1 sql/$item -O` | psql -hlocalhost -U $2 -w $4 > /dev/null 2>&1
done
fi
else
echo "Выполняется запрос в PostgreSQL '$1'..."
export PGPASSWORD=$3
cat $1 | echo
cat $1 | gzip -d | psql -hlocalhost -U $2 -w $4 > /dev/null 2>&1
fi
}
do_my_query () {
if test "`echo $1 | rev | cut -d'.' -f-2 | rev`" = "tar.gz"
then
if tar xzf $1 info/mysql.list -O > /dev/null 2>&1
then
for item in `tar xzf $1 info/mysql.list -O`
do
echo 'Doing Mysql Query in '$item'...'
echo `tar xzf $1 sql/$item -O` | mysql -u$2 -p$3 $4
done
fi
else
echo 'Doing Mysql Query in '$1'...'
cat $1 | gzip -d | mysql -u$2 -p$3 $4
fi
}
do_ms_query () {
if test "`echo $1 | rev | cut -d'.' -f-2 | rev`" = "tar.gz"
then
if tar xzf $1 info/mssql.list -O > /dev/null 2>&1
then
for item in `tar xzf $1 info/mssql.list -O`
do
echo 'Doing MSSQL Query in '$item'...'
echo "USE $4
GO
`tar xzf $1 sql/$item -O`" | tsql -S $5 -U $2 -P $3
done
fi
else
echo 'Doing Mysql Query in '$1'...'
cat $1 | gzip -d | mysql -u$2 -p$3 $4
fi
}
check_lic () {
token=`wget $ins_serv/check.php?lic=$lic -q -O -`
if test $? != 0
then
echo 'Сервер установки недоступен. Выход.'
exit 1
else
while test "$token" = "False" || test "$token" = ""
do
echo "Лицензионный ключ неверен\nПроверьте ключ и введите снова:"
read lic
token=`wget $ins_serv/check.php?lic=$lic -q -O -`
if test $? != 0
then
echo 'Сервер установки недоступен. Выход.'
exit 1
fi
done
fi
}
execute_shell () {
if tar xzf $1 info/shell -O > /dev/null 2>&1
then
echo "Запуск скрипта"
for item in `tar xzf $1 info/shell -O`;
do
tar xzf $1 --strip-components=1 -C $shell_dir shell/$item
bash $shell_dir/$item
done
fi
}
www_dir='/var/www'
ins_serv='http://install.z-taxi.ru'
apt_cmd='apt-get -y --force-yes'
dahdi_dist='dahdi-linux-complete-2.9.1.1+2.9.1.tar.gz'
dahdi_dist2100='dahdi-linux-complete-2.10.0.1+2.10.0.1.tar.gz'
dahdi_dist2102='dahdi-linux-complete-2.10.2+2.10.2.tar.gz'
uid=$(id -u)
[ $uid -ne 0 ] && { echo "Для запуска скрипта необходимы root права."; exit 1; }
ast_dist='asterisk-11.9.0.tar.gz'
tmp_dir='/tmp/build'
shell_dir='/tmp/shell'
cur_dir=`pwd`
mysql_root_pass=`wget $ins_serv/passgen.php -q -O -`
postgres_pass=`wget $ins_serv/passgen.php -q -O -`
echo 'mysql-server mysql-server/root_password password root' | debconf-set-selections
echo 'mysql-server mysql-server/root_password_again password root' | debconf-set-selections
echo 'proftpd-basic shared/proftpd/inetd_or_standalone select standalone' | debconf-set-selections
mysql_user='zebra'
mysql_pass='Zy3puv5CBA23MrJv'
mysql_db='zebra'
pg_user='ivr'
pg_pass='ivr'
pg_db='ivr'
as_pg_user='asterisko'
as_pg_pass='qazWSX123'
as_pg_db='asterisko'
tmp_list=''
if test -e /var/www/zebra.lic
then
if test -n "`cat /var/www/zebra.lic | head -n1 | tr '\n' ' ' | sed 's/ //'`"
then
echo 'Получение ключа из файла лицензии'
lic=`cat /var/www/zebra.lic | head -n1 | tr '\n' ' ' | sed 's/ //'`
fi
fi
for i
do
case "`echo $i | awk -F '=' '{print $1}'`" in
'--lic') if test -n "`echo $i | awk -F '=' '{print $2}'`"
then
lic=`echo $i | awk -F '=' '{print $2}'`;
else
echo 'Лицензионный ключ не указан.';
fi;;
'-y') delete='y';;
*) tmp_list="$tmp_list $i";;
esac
done
check_lic
rm /tmp/install.ec > /dev/null 2>&1
$apt_cmd update > /tmp/update.log 2>&1 && echo $? > /tmp/install.ec &
pid=$!
progress 'Обновление базы пакетов' $pid
check_ec
rm /tmp/install.ec > /dev/null 2>&1
$apt_cmd install python2.7-pyodbc python2.7-psycopg2 proftpd tdsodbc odbcinst openssh-server linux-headers-`uname -r` flex ncurses-dev libssl-dev make libsqlite3-dev libncurses-dev gcc g++ libxml2-dev libxml2-utils libsox-dev sox libsox-fmt-mp3 mpg123 lame zlibc zlib-bin libcrypto++-dev libcrypto++-utils uuid-dev pgtune freetds-bin freetds-common freetds-dev libapache2-mod-suphp php-apc php-pear php5 php5-cgi php5-cli php5-common php5-curl php5-dev php5-gd php5-imagick php5-mcrypt php5-memcache php5-mysql php5-pgsql php5-sybase php5-fpm suphp-common nodejs memcached mysql-server postgresql nginx curl apache2 gtk+-2.0 > /tmp/apt-get.log 2>&1 && echo $? > /tmp/install.ec &
pid=$!
progress 'Установка необходимого ПО' $pid
check_ec
$apt_cmd install default-jre-headless libwxbase2.8-0 libwxgtk2.8-0 > /tmp/apt-get.log 2>&1 && echo $? > /tmp/install.ec &
pid=$!
progress 'Выбор зависимостей erlang' $pid
$apt_cmd -f install >> /tmp/apt-get.log 2>&1 && echo $? > /tmp/install.ec &
pid=$!
progress 'Установка зависимостей erlang' $pid
wget --progress=dot $ins_serv/erl/esl-erlang_16.b.3-2~ubuntu~saucy_`uname -i`.deb -O /tmp/build/esl-erlang.deb 2>&1 | grep --line-buffered "%" | sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bDownloading...%4s", $2)}'
echo
rm /tmp/install.ec > /dev/null 2>&1
dpkg -i /tmp/build/esl-erlang.deb >> /tmp/apt-get.log 2>&1 && echo $? > /tmp/install.ec &
rm -rf /etc/apache2/sites-enabled/* /etc/nginx/sites-enabled/* > /dev/null 2>&1
mkdir -p $tmp_dir
mkdir -p $shell_dir
echo 'Укажите версию Dahdi, которую необходимо установить'
echo '1 - 2.9'
echo '2 - 2.10.2'
read dahdi_ver
if [ "$dahdi_ver" = 2 ]
then
dahdi_dist=$dahdi_dist2102
fi
echo 'Установка Dahdi (log is here: /tmp/dahdi_inst.log)'
echo > /tmp/dahdi_inst.log 2>&1 &
wget --progress=dot $ins_serv/ast/$dahdi_dist -O /tmp/build/$dahdi_dist 2>&1 | grep --line-buffered "%" | sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bDownloading...%4s", $2)}'
echo
tar xzf $tmp_dir/$dahdi_dist -C $tmp_dir
cd $tmp_dir/`echo $dahdi_dist | sed 's/.tar.gz//'`/linux
rm /tmp/install.ec > /dev/null 2>&1
make >> /tmp/dahdi_inst.log 2>&1 && echo $? > /tmp/install.ec &
progress 'Создание модуля ядра для dahdi' $!
check_ec
rm /tmp/install.ec > /dev/null 2>&1
make install >> /tmp/dahdi_inst.log 2>&1 && echo $? > /tmp/install.ec &
progress 'Установка модуля ядра для dahdi' $!
check_ec
cd $tmp_dir/`echo $dahdi_dist | sed 's/.tar.gz//'`/tools
rm /tmp/install.ec > /dev/null 2>&1
./configure >> /tmp/dahdi_inst.log 2>&1 && echo $? > /tmp/install.ec &
progress 'Настрока инстументов Dahdi' $!
check_ec
rm /tmp/install.ec > /dev/null 2>&1
make >> /tmp/dahdi_inst.log 2>&1 && echo $? > /tmp/install.ec &
progress 'Создание инстументов Dahdi' $!
check_ec
rm /tmp/install.ec > /dev/null 2>&1
make install >> /tmp/dahdi_inst.log 2>&1 && echo $? > /tmp/install.ec &
progress 'Установка инстументов Dahdi' $!
check_ec
rm /tmp/install.ec > /dev/null 2>&1
make config >> /tmp/dahdi_inst.log 2>&1 && echo $? > /tmp/install.ec &
progress 'Создание конфигурации' $!
check_ec
echo -n 'Запуск Dahdi...'
/etc/init.d/dahdi restart >> /tmp/dahdi_inst.log 2>&1
echo 'done'
echo 'Установка Asterisk (log is here: /tmp/asterisk_inst.log)'
echo > /tmp/asterisk_inst.log 2>&1 &
wget --progress=dot $ins_serv/ast/$ast_dist -O /tmp/build/$ast_dist 2>&1 | grep --line-buffered "%" | sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bDownloading...%4s", $2)}'
echo
tar xzf $tmp_dir/$ast_dist -C $tmp_dir
cd $tmp_dir/`echo $ast_dist | sed 's/.tar.gz//'`
rm /tmp/install.ec > /dev/null 2>&1
./configure --prefix=/usr/local/asterisko --with-dahdi=/usr/include/dahdi --disable-asteriskssl >> /tmp/asterisk_inst.log 2>&1 && echo $? > /tmp/install.ec &
progress 'Конфигурация сборки' $!
check_ec
rm /tmp/install.ec > /dev/null 2>&1
make >> /tmp/asterisk_inst.log 2>&1 && echo $? > /tmp/install.ec &
progress 'Сборка' $!
check_ec
rm /tmp/install.ec > /dev/null 2>&1
make install >> /tmp/asterisk_inst.log 2>&1 && echo $? > /tmp/install.ec &
progress 'Установка' $!
check_ec
rm /tmp/install.ec > /dev/null 2>&1
make config >> /tmp/asterisk_inst.log 2>&1 && echo $? > /tmp/install.ec &
progress 'Создание конфигурации' $!
check_ec
rm /tmp/install.ec > /dev/null 2>&1
make samples >> /tmp/asterisk_inst.log 2>&1 && echo $? > /tmp/install.ec &
progress 'Создание семплов' $!
check_ec
echo -e 'Запускаем Asterisk'
/etc/init.d/asterisk start >> /tmp/asterisk_inst.log 2>&1
echo 'OK'
cd $cur_dir
pg_version=`psql --version | awk '{print $3}' | awk -F '.' '{printf ("%d.%d",$1,$2)}'`
echo -n 'Configuring postgresql v'$pg_version'...'
pgtune -M `expr \`free | head -n 2 | tail -n 1 | awk '{print $2}'\` / 2 '*' 1024` -i /etc/postgresql/$pg_version/main/postgresql.conf -o /etc/postgresql/$pg_version/main/postgresql.conf
echo 'max_connections = 100' >> /etc/postgresql/$pg_version/main/postgresql.conf
/etc/init.d/postgresql restart > /dev/null 2>&1
su postgres -c psql << EOF
ALTER USER postgres with PASSWORD '$postgres_pass';
CREATE USER ivr WITH PASSWORD 'ivr';
CREATE DATABASE ivr;
GRANT ALL PRIVILEGES ON DATABASE ivr to ivr;
CREATE USER asterisko WITH PASSWORD 'qazWSX123';
CREATE DATABASE asterisko;
GRANT ALL PRIVILEGES ON DATABASE asterisko to asterisko;
EOF
echo 'postgres:'$postgres_pass | chpasswd
echo 'готово'
echo -n 'Настройка MySQL...'
mysql -uroot -proot mysql << EOF
FLUSH PRIVILEGES;
CREATE USER '$mysql_user'@'localhost' IDENTIFIED BY '$mysql_pass';
CREATE DATABASE $mysql_db;
UPDATE user SET password=PASSWORD("$mysql_root_pass") where User='root';
USE $mysql_db;
GRANT ALL PRIVILEGES ON $mysql_db TO '$mysql_user'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON $mysql_db.* to '$mysql_user'@'localhost';
FLUSH PRIVILEGES;
EOF
echo 'готово'
echo 'Установка ioncube...'
wget --progress=dot $ins_serv/ioncube/ioncube_loaders_lin_`uname -i`.tar.gz -O /tmp/build/ioncube.tar.gz 2>&1 | grep --line-buffered "%" | sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bDownloading...%4s", $2)}'
tar xzf /tmp/build/ioncube.tar.gz -C /usr/local
echo "zend_extension=/usr/local/ioncube/ioncube_loader_lin_`php -v | head -n 1 | awk '{print $2}' | awk -F '.' '{print $1\".\"$2}'`.so" > /etc/php5/fpm/conf.d/0-ioncube.ini
echo "zend_extension=/usr/local/ioncube/ioncube_loader_lin_`php -v | head -n 1 | awk '{print $2}' | awk -F '.' '{print $1\".\"$2}'`.so" > /etc/php5/cgi/conf.d/0-ioncube.ini
echo "zend_extension=/usr/local/ioncube/ioncube_loader_lin_`php -v | head -n 1 | awk '{print $2}' | awk -F '.' '{print $1\".\"$2}'`.so" > /etc/php5/cli/conf.d/0-ioncube.ini
echo 'готово'
echo -n 'Configuring suphp...'
sed 's/min_uid=100/min_uid=0/' -i /etc/suphp/suphp.conf
sed 's/min_gid=100/min_gid=0/' -i /etc/suphp/suphp.conf
echo 'готово'
echo -n 'Настрока PHP '`php -v 2> /dev/null | grep 5. | awk '{print $2}'`'...'
sed 's%listen = 127.0.0.1:9000%listen = /var/run/php5-fpm.sock%' -i /etc/php5/fpm/pool.d/www.conf
sed 's/;listen.owner = www-data/listen.owner = www-data/' -i /etc/php5/fpm/pool.d/www.conf
sed 's/;listen.group = www-data/listen.group = www-data/' -i /etc/php5/fpm/pool.d/www.conf
sed 's/;listen.mode = 0660/listen.mode = 0660/' -i /etc/php5/fpm/pool.d/www.conf
sed 's/upload_max_filesize = 2M/upload_max_filesize = 100M/' -i /etc/php5/fpm/php.ini
sed 's/post_max_size = 8M/post_max_size = 128M/' -i /etc/php5/fpm/php.ini
echo 'готово'
echo -n 'Настройка ProFTPd'
useradd -d/usr/local/asterisko/var/spool/asterisk/monitor/ -u999 -s/bin/false -p'$1$nfNYVhXQ$QN3DdP3iSIy0QZqTxRef2/' records
sed 's/# DefaultRoot/DefaultRoot/' -i /etc/proftpd/proftpd.conf
sed 's/# RequireValidShell/RequireValidShell/' -i /etc/proftpd/proftpd.conf
sed 's/start-stop-daemon --stop --signal $SIGNAL --quiet --pidfile "$PIDFILE"$/start-stop-daemon --stop --signal $SIGNAL --retry 1 --quiet --pidfile "$PIDFILE"/1' -i /etc/init.d/proftpd
/etc/init.d/proftpd restart
echo 'OK'
echo 'Установка основных пакетов.'
tmp_list=`wget "$ins_serv/check.php?token=$token&act=get&ftype=tar" -q -O -`
for i in $tmp_list
do
wget --progress=dot "$ins_serv/check.php?token=$token&file=$i" -O $tmp_dir/$i 2>&1 | grep --line-buffered "%" | sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bDownloading...%4s", $2)}'
echo 'Установка "'`tar xzf $tmp_dir/$i info/meta -O`'"'
extract_files $tmp_dir/$i $www_dir
change_permissions $tmp_dir/$i $www_dir
make_symlinks $tmp_dir/$i
do_my_query $tmp_dir/$i $mysql_user $mysql_pass $mysql_db
do_pg_query $tmp_dir/$i $pg_user $pg_pass $pg_db
if [ -n "`tar -tf $tmp_dir/$i | grep mssql.list`" ]
then
echo "Укажите параметры подключения к базе MSSQL"
echo "[Enter] по умолчанию"
echo -n "Пользователь ($mssql_user): "
read mssql_i_user
if [ -n "$mssql_i_user" ]
then
mssql_user=$mssql_i_user
fi
echo -n "Имя базы ($mssql_db): "
read mssql_i_db
if [ -n "$mssql_i_db" ]
then
mssql_db=$mssql_i_db
fi
echo -n "Пароль (ch....d): "
read mssql_i_pass
if [ -n "$mssql_i_pass" ]
then
mssql_pass=$mssql_i_pass
fi
echo -n "Имя сервера ($mssql_server): "
read mssql_i_server
if [ -n "$mssql_i_server" ]
then
mssql_server=$mssql_i_server
fi
do_ms_query $tmp_dir/$i $mssql_user $mssql_pass $mssql_db $mssql_server
fi
done
tmp_list=`wget "$ins_serv/check.php?token=$token&act=get&ftype=pg.sql" -q -O -`
for i in $tmp_list
do
wget --progress=dot "$ins_serv/check.php?token=$token&file=$i" -O $tmp_dir/$i 2>&1 | grep --line-buffered "%" | sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bDownloading...%4s", $2)}'
echo
if test "`echo $i | awk -F'.' '{print $2}'`" = $as_pg_db
then
do_pg_query $tmp_dir/$i $as_pg_user $as_pg_pass $as_pg_db
else
do_pg_query $tmp_dir/$i $pg_user $pg_pass $pg_db
fi
done
tmp_list=`wget "$ins_serv/check.php?token=$token&act=get&ftype=my.sql" -q -O -`
for i in $tmp_list
do
wget --progress=dot "$ins_serv/check.php?token=$token&file=$i" -O $tmp_dir/$i 2>&1 | grep --line-buffered "%" | sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bDownloading...%4s", $2)}'
echo
do_my_query $tmp_dir/$i $mysql_user $mysql_pass $mysql_db
done
echo 'Установка modules.'
tmp_list=`wget "$ins_serv/check.php?token=$token&act=get&ptype=modules" -q -O -`
for i in $tmp_list
do
wget --progress=dot "$ins_serv/check.php?token=$token&file=$i" -O $tmp_dir/$i 2>&1 | grep --line-buffered "%" | sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bDownloading...%4s", $2)}'
echo
echo 'Установка "'`tar xzf $tmp_dir/$i info/meta -O`'"'
extract_files $tmp_dir/$i $www_dir
change_permissions $tmp_dir/$i $www_dir
make_symlinks $tmp_dir/$i
do_my_query $tmp_dir/$i $mysql_user $mysql_pass $mysql_db
do_pg_query $tmp_dir/$i $pg_user $pg_pass $pg_db
if [ -n "`tar -tf $tmp_dir/$i | grep mssql.list`" ]
then
echo "Укажите параметры подключения к базе MSSQL"
echo "[Enter] по умолчанию"
echo -n "Пользователь ($mssql_user): "
read mssql_i_user
if [ -n "$mssql_i_user" ]
then
mssql_user=$mssql_i_user
fi
echo -n "Имя базы ($mssql_db): "
read mssql_i_db
if [ -n "$mssql_i_db" ]
then
mssql_db=$mssql_i_db
fi
echo -n "Пароль (ch....d): "
read mssql_i_pass
if [ -n "$mssql_i_pass" ]
then
mssql_pass=$mssql_i_pass
fi
echo -n "Имя сервера ($mssql_server): "
read mssql_i_server
if [ -n "$mssql_i_server" ]
then
mssql_server=$mssql_i_server
fi
do_ms_query $tmp_dir/$i $mssql_user $mssql_pass $mssql_db $mssql_server
fi
execute_shell $tmp_dir/$i
done
cat > $www_dir/key_pub.pem << EOF
-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAlY9/1FRSX8fQ7RBSXzP/
1/TehCYdKOKDCd87vPVHFSr7xfKbOrFHhv/v+psokSQ41evY4Z4QrbLPc5BXN0ox
e3TyZvkU3q7k4eL1MnFrDJSv8zL/CVV8UwYQttaaCJ7W3fPWzCebmkwT72FBf9hw
qojlYua2k7gWB0MArjWRtqregDu4m8Ybvr34XsuuIpMVEfCO9MzY8+VZZqsazkj6
e+DrDLPN+xNRQALToKzVoj5a8PBt/zka2zQ4cycgxpR/F1X8HCcDwGpiEjdDHtX1
MEWJ4AtafohdzB0HFBNlGxuKl9xcCSHtlnhkTbbsYZVm1wHu14yaSF/y2xCVoH10
IO9iT1XHwm4bAp3v5NPFSMrAExFLMNJwst3vwBVcANSLdXmpJbJYqOfoYhSIQqUH
Rl4sxMGz+mip0VW5/Dz9fSuRsUDDGM7iUirLnQjDz+dbWjhLgpXFbOQd1cNMSgkD
rMaSo1g1KR+e4AlCF4kSNwnFmll7pNFRtZzcJAcaLFELKzi3M2+EdkoPP9n6KCtC
gl7GGcQIFQD0RAvimdUOaAVBZtpBkvBfVq+e7x3ABu5D40OQDMNBBW47sb5bpgLI
Jq/tqTGJsIOcoJR/OtrSH3EB5xOMuIMTPEMzehxqm3FZ4VEkYqUJOTVWjsMhqBxB
uB6vn692msCqMOqgApJgJH0CAwEAAQ==
-----END PUBLIC KEY-----
EOF
touch $www_dir/zebra.lic
chown www-data:www-data $www_dir/zebra.lic
sed "/io.set/s/('origins',.*);/('origins',['`ifconfig eth0 | grep 'inet' | grep -v 'inet6' | awk '{print $2}' | sed 's/addr://'`:80','`wget $ins_serv/ip.php -O - 2> /dev/null`:80','127.0.0.1:80','localhost:80']);/g" -i /opt/swss/swss.js
sed "s/demo/$lic/" -i /opt/moongate/moongate.conf
echo 'Пароль PG="'$postgres_pass'"' > /tmp/pass
echo 'Пароль Mysql="'$mysql_root_pass'"' >> /tmp/pass
echo 'Перезапуск служб...'
/etc/init.d/postgresql restart
/etc/init.d/mysql restart
/etc/init.d/apache2 restart
/etc/init.d/nginx restart
service php5-fpm restart
service currentcall restart
service dnd-service restart
service hold-service restart
service queue-service restart
service sum-service restart
service swss restart
echo 'Настрока FreeTDS:'
/root/add_freetds.py
echo 'готово'
echo 'Готово.'
rm -rf $tmp_dir
rm -rf $shell_dir