quick_jibri_installer.sh: organize echo and printf.

This commit is contained in:
Luis Guzmán 2023-11-13 22:39:41 -06:00
parent 079ddfde03
commit 5a9ae4d5f5
1 changed files with 93 additions and 91 deletions

View File

@ -47,11 +47,10 @@ printwc() {
} }
exit_ifinstalled() { exit_ifinstalled() {
if [ "$(dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed")" == "1" ]; then if [ "$(dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed")" == "1" ]; then
echo " echo -e "\nThis instance already has $1 installed, exiting..."
This instance already has $1 installed, exiting... echo -e "Please try again on a clean system."
Please try again on a clean system. echo -e " If you think this is an error, please report to:"
If you think this is an error, please report to: echo -e " -> https://forge.switnet.net/switnet/quick-jibri-installer/issues"
-> https://forge.switnet.net/switnet/quick-jibri-installer/issues"
exit exit
fi fi
} }
@ -76,14 +75,10 @@ fi
} }
check_serv() { check_serv() {
if [ "$APACHE_2" -eq 1 ]; then if [ "$APACHE_2" -eq 1 ]; then
echo " echo -e "\nThe recommended setup is using NGINX, exiting...\n"
The recommended setup is using NGINX, exiting...
"
exit exit
elif [ "$NGINX" -eq 1 ]; then elif [ "$NGINX" -eq 1 ]; then
printf "\nWebserver already installed!\n" printf "\nWebserver already installed!\n"
else else
printf "\nInstalling nginx webserver!\n" printf "\nInstalling nginx webserver!\n"
install_ifnot nginx install_ifnot nginx
@ -94,16 +89,14 @@ printf "\n# Checking ALSA - Loopback module..."
echo "snd-aloop" | tee -a /etc/modules echo "snd-aloop" | tee -a /etc/modules
modprobe snd-aloop modprobe snd-aloop
if [ "$(lsmod|awk '/snd_aloop/{print$1}'|awk 'NR==1')" = "snd_aloop" ]; then if [ "$(lsmod|awk '/snd_aloop/{print$1}'|awk 'NR==1')" = "snd_aloop" ]; then
echo " echo -e "\n#-----------------------------------------------------------------------"
#----------------------------------------------------------------------- echo "# Audio driver seems - OK."
# Audio driver seems - OK. echo -e "#-----------------------------------------------------------------------\n"
#-----------------------------------------------------------------------"
else else
echo " echo -e "\n#-----------------------------------------------------------------------"
#----------------------------------------------------------------------- echo "# Your audio driver might not be able to load."
# Your audio driver might not be able to load. echo "# We'll check the state of this Jibri with our 'test-jibri-env.sh' tool."
# We'll check the state of this Jibri with our 'test-jibri-env.sh' tool. echo -e "#-----------------------------------------------------------------------\n"
#-----------------------------------------------------------------------"
#Test tool #Test tool
if [ "$MODE" = "debug" ]; then if [ "$MODE" = "debug" ]; then
bash "$PWD"/tools/test-jibri-env.sh -m debug bash "$PWD"/tools/test-jibri-env.sh -m debug
@ -117,6 +110,12 @@ fi
var_dlim() { var_dlim() {
grep -n "$1" add-jibri-node.sh|head -n1|cut -d ":" -f1 grep -n "$1" add-jibri-node.sh|head -n1|cut -d ":" -f1
} }
add_gpg_keyring() {
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com \$1
apt-key export \$1 | gpg --dearmour | tee /tmp/\$1.gpg >/dev/null
apt-key del \$1
mv /tmp/\$1.gpg /etc/apt/trusted.gpg.d/
}
add_prosody_repo() { add_prosody_repo() {
echo "Add Prosody repo" echo "Add Prosody repo"
if [ "$PROSODY_REPO" = "main" ]; then if [ "$PROSODY_REPO" = "main" ]; then
@ -170,7 +169,7 @@ Featuring:
Learn more about these at, Learn more about these at,
Main repository: https://forge.switnet.net/switnet/quick-jibri-installer Main repository: https://forge.switnet.net/switnet/quick-jibri-installer
Wiki and documentation: https://forge.switnet.net/switnet/quick-jibri-installer/wiki\n\n' Wiki and documentation: https://forge.switnet.net/switnet/quick-jibri-installer/wiki\n\n'
sleep .1
read -n 1 -s -r -p "Press any key to continue..."$'\n' read -n 1 -s -r -p "Press any key to continue..."$'\n'
#Check if user is root #Check if user is root
@ -193,8 +192,8 @@ NEXT_LTS_DATE=$(date -d 2024-04-01 +%s)
if [ "$DIST" = "focal" ]; then if [ "$DIST" = "focal" ]; then
if [ "$TODAY" -gt "$NEXT_LTS_DATE" ]; then if [ "$TODAY" -gt "$NEXT_LTS_DATE" ]; then
echo " > $(lsb_release -sc), even when it's compatible and functional. echo " > $(lsb_release -sc), even when it's compatible and functional."
We suggest to use the next (LTS) release, for longer support and security reasons." echo " We suggest to use the next (LTS) release, for longer support and security reasons."
read -n 1 -s -r -p "Press any key to continue..."$'\n' read -n 1 -s -r -p "Press any key to continue..."$'\n'
else else
echo "Focal is supported." echo "Focal is supported."
@ -281,9 +280,9 @@ printf "\nChecking for common desktop system oriented purpose....\n"
for de in "${SYSTEM_DE_ARRAY[@]}" for de in "${SYSTEM_DE_ARRAY[@]}"
do do
if [ "$(dpkg-query -W -f='${Status}' "$de" 2>/dev/null | grep -c "ok installed")" == "1" ]; then if [ "$(dpkg-query -W -f='${Status}' "$de" 2>/dev/null | grep -c "ok installed")" == "1" ]; then
printf "\n > This instance has %s installed, exiting... printf "\n > This instance has %s installed, exiting...\n" "$de"
\nPlease avoid using this installer on a desktop-user oriented GNU/Linux system. printf "\nPlease avoid using this installer on a desktop-user oriented GNU/Linux system.\n"
This is an unsupported use, as it will likely BREAK YOUR SYSTEM, so please don't." "$de" printf "This is an unsupported use, as it will likely BREAK YOUR SYSTEM, so please don't.\n"
exit exit
else else
printf " > No standard desktop environment for user oriented porpuse detected, good!, continuing...\n\n" printf " > No standard desktop environment for user oriented porpuse detected, good!, continuing...\n\n"
@ -340,8 +339,10 @@ sleep .1
if [ "$PUBLIC_IP" = "$(dig -4 +short "$JITSI_DOMAIN"||awk -v RS='([0-9]+\\.){3}[0-9]+' 'RT{print RT}')" ]; then if [ "$PUBLIC_IP" = "$(dig -4 +short "$JITSI_DOMAIN"||awk -v RS='([0-9]+\\.){3}[0-9]+' 'RT{print RT}')" ]; then
printf "\nServer public IP & DNS record for %s seems to match, continuing..." "$JITSI_DOMAIN" printf "\nServer public IP & DNS record for %s seems to match, continuing..." "$JITSI_DOMAIN"
else else
echo "Server public IP ($PUBLIC_IP) & DNS record for $JITSI_DOMAIN don't seem to match." echo -n "Server public IP ($PUBLIC_IP) & DNS record for $JITSI_DOMAIN"
echo " > Please check your dns records are applied and updated, otherwise components may fail." echo " don't seem to match."
echo -n " > Please check your dns records are applied and updated,"
echo " otherwise components may fail."
read -p " > Do you want to continue?: (yes or no)$NL" -r DNS_CONTINUE read -p " > Do you want to continue?: (yes or no)$NL" -r DNS_CONTINUE
if [ "$DNS_CONTINUE" = "yes" ]; then if [ "$DNS_CONTINUE" = "yes" ]; then
echo " - We'll continue anyway..." echo " - We'll continue anyway..."
@ -375,8 +376,8 @@ if [ "$LE_SSL" = "yes" ]; then
apt-get -y install \ apt-get -y install \
certbot certbot
if [ "$(dpkg-query -W -f='${Status}' ufw 2>/dev/null | grep -c "ok installed")" == "1" ]; then if [ "$(dpkg-query -W -f='${Status}' ufw 2>/dev/null | grep -c "ok installed")" == "1" ]; then
echo "# Disable pre-installed ufw, more on firewall see: echo "# Disable pre-installed ufw, more on firewall see:"
> https://forge.switnet.net/switnet/quick-jibri-installer/wiki/Firewall" echo " > https://forge.switnet.net/switnet/quick-jibri-installer/wiki/Firewall"
ufw disable ufw disable
fi fi
fi fi
@ -1117,9 +1118,9 @@ if [ "$ENABLE_SC" = "yes" ]; then
prosodyctl register "$SEC_ROOM_USER" "$DOMAIN" "$SEC_ROOM_PASS" prosodyctl register "$SEC_ROOM_USER" "$DOMAIN" "$SEC_ROOM_PASS"
sleep .1 sleep .1
printf "\nSecure rooms are being enabled...\n" printf "\nSecure rooms are being enabled...\n"
echo "You'll be able to login Secure Room chat with '${SEC_ROOM_USER}' \ echo -n "You'll be able to login Secure Room chat with '${SEC_ROOM_USER}' "
or '${SEC_ROOM_USER}@${DOMAIN}' using the password you just entered. echo "or '${SEC_ROOM_USER}@${DOMAIN}' using the password you just entered."
If you have issues with the password refer to your sysadmin." echo "If you have issues with the password refer to your sysadmin."
sed -i "s|#org.jitsi.jicofo.auth.URL=XMPP:|org.jitsi.jicofo.auth.URL=XMPP:|" "$JICOFO_SIP" sed -i "s|#org.jitsi.jicofo.auth.URL=XMPP:|org.jitsi.jicofo.auth.URL=XMPP:|" "$JICOFO_SIP"
sed -i "s|SEC_ROOM=.*|SEC_ROOM=\"on\"|" jm-bm.sh sed -i "s|SEC_ROOM=.*|SEC_ROOM=\"on\"|" jm-bm.sh
fi fi
@ -1219,7 +1220,8 @@ if [ "$DISABLE_LOCAL_JIBRI" = "yes" ]; then
systemctl disable jibri systemctl disable jibri
systemctl disable jibri-xorg systemctl disable jibri-xorg
systemctl disable jibri-icewm systemctl disable jibri-icewm
# Manually apply permissions since finalize_recording.sh won't be triggered under this server options. # Manually apply permissions since finalize_recording.sh won't be
# triggered under this server options.
chmod -R 770 "$DIR_RECORD" chmod -R 770 "$DIR_RECORD"
fi fi