|
|
|
@ -108,12 +108,16 @@ function criar_banco_pbx(){
|
|
|
|
|
function inserir_sql(){ |
|
|
|
|
cd /var/lib/postgresql/ |
|
|
|
|
|
|
|
|
|
file_sql=$(find ${TAR_DATABASE:0:-7}/* -type f ) |
|
|
|
|
for sql in $file_sql; |
|
|
|
|
do |
|
|
|
|
sudo -u postgres psql -d pbx -f "$sql" |
|
|
|
|
echo "$sql" |
|
|
|
|
[ $? -ne 0 ] && sair_instalacao |
|
|
|
|
# Quantidade de thread para fazer o restore |
|
|
|
|
num_cpu=$(lscpu|grep -E "^CPU\(s\):" | sed 's/: \+/-/g' |awk -F- '{print $2}') |
|
|
|
|
num_thread=$(lscpu|grep -E "^Thread\(s\).*:" | sed 's/: \+/-/g' |awk -F- '{print $2}') |
|
|
|
|
thread_restore=$( expr "$num_cpu" \* "$num_thread" ) |
|
|
|
|
|
|
|
|
|
sudo -iu postgres psql -d "pbx" -c "DROP SCHEMA public CASCADE;" |
|
|
|
|
if ! sudo -iu postgres /bin/pg_restore -v -Fc --jobs="$thread_restore" -d pbx /var/lib/postgresql/database/pbx-1.8.1.db |
|
|
|
|
then |
|
|
|
|
echo "não foi possível resturar, colocar o banco de dados" |
|
|
|
|
sair_instalacao 28 |
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -156,7 +160,7 @@ function parar_servicos_antes_instalacao(){
|
|
|
|
|
|
|
|
|
|
function sair_instalacao(){ |
|
|
|
|
|
|
|
|
|
/bin/rm -rf /tmp/app_install.pid |
|
|
|
|
/bin/rm -f /tmp/app_install.pid |
|
|
|
|
cd $path_arquivo |
|
|
|
|
rm -rf $path_arquivo/*/ |
|
|
|
|
rm -rf $path_arquivo/*.tar.gz |
|
|
|
@ -176,10 +180,10 @@ function mudar_password(){
|
|
|
|
|
|
|
|
|
|
function delete_usuario(){ |
|
|
|
|
|
|
|
|
|
[ -n "$(cat /etc/passwd | grep -iE "^$1")" ] && /usr/sbin/userdel -fr $1 2> /dev/null |
|
|
|
|
[ -n "$(cat /etc/group | grep -iE "^$1")" ] && /usr/sbin/groupdel $1 2> /dev/null |
|
|
|
|
[ -n "$(cat /etc/passwd | grep -iE "^$1")" ] && /usr/sbin/userdel -f $1 2> /dev/null |
|
|
|
|
[ -n "$(cat /etc/group | grep -iE "^$1")" ] && /usr/sbin/groupdel $1 2> /dev/null |
|
|
|
|
|
|
|
|
|
return 0 |
|
|
|
|
return 0 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -187,19 +191,21 @@ function criar_usuario_limitado(){
|
|
|
|
|
|
|
|
|
|
#excluí usuário |
|
|
|
|
if [ -n "$(cat /etc/passwd | grep -i ^$1:)" ] ; then |
|
|
|
|
delete_usuario $1 |
|
|
|
|
fi |
|
|
|
|
delete_usuario $1 |
|
|
|
|
[ -d "/home/$1" ] && rm -rf /home/$1 |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
/usr/sbin/groupadd $1 &> /dev/null |
|
|
|
|
/usr/sbin/useradd -s /usr/bin/rbash -m $1 -g $1 &> /dev/null |
|
|
|
|
|
|
|
|
|
/usr/sbin/groupadd $1 &> /dev/null |
|
|
|
|
/usr/sbin/useradd -s /usr/bin/rbash -m $1 -g $1 &> /dev/null |
|
|
|
|
/usr/bin/mkdir /home/$1/bin |
|
|
|
|
if [ ! -d "/home/$1/bin" ] && /usr/bin/mkdir /home/$1/bin |
|
|
|
|
|
|
|
|
|
## Restringir permissões do usuário manutenção |
|
|
|
|
## Restringir permissões do usuário manutenção |
|
|
|
|
echo "readonly PATH=/home/$1/bin |
|
|
|
|
export PATH" >> /home/$1/.bashrc |
|
|
|
|
|
|
|
|
|
ln -s /sbin/reboot /home/$1/bin/reiniciar |
|
|
|
|
ln -s /sbin/halt /home/$1/bin/desligar |
|
|
|
|
[ ! -f "/home/$1/bin/reiniciar" ] && ln -s "/sbin/reboot" "/home/$1/bin/reiniciar" |
|
|
|
|
[ ! -f "/home/$1/bin/desligar" ] && ln -s "/sbin/halt" "/home/$1/bin/desligar" |
|
|
|
|
|
|
|
|
|
[ $1 == "manutencao" ] && echo "if [[ -f /home/$1/manutencao.sh ]];then /home/manutencao/manutencao.sh; else echo \"Sem script de manutencao.\";fi" >> /home/$1/.bashrc |
|
|
|
|
[ $1 == "manutencao" ] && echo "exit" >> /home/$1/.bashrc |
|
|
|
@ -213,13 +219,14 @@ function criar_usuario(){
|
|
|
|
|
#excluí usuário |
|
|
|
|
if [ -n "$(cat /etc/passwd | grep -i ^$1:)" ] || [ -n "$(cat /etc/group| grep -iE "^$1")" ] |
|
|
|
|
then |
|
|
|
|
delete_usuario $1 |
|
|
|
|
fi |
|
|
|
|
delete_usuario $1 |
|
|
|
|
[ -d "/home/$1" ] && rm -rf /home/$1 |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
/usr/sbin/groupadd $1 2> /dev/null |
|
|
|
|
/usr/sbin/useradd -s /usr/bin/bash $([ -n "$3" ] && echo "-d" "$3" || echo "-m" ) $1 -g $1 2> /dev/null |
|
|
|
|
/usr/sbin/groupadd $1 2> /dev/null |
|
|
|
|
/usr/sbin/useradd -s /usr/bin/bash $([ -n "$3" ] && echo "-d" "$3" || echo "-m" ) $1 -g $1 2> /dev/null |
|
|
|
|
|
|
|
|
|
mudar_password $1 $2 |
|
|
|
|
mudar_password $1 $2 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -233,7 +240,7 @@ function verificar_encode(){
|
|
|
|
|
read -n 1 resposta |
|
|
|
|
echo "" |
|
|
|
|
if [[ $resposta != +(s|S|y|Y|sim|SIM) ]] ; then |
|
|
|
|
/bin/rm -rf /tmp/app_install.pid |
|
|
|
|
/bin/rm -f /tmp/app_install.pid |
|
|
|
|
exit |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
@ -255,7 +262,7 @@ function verificar_encode(){
|
|
|
|
|
for i in {5..1};do sleep 1 && echo -n "$i ";done |
|
|
|
|
echo "" |
|
|
|
|
echo "Recomece a atualizacao" |
|
|
|
|
/bin/rm -rf /tmp/app_install.pid |
|
|
|
|
/bin/rm -f /tmp/app_install.pid |
|
|
|
|
[ -e /sbin/reboot ] && /sbin/reboot |
|
|
|
|
reboot |
|
|
|
|
fi |
|
|
|
@ -271,7 +278,7 @@ function ja_instalado(){
|
|
|
|
|
read -n 1 resposta |
|
|
|
|
echo "" |
|
|
|
|
if [[ $resposta != +(s|S|y|Y|sim|SIM) ]] ; then |
|
|
|
|
/bin/rm -rf /tmp/app_install.pid |
|
|
|
|
/bin/rm -f /tmp/app_install.pid |
|
|
|
|
cd $path_arquivo |
|
|
|
|
[ 0 -eq $? ] && /bin/rm -rf $(ls -d */) |
|
|
|
|
/bin/rm -rf *.tar.gz |
|
|
|
@ -314,13 +321,13 @@ function definir_timezone(){
|
|
|
|
|
TIMEZONE=$(dialog --stdout --default-item America/Cuiaba --radiolist " CONFIGURE O TIMEZONE " 0 0 0 $DIALOGDATA) |
|
|
|
|
|
|
|
|
|
# Apertou CANCELAR ou ESC, sair... |
|
|
|
|
[ $? -ne 0 ] && /bin/rm -rf /tmp/sip_atualiza.pid && exit |
|
|
|
|
[ $? -ne 0 ] && /bin/rm -f /tmp/app_atualiza.pid && exit |
|
|
|
|
OPCAO=$(echo $TIMEZONE | sed "s/,/\\n/g") |
|
|
|
|
|
|
|
|
|
if ! [ -z "$OPCAO" ] ; then |
|
|
|
|
/usr/bin/timedatectl set-timezone $OPCAO |
|
|
|
|
break |
|
|
|
|
fi |
|
|
|
|
if ! [ -z "$OPCAO" ] ; then |
|
|
|
|
/usr/bin/timedatectl set-timezone $OPCAO |
|
|
|
|
break |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
done |
|
|
|
|
|
|
|
|
@ -374,6 +381,7 @@ function criar_directory_app(){
|
|
|
|
|
|
|
|
|
|
[ -d /etc/asterisk ] && rm -rf /etc/asterisk/ |
|
|
|
|
|
|
|
|
|
return 0 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -646,31 +654,35 @@ server_postgresql &
|
|
|
|
|
PID_PG=$! |
|
|
|
|
cd $path_arquivo |
|
|
|
|
|
|
|
|
|
config_msmt |
|
|
|
|
config_msmt & |
|
|
|
|
|
|
|
|
|
rota_vpn |
|
|
|
|
rota_vpn & |
|
|
|
|
|
|
|
|
|
config_sshd_sudo |
|
|
|
|
config_sshd_sudo & |
|
|
|
|
|
|
|
|
|
config_ntp |
|
|
|
|
config_ntp & |
|
|
|
|
|
|
|
|
|
apache2_e_php |
|
|
|
|
apache2_e_php & |
|
|
|
|
|
|
|
|
|
#DNSMASQ |
|
|
|
|
DNSRESOLV=$(cat /etc/resolv.conf | grep -v "#" | grep -v "127.0.0.1" | wc -l) |
|
|
|
|
|
|
|
|
|
if ! [ "$DNSRESOLV" = "0" ] ; then |
|
|
|
|
|
|
|
|
|
/bin/cp -Rapf /etc/dnsmasq.conf /etc/dnsmasq.conf.$(date +%F-%H-%M-%S) |
|
|
|
|
sed -i "/\(^server=.*\)/d" /etc/dnsmasq.conf |
|
|
|
|
for i in $(cat /etc/resolv.conf | grep -v "#" | grep -v "127.0.0.1" | awk {'print $2'}) ; do echo "server=$i" >> /etc/dnsmasq.conf ; done |
|
|
|
|
/bin/cp -Rapf /etc/dnsmasq.conf /etc/dnsmasq.conf.$(date +%F-%H-%M-%S) |
|
|
|
|
sed -i "/\(^server=.*\)/d" /etc/dnsmasq.conf |
|
|
|
|
for i in $(cat /etc/resolv.conf | grep -v "#" | grep -v "127.0.0.1" | awk {'print $2'}) ; do echo "server=$i" >> /etc/dnsmasq.conf ; done |
|
|
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
|
|
echo "Nao ha DNS configurado!" |
|
|
|
|
echo "Nao ha DNS configurado!" |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
wait |
|
|
|
|
|
|
|
|
|
/hdaux/utilitarios/scripts/permissoes_atualizacao.sh |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "Instalaçao finalizada" |
|
|
|
|
|
|
|
|
|
sair_instalacao 0 |
|
|
|
|