1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mumbleserver_ynh.git synced 2024-09-03 19:46:03 +02:00

Use helpers and shellcheck

This commit is contained in:
Jean-Baptiste Holcroft 2017-11-21 11:52:26 +01:00
parent c736ccf103
commit f6368ee675
2 changed files with 26 additions and 25 deletions

View file

@ -85,17 +85,17 @@ pidfile=/var/run/mumble-server/mumble-server.pid
# configure it here than through D-Bus or Ice.
#
# Welcome message sent to clients when they connect.
welcometext="<br />Welcome to this server running <b>Murmur</b>.<br />Enjoy your stay!<br />"
welcometext="__WELCOME__"
# Port to bind TCP and UDP sockets to.
port=64738
port=__PORT__
# Specific IP or hostname to bind to.
# If this is left blank (default), Murmur will bind to all available addresses.
#host=
# Password to join server.
serverpassword=
serverpassword=__SRV_PWD__
# Maximum bandwidth (in bits per second) clients are allowed
# to send speech at.
@ -143,7 +143,7 @@ users=100
# addresses.
# Only uncomment the 'registerName' parameter if you wish to give your "Root" channel a custom name.
#
#registerName=Mumble Server
registerName=__REGISTER__
#registerPassword=secret
#registerUrl=http://mumble.sourceforge.net/
#registerHostname=

View file

@ -33,14 +33,14 @@ registerName=$YNH_APP_ARG_REGISTERNAME
#=================================================
# Check port availability
yunohost app checkport $port
if [[ ! $? -eq 0 ]]; then
ynh_die
if [[ ! $(yunohost app checkport "$port") -eq 0 ]]; then
ynh_die "Port is not available"
fi
# Check if su_password is not empty
if [[ -z "$su_passwd" ]]; then
ynh_die
ynh_die "Password is not set"
fi
#=================================================
@ -48,8 +48,11 @@ fi
#=================================================
# Save app settings
ynh_app_setting_set $app port "$port"
ynh_app_setting_set "$app" port "$port"
ynh_app_setting_set "$app" server_password "$server_password"
ynh_app_setting_set "$app" su_passwd "$su_passwd"
ynh_app_setting_set "$app" welcometext "$welcometext"
ynh_app_setting_set "$app" registerName "$registerName"
#=================================================
# STANDARD MODIFICATIONS
@ -58,16 +61,14 @@ ynh_app_setting_set $app port "$port"
#=================================================
# Open port in firewall
yunohost firewall allow Both $port > /dev/null 2>&1
yunohost firewall allow Both "$port"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
# Install Mumble Debian package via apt
apt update > /dev/null 2>&1
apt install -y mumble-server > /dev/null 2>&1
ynh_install_app_dependencies mumble-server
#=================================================
# SPECIFIC SETUP
@ -77,21 +78,21 @@ apt install -y mumble-server > /dev/null 2>&1
# TODO: clean this
# Configuring with given settings
mumble_conf="../conf/mumble-server.ini"
sed -i "s/welcometext=.*/welcometext=$welcometext/" $mumble_conf
sed -i "s/port=.*/port=$port/" $mumble_conf
sed -i "s/serverpassword=.*/serverpassword=$server_password/" $mumble_conf
sed -i "s/#registerName=.*/registerName=$registerName/" $mumble_conf
# Copying conf file
mumble_conf="/etc/mumble-server.ini"
cp ../conf/mumble-server.ini $mumble_conf
cp ../conf/mumble-server.ini "$mumble_conf"
ynh_replace_string "__WELCOME__" "$welcometext" "$mumble_conf"
ynh_replace_string "__PORT__" "$port" "$mumble_conf"
ynh_replace_string "__SRV_PWD__" "$server_password" "$mumble_conf"
ynh_replace_string "__REGISTER__" "$registerName" "$mumble_conf"
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
# TODO: add this checksum step
ynh_store_file_checksum "$mumble_conf"
#=================================================
# Start services
@ -101,7 +102,7 @@ cp ../conf/mumble-server.ini $mumble_conf
/etc/init.d/mumble-server start
# Set super-user password
murmurd -ini $mumble_conf -supw $su_passwd
murmurd -ini "$mumble_conf" -supw "$su_passwd"
# Restart Mumble server
/etc/init.d/mumble-server restart
@ -112,8 +113,8 @@ murmurd -ini $mumble_conf -supw $su_passwd
# SECURE FILES AND DIRECTORIES
#=================================================
chmod 660 $mumble_conf
chown :mumble-server $mumble_conf
chmod 660 "$mumble_conf"
chown :mumble-server "$mumble_conf"
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL