Update INSTALL.sh

This commit is contained in:
Stefan Pejcic 2024-08-18 18:09:53 +02:00 committed by GitHub
parent c1649434e4
commit 6c5c63fb61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,7 +6,7 @@
# Author: Stefan Pejcic # Author: Stefan Pejcic
# Created: 11.07.2023 # Created: 11.07.2023
# Last Modified: 02.08.2024 # Last Modified: 02.08.2024
# Company: openpanel.co # Company: openpanel.com
# Copyright (c) OPENPANEL # Copyright (c) OPENPANEL
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
@ -168,7 +168,7 @@ set_version_to_install(){
if [[ $PANEL_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then if [[ $PANEL_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
PANEL_VERSION=$PANEL_VERSION PANEL_VERSION=$PANEL_VERSION
else else
PANEL_VERSION="0.2.4" PANEL_VERSION="0.2.5"
fi fi
fi fi
} }
@ -232,21 +232,21 @@ install_packages
download_skeleton_directory_from_github download_skeleton_directory_from_github
install_openadmin install_openadmin
opencli_setup opencli_setup
add_file_watcher
configure_docker configure_docker
download_and_import_docker_images download_and_import_docker_images
docker_compose_up
panel_customize panel_customize
set_premium_features set_premium_features
configure_nginx configure_nginx
helper_function_for_nginx_on_aws_and_azure docker_compose_up # must be after nginx setup
configure_modsecurity configure_modsecurity
setup_email ##### NOT PRODUCTION READY #setup_email
setup_ftp setup_ftp
set_custom_hostname set_custom_hostname
generate_and_set_ssl_for_panels generate_and_set_ssl_for_panels
setup_firewall_service setup_firewall_service
set_system_cronjob # cron after firewall, otherwise user gets false-positive notification that csf is not running set_system_cronjob # cron after firewall, otherwise user gets false-positive notification that csf is not running
set_logrotate
tweak_ssh tweak_ssh
setup_swap setup_swap
clean_apt_cache clean_apt_cache
@ -615,7 +615,7 @@ docker_compose_up(){
# generate random password for mysql # generate random password for mysql
MYSQL_ROOT_PASSWORD=$(openssl rand -base64 -hex 9) MYSQL_ROOT_PASSWORD=$(openssl rand -base64 -hex 9)
echo "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD" >> .env echo "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD" > .env
echo "" echo ""
echo "MYSQL_ROOT_PASSWORD = $MYSQL_ROOT_PASSWORD" echo "MYSQL_ROOT_PASSWORD = $MYSQL_ROOT_PASSWORD"
echo "" echo ""
@ -623,9 +623,10 @@ docker_compose_up(){
ln -s /etc/openpanel/mysql/db.cnf /etc/my.cnf > /dev/null 2>&1 ln -s /etc/openpanel/mysql/db.cnf /etc/my.cnf > /dev/null 2>&1
sed -i 's/password = .*/password = '"${MYSQL_ROOT_PASSWORD}"'/g' ${ETC_DIR}mysql/db.cnf > /dev/null 2>&1 sed -i 's/password = .*/password = '"${MYSQL_ROOT_PASSWORD}"'/g' ${ETC_DIR}mysql/db.cnf > /dev/null 2>&1
cp /etc/openpanel/docker/compose/docker-compose.yml /root/docker-compose.yml > /dev/null 2>&1 cp /etc/openpanel/docker/compose/new-docker-compose.yml /root/docker-compose.yml > /dev/null 2>&1 # from 0.2.5 new-docker-compose.yml isntead of docker-compose.yml
# start the stack # from 0.2.5 we only start mysql by default,panel on first user and nginx/dns on first domain
docker compose up -d #docker compose up -d
cd /root && docker compose up -d openpanel_mysql
} }
@ -673,12 +674,6 @@ setup_email() {
} }
add_file_watcher(){
bash <(curl -sSL https://raw.githubusercontent.com/stefanpejcic/file-watcher/main/install.sh)
}
setup_firewall_service() { setup_firewall_service() {
if [ -z "$SKIP_FIREWALL" ]; then if [ -z "$SKIP_FIREWALL" ]; then
echo "Setting up the firewall.." echo "Setting up the firewall.."
@ -806,7 +801,7 @@ 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 &&
# 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
@ -864,6 +859,54 @@ update_package_manager() {
} }
set_logrotate(){
echo "Setting Logrotate for Nginx.."
bash /usr/local/admin/scripts/server/logrotate
echo "Setting Logrotate for OpenPanel logs.."
cat <<EOF > "/etc/logrotate.d/openpanel"
/var/log/openpanel/**/*.log {
su root adm
size 50M
rotate 5
missingok
notifempty
compress
delaycompress
copytruncate
create 640 root adm
postrotate
endscript
}
EOF
logrotate -f /etc/logrotate.d/openpanel
echo "Setting Logrotate for Syslogs.."
cat <<EOF > "/etc/logrotate.d/syslog"
/var/log/syslog {
su root syslog
weekly
rotate 4
missingok
notifempty
compress
delaycompress
postrotate
/usr/bin/systemctl reload rsyslog > /dev/null 2>&1 || true
endscript
}
EOF
logrotate -f /etc/logrotate.d/syslog
}
install_packages() { install_packages() {
@ -874,7 +917,7 @@ install_packages() {
debug_log sed -i 's/#$nrconf{restart} = '"'"'i'"'"';/$nrconf{restart} = '"'"'a'"'"';/g' /etc/needrestart/needrestart.conf debug_log sed -i 's/#$nrconf{restart} = '"'"'i'"'"';/$nrconf{restart} = '"'"'a'"'"';/g' /etc/needrestart/needrestart.conf
packages=("docker.io" "default-mysql-client" "nginx" "zip" "bind9" "unzip" "python3-pip" "pip" "gunicorn" "jc" "certbot" "python3-certbot-nginx" "sqlite3" "geoip-bin" "ufw") packages=("docker.io" "default-mysql-client" "zip" "unzip" "python3-pip" "pip" "gunicorn" "jc" "sqlite3" "geoip-bin")
if [ "$PACKAGE_MANAGER" == "apt-get" ]; then if [ "$PACKAGE_MANAGER" == "apt-get" ]; then
#only once.. #only once..
@ -918,7 +961,7 @@ install_packages() {
done done
elif [ "$PACKAGE_MANAGER" == "dnf" ]; then elif [ "$PACKAGE_MANAGER" == "dnf" ]; then
# MORA DRUGI ZA ALMU.. # 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" "nginx" "zip" "unzip" "ufw" "certbot" "python3-certbot-nginx" "sqlite3" "geoip-bin") packages=("python3-flask" "python3-pip" "docker-ce" "docker-compose" "docker-ce-cli" "mysql-client-core-8.0" "containerd.io" "docker-compose-plugin" "zip" "unzip" "sqlite3" "geoip-bin")
#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 dnf install yum-utils -y
@ -930,9 +973,6 @@ install_packages() {
# ovo za gunicorn # ovo za gunicorn
dnf install python3-pip python3-devel gcc -y dnf install python3-pip python3-devel gcc -y
# bind radi ovako
dnf install bind bind-utils -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 $PACKAGE_MANAGER install "$package" -y
@ -951,15 +991,20 @@ install_packages() {
configure_modsecurity() { configure_modsecurity() {
echo "Warning: modsecurity is currently disbaled and will not be installed"
: '
# ModSecurity # ModSecurity
# #
# https://openpanel.co/docs/admin/settings/waf/#install-modsecurity # https://openpanel.com/docs/admin/settings/waf/#install-modsecurity
# #
if [ "$MODSEC" ]; then if [ "$MODSEC" ]; then
echo "Installing ModSecurity and setting OWASP core ruleset.." echo "ModSecurity is temporary disabled and will not be installed."
debug_log opencli nginx-install_modsec #echo "Installing ModSecurity and setting OWASP core ruleset.."
#debug_log opencli nginx-install_modsec
fi fi
'
} }
@ -981,30 +1026,6 @@ cleanup() {
helper_function_for_nginx_on_aws_and_azure(){
#
# FIX FOR:
#
# https://stackoverflow.com/questions/3191509/nginx-error-99-cannot-assign-requested-address/13141104#13141104
#
nginx_status=$(systemctl status nginx 2>&1)
# Search for "Cannot assign requested address" in the output
if echo "$nginx_status" | grep -q "Cannot assign requested address"; then
echo "net.ipv4.ip_nonlocal_bind = 1" >> /etc/sysctl.conf
sysctl -p /etc/sysctl.conf
sed -i "s/IP_HERE/*/" /etc/nginx/sites-enabled/default
debug_log "echo Configuration updated and applied."
else
debug_log "echo Nginx started normally."
fi
}
set_custom_hostname(){ set_custom_hostname(){
if [ "$SET_HOSTNAME_NOW" = true ]; then if [ "$SET_HOSTNAME_NOW" = true ]; then
# Check if the provided hostname is a valid FQDN # Check if the provided hostname is a valid FQDN
@ -1072,8 +1093,16 @@ configure_nginx() {
echo "Setting Nginx configuration.." echo "Setting Nginx configuration.."
mkdir -p /etc/nginx/sites-available/
mkdir -p /etc/nginx/sites-enabled/
mkdir -p /etc/letsencrypt/
mkdir -p /var/log/nginx/domlogs/
# https://dev.openpanel.co/services/nginx # https://dev.openpanel.co/services/nginx
rm /etc/nginx/nginx.conf && ln -s /etc/openpanel/nginx/nginx.conf /etc/nginx/nginx.conf rm /etc/nginx/nginx.conf
ln -s /etc/openpanel/nginx/nginx.conf /etc/nginx/nginx.conf
# dir for domlogs # dir for domlogs
mkdir -p /var/log/nginx/domlogs mkdir -p /var/log/nginx/domlogs
@ -1098,16 +1127,19 @@ configure_nginx() {
ln -s /etc/openpanel/nginx/error_pages /srv/http/default ln -s /etc/openpanel/nginx/error_pages /srv/http/default
ln -s /etc/openpanel/nginx/error_pages/snippets/error_pages.conf /etc/nginx/snippets/error_pages.conf ln -s /etc/openpanel/nginx/error_pages/snippets/error_pages.conf /etc/nginx/snippets/error_pages.conf
ln -s /etc/openpanel/nginx/error_pages/snippets/error_pages_content.conf /etc/nginx/snippets/error_pages_content.conf ln -s /etc/openpanel/nginx/error_pages/snippets/error_pages_content.conf /etc/nginx/snippets/error_pages_content.conf
service nginx restart
} }
set_premium_features(){ set_premium_features(){
if [ "$SET_HOSTNAME_NOW" = true ]; then if [ "$SET_PREMIUM" = true ]; then
echo "Setting OpenPanel enterprise version license key $license_key" echo "Setting OpenPanel enterprise version license key $license_key"
opencli config update key "$license_key" opencli config update key "$license_key"
#added in 0.2.5 https://community.openpanel.com/d/91-email-support-for-openpanel-enterprise-edition
echo "Setting mailserver.."
opencli email-server install
fi fi
} }
@ -1173,7 +1205,7 @@ run_custom_postinstall_script() {
# run the custom script # run the custom script
echo " " echo " "
echo "Running post install script.." echo "Running post install script.."
debug_log "https://dev.openpanel.co/customize.html#After-installation" debug_log "https://dev.openpanel.com/customize.html#After-installation"
debug_log bash $post_install_path debug_log bash $post_install_path
fi fi
} }
@ -1192,6 +1224,8 @@ download_skeleton_directory_from_github(){
echo "Downloading configuration files to ${ETC_DIR}" echo "Downloading configuration files to ${ETC_DIR}"
echo "" echo ""
git clone https://github.com/stefanpejcic/openpanel-configuration ${ETC_DIR} > /dev/null 2>&1 git clone https://github.com/stefanpejcic/openpanel-configuration ${ETC_DIR} > /dev/null 2>&1
mkdir -p /etc/bind/
cp -r /etc/openpanel/bind9/* /etc/bind/
} }
@ -1257,18 +1291,18 @@ support_message() {
echo "Your journey with OpenPanel has just begun, and we're here to help every step of the way." echo "Your journey with OpenPanel has just begun, and we're here to help every step of the way."
echo "" echo ""
echo "To get started, check out our Getting Started guide:" echo "To get started, check out our Getting Started guide:"
echo "👉 https://openpanel.co/docs/admin/intro/#post-install-steps" echo "👉 https://openpanel.com/docs/admin/intro/#post-install-steps"
echo "" echo ""
echo "Need assistance or looking to learn more? We've got you covered:" echo "Need assistance or looking to learn more? We've got you covered:"
echo "" echo ""
echo "📚 Admin Docs: Dive into our comprehensive documentation for all things OpenPanel:" echo "📚 Admin Docs: Dive into our comprehensive documentation for all things OpenPanel:"
echo "👉 https://openpanel.co/docs/admin/intro/" echo "👉 https://openpanel.com/docs/admin/intro/"
echo "" echo ""
echo "💬 Forums: Join our community forum to ask questions, share tips, and connect with fellow admins:" echo "💬 Forums: Join our community forum to ask questions, share tips, and connect with fellow admins:"
echo "👉 https://community.openpanel.co/" echo "👉 https://community.openpanel.com/"
echo "" echo ""
echo "🎮 Discord: For real-time chat and support, hop into our Discord server:" echo "🎮 Discord: For real-time chat and support, hop into our Discord server:"
echo "👉 https://discord.openpanel.co/" echo "👉 https://discord.openpanel.com/"
echo "" echo ""
echo "We're thrilled to have you with us. Let's make something amazing together! 🚀" echo "We're thrilled to have you with us. Let's make something amazing together! 🚀"
echo "" echo ""
@ -1292,7 +1326,7 @@ install_openadmin(){
# OpenAdmin # OpenAdmin
# #
# https://openpanel.co/docs/admin/intro/ # https://openpanel.com/docs/admin/intro/
# #
echo "Setting up Admin panel.." echo "Setting up Admin panel.."
@ -1352,7 +1386,8 @@ create_admin_and_show_logins_success_message() {
#cp version file #cp version file
mkdir -p /usr/local/panel/ > /dev/null 2>&1 mkdir -p /usr/local/panel/ > /dev/null 2>&1
docker cp openpanel:/usr/local/panel/version /usr/local/panel/version > /dev/null 2>&1 echo "$PANEL_VERSION" > /usr/local/panel/version > /dev/null 2>&1
######docker cp openpanel:/usr/local/panel/version /usr/local/panel/version > /dev/null 2>&1
echo -e "${GREEN}OpenPanel [$(cat /usr/local/panel/version)] installation complete.${RESET}" echo -e "${GREEN}OpenPanel [$(cat /usr/local/panel/version)] installation complete.${RESET}"
echo "" echo ""