2017-06-09 14:03:32 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC STARTING
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE FAILURE OF THE SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2017-10-20 10:16:34 +02:00
|
|
|
ynh_abort_if_errors
|
2017-06-09 14:03:32 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
pvp=$YNH_APP_ARG_PVP
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2017-10-20 10:16:34 +02:00
|
|
|
damage=$YNH_APP_ARG_DAMAGE
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
creative=$YNH_APP_ARG_CREATIVE
|
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
2017-06-09 14:03:32 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# 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.
|
|
|
|
|
2017-10-20 10:16:34 +02:00
|
|
|
# Open ports in firewall
|
|
|
|
ALL_QUIET yunohost firewall allow UDP $port
|
|
|
|
ALL_QUIET yunohost firewall allow TCP $port
|
2017-06-09 14:03:32 +02:00
|
|
|
ynh_app_setting_set $app port $port
|
|
|
|
|
2017-10-20 10:16:34 +02:00
|
|
|
# Store informations in Yunohost config
|
2017-06-09 14:03:32 +02:00
|
|
|
ynh_app_setting_set $app pvp ${pvp}
|
|
|
|
ynh_app_setting_set $app damage ${damage}
|
2017-10-20 10:16:34 +02:00
|
|
|
ynh_app_setting_set $app domain ${domain}
|
|
|
|
ynh_app_setting_set $app creative ${creative}
|
|
|
|
ynh_app_setting_set $app is_public ${is_public}
|
2017-06-09 14:03:32 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
|
|
|
# INSTALL MINETEST
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Installation du paquet minetest et ses dépendances
|
2017-10-20 10:16:34 +02:00
|
|
|
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"
|
2017-06-23 15:19:48 +02:00
|
|
|
if [ $(uname -m) == "armv7l" ]
|
|
|
|
then
|
2017-10-20 11:30:28 +02:00
|
|
|
gpg --list-keys 7638D0442B90D010 > /dev/null 2>&1
|
|
|
|
if [ $? != 0 ]
|
|
|
|
then
|
|
|
|
gpg --keyserver pgpkeys.mit.edu --recv-key 7638D0442B90D010
|
|
|
|
fi
|
|
|
|
gpg --list-keys 8B48AD6246925553 > /dev/null 2>&1
|
|
|
|
if [ $? != 0 ]
|
|
|
|
then
|
|
|
|
gpg --keyserver pgpkeys.mit.edu --recv-key 8B48AD6246925553
|
|
|
|
fi
|
2017-10-20 10:16:34 +02:00
|
|
|
gpg -a --export 7638D0442B90D010 | apt-key add -
|
2017-10-20 10:58:42 +02:00
|
|
|
gpg -a --export 8B48AD6246925553 | apt-key add -
|
2017-06-23 15:19:48 +02:00
|
|
|
fi
|
2017-10-20 10:16:34 +02:00
|
|
|
ynh_package_update
|
|
|
|
ynh_install_app_dependencies minetest-server
|
2017-06-09 14:03:32 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ENABLE SERVICE IN ADMIN PANEL
|
|
|
|
#=================================================
|
|
|
|
|
2017-10-20 10:16:34 +02:00
|
|
|
# Add service to Yunohost's monitoring
|
|
|
|
yunohost service add minetest --log "/var/log/minetest/minetest.log"
|
2017-06-09 14:03:32 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CONFIGURE MINETEST
|
|
|
|
#=================================================
|
|
|
|
|
2017-10-20 10:16:34 +02:00
|
|
|
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
|
2017-06-09 14:03:32 +02:00
|
|
|
if [ $is_public -eq 1 ]
|
|
|
|
then
|
2017-10-20 10:16:34 +02:00
|
|
|
ynh_replace_string "__ANNOUNCE__" "true" /etc/minetest/minetest.conf
|
2017-06-09 14:03:32 +02:00
|
|
|
else
|
2017-10-20 10:16:34 +02:00
|
|
|
ynh_replace_string "__ANNOUNCE__" "false" /etc/minetest/minetest.conf
|
2017-06-09 14:03:32 +02:00
|
|
|
fi
|
2017-10-20 10:16:34 +02:00
|
|
|
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
|
2017-06-09 14:03:32 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTART MINETEST'S SERVICE
|
|
|
|
#=================================================
|
|
|
|
|
2017-10-20 10:16:34 +02:00
|
|
|
# Restart Minetest to use new settings
|
|
|
|
systemctl restart minetest-server
|