-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathupdate-config.sh
75 lines (59 loc) · 1.85 KB
/
update-config.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
#!/bin/bash
# Check if script is run with sudo
if [ "$EUID" -ne 0 ]; then
echo "Please run with sudo"
exit 1
fi
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check for required commands and install if missing
echo "Checking dependencies..."
PACKAGES_TO_INSTALL=""
if ! command_exists wget; then
PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL wget"
fi
if ! command_exists unzip; then
PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL unzip"
fi
if [ ! -z "$PACKAGES_TO_INSTALL" ]; then
echo "Installing required packages: $PACKAGES_TO_INSTALL"
apt-get update
apt-get install -y $PACKAGES_TO_INSTALL
if [ $? -ne 0 ]; then
echo "Failed to install required packages"
exit 1
fi
fi
# Create temporary directory
TEMP_DIR=$(mktemp -d)
echo "Created temporary directory: $TEMP_DIR"
# Download repository
echo "Downloading configuration files..."
wget -q https://github.com/Swofty-Developments/HypixelSkyBlock/archive/refs/heads/master.zip -O "$TEMP_DIR/master.zip"
# Check if download was successful
if [ $? -ne 0 ]; then
echo "Failed to download repository"
rm -rf "$TEMP_DIR"
exit 1
fi
# Unzip the repository
echo "Extracting files..."
unzip -q "$TEMP_DIR/master.zip" -d "$TEMP_DIR"
# Remove existing folders if they exist
echo "Removing existing configuration folders..."
rm -rf ./items
rm -rf ./collections
# Copy new configuration folders
echo "Copying new configuration files..."
cp -r "$TEMP_DIR/HypixelSkyBlock-master/configuration/items" .
cp -r "$TEMP_DIR/HypixelSkyBlock-master/configuration/collections" .
# Fix permissions to make files accessible to the original user
SUDO_USER=$(logname)
chown -R $SUDO_USER:$SUDO_USER ./items
chown -R $SUDO_USER:$SUDO_USER ./collections
# Cleanup
echo "Cleaning up..."
rm -rf "$TEMP_DIR"
echo "Configuration update complete!"