This repository has been archived by the owner on Oct 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
start-on-system.sh
executable file
·94 lines (91 loc) · 2.36 KB
/
start-on-system.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
### BEGIN INIT INFO
# Provides: BDS
# Required-Start: $network
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Minecraft BDS Auto Start
### END INIT INFO
NAME="BDS"
if [[ "$EUID" -ne 0 ]]; then
echo "Você não está executando o service com root ou sudo";exit 1
fi
sh23backup(){
DATE="$(TZ=UTC+3 date +"%H-%M-%S")"
DA2TE="$(TZ=UTC+3 date +"%d/%m/%Y-%H-%M-%S")"
TM="/tmp/"
MKDIRID="IDSh23"
rm -rf "$TM/ID.txt"
gdrive mkdir $(echo $DA2TE) -p "$MKDIRID" >> "$TM/ID.txt"
sed -i "s| created||g" "$TM/ID.txt"
sed -i "s|Directory ||g" "$TM/ID.txt"
GDRIVE_FOLDE="$(cat $TM/ID.txt)"
# ------------------------------
PATH_TO_INSTALL="MINESh23"
PATH_TO_BACKUP="MINE2Sh23"
MAPS_DO="NAMESh23"
ALLNAME="$MAPS_DO-$DATE"
# -------------------------------
cd "$PATH_TO_INSTALL/worlds/"
zip "$ALLNAME.zip" -r "$MAPS_DO"
cp "$ALLNAME.zip" "$PATH_TO_BACKUP/"
gdrive upload "$ALLNAME.zip" --parent "$GDRIVE_FOLDE"
rm "$ALLNAME.zip"
}
startsh23(){
sudo screen -dmS bedrock BDS
}
stopsh23(){
screen -Rd bedrock -X stuff
sleep 5
screen -Rd bedrock -X stuff
sleep 1
screen -Rd bedrock -X stuff
sleep 1
screen -Rd bedrock -X stuff
sleep 1
screen -Rd bedrock -X stuff
sleep 1
screen -Rd bedrock -X stuff
sleep 1
screen -Rd bedrock -X stuff
screen -X -S bedrock quit
sh23backup
}
restartsh23(){
if ! screen -list | grep -q "bedrock"; then
echo "Servidor não está ligado ou Não foi possivel reinicia."
else
echo "Reiniciando o servidor em 30 segundos"
screen -Rd bedrock -X stuff
sleep 25
screen -Rd bedrock -X stuff
sleep 1
screen -Rd bedrock -X stuff
sleep 1
screen -Rd bedrock -X stuff
sleep 1
screen -Rd bedrock -X stuff
sleep 1
screen -Rd bedrock -X stuff
sleep 1
screen -Rd bedrock -X stuff
sh23backup
screen -X -S bedrock quit
echo "O servidor está ligado ágora:)"
sleep 2
screen -dmS bedrock
screen -S bedrock -X stuff "./bedrock_server"
fi
}
status-sh23(){
status_of_proc -p $PIDFILE "$NAME" "$NAME"
exit $?
}
case "$1" in
start) startsh23 ;;
stop) stopsh23 ;;
restart) restartsh23;;
esac
exit 0