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

Add generic headers and _common.sh

This commit is contained in:
Jean-Baptiste Holcroft 2017-11-21 11:22:26 +01:00
parent c3f4863564
commit 6e7df45f12
4 changed files with 59 additions and 33 deletions

3
scripts/_common.sh Normal file
View file

@ -0,0 +1,3 @@
#!/bin/bash

View file

@ -1,24 +1,35 @@
#!/bin/bash #!/bin/bash
#debug commands
#exec > >(tee /tmp/mumble-install.log)
#exec 2>&1
# Exit on command errors and treat unset variables as an error #=================================================
set -eu # 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 # Retrieve arguments
app="mumbleserver" app=$YNH_APP_INSTANCE_NAME
server_password=$YNH_APP_ARG_SERVER_LOGIN_PASSWORD server_password=$YNH_APP_ARG_SERVER_LOGIN_PASSWORD
su_passwd=$YNH_APP_ARG_PASSWORD su_passwd=$YNH_APP_ARG_PASSWORD
welcometext=$YNH_APP_ARG_WELCOMETEXT welcometext=$YNH_APP_ARG_WELCOMETEXT
port=$YNH_APP_ARG_PORT port=$YNH_APP_ARG_PORT
registerName=$YNH_APP_ARG_REGISTERNAME registerName=$YNH_APP_ARG_REGISTERNAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Check port availability # Check port availability
sudo yunohost app checkport $port yunohost app checkport $port
if [[ ! $? -eq 0 ]]; then if [[ ! $? -eq 0 ]]; then
ynh_die ynh_die
fi fi
@ -32,33 +43,33 @@ fi
ynh_app_setting_set $app port "$port" ynh_app_setting_set $app port "$port"
# Install Mumble Debian package via apt # Install Mumble Debian package via apt
sudo apt update > /dev/null 2>&1 apt update > /dev/null 2>&1
sudo apt install -y mumble-server > /dev/null 2>&1 apt install -y mumble-server > /dev/null 2>&1
# Configuring with given settings # Configuring with given settings
mumble_conf="../conf/mumble-server.ini" mumble_conf="../conf/mumble-server.ini"
sudo sed -i "s/welcometext=.*/welcometext=$welcometext/" $mumble_conf sed -i "s/welcometext=.*/welcometext=$welcometext/" $mumble_conf
sudo sed -i "s/port=.*/port=$port/" $mumble_conf sed -i "s/port=.*/port=$port/" $mumble_conf
sudo sed -i "s/serverpassword=.*/serverpassword=$server_password/" $mumble_conf sed -i "s/serverpassword=.*/serverpassword=$server_password/" $mumble_conf
sudo sed -i "s/#registerName=.*/registerName=$registerName/" $mumble_conf sed -i "s/#registerName=.*/registerName=$registerName/" $mumble_conf
# Copying conf file # Copying conf file
mumble_conf="/etc/mumble-server.ini" mumble_conf="/etc/mumble-server.ini"
sudo cp ../conf/mumble-server.ini $mumble_conf cp ../conf/mumble-server.ini $mumble_conf
sudo chmod 660 $mumble_conf chmod 660 $mumble_conf
sudo chown :mumble-server $mumble_conf chown :mumble-server $mumble_conf
# Open port in firewall # Open port in firewall
sudo yunohost firewall allow Both $port > /dev/null 2>&1 yunohost firewall allow Both $port > /dev/null 2>&1
# Start Mumble server # Start Mumble server
sudo /etc/init.d/mumble-server start /etc/init.d/mumble-server start
# Set super-user password # Set super-user password
sudo murmurd -supw $su_passwd murmurd -supw $su_passwd
# Restart Mumble server # Restart Mumble server
sudo /etc/init.d/mumble-server restart /etc/init.d/mumble-server restart
# Add Mumble as a YunoHost service # Add Mumble as a YunoHost service
sudo yunohost service add mumble-server -l /var/log/mumble-server/mumble-server.log yunohost service add mumble-server -l /var/log/mumble-server/mumble-server.log

View file

@ -1,9 +1,12 @@
#!/bin/bash #!/bin/bash
# Exit and treat unset variables as an error #=================================================
set -u # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Source YunoHost helpers source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
app=mumbleserver app=mumbleserver
@ -12,13 +15,13 @@ app=mumbleserver
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get $app port)
# Uninstall Mumble and its dependencies # Uninstall Mumble and its dependencies
sudo apt autoremove -y mumble-server > /dev/null 2>&1 apt autoremove -y mumble-server > /dev/null 2>&1
# Close ports # Close ports
sudo yunohost firewall disallow Both $port > /dev/null 2>&1 yunohost firewall disallow Both $port > /dev/null 2>&1
# Removing config file # Removing config file
sudo rm -f /etc/mumble-server.ini rm -f /etc/mumble-server.ini
# Remove mumble-server service # Remove mumble-server service
sudo yunohost service remove mumble-server yunohost service remove mumble-server

View file

@ -1,4 +1,13 @@
#!/bin/bash #!/bin/bash
# Exit on command errors and treat unset variables as an error #=================================================
set -eu # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
ynh_abort_if_errors
ynh_die "There is no upgrade yet"