-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathinstall.sh
74 lines (65 loc) · 2.16 KB
/
install.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
#!/usr/bin/env bash
#########################################################
#
# This script performs the following tasks:
# 1. Sets the version tag for the Yiimpoolv1 installation.
# 2. Checks and installs git if it's not already installed.
# 3. Clones the Yiimpoolv1 installer repository from GitHub.
# 4. Updates the repository to the specified version tag if necessary.
# 5. Starts the Yiimpoolv1 installation process.
#
# Author: Afiniel
# Date: 2024-07-13
#
#########################################################
# Default version tag if not provided as environment variable
TAG=${TAG:-v2.5.0}
# File paths
YIIMPOOL_VERSION_FILE="/etc/yiimpoolversion.conf"
YIIMPOOL_INSTALL_DIR="$HOME/Yiimpoolv1"
# Function to log messages to stderr
log_error() {
echo "[ERROR] $1" >&2
}
# Function to install git if not already installed
install_git() {
if ! command -v git &>/dev/null; then
log_error "Git is not installed. Installing git..."
sudo apt-get -q update
DEBIAN_FRONTEND=noninteractive sudo apt-get -q install -y git < /dev/null
echo "Git installed."
else
echo "Git is already installed."
fi
}
# Function to clone or update the Yiimpool installer repository
clone_or_update_repo() {
if [ ! -d "$YIIMPOOL_INSTALL_DIR" ]; then
echo "Cloning Yiimpool Installer ${TAG}..."
git clone -b "${TAG}" --depth 1 https://github.com/afiniel/Yiimpoolv1 "$YIIMPOOL_INSTALL_DIR" < /dev/null
echo "Repository cloned."
else
echo "Updating Yiimpool Installer to ${TAG}..."
cd "$YIIMPOOL_INSTALL_DIR"
sudo chown -R "$USER" "$YIIMPOOL_INSTALL_DIR/.git/"
git fetch --depth 1 --force --prune origin tag "${TAG}"
if ! git checkout -q "${TAG}"; then
log_error "Failed to update repository to ${TAG}."
exit 1
fi
echo "Repository updated."
fi
}
# Function to set the Yiimpool version in configuration file
set_yiimpool_version() {
echo "VERSION=${TAG}" | sudo tee "$YIIMPOOL_VERSION_FILE" >/dev/null
}
# Function to start the Yiimpool installation script
start_installation() {
bash "$YIIMPOOL_INSTALL_DIR/install/start.sh"
}
# Perform installation steps
install_git
clone_or_update_repo
set_yiimpool_version
start_installation