2017-10-20 13:56:48 +02:00

100 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
#=================================================
# GENERIC STARTING
#=================================================
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
if [ ! -e _common.sh ]; then
# Get the functions file if not present in the current directory
sudo cp ../settings/scripts/_common.sh ./_common.sh
sudo chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
pvp=$(ynh_app_setting_get $app pvp)
damage=$(ynh_app_setting_get $app damage)
domain=$(ynh_app_setting_get $app domain)
creative=$(ynh_app_setting_get $app creative)
is_public=$(ynh_app_setting_get $app is_public)
#=================================================
# BACKUP STEPS
#=================================================
# RESTORE APT PREFERENCES AND SOURCES.LIST
#=================================================
ynh_restore_file "/etc/apt/sources.list.d/$app.list"
ynh_restore_file "/etc/apt/preferences.d/00MinetestPinning"
#=================================================
# INSTALL
#=================================================
if [ $(uname -m) == "armv7l" ]
then
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
if [ $(apt-key finger | grep "7638 D044 2B90 D010" -c) == 0 ]
then
gpg -a --export 7638D0442B90D010 | apt-key add -
fi
if [ $(apt-key finger | grep "8B48 AD62 4692 5553" -c) == 0 ]
then
gpg -a --export 8B48AD6246925553 | apt-key add -
fi
fi
ynh_package_update
ynh_install_app_dependencies minetest-server sqlite3
#=================================================
# ENABLE SERVICE IN ADMIN PANEL
#=================================================
# Add service to Yunohost's monitoring
yunohost service add minetest --log "/var/log/minetest/minetest.log"
#=================================================
# STOP MINETEST
#=================================================
service minetest-server stop
#=================================================
# CONFIGURATION
#=================================================
ynh_secure_remove "/etc/minetest/minetest.conf"
ynh_restore_file "/etc/minetest/minetest.conf"
#=================================================
# DATA
#=================================================
ynh_secure_remove "/var/games/minetest-server/"
ynh_restore_file "/var/games/minetest-server/"
ynh_restore_file "/tmp/map.sqlite"
echo ".restore /tmp/map.sqlite" | sqlite3 /var/games/minetest-server/.minetest/worlds/world/map.sqlite
#=================================================
# START MINETEST
#=================================================
service minetest-server start