2019-02-13 23:07:44 +01:00
|
|
|
#!/bin/bash
|
2019-04-07 18:20:06 +02:00
|
|
|
serverpath=/home/minetest/nalc-1.1
|
|
|
|
bak=0
|
|
|
|
restart=0
|
2019-02-13 23:07:44 +01:00
|
|
|
|
2019-04-07 18:20:06 +02:00
|
|
|
action() {
|
|
|
|
kill -s TERM $(pidof minetestserver)
|
|
|
|
sleep 10
|
2019-02-13 23:07:44 +01:00
|
|
|
|
2019-04-07 18:20:06 +02:00
|
|
|
kill -s TERM $(pidof -x $serverpath/start.sh)
|
2019-02-13 23:07:44 +01:00
|
|
|
|
2019-04-07 18:20:06 +02:00
|
|
|
[[ $bak -eq 1 ]] && $serverpath/backup.sh
|
|
|
|
[[ $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 -l bak,restart -- "$@")
|
|
|
|
|
|
|
|
# éclatement de $options en $1, $2...
|
|
|
|
set -- $OPT
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
-b|--bak)
|
|
|
|
bak=1
|
|
|
|
shift;;
|
|
|
|
-r|--restart)
|
|
|
|
restart=1
|
|
|
|
shift;;
|
|
|
|
--)
|
|
|
|
shift;;
|
|
|
|
*)
|
|
|
|
action
|
|
|
|
shift;;
|
|
|
|
esac
|
|
|
|
done
|