forked from nalc/nalc-server
67 lines
1.4 KiB
Bash
Executable File
67 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Author: Sys4
|
|
# Licence: GPLv3
|
|
serverpath=/home/minetest/nalc-stable
|
|
world=nalc-stable
|
|
world_file=all # news|technic|fbn|fbnp|bitchange|christmas|randommsg
|
|
branch=stable # 1.0|1.1|dev
|
|
bak=0
|
|
update=0
|
|
restart=0
|
|
|
|
usage() {
|
|
echo "usage: ./shutdown.sh [-h|--help] [-r|--restart] [-b|--bak] [-u|--update]"
|
|
echo "Options:"
|
|
echo -e "\t-h --help\tAffiche cette aide."
|
|
echo -e "\t-r --restart\tRedémarre le serveur après arrêt."
|
|
echo -e "\t-b --bak\tRéalise une sauvegarde après arrêt."
|
|
echo -e "\t-u --update\tRéalise une mise à jour après arrêt."
|
|
exit 0
|
|
}
|
|
|
|
action() {
|
|
kill -s TERM $(pidof minetestserver)
|
|
sleep 10
|
|
|
|
kill -s TERM $(pidof -x $serverpath/start.sh)
|
|
|
|
[[ $bak -eq 1 ]] && $serverpath/backup.sh
|
|
[[ $update -eq 1 ]] && $serverpath/upgrade.sh -s $serverpath -m -w $world -b $branch -f $world_file
|
|
[[ $restart -eq 1 ]] && $serverpath/start.sh&
|
|
|
|
exit 0
|
|
}
|
|
|
|
# Pas de paramètre
|
|
#[[ $# -lt 1 ]] && error
|
|
# ou
|
|
[[ $# -lt 1 ]] && action
|
|
|
|
# -o : Options courtes
|
|
# -l : options longues
|
|
OPT=$(getopt -o b,r,h,u -l bak,restart,help,update -- "$@")
|
|
|
|
# éclatement de $options en $1, $2...
|
|
set -- $OPT
|
|
|
|
while true; do
|
|
case "$1" in
|
|
-b|--bak)
|
|
bak=1
|
|
shift;;
|
|
-r|--restart)
|
|
restart=1
|
|
shift;;
|
|
-h|--help)
|
|
usage;;
|
|
-u|--update)
|
|
update=1
|
|
shift;;
|
|
--)
|
|
shift;;
|
|
*)
|
|
action
|
|
shift;;
|
|
esac
|
|
done
|