1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/minetest_ynh.git synced 2024-09-03 20:36:00 +02:00
minetest_ynh/scripts/install

111 lines
3.7 KiB
Text
Raw Normal View History

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
#=================================================
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
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.
# 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
# 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}
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
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
gpg --keyserver pgpkeys.mit.edu --recv-key 7638D0442B90D010
2017-10-20 10:58:42 +02:00
gpg --keyserver pgpkeys.mit.edu --recv-key 8B48AD6246925553
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
ynh_package_update
ynh_install_app_dependencies minetest-server
2017-06-09 14:03:32 +02:00
#=================================================
# ENABLE SERVICE IN ADMIN PANEL
#=================================================
# 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
#=================================================
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
ynh_replace_string "__ANNOUNCE__" "true" /etc/minetest/minetest.conf
2017-06-09 14:03:32 +02:00
else
ynh_replace_string "__ANNOUNCE__" "false" /etc/minetest/minetest.conf
2017-06-09 14:03:32 +02:00
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
2017-06-09 14:03:32 +02:00
#=================================================
# RESTART MINETEST'S SERVICE
#=================================================
# Restart Minetest to use new settings
systemctl restart minetest-server