mirror of
https://github.com/YunoHost-Apps/minetest_ynh.git
synced 2024-09-03 20:36:00 +02:00
110 lines
3.7 KiB
Bash
Executable file
110 lines
3.7 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC STARTING
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# MANAGE FAILURE OF THE SCRIPT
|
|
#=================================================
|
|
|
|
ynh_abort_if_errors
|
|
|
|
#=================================================
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
#=================================================
|
|
|
|
pvp=$YNH_APP_ARG_PVP
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
damage=$YNH_APP_ARG_DAMAGE
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
creative=$YNH_APP_ARG_CREATIVE
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
|
|
#=================================================
|
|
# CHECK THE DEBIAN'S CODENAME
|
|
#=================================================
|
|
|
|
codename=$(lsb_release -a 2>/dev/null | grep Codename | cut -f 2)
|
|
test -z "$codename" && (ynh_die "codename empty")
|
|
|
|
#=================================================
|
|
# STANDARD MODIFICATIONS
|
|
#=================================================
|
|
# FIND AND OPEN A PORT
|
|
#=================================================
|
|
|
|
port=$(ynh_find_port 30000) # Cherche un port libre.
|
|
|
|
# Open ports in firewall
|
|
ALL_QUIET yunohost firewall allow UDP $port
|
|
ALL_QUIET yunohost firewall allow TCP $port
|
|
ynh_app_setting_set $app port $port
|
|
|
|
# Store informations in Yunohost config
|
|
ynh_app_setting_set $app pvp ${pvp}
|
|
ynh_app_setting_set $app damage ${damage}
|
|
ynh_app_setting_set $app domain ${domain}
|
|
ynh_app_setting_set $app creative ${creative}
|
|
ynh_app_setting_set $app is_public ${is_public}
|
|
|
|
#=================================================
|
|
# SPECIFIC SETUP
|
|
#=================================================
|
|
# INSTALL MINETEST
|
|
#=================================================
|
|
|
|
# Installation du paquet minetest et ses dépendances
|
|
cp -a "../conf/minetest.list" "/etc/apt/sources.list.d/$app.list"
|
|
ynh_replace_string "__CODENAME__" "$codename" "/etc/apt/sources.list.d/$app.list"
|
|
cp -a "../conf/minetest-preferences" "/etc/apt/preferences.d/00MinetestPinning"
|
|
ynh_replace_string "__CODENAME__" "$codename" "/etc/apt/preferences.d/00MinetestPinning"
|
|
if [ $(uname -m) == "armv7l" ]
|
|
then
|
|
gpg --keyserver pgpkeys.mit.edu --recv-key 7638D0442B90D010
|
|
gpg --keyserver pgpkeys.mit.edu --recv-key 8B48AD6246925553
|
|
gpg -a --export 7638D0442B90D010 | apt-key add -
|
|
gpg -a --export 8B48AD6246925553 | apt-key add -
|
|
fi
|
|
ynh_package_update
|
|
ynh_install_app_dependencies minetest-server
|
|
|
|
#=================================================
|
|
# ENABLE SERVICE IN ADMIN PANEL
|
|
#=================================================
|
|
|
|
# Add service to Yunohost's monitoring
|
|
yunohost service add minetest --log "/var/log/minetest/minetest.log"
|
|
|
|
#=================================================
|
|
# CONFIGURE MINETEST
|
|
#=================================================
|
|
|
|
cp "../conf/minetest.conf" "/etc/minetest/minetest.conf"
|
|
chown root:root /etc/minetest/minetest.conf
|
|
chmod 644 /etc/minetest/minetest.conf
|
|
|
|
# Change Minetest configuration
|
|
ynh_replace_string "__PORT__" "$port" /etc/minetest/minetest.conf
|
|
if [ $is_public -eq 1 ]
|
|
then
|
|
ynh_replace_string "__ANNOUNCE__" "true" /etc/minetest/minetest.conf
|
|
else
|
|
ynh_replace_string "__ANNOUNCE__" "false" /etc/minetest/minetest.conf
|
|
fi
|
|
ynh_replace_string "__DOMAIN__" "$domain" /etc/minetest/minetest.conf
|
|
ynh_replace_string "__PVP__" "$pvp" /etc/minetest/minetest.conf
|
|
ynh_replace_string "__CREATIVE__" "$creative" /etc/minetest/minetest.conf
|
|
ynh_replace_string "__DAMAGE__" "$damage" /etc/minetest/minetest.conf
|
|
|
|
#=================================================
|
|
# RESTART MINETEST'S SERVICE
|
|
#=================================================
|
|
|
|
# Restart Minetest to use new settings
|
|
systemctl restart minetest-server
|