mirror of
https://github.com/YunoHost-Apps/mumbleserver_ynh.git
synced 2024-09-03 19:46:03 +02:00
228 lines
7.9 KiB
Bash
228 lines
7.9 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# MANAGE SCRIPT FAILURE
|
|
#=================================================
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
ynh_abort_if_errors
|
|
|
|
#=================================================
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
#=================================================
|
|
|
|
# Retrieve arguments
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
path_url="/"
|
|
welcometext=$YNH_APP_ARG_WELCOMETEXT
|
|
registername=$YNH_APP_ARG_REGISTERNAME
|
|
instance_id=$YNH_APP_INSTANCE_NUMBER
|
|
mumbleweb=$YNH_APP_ARG_MUMBLEWEB
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
server_password=$(ynh_string_random)
|
|
su_passwd=$(ynh_string_random)
|
|
|
|
#=================================================
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
#=================================================
|
|
|
|
if [ "$mumbleweb" -eq 1 ] ; then
|
|
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
|
|
|
final_path=/var/www/$app
|
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
|
|
|
# Register (book) web path
|
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
|
fi
|
|
|
|
#=================================================
|
|
# STORE SETTINGS FROM MANIFEST
|
|
#=================================================
|
|
ynh_script_progression --message="Storing installation settings..." --weight=2
|
|
|
|
# Save app settings
|
|
ynh_app_setting_set --app=$app --key=domain --value="$domain"
|
|
ynh_app_setting_set --app=$app --key=no_sso --value="true"
|
|
ynh_app_setting_set --app=$app --key=server_password --value="$server_password"
|
|
ynh_app_setting_set --app=$app --key=su_passwd --value="$su_passwd"
|
|
ynh_app_setting_set --app=$app --key=welcometext --value="$welcometext"
|
|
ynh_app_setting_set --app=$app --key=registername --value="$registername"
|
|
ynh_app_setting_set --app=$app --key=instance_id --value="$instance_id"
|
|
ynh_app_setting_set --app=$app --key=mumbleweb --value="$mumbleweb"
|
|
|
|
#=================================================
|
|
# STANDARD MODIFICATIONS
|
|
#=================================================
|
|
# FIND AND OPEN A PORT
|
|
#=================================================
|
|
ynh_script_progression --message="Finding an available port..." --weight=1
|
|
|
|
port=$(ynh_find_port --port=64738)
|
|
ynh_app_setting_set --app=$app --key=port --value=$port
|
|
|
|
# Open the port
|
|
ynh_script_progression --message="Configuring firewall..." --weight=1
|
|
ynh_exec_warn_less yunohost firewall allow Both $port
|
|
|
|
#=================================================
|
|
# INSTALL MUMBLE WEB
|
|
#=================================================
|
|
|
|
if [ "$mumbleweb" -eq 1 ] ; then
|
|
ynh_script_progression --message="Installing Mumble web..." --weight=1
|
|
|
|
port_web=$(ynh_find_port --port=64737)
|
|
ynh_app_setting_set --app=$app --key=port_web --value=$port_web
|
|
|
|
# Install NodeJS
|
|
ynh_install_nodejs --nodejs_version=$nodejs_version
|
|
|
|
# Create a system user
|
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
|
|
|
# Installing Mumble Web
|
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|
ynh_setup_source --dest_dir="$final_path"
|
|
|
|
chmod 750 "$final_path"
|
|
chmod -R o-rwx "$final_path"
|
|
chown -R $app:www-data "$final_path"
|
|
|
|
# Configuring NGINX web server
|
|
ynh_add_nginx_config
|
|
|
|
# Configuring Mumble server
|
|
ynh_use_nodejs
|
|
(
|
|
cd $final_path
|
|
chown -R $app: $final_path
|
|
ynh_exec_warn_less ynh_exec_as "$app" PATH="$nodejs_path:$PATH" "$nodejs_path/npm" install --save --loglevel warn
|
|
ynh_exec_warn_less ynh_exec_as "$app" PATH="$nodejs_path:$PATH" "$nodejs_path/npm" run build
|
|
ls -lah
|
|
)
|
|
|
|
ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/mumble-web.service"
|
|
ynh_exec_warn_less ynh_add_systemd_config --service=mumble-web --template=mumble-web.service
|
|
|
|
yunohost service add mumble-web --description="Mumble web interface" --log="/var/log/$app/mumble-web.log"
|
|
|
|
# Make app public if necessary
|
|
if [ $is_public -eq 1 ]
|
|
then
|
|
ynh_permission_update --permission="main" --add="visitors"
|
|
fi
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
fi
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Installing dependencies..." --weight=4
|
|
|
|
# Install Mumble Debian package via apt
|
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
#=================================================
|
|
# SPECIFIC SETUP
|
|
#=================================================
|
|
# mumble server conf.ini
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring Mumble server..." --weight=1
|
|
|
|
ynh_add_config --template="../conf/mumble-server.ini" --destination="$final_path/mumble-server.ini"
|
|
|
|
#=================================================
|
|
# SETUP SYSTEMD
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring a systemd service..." --weight=10
|
|
|
|
# Create a dedicated systemd config
|
|
ynh_add_systemd_config
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
# SECURE FILES AND DIRECTORIES
|
|
#=================================================
|
|
|
|
chmod -R 770 "$final_path"
|
|
chown -R :mumble-server "$final_path"
|
|
|
|
#=================================================
|
|
# ADD USER TO SSL-CERT
|
|
#=================================================
|
|
|
|
# Add user to ssl-cert so it can read certificates
|
|
usermod --append --groups ssl-cert mumble-server
|
|
|
|
#=================================================
|
|
# Set SuperUser password
|
|
#=================================================
|
|
|
|
# || true temporarily to ignore a bug in murmurd 1.3.0
|
|
# https://github.com/mumble-voip/mumble/issues/3911
|
|
murmurd -ini "$final_path/mumble-server.ini" -supw "$su_passwd" "$instance_id" || true
|
|
|
|
#=================================================
|
|
# DISABLE DEFAULT SERVER
|
|
#=================================================
|
|
|
|
# Disable default server installed by Debian's package
|
|
systemctl stop mumble-server
|
|
systemctl disable mumble-server --quiet
|
|
|
|
#=================================================
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
#=================================================
|
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
|
|
|
# Add Mumble as a YunoHost service
|
|
yunohost service add $app --description="Mumble server" --log="/var/log/$app/$app.log" --needs_exposed_ports=$port
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
|
|
|
ynh_systemd_action --service_name=$app --action=restart --log_path="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# SEND README TO ADMIN
|
|
#=================================================
|
|
|
|
message="
|
|
Port : $port
|
|
Password to join server: $server_password
|
|
SuperUser Password : $su_passwd
|
|
Welcome text : $welcometext
|
|
Root channel (your Mumble server name): $registername
|
|
Final path (where to find your files) : $final_path
|
|
Mumble configuration file : $final_path/mumble-server.ini
|
|
|
|
Note about config file: this package will regenerate the config file on upgrade.
|
|
If you changed it manually and upgrade Mumble, you'll find a backup in $final_path.
|
|
|
|
Are you facing an issue, want to improve this app or say thank you?
|
|
Please open a new issue in this project: https://github.com/YunoHost-Apps/mumbleserver_ynh
|
|
"
|
|
ynh_send_readme_to_admin "$message"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|