Commit 5012b96c authored by root's avatar root

unifi

parent 983684e4
Pipeline #8736 canceled with stages
#!/bin/bash
# Script para Centos 7
function check_dialog
{
echo -e "Looking for dialog...\n\n"
if ! dialog &> /dev/null
then
echo -e "Not found\n"
echo -e "Installing dialog...\n\n"
yum -y install dialog
if [ $? -ne 0 ]
then
echo -e "\n***yum install dialog FAILED***\n\n"
fi
if ! dialog > /dev/null
then
echo -e "Dialog is requiered\n"
exit
fi
fi
}
function generate_files
{
cat > /tmp/inst1.txt <<EOF
epel-release
mongodb-org
java-1.8.0-openjdk
unzip
wget
EOF
}
function welcome
{
dialog --stdout --sleep 1 --backtitle "$BACKTITLE" \
--infobox " USB -SCRIPTS " \
5 17
}
function settings
{
if [ ! "$TERM" = "xterm-256color" ]
then
export NCURSES_NO_UTF8_ACS=1
fi
BACKTITLE="Issabel 4 netinstall"
setenforce 0
sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/selinux/config
adduser -r -s /bin/nologin ubnt
}
function add_repos
{
cat >/etc/yum.repos.d/mongodb-org-5.0.repo<<EOF
[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc
EOF
}
function yum_gauge
{
PACKAGES=$1 #Space separated list of packages.
TITLE=$2 #Window title
YUMCMD=$3 #install / update
dialog --backtitle "$BACKTITLE" --title "$TITLE" --gauge "Instalando..." 10 75 < <(
# Get total number of packages
n=$(echo $PACKAGES | wc -w);
# set counter - it will increase every-time a rpm install
i=0
#
# Start the for loop
#
# read each package from $PACKAGES array
# $f has filename
for p in $PACKAGES
do
# calculate progress
PCT=$(( 100*(++i)/n ))
# update dialog box
cat <<EOF
XXX
$PCT
Installing "$p"...
XXX
EOF
rpm --quiet -q $p
if [ $? -ne 0 ] || [ "$YUMCMD" = "update" ]
then
if ! yum $BETAREPO --nogpg -y $YUMCMD $p &>/dev/null
then
echo "$p: ERRO na instalação dos pacotes" >> /tmp/netinstall_errors.txt
fi
fi
done
)
}
function install_packages
{
yum clean all &> /dev/null
PACKAGES=$(cat /tmp/inst1.txt)
yum_gauge "$PACKAGES" "Instalando, aguarde..." install
}
function install_unifi
{
dialog --stdout --sleep 2 --backtitle "$BACKTITLE" --infobox \
"Baixando pacotes Unifi.." \ 5 35
wget https://dl.ui.com/unifi/7.1.65/UniFi.unix.zip -P /opt -q
dialog --stdout --sleep 2 --backtitle "$BACKTITLE" --infobox \
"instalando Unifi.." \ 5 35
unzip -qq /opt/UniFi.unix.zip -d /opt
chown -R ubnt:ubnt /opt/UniFi
rm -rf /opt/UniFi.unix.zip
}
function creating_service_unifi
{
dialog --stdout --sleep 2 --backtitle "$BACKTITLE" --infobox \
"Criando serviço.." \ 5 35
cat >/etc/systemd/system/unifi.service<<EOF
#
# Systemd unit file for UniFi Controller
#
[Unit]
Description=UniFi AP Web Controller
After=syslog.target network.target
[Service]
Type=simple
User=ubnt
WorkingDirectory=/opt/UniFi
ExecStart=/usr/bin/java -Xmx1024M -jar /opt/UniFi/lib/ace.jar start
ExecStop=/usr/bin/java -jar /opt/UniFi/lib/ace.jar stop
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
}
function starting_service_unifi
{
dialog --stdout --sleep 2 --backtitle "$BACKTITLE" --infobox \
"Iniciando Unifi.." \ 5 35
systemctl enable unifi.service --quiet
systemctl start unifi.service --quiet
}
function bye()
{
dialog --stdout --sleep 5 --backtitle "$BACKTITLE" --infobox \
" Instalação concluida \n verifique em \n systemctl status unifi" \ 5 35
clear
}
check_dialog
welcome
settings
generate_files
add_repos
install_packages
install_unifi
creating_service_unifi
starting_service_unifi
bye
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment