|
|
@@ -15,16 +15,16 @@ if [ -f /etc/os-release ]; then |
|
|
|
OS_NAME=$NAME |
|
|
|
fi |
|
|
|
|
|
|
|
# Function to check the OS type |
|
|
|
# Function to check if the OS is CentOS or CentOS Stream |
|
|
|
is_centos() { |
|
|
|
# Check if the OS is CentOS |
|
|
|
# Check if the OS is CentOS or CentOS Stream |
|
|
|
if [ -f /etc/os-release ]; then |
|
|
|
. /etc/os-release |
|
|
|
if [[ "$NAME" == "CentOS Linux" ]] || [[ "$NAME" == "CentOS" ]]; then |
|
|
|
return 0 # It's CentOS |
|
|
|
if [[ "$OS_NAME" == "CentOS Linux" ]] || [[ "$NAME" == "CentOS Stream" ]]; then |
|
|
|
return 0 # It's CentOS or CentOS Stream |
|
|
|
fi |
|
|
|
fi |
|
|
|
return 1 # Not CentOS |
|
|
|
return 1 # Not CentOS or CentOS Stream |
|
|
|
} |
|
|
|
|
|
|
|
# Set ROOT directory |
|
|
@@ -37,7 +37,6 @@ else |
|
|
|
GROUP_NAME="wheel" # CentOS/RHEL typically use 'wheel' |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# Trim whitespace from both current_user and username |
|
|
|
current_user=$(echo "$current_user" | xargs) |
|
|
|
username=$(echo "$username" | xargs) |
|
|
@@ -148,25 +147,23 @@ sudo chown -R $USER:$USER $ROOT |
|
|
|
cd $ROOT || { echo "Failed to change to ROOT directory $ROOT"; exit 1; } |
|
|
|
echo $PWD |
|
|
|
|
|
|
|
# Only run this block if it's CentOS or CentOS Stream |
|
|
|
# if is_centos; then |
|
|
|
|
|
|
|
if [ -f /etc/os-release ]; then |
|
|
|
. /etc/os-release |
|
|
|
if [[ "$OS_NAME" == "CentOS Linux" ]] || [[ "$NAME" == "CentOS" ]]; then |
|
|
|
echo "This is CentOS Running CentOS specific script..." |
|
|
|
|
|
|
|
# Only run this block if it's CentOS |
|
|
|
if is_centos; then |
|
|
|
echo "This is CentOS. Running CentOS specific script..." |
|
|
|
|
|
|
|
# Download and run CentOS-specific script |
|
|
|
wget -q -O - http://git.bbh/chess/elxr/raw/branch/master/centosinit.sh > $ROOT/centosinit.sh |
|
|
|
sudo chmod u+x $ROOT/centosinit.sh |
|
|
|
sh $ROOT/centosinit.sh |
|
|
|
else |
|
|
|
echo "This is not CentOS. Skipping CentOS-specific setup." |
|
|
|
fi |
|
|
|
|
|
|
|
# Platform-specific installation |
|
|
|
if [ -f /etc/os-release ]; then |
|
|
|
. /etc/os-release |
|
|
|
OS_NAME=$NAME |
|
|
|
OS_VERSION=$VERSION_ID |
|
|
|
fi |
|
|
|
# Download and run CentOS-specific script |
|
|
|
wget -q -O - http://git.bbh/chess/elxr/raw/branch/master/centosinit.sh > $ROOT/centosinit.sh |
|
|
|
sudo chmod u+x $ROOT/centosinit.sh |
|
|
|
sh $ROOT/centosinit.sh |
|
|
|
fi |
|
|
|
fi |
|
|
|
# else |
|
|
|
# echo "This is not CentOS. Skipping CentOS-specific setup." |
|
|
|
# fi |
|
|
|
|
|
|
|
# Function to check if a package is installed |
|
|
|
is_package_installed() { |
|
|
@@ -184,8 +181,8 @@ install_package() { |
|
|
|
if [ "$OS_NAME" == "Ubuntu" ] || [ "$OS_NAME" == "Debian" ]; then |
|
|
|
sudo apt update |
|
|
|
sudo apt install -y $package || { echo "Failed to install $package"; exit 1; } |
|
|
|
elif [[ "$OS_NAME" == "CentOS Linux" ]] || [[ "$OS_NAME" == "CentOS" ]] || [[ "$OS_NAME" == "Red Hat" ]]; then |
|
|
|
# Prefer dnf for CentOS 8 and above |
|
|
|
elif [[ "$OS_NAME" == "CentOS Linux" ]] || [[ "$OS_NAME" == "CentOS Stream" ]] || [[ "$OS_NAME" == "Red Hat" ]]; then |
|
|
|
# Prefer dnf for CentOS Stream |
|
|
|
if command -v dnf &>/dev/null; then |
|
|
|
sudo dnf install -y $package || { echo "Failed to install $package"; exit 1; } |
|
|
|
else |
|
|
@@ -216,18 +213,25 @@ else |
|
|
|
|
|
|
|
# Install Python 2 if not installed |
|
|
|
if ! is_package_installed "python2"; then |
|
|
|
install_package "python2" |
|
|
|
if [ -f /etc/os-release ]; then |
|
|
|
. /etc/os-release |
|
|
|
if [[ "$OS_NAME" == "CentOS Linux" ]] || [[ "$NAME" == "Ubuntu" ]]; then |
|
|
|
install_package "python2" |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
# Install build tools based on OS type |
|
|
|
if [ "$OS_NAME" == "Ubuntu" ] || [ "$OS_NAME" == "Debian" ]; then |
|
|
|
install_package "build-essential" |
|
|
|
elif [[ "$OS_NAME" == "CentOS Linux" ]] || [[ "$OS_NAME" == "CentOS" ]] || [[ "$OS_NAME" == "Red Hat" ]]; then |
|
|
|
elif [[ "$OS_NAME" == "CentOS Linux" ]] || [[ "$OS_NAME" == "CentOS Stream" ]] || [[ "$OS_NAME" == "Red Hat" ]]; then |
|
|
|
install_package "gcc" |
|
|
|
install_package "make" |
|
|
|
install_package "glibc-devel" |
|
|
|
install_package "gcc-c++" |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
# Install NVM (Node Version Manager) |
|
|
|
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash |
|
|
@@ -253,7 +257,6 @@ command -v nvm |
|
|
|
|
|
|
|
# Install code editor (VSCode) |
|
|
|
if [[ "$OS_NAME" == "Ubuntu" ]] || [[ "$OS_NAME" == "Debian" ]]; then |
|
|
|
# VSCode installation for Debian-based systems (Ubuntu/Debian) |
|
|
|
install_package "wget" |
|
|
|
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg |
|
|
|
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg |
|
|
@@ -262,31 +265,28 @@ command -v nvm |
|
|
|
sudo apt install apt-transport-https |
|
|
|
sudo apt update |
|
|
|
sudo apt install code -y |
|
|
|
elif [[ "$OS_NAME" == "CentOS Linux" ]] || [[ "$OS_NAME" == "CentOS" ]] || [[ "$OS_NAME" == "Red Hat" ]]; then |
|
|
|
# VSCode installation for CentOS-based systems (CentOS 8 / RHEL) |
|
|
|
elif [[ "$OS_NAME" == "CentOS Stream" ]] || [[ "$OS_NAME" == "CentOS Linux" ]] || [[ "$OS_NAME" == "Red Hat" ]]; then |
|
|
|
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc |
|
|
|
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo' |
|
|
|
sudo dnf check-update |
|
|
|
sudo dnf install code -y |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
# Install OpenJDK 11 (Java) for both Debian/Ubuntu and CentOS/RHEL systems |
|
|
|
if [ "$OS_NAME" == "Ubuntu" ] || [ "$OS_NAME" == "Debian" ]; then |
|
|
|
install_package "openjdk-11-jre-headless" |
|
|
|
elif [[ "$OS_NAME" == "CentOS Linux" ]] || [[ "$OS_NAME" == "CentOS" ]] || [[ "$OS_NAME" == "Red Hat" ]]; then |
|
|
|
# Install Java 11 on CentOS/RHEL-based systems |
|
|
|
elif [[ "$OS_NAME" == "CentOS Linux" ]] || [[ "$OS_NAME" == "Red Hat" ]]; then |
|
|
|
# [[ "$OS_NAME" == "CentOS Stream" ]] || -- skip java for centos stream |
|
|
|
sudo dnf install java-11-openjdk -y || { echo "Failed to install Java 11"; exit 1; } |
|
|
|
fi |
|
|
|
|
|
|
|
# MySQL Installation for CentOS (without debconf-set-selections) |
|
|
|
if [[ "$OS_NAME" == "CentOS Linux" ]] || [[ "$OS_NAME" == "CentOS" ]] || [[ "$OS_NAME" == "Red Hat" ]]; then |
|
|
|
# MySQL Installation for CentOS Stream |
|
|
|
if [[ "$OS_NAME" == "CentOS Linux" ]] || [[ "$OS_NAME" == "CentOS Stream" ]]; then |
|
|
|
sudo dnf install mysql-server -y |
|
|
|
sudo systemctl start mysqld |
|
|
|
sudo systemctl enable mysqld |
|
|
|
MYSQL_ROOT_PASSWORD=$(sudo grep 'temporary password' /var/log/mysqld.log | tail -n 1 | awk '{print $NF}') |
|
|
|
echo "MySQL root temporary password: $MYSQL_ROOT_PASSWORD" |
|
|
|
# Secure MySQL installation |
|
|
|
sudo mysql_secure_installation |
|
|
|
else |
|
|
|
# If on Ubuntu/Debian, you can use debconf-set-selections |
|
|
@@ -301,7 +301,7 @@ fi |
|
|
|
git clone $REPOSERVER/$REPOOWNER/bbhverse |
|
|
|
cd bbhverse |
|
|
|
npm i |
|
|
|
cd .. |
|
|
|
cd .. |
|
|
|
git clone $REPOSERVER/$REPOOWNER/serververse |
|
|
|
git clone $REPOSERVER/$REPOOWNER/global-this |
|
|
|
git clone $REPOSERVER/$REPOOWNER/elxr.git |
|
|
@@ -336,7 +336,7 @@ echo "Setup completed successfully!" |
|
|
|
# ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'cihsr'; |
|
|
|
# FLUSH PRIVILEGES; |
|
|
|
|
|
|
|
bash elxr/load.mysql.init.sh |
|
|
|
bash elxr/mysql.init.sh |
|
|
|
bash elxr/load.mysql.sh |
|
|
|
bash elxr/i.sqlexpress.sh |
|
|
|
bash elxr/load.sqlexpress.sh |