1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mumbleserver_ynh.git synced 2024-09-03 19:46:03 +02:00
This commit is contained in:
ericgaspar 2021-06-04 23:18:25 +02:00
parent 10e607da6a
commit 7ee913d75c
No known key found for this signature in database
GPG key ID: 574F281483054D44
3 changed files with 48 additions and 100 deletions

View file

@ -1,14 +1,14 @@
#!/bin/bash #!/bin/bash
pkg_dependencies="mumble-server mailutils websockify"
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app # dependencies used by the app
pkg_dependencies="mumble-server mailutils" pkg_dependencies="mumble-server mailutils websockify"
# NodeJS version
nodejs_version=12
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS

View file

@ -56,8 +56,8 @@ 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=welcometext --value="$welcometext"
ynh_app_setting_set --app=$app --key=registerName --value="$registername" 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=instance_id --value="$instance_id"
ynh_app_setting_set "$app" mumbleweb "$mumbleweb" ynh_app_setting_set --app=$app --key=mumbleweb --value="$mumbleweb"
ynh_app_setting_set "$app" is_public "$is_public" ynh_app_setting_set --app=$app --key=i_public --value="$is_public"
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -74,10 +74,10 @@ ynh_script_progression --message="Configuring firewall..." --weight=1
ynh_exec_warn_less yunohost firewall allow Both $port ynh_exec_warn_less yunohost firewall allow Both $port
if [ "$mumbleweb" -eq 1 ] ; then if [ "$mumbleweb" -eq 1 ] ; then
port_web=$(ynh_find_port 64800) port_web=$(ynh_find_port 64737)
ynh_app_setting_set "$app" port_web "$port_web" ynh_app_setting_set --app=$app --key=port_web --value=$port_web
# Open port in firewall # Open port in firewall
yunohost firewall allow Both "$port_web" ynh_exec_warn_less yunohost firewall allow Both "$port_web"
fi fi
#================================================= #=================================================
@ -86,47 +86,30 @@ fi
ynh_script_progression --message="Installing dependencies..." --weight=4 ynh_script_progression --message="Installing dependencies..." --weight=4
# Install Mumble Debian package via apt # Install Mumble Debian package via apt
ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
if [ "$mumbleweb" -eq 1 ] ; then if [ "$mumbleweb" -eq 1 ] ; then
ynh_install_nodejs --nodejs_version="12" ynh_install_nodejs --nodejs_version=$nodejs_version
fi fi
#================================================= #=================================================
# INSTALL Mumble-web # INSTALL Mumble-web
#================================================= #=================================================
ynh_script_progression --message="Installing Mumble Web..." --weight=4
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_app_setting_set "$app" final_path "$final_path"
mkdir -p "$final_path"
if [ "$mumbleweb" -eq 1 ] ; then if [ "$mumbleweb" -eq 1 ] ; then
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
fi fi
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring nginx web server..." --time --weight=1 ynh_script_progression --message="Configuring NGINX web server..." --weight=1
### `ynh_add_nginx_config` will use the file conf/nginx.conf
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config
ynh_add_nginx_config "port_web"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=3
# Create a dedicated system user
ynh_system_user_create --username="$app" --home_dir="$final_path"
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
@ -134,14 +117,7 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
# mumble server conf.ini # mumble server conf.ini
#================================================= #=================================================
ynh_add_config --template="../conf/mumble-server.ini" --destination="$final_path/mumble-server.ini"
mkdir -p "$final_path"
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Configuring with given settings
mumble_conf="$final_path/mumble-server.ini"
ynh_add_config --template="../conf/mumble-server.ini" --destination="$mumble_conf"
if [ "$mumbleweb" -eq 1 ] ; then if [ "$mumbleweb" -eq 1 ] ; then
ynh_use_nodejs ynh_use_nodejs
@ -157,13 +133,12 @@ fi
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
if [ "$mumbleweb" -eq 1 ] ; then if [ "$mumbleweb" -eq 1 ] ; then
ynh_replace_string "__PORT__" "$port" "../conf/mumble-web.service"
ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mumble-web.service"
ynh_add_systemd_config "$app-web" mumble-web.service ynh_add_systemd_config "$app-web" mumble-web.service
fi fi
@ -203,31 +178,30 @@ systemctl disable mumble-server --quiet
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
# Add Mumble as a YunoHost service # Add Mumble as a YunoHost service
yunohost service add $app --description="Mumble server" --log="/var/log/$app/$app.log" --needs_exposed_ports $port yunohost service add $app --description="Mumble server" --log="/var/log/$app/$app.log" --needs_exposed_ports=$port
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=3 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" ynh_systemd_action --service_name=$app --action=restart --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary # Make app public if necessary
if [ "$is_public" -eq 1 ] if [ $is_public -eq 1 ]
then then
# unprotected_uris allows SSO credentials to be passed anyway. ynh_permission_update --permission="main" --add="visitors"
ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/"
fi fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload

View file

@ -16,19 +16,19 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app="$app" --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
is_public=$(ynh_app_setting_get --app="$app" --key=is_public) is_public=$(ynh_app_setting_get --app=$app --key=is_public)
no_sso=$(ynh_app_setting_get "$app" no_sso) no_sso=$(ynh_app_setting_get --app=$app --key=no_sso)
server_password=$(ynh_app_setting_get "$app" server_password) server_password=$(ynh_app_setting_get --app=$app --key=server_password)
su_passwd=$(ynh_app_setting_get "$app" su_passwd) su_passwd=$(ynh_app_setting_get --app=$app --key=su_passwd)
welcometext=$(ynh_app_setting_get "$app" welcometext) welcometext=$(ynh_app_setting_get --app=$app --key=welcometext)
registerName=$(ynh_app_setting_get "$app" registerName) registerName=$(ynh_app_setting_get --app=$app r--key=egisterName)
port=$(ynh_app_setting_get "$app" port) port=$(ynh_app_setting_get --app=$app --key=port)
port_web=$(ynh_app_setting_get "$app" port_web) port_web=$(ynh_app_setting_get --app=$app --key=port_web)
final_path=$(ynh_app_setting_get "$app" final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
instance_id=$(ynh_app_setting_get "$app" instance_id) instance_id=$(ynh_app_setting_get --app=$app --key=instance_id)
mumbleweb=$(ynh_app_setting_get "$app" mumbleweb) mumbleweb=$(ynh_app_setting_get --app=$app --key=mumbleweb)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -123,7 +123,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name="$app" --action="stop" ynh_systemd_action --service_name="$app" --action="stop"
ynh_systemd_action --service_name="$app-web" --action="stop" ynh_systemd_action --service_name="$app-web" --action="stop"
@ -134,7 +134,7 @@ ynh_systemd_action --service_name="$app-web" --action="stop"
if [ "$mumbleweb" -eq 1 ] ; then if [ "$mumbleweb" -eq 1 ] ; then
then then
ynh_script_progression --message="Upgrading source files..." --time --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
@ -146,15 +146,15 @@ fi
ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config "port_web" ynh_add_nginx_config
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 ynh_script_progression --message="Upgrading dependencies..." --weight=1
# Install Mumble Debian package via apt # Install Mumble Debian package via apt
ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -164,14 +164,6 @@ ynh_script_progression --message="Making sure dedicated system user exists..." -
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username="$app" ynh_system_user_create --username="$app"
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=6
# Install Mumble Debian package via apt
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
@ -179,23 +171,7 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
mkdir -p $final_path mkdir -p $final_path
ynh_add_config --template="../conf/mumble-server.ini" --destination="$final_path/mumble-server.ini"
# Configuring with given settings
mumble_conf="$final_path/mumble-server.ini"
ynh_add_config --template="../conf/mumble-server.ini" --destination="$mumble_conf"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1
# Make app public if necessary
if [ "$is_public" -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway
ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/"
fi
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -206,8 +182,6 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
ynh_add_systemd_config ynh_add_systemd_config
if [ "$mumbleweb" -eq 1 ] ; then if [ "$mumbleweb" -eq 1 ] ; then
ynh_replace_string "__PORT__" "$port" "../conf/mumble-web.service"
ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mumble-web.service"
ynh_add_systemd_config "$app-web" mumble-web.service ynh_add_systemd_config "$app-web" mumble-web.service
fi fi