mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
Update INSTALL.sh
This commit is contained in:
parent
8c057bdb0d
commit
ad279c6eab
184
INSTALL.sh
184
INSTALL.sh
@ -172,13 +172,6 @@ set_version_to_install(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# configure apt to retry downloading on error
|
|
||||||
if [ ! -f /etc/apt/apt.conf.d/80-retries ]; then
|
|
||||||
echo "APT::Acquire::Retries \"3\";" > /etc/apt/apt.conf.d/80-retries
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# print fullwidth line
|
# print fullwidth line
|
||||||
print_space_and_line() {
|
print_space_and_line() {
|
||||||
echo " "
|
echo " "
|
||||||
@ -187,15 +180,29 @@ print_space_and_line() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
setup_progress_bar_script(){
|
||||||
|
# Progress bar script
|
||||||
|
PROGRESS_BAR_URL="https://raw.githubusercontent.com/pollev/bash_progress_bar/master/progress_bar.sh"
|
||||||
|
PROGRESS_BAR_FILE="progress_bar.sh"
|
||||||
|
|
||||||
# Progress bar script
|
# Check if wget is available
|
||||||
PROGRESS_BAR_URL="https://raw.githubusercontent.com/pollev/bash_progress_bar/master/progress_bar.sh"
|
if command -v wget &> /dev/null; then
|
||||||
PROGRESS_BAR_FILE="progress_bar.sh"
|
wget "$PROGRESS_BAR_URL" -O "$PROGRESS_BAR_FILE" > /dev/null 2>&1
|
||||||
wget "$PROGRESS_BAR_URL" -O "$PROGRESS_BAR_FILE" > /dev/null 2>&1
|
# If wget is not available, check if curl is available *(fallback for fedora)
|
||||||
if [ ! -f "$PROGRESS_BAR_FILE" ]; then
|
elif command -v curl &> /dev/null; then
|
||||||
echo "ERROR: Failed to download progress_bar.sh - Github is not reachable by your server: https://raw.githubusercontent.com"
|
curl -s "$PROGRESS_BAR_URL" -o "$PROGRESS_BAR_FILE" > /dev/null 2>&1
|
||||||
exit 1
|
else
|
||||||
fi
|
echo "Neither wget nor curl is available. Please install one of them to proceed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$PROGRESS_BAR_FILE" ]; then
|
||||||
|
echo "ERROR: Failed to download progress_bar.sh - Github is not reachable by your server: https://raw.githubusercontent.com"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_progress_bar_script
|
||||||
|
|
||||||
# Source the progress bar script
|
# Source the progress bar script
|
||||||
source "$PROGRESS_BAR_FILE"
|
source "$PROGRESS_BAR_FILE"
|
||||||
@ -226,7 +233,7 @@ set_system_cronjob # cron after firewall, otherwise user gets false-positive not
|
|||||||
set_logrotate
|
set_logrotate
|
||||||
tweak_ssh
|
tweak_ssh
|
||||||
setup_swap
|
setup_swap
|
||||||
clean_apt_cache
|
clean_apt_and_dnf_cache
|
||||||
verify_license
|
verify_license
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -484,7 +491,7 @@ detect_os_and_package_manager() {
|
|||||||
"debian"|"ubuntu")
|
"debian"|"ubuntu")
|
||||||
PACKAGE_MANAGER="apt-get"
|
PACKAGE_MANAGER="apt-get"
|
||||||
;;
|
;;
|
||||||
"centos"|"cloudlinux"|"rhel"|"fedora"|"almalinux"|"rockylinux")
|
"centos"|"cloudlinux"|"rhel"|"fedora"|"almalinux"|"rocky")
|
||||||
PACKAGE_MANAGER="yum"
|
PACKAGE_MANAGER="yum"
|
||||||
if [ "$(command -v dnf)" ]; then
|
if [ "$(command -v dnf)" ]; then
|
||||||
PACKAGE_MANAGER="dnf"
|
PACKAGE_MANAGER="dnf"
|
||||||
@ -546,8 +553,6 @@ check_lock_file_age() {
|
|||||||
|
|
||||||
configure_docker() {
|
configure_docker() {
|
||||||
|
|
||||||
#########apt-get install docker.io -y
|
|
||||||
|
|
||||||
docker_daemon_json_path="/etc/docker/daemon.json"
|
docker_daemon_json_path="/etc/docker/daemon.json"
|
||||||
mkdir -p $(dirname "$docker_daemon_json_path")
|
mkdir -p $(dirname "$docker_daemon_json_path")
|
||||||
|
|
||||||
@ -619,11 +624,14 @@ docker_compose_up(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
clean_apt_cache(){
|
clean_apt_and_dnf_cache(){
|
||||||
# clear /var/cache/apt/archives/
|
|
||||||
apt-get clean
|
|
||||||
|
|
||||||
# TODO: cover https://github.com/debuerreotype/debuerreotype/issues/95
|
if [ "$PACKAGE_MANAGER" == "dnf" ]; then
|
||||||
|
dnf clean > /dev/null > /dev/null 2>&1
|
||||||
|
elif [ "$PACKAGE_MANAGER" == "apt-get" ]; then
|
||||||
|
# clear /var/cache/apt/archives/ # TODO: cover https://github.com/debuerreotype/debuerreotype/issues/95
|
||||||
|
apt-get clean > /dev/null > /dev/null 2>&1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
tweak_ssh(){
|
tweak_ssh(){
|
||||||
@ -674,25 +682,29 @@ setup_firewall_service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
install_csf() {
|
install_csf() {
|
||||||
wget https://download.configserver.com/csf.tgz
|
debug_log wget https://download.configserver.com/csf.tgz
|
||||||
tar -xzf csf.tgz
|
debug_log tar -xzf csf.tgz
|
||||||
rm csf.tgz
|
rm csf.tgz
|
||||||
cd csf
|
cd csf
|
||||||
sh install.sh
|
debug_log sh install.sh
|
||||||
cd ..
|
cd ..
|
||||||
rm -rf csf
|
rm -rf csf
|
||||||
#perl /usr/local/csf/bin/csftest.pl
|
#perl /usr/local/csf/bin/csftest.pl
|
||||||
|
|
||||||
# for csf ui
|
|
||||||
apt-get install -y perl libwww-perl libgd-dev libgd-perl libgd-graph-perl
|
|
||||||
|
|
||||||
|
echo "Setting CSF auto-login from OpenAdmin interface.."
|
||||||
|
if [ "$PACKAGE_MANAGER" == "dnf" ]; then
|
||||||
|
debug_log dnf install -y wget curl unzip yum-utils policycoreutils-python-utils
|
||||||
|
elif [ "$PACKAGE_MANAGER" == "apt-get" ]; then
|
||||||
|
debug_log apt-get install -y perl libwww-perl libgd-dev libgd-perl libgd-graph-perl
|
||||||
|
fi
|
||||||
# autologin from openpanel
|
# autologin from openpanel
|
||||||
ln -s /etc/csf/ui/images/ /usr/local/admin/static/configservercsf
|
ln -s /etc/csf/ui/images/ /usr/local/admin/static/configservercsf
|
||||||
chmod +x /usr/local/admin/modules/security/csf.pl
|
chmod +x /usr/local/admin/modules/security/csf.pl
|
||||||
|
|
||||||
|
|
||||||
# play nice with docker
|
# play nice with docker
|
||||||
git clone https://github.com/stefanpejcic/csfpost-docker.sh
|
git clone https://github.com/stefanpejcic/csfpost-docker.sh > /dev/null 2>&1 &&
|
||||||
mv csfpost-docker.sh/csfpost.sh /usr/local/csf/bin/csfpost.sh
|
mv csfpost-docker.sh/csfpost.sh /usr/local/csf/bin/csfpost.sh
|
||||||
chmod +x /usr/local/csf/bin/csfpost.sh
|
chmod +x /usr/local/csf/bin/csfpost.sh
|
||||||
rm -rf csfpost-docker.sh
|
rm -rf csfpost-docker.sh
|
||||||
@ -787,7 +799,15 @@ setup_firewall_service() {
|
|||||||
|
|
||||||
elif [ "$UFW_SETUP" = true ]; then
|
elif [ "$UFW_SETUP" = true ]; then
|
||||||
echo "Setting up UncomplicatedFirewall.."
|
echo "Setting up UncomplicatedFirewall.."
|
||||||
apt-get install ufw > /dev/null 2>&1 &&
|
if [ "$PACKAGE_MANAGER" == "dnf" ]; then
|
||||||
|
dnf makecache --refresh > /dev/null 2>&1
|
||||||
|
dnf install -y ufw > /dev/null 2>&1
|
||||||
|
|
||||||
|
elif [ "$PACKAGE_MANAGER" == "apt-get" ]; then
|
||||||
|
apt-get install -y ufw > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# set ufw to be monitored instead of csf
|
# set ufw to be monitored instead of csf
|
||||||
sed -i 's/csf/ufw/g' "${ETC_DIR}openadmin/config/notifications.ini" > /dev/null 2>&1
|
sed -i 's/csf/ufw/g' "${ETC_DIR}openadmin/config/notifications.ini" > /dev/null 2>&1
|
||||||
sed -i 's/ConfigServer Firewall/Uncomplicated Firewall/g' "${ETC_DIR}openadmin/config/services.json" > /dev/null 2>&1
|
sed -i 's/ConfigServer Firewall/Uncomplicated Firewall/g' "${ETC_DIR}openadmin/config/services.json" > /dev/null 2>&1
|
||||||
@ -899,25 +919,25 @@ install_packages() {
|
|||||||
|
|
||||||
echo "Installing required services.."
|
echo "Installing required services.."
|
||||||
|
|
||||||
# https://www.faqforge.com/linux/fixed-ubuntu-apt-get-upgrade-auto-restart-services/
|
|
||||||
|
|
||||||
debug_log sed -i 's/#$nrconf{restart} = '"'"'i'"'"';/$nrconf{restart} = '"'"'a'"'"';/g' /etc/needrestart/needrestart.conf
|
|
||||||
|
|
||||||
packages=("docker.io" "default-mysql-client" "python3-pip" "pip" "gunicorn" "jc" "sqlite3" "geoip-bin")
|
packages=("docker.io" "default-mysql-client" "python3-pip" "pip" "gunicorn" "jc" "sqlite3" "geoip-bin")
|
||||||
|
|
||||||
if [ "$PACKAGE_MANAGER" == "apt-get" ]; then
|
if [ "$PACKAGE_MANAGER" == "apt-get" ]; then
|
||||||
#only once..
|
|
||||||
debug_log $PACKAGE_MANAGER -qq install apt-transport-https ca-certificates -y
|
# https://www.faqforge.com/linux/fixed-ubuntu-apt-get-upgrade-auto-restart-services/
|
||||||
|
debug_log sed -i 's/#$nrconf{restart} = '"'"'i'"'"';/$nrconf{restart} = '"'"'a'"'"';/g' /etc/needrestart/needrestart.conf
|
||||||
|
|
||||||
|
debug_log $PACKAGE_MANAGER -qq install apt-transport-https ca-certificates -y
|
||||||
|
|
||||||
|
# configure apt to retry downloading on error
|
||||||
|
if [ ! -f /etc/apt/apt.conf.d/80-retries ]; then
|
||||||
|
echo "APT::Acquire::Retries \"3\";" > /etc/apt/apt.conf.d/80-retries
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Updating certificates.."
|
echo "Updating certificates.."
|
||||||
if [ "$DEBUG" = false ]; then
|
debug_log update-ca-certificates
|
||||||
update-ca-certificates > /dev/null 2>&1
|
|
||||||
else
|
|
||||||
update-ca-certificates
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "Installing services.."
|
echo -e "Installing services.."
|
||||||
|
|
||||||
for package in "${packages[@]}"; do
|
for package in "${packages[@]}"; do
|
||||||
echo -e "Installing ${GREEN}$package${RESET}"
|
echo -e "Installing ${GREEN}$package${RESET}"
|
||||||
debug_log $PACKAGE_MANAGER -qq install "$package" -y
|
debug_log $PACKAGE_MANAGER -qq install "$package" -y
|
||||||
@ -941,30 +961,38 @@ install_packages() {
|
|||||||
|
|
||||||
|
|
||||||
elif [ "$PACKAGE_MANAGER" == "yum" ]; then
|
elif [ "$PACKAGE_MANAGER" == "yum" ]; then
|
||||||
for package in "${packages[@]}"; do
|
|
||||||
|
packages=("docker.io" "default-mysql-client" "python3-pip" "pip" "gunicorn" "jc" "sqlite" "geoip-bin" "perl-Math-BigInt") #sqlite for almalinux and perl-Math-BigInt is needed for csf
|
||||||
|
|
||||||
|
for package in "${packages[@]}"; do
|
||||||
echo -e "Installing ${GREEN}$package${RESET}"
|
echo -e "Installing ${GREEN}$package${RESET}"
|
||||||
$PACKAGE_MANAGER install "$package" -y
|
debug_log $PACKAGE_MANAGER install "$package" -y
|
||||||
done
|
done
|
||||||
|
|
||||||
elif [ "$PACKAGE_MANAGER" == "dnf" ]; then
|
elif [ "$PACKAGE_MANAGER" == "dnf" ]; then
|
||||||
# MORA DRUGI ZA ALMU..
|
|
||||||
packages=("python3-flask" "python3-pip" "docker-ce" "docker-compose" "docker-ce-cli" "mysql-client-core-8.0" "containerd.io" "docker-compose-plugin" "sqlite3" "geoip-bin")
|
packages=("git" "wget" "python3-flask" "python3-pip" "docker-ce" "docker-compose" "docker-ce-cli" "mysql" "containerd.io" "docker-compose-plugin" "sqlite" "sqlite-devel" "geoip-bin" "perl-Math-BigInt")
|
||||||
|
# on some mysql should be repalced with: ysql-client-core-8.0
|
||||||
|
|
||||||
#utils must be added first, then install from that repo
|
#utils must be added first, then install from that repo
|
||||||
dnf install yum-utils -y
|
debug_log dnf install yum-utils -y
|
||||||
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
debug_log yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo -y # need confirm on alma, rocky and centos
|
||||||
|
|
||||||
|
# needed for csf
|
||||||
|
dnf --allowerasing install perl -y
|
||||||
|
|
||||||
# needed for ufw and gunicorn
|
# needed for ufw and gunicorn
|
||||||
dnf install epel-release
|
dnf install epel-release
|
||||||
|
|
||||||
# ovo za gunicorn
|
# needed for admin panel
|
||||||
dnf install python3-pip python3-devel gcc -y
|
debug_log dnf install python3-pip python3-devel gcc -y
|
||||||
|
|
||||||
for package in "${packages[@]}"; do
|
for package in "${packages[@]}"; do
|
||||||
echo -e "Installing ${GREEN}$package${RESET}"
|
echo -e "Installing ${GREEN}$package${RESET}"
|
||||||
$PACKAGE_MANAGER install "$package" -y
|
debug_log $PACKAGE_MANAGER install "$package" -y
|
||||||
done
|
done
|
||||||
#gunicorn mora preko pip na almi..
|
#gunicorn mora preko pip na almi..
|
||||||
pip3 install gunicorn flask
|
debug_log pip3 install gunicorn flask
|
||||||
else
|
else
|
||||||
echo -e "${RED}Unsupported package manager: $PACKAGE_MANAGER${RESET}"
|
echo -e "${RED}Unsupported package manager: $PACKAGE_MANAGER${RESET}"
|
||||||
return 1
|
return 1
|
||||||
@ -1316,34 +1344,40 @@ install_openadmin(){
|
|||||||
|
|
||||||
mkdir -p $OPENPADMIN_DIR
|
mkdir -p $OPENPADMIN_DIR
|
||||||
|
|
||||||
# Ubuntu 22
|
# UBUNTU 22 & 24
|
||||||
if [ -f /etc/os-release ] && grep -q "Ubuntu 22" /etc/os-release; then
|
if [ -f /etc/os-release ]; then
|
||||||
echo "Downloading files for Ubuntu22 and python version $current_python_version"
|
pretty_os_name="Ubuntu"
|
||||||
git clone -b $current_python_version --single-branch https://github.com/stefanpejcic/openadmin $OPENPADMIN_DIR
|
py_enchoded_for_distro="$current_python_version"
|
||||||
cd $OPENPADMIN_DIR
|
# ROCKULINUX
|
||||||
debug_log pip install --default-timeout=3600 -r requirements.txt
|
elif [ -f /etc/rocky-release ]; then
|
||||||
# Ubuntu 24
|
pretty_os_name="Rocky Linux"
|
||||||
elif [ -f /etc/os-release ] && grep -q "Ubuntu 24" /etc/os-release; then
|
py_enchoded_for_distro="rocky-$current_python_version"
|
||||||
echo "Downloading files for Ubuntu24 and python version $current_python_version"
|
# RHEL
|
||||||
git clone -b $current_python_version --single-branch https://github.com/stefanpejcic/openadmin $OPENPADMIN_DIR
|
elif [ -f /etc/redhat-release ]; then
|
||||||
cd $OPENPADMIN_DIR
|
pretty_os_name="RedHat"
|
||||||
debug_log pip install --default-timeout=3600 -r requirements.txt --break-system-packages
|
py_enchoded_for_distro="redhat-$current_python_version"
|
||||||
|
# DEBIAN 12 & 11
|
||||||
# Debian12 and 11
|
|
||||||
elif [ -f /etc/debian_version ]; then
|
elif [ -f /etc/debian_version ]; then
|
||||||
echo "Installing PIP and Git"
|
apt-get install git pip python3-yaml -y > /dev/null 2>&1 # will be removed in future!
|
||||||
apt-get install git pip python3-yaml -y > /dev/null 2>&1
|
pretty_os_name="Debian"
|
||||||
echo "Downloading files for Debian and python version $current_python_version"
|
py_enchoded_for_distro="debian-$current_python_version"
|
||||||
git clone -b debian-$current_python_version --single-branch https://github.com/stefanpejcic/openadmin $OPENPADMIN_DIR
|
# FEDORA
|
||||||
cd $OPENPADMIN_DIR
|
elif [ -f /etc/fedora-release ]; then
|
||||||
debug_log pip install --default-timeout=3600 -r requirements.txt
|
pretty_os_name="Fedora"
|
||||||
debug_log pip install --default-timeout=3600 -r requirements.txt --break-system-packages
|
py_enchoded_for_distro="fedora-$current_python_version"
|
||||||
# other
|
|
||||||
|
# everything else should fail..
|
||||||
else
|
else
|
||||||
echo "Unsuported OS. Currently only Ubuntu22-24 and Debian11-12 are supported."
|
echo "Unsuported OS."
|
||||||
echo 0
|
echo 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Downloading files for $pretty_os_name and python version $current_python_version"
|
||||||
|
|
||||||
|
git clone -b $py_enchoded_for_distro --single-branch https://github.com/stefanpejcic/openadmin $OPENPADMIN_DIR
|
||||||
|
cd $OPENPADMIN_DIR
|
||||||
|
debug_log pip install --default-timeout=3600 -r requirements.txt
|
||||||
|
debug_log pip install --default-timeout=3600 -r requirements.txt --break-system-packages
|
||||||
|
|
||||||
|
|
||||||
cp -fr /usr/local/admin/service/admin.service ${SERVICES_DIR}admin.service > /dev/null 2>&1
|
cp -fr /usr/local/admin/service/admin.service ${SERVICES_DIR}admin.service > /dev/null 2>&1
|
||||||
|
Loading…
Reference in New Issue
Block a user