-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreset-world.sh
More file actions
executable file
·146 lines (125 loc) · 6.39 KB
/
Copy pathreset-world.sh
File metadata and controls
executable file
·146 lines (125 loc) · 6.39 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env bash
###############################################################################
# Reset Project Zomboid World - Fresh Start
###############################################################################
# Load configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/config.sh"
# Colors
RED=$'\033[0;31m'
GREEN=$'\033[0;32m'
YELLOW=$'\033[1;33m'
BLUE=$'\033[0;34m'
CYAN=$'\033[0;36m'
NC=$'\033[0m'
source "$SCRIPT_DIR/lib/ui-box.sh"
BACKUP_DIR="$INSTALL_DIR/backups"
SERVER_NAME="pzserver"
SAVE_DIR="$ZOMBOID_DIR/Saves/Multiplayer/$SERVER_NAME"
DB_FILE="$ZOMBOID_DIR/db/$SERVER_NAME.db"
show_header() {
clear
# CRT Phosphor Green
local CRT_GREEN='\033[1;92m'
echo -e "${RED}"
cat << 'EOF'
██▓███ ██▀███ ▒█████ ▄▄▄██▀▀▀▓█████ ▄████▄ ▄▄▄█████▓ ▒███████▒ ▒█████ ███▄ ▄███▓ ▄▄▄▄ ▒█████ ██▓▓█████▄
▓██░ ██▒▓██ ▒ ██▒▒██▒ ██▒ ▒██ ▓█ ▀ ▒██▀ ▀█ ▓ ██▒ ▓▒ ▒ ▒ ▒ ▄▀░▒██▒ ██▒▓██▒▀█▀ ██▒▓█████▄ ▒██▒ ██▒▓██▒▒██▀ ██▌
▓██░ ██▓▒▓██ ░▄█ ▒▒██░ ██▒ ░██ ▒███ ▒▓█ ▄ ▒ ▓██░ ▒░ ░ ▒ ▄▀▒░ ▒██░ ██▒▓██ ▓██░▒██▒ ▄██▒██░ ██▒▒██▒░██ █▌
▒██▄█▓▒ ▒▒██▀▀█▄ ▒██ ██░▓██▄██▓ ▒▓█ ▄ ▒▓▓▄ ▄██▒░ ▓██▓ ░ ▄▀▒ ░▒██ ██░▒██ ▒██ ▒██░█▀ ▒██ ██░░██░░▓█▄ ▌
▒██▒ ░ ░░██▓ ▒██▒░ ████▓▒░ ▓███▒ ░▒████▒▒ ▓███▀ ░ ▒██▒ ░ ▒███████▒░ ████▓▒░▒██▒ ░██▒░▓█ ▀█▓░ ████▓▒░░██░░▒████▓
▒▓▒░ ░ ░░ ▒▓ ░▒▓░░ ▒░▒░▒░ ▒▓▒▒░ ░░ ▒░ ░░ ░▒ ▒ ░ ▒ ░░ ░▒▒ ▓░▒░▒░ ▒░▒░▒░ ░ ▒░ ░ ░░▒▓███▀▒░ ▒░▒░▒░ ░▓ ▒▒▓ ▒
░▒ ░ ░▒ ░ ▒░ ░ ▒ ▒░ ▒ ░▒░ ░ ░ ░ ░ ▒ ░ ░░▒ ▒ ░ ▒ ░ ▒ ▒░ ░ ░ ░▒░▒ ░ ░ ▒ ▒░ ▒ ░ ░ ▒ ▒
░░ ░░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ▒ ▒ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░
EOF
echo -e "${CRT_GREEN}"
cat << 'EOF'
▄▄▄▄▄▄ ▄▄ ▄▄ ▄▄▄▄▄▄▄
███▀▀██▄ ██ ▀▀ ██ ██ █████▀▀▀
███ ███ ▄█▀█▄ ▄████ ██ ▄████ ▀▀█▄ ▀██▀▀ ▄█▀█▄ ▄████ ▀████▄ ▄█▀█▄ ████▄ ██ ██ ▄█▀█▄ ████▄
███ ███ ██▄█▀ ██ ██ ██ ██ ▄█▀██ ██ ██▄█▀ ██ ██ ▀████ ██▄█▀ ██ ▀▀ ██▄██ ██▄█▀ ██ ▀▀
██████▀ ▀█▄▄▄ ▀████ ██▄ ▀████ ▀█▄██ ██ ▀█▄▄▄ ▀████ ███████▀ ▀█▄▄▄ ██ ▀█▀ ▀█▄▄▄ ██
EOF
echo -e "${NC}"
echo ""
}
show_header
box_header "${YELLOW}RESET WORLD TOOL${NC}"
echo -e "${RED}This will DELETE all world data and start fresh!${NC}"
echo ""
# Check if server is running
if pgrep -f "ProjectZomboid64.*pzserver" > /dev/null; then
echo "⚠ WARNING: Server is currently running!"
echo ""
read -p "Stop the server and continue? (yes/no): " confirm
if [ "$confirm" != "yes" ]; then
echo "Cancelled."
exit 0
fi
echo "Stopping server..."
pkill -f "ProjectZomboid64.*pzserver"
sleep 3
fi
# Check if world exists
if [ ! -d "$SAVE_DIR" ] && [ ! -f "$DB_FILE" ]; then
echo "ℹ No world found. Nothing to reset."
echo "The server will create a new world on next start."
exit 0
fi
echo ""
read -p "Create backup before reset? (yes/no): " do_backup
if [ "$do_backup" = "yes" ]; then
# Create backup
mkdir -p "$BACKUP_DIR"
BACKUP_FILE="$BACKUP_DIR/world-backup-$(date +%Y%m%d-%H%M%S).tar.gz"
echo ""
echo "Creating backup..."
# Create tar with conditional files
BACKUP_PATHS=""
[ -d "$SAVE_DIR" ] && BACKUP_PATHS="$BACKUP_PATHS $SAVE_DIR"
[ -f "$DB_FILE" ] && BACKUP_PATHS="$BACKUP_PATHS $DB_FILE"
if [ -n "$BACKUP_PATHS" ]; then
tar -czf "$BACKUP_FILE" $BACKUP_PATHS 2>/dev/null
fi
if [ -f "$BACKUP_FILE" ]; then
SIZE=$(du -h "$BACKUP_FILE" | cut -f1)
echo "✓ Backup created: $BACKUP_FILE ($SIZE)"
else
echo "✗ Backup failed!"
exit 1
fi
fi
echo ""
read -p "Are you SURE you want to DELETE the world? (type 'DELETE' to confirm): " final_confirm
if [ "$final_confirm" != "DELETE" ]; then
echo "Cancelled. World preserved."
exit 0
fi
# Delete world data
echo ""
echo "Deleting world data..."
if [ -d "$SAVE_DIR" ]; then
rm -rf "$SAVE_DIR"
echo "✓ Deleted: $SAVE_DIR"
fi
if [ -f "$DB_FILE" ]; then
rm -f "$DB_FILE"
echo "✓ Deleted: $DB_FILE (player database)"
fi
echo ""
box_top
box_line "${GREEN}✓ World Reset Complete!${NC}"
box_bottom
echo ""
echo "The server will create a fresh new world on next start."
echo ""
echo -e "${YELLOW}To start the server:${NC}"
echo " ./start-all.sh"
echo ""
if [ "$do_backup" = "yes" ]; then
echo -e "${BLUE}Your old world backup is saved at:${NC}"
echo " $BACKUP_FILE"
echo ""
fi