Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scripts
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
infra
scripts
Commits
89d9b2a2
Commit
89d9b2a2
authored
Aug 17, 2023
by
Joab Bremer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
144d8b09
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
139 additions
and
0 deletions
+139
-0
install_unifi_with_nxrelay
install_unifi_with_nxrelay
+139
-0
No files found.
install_unifi_with_nxrelay
0 → 100644
View file @
89d9b2a2
#!/bin/bash
#Instalação do UNIFI 7.3.83
####################################################################################
#Variaveis de instalação
RED
=
'\033[0;31m'
NC
=
'\033[0m'
# No Color
####################################################################################
disable_selinux
(){
sed
-i
/etc/selinux/config
-r
-e
's/^SELINUX=.*/SELINUX=disabled/g'
}
backup_unifi
(){
cp
-r
/opt/UniFi /opt/UniFi_bkp_
$(
date
+%d%m%Y
)
}
backup_nxrelay
(){
cp
-r
/nxrelay /nxrelay_bkp_
$(
date
+%d%m%Y
)
}
clean_old_install
(){
/usr/bin/systemctl stop nxrelay
yum erase
-y
-q
java-1.8.0-openjdk-headless
}
install_components
(){
#yum -q -y install epel-release java-1.8.0-openjdk unzip wget
yum
-q
-y
install
java-11-openjdk-devel epel-release unzip wget
}
configure_mongorepo
(){
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
}
install_mongo
(){
yum
install
-q
-y
mongodb-org
}
creating_user
(){
adduser
-r
-s
/bin/nologin ubnt
}
install_unifi
(){
wget https://dl.ui.com/unifi/7.3.83/UniFi.unix.zip
-P
/opt
-q
unzip
-qq
/opt/UniFi.unix.zip
-d
/opt
chown
-R
ubnt:ubnt /opt/UniFi
rm
-rf
/opt/UniFi.unix.zip
}
install_nxrelay
(){
mkdir
/nxrelay
cd
/nxrelay
/usr/bin/wget
--quiet
--no-check-certificate
http://git.usb.org.br/infra/scripts/raw/master/nxrelay-2.7.8-adv.zip
/usr/bin/zip
-qq
-d
nxrelay-2.7.8-adv.zip
"conf/cfg.properties"
/usr/bin/zip
-qq
-d
nxrelay-2.7.8-adv.zip
"conf/log4j.properties"
/usr/bin/zip
-qq
-d
nxrelay-2.7.8-adv.zip
"bin/startup.sh"
/usr/bin/unzip
-qq
-o
nxrelay-2.7.8-adv.zip
}
reconfigure_nxrelay
(){
cp
/nxrelay_bkp_
$(
date
+%d%m%Y
)
/conf/cfg.properties /nxrelay/conf/cfg.properties
cp
/nxrelay_bkp_
$(
date
+%d%m%Y
)
/conf/log4j.properties /nxrelay/conf/log4j.properties
cp
/nxrelay_bkp_
$(
date
+%d%m%Y
)
bin/startup.sh /nxrelay/bin/startup.sh
}
creating_service_unifi
(){
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
}
creating_service_nxrelay
(){
cat
>
/etc/systemd/system/unifi.service
<<
EOF
#
# Systemd unit file for nxrelay
#
[Unit]
Description=NxRelay
After=network.target
[Service]
Type=simple
ExecStart=/bin/bash /nxrelay/bin/startup.sh
ExecStop=/bin/bash /nxrelay/bin/shutdown.sh
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
}
starting_services
(){
/usr/bin/systemctl
enable
unifi.service
--quiet
/usr/bin/systemctl start unifi.service
--quiet
/usr/bin/systemctl
enable
nxrelay
--quiet
/usr/bin/systemctl start nxrelay
--quiet
}
stty echo
echo
-e
"
${
RED
}
Iniciando Instalação
${
NC
}
"
echo
-e
"
${
RED
}
Fazendo BKP do UNIFI
${
NC
}
"
backup_unifi
echo
-e
"
${
RED
}
Fazendo BKP do NXRELAY{NC}"
backup_nxrelay
echo
-e
"
${
RED
}
Limpando Instalações antigas{NC}"
clean_old_install
echo
-e
"
${
RED
}
Desabilitando SE Linux
${
NC
}
"
disable_selinux
echo
-e
"
${
RED
}
Instalando Componentes
${
NC
}
"
install_components
configure_mongorepo
echo
-e
"
${
RED
}
Instalando MongoDB
${
NC
}
"
install_mongo
echo
-e
"
${
RED
}
Criando Usuário
${
NC
}
"
creating_user
echo
-e
"
${
RED
}
Instalando UniFi
${
NC
}
"
install_unifi
echo
-e
"
${
RED
}
Instalando Nxrelay{NC}"
install_nxrelay
echo
-e
"
${
RED
}
Configurando serviços
${
NC
}
"
creating_service_unifi
creating_service_nxrelay
echo
-e
"
${
RED
}
Reconfigurando Nxrelay
${
NC
}
"
reconfigure_nxrelay
echo
-e
"
${
RED
}
Iniciando Unifi e Nxrelay{NC}"
starting_services
echo
-e
"
${
RED
}
Instalação Concluida
${
NC
}
"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment