-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-toolbox.sh
More file actions
62 lines (52 loc) · 1.69 KB
/
install-toolbox.sh
File metadata and controls
62 lines (52 loc) · 1.69 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
#!/bin/bash
REPO_URL="https://github.com/Elpu7/linux-toolbox.git"
INSTALL_DIR="/opt/linux-toolbox"
BIN_PATH="/usr/local/bin/toolbox"
# Check if script is run as root
if [[ $EUID -ne 0 ]]; then
echo "This script requires root privileges. Please run it with sudo."
exit 1
fi
# Function to install or update
install_toolbox() {
echo "Downloading Linux-Toolbox from GitHub..."
if [ -d "$INSTALL_DIR" ]; then
echo "Updating existing installation..."
cd "$INSTALL_DIR"
git pull
else
echo "Installing in: $INSTALL_DIR"
git clone "$REPO_URL" "$INSTALL_DIR"
fi
# Set execution permissions
chmod +x "$INSTALL_DIR/toolbox.sh"
# Create a wrapper script to handle toolbox execution
echo '#!/bin/bash' > "$BIN_PATH"
echo 'if [[ "$1" == "update" ]]; then' >> "$BIN_PATH"
echo ' sudo bash /opt/linux-toolbox/install-toolbox.sh' >> "$BIN_PATH"
echo 'elif [[ "$1" == "remove" ]]; then' >> "$BIN_PATH"
echo ' sudo rm -rf /opt/linux-toolbox /usr/local/bin/toolbox' >> "$BIN_PATH"
echo ' echo "Linux-Toolbox has been removed."' >> "$BIN_PATH"
echo 'else' >> "$BIN_PATH"
echo ' bash /opt/linux-toolbox/toolbox.sh "$@"' >> "$BIN_PATH"
echo 'fi' >> "$BIN_PATH"
chmod +x "$BIN_PATH"
echo "Installation complete. Use 'toolbox' command to run."
}
# Function to remove toolbox
remove_toolbox() {
echo "Removing Linux-Toolbox..."
rm -rf "$INSTALL_DIR"
rm -f "$BIN_PATH"
echo "Linux-Toolbox has been removed."
}
# Handle command arguments
if [[ "$1" == "update" ]]; then
install_toolbox
exit 0
elif [[ "$1" == "remove" ]]; then
remove_toolbox
exit 0
fi
# Default to install
install_toolbox