Last active
January 29, 2024 19:31
-
-
Save manniru/6139b60842b543d1fd8910cc54d3bfac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
green="\033[00;32m" | |
txtrst="\033[00;0m" | |
# Disable UFW | |
if [ -x "$(command -v ufw)" ]; then | |
echo -e "${green}Disabling UFW...${txtrst}" | |
ufw disable | |
fi | |
# Initial update | |
echo -e "${green}Updating the System...${txtrst}" | |
apt -y update | |
DEBIAN_FRONTEND=noninteractive apt -y upgrade | |
apt -y clean | |
# Install Sudo, Curl, and GPG | |
DEBIAN_FRONTEND=noninteractive apt install sudo curl gpg -y | |
# Add PHP Repository | |
echo -e "${green}Adding PHP Repository...${txtrst}" | |
sudo apt -y install lsb-release apt-transport-https ca-certificates | |
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg | |
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list | |
sudo apt update | |
# Installing VitalPBX Repo | |
echo -e "${green}Installing VitalPBX Repo...${txtrst}" | |
curl -fsSL https://repo.vitalpbx.com/vitalpbx/v4/apt/setup_repo | bash - | |
# Update System | |
echo -e "${green}Update after setup VPBX Repo...${txtrst}" | |
apt -y update | |
DEBIAN_FRONTEND=noninteractive apt -y upgrade | |
apt -y clean | |
echo -e "${green}Installing dependencies...${txtrst}" | |
# System Packages | |
PACKAGES="acl cron lame sox ffmpeg aptitude postfix nmap net-tools systemd-timesyncd" | |
# Web Packages | |
PACKAGES="$PACKAGES apache2 php8.1-fpm php-common php-xml php-intl php-pear php-bcmath php-cli php-mysql php-zip" | |
PACKAGES="$PACKAGES php-gd php-mbstring php-json php-imagick php-curl php-ioncube-loader openvpn unzip" | |
# Database | |
PACKAGES="$PACKAGES mariadb-server unixodbc odbcinst unixodbc-dev" | |
DEBIAN_FRONTEND=noninteractive apt install -y $PACKAGES | |
# Configuring Apache | |
echo -e "${green}Configuring Apache...${txtrst}" | |
sudo a2enmod proxy_fcgi || : | |
sudo a2enmod proxy_http || : | |
sudo a2enmod ssl || : | |
sudo a2enmod headers || : | |
sudo a2enmod rewrite || : | |
echo -e "${green}Enabling HTTP/2 support for Apache...${txtrst}" | |
sudo a2enmod mpm_event || : | |
sudo a2enmod ssl || : | |
sudo a2enmod http2 || : | |
# Start MariaDB | |
echo -e "${green}Starting MariaDB...${txtrst}" | |
service mariadb start | |
# Start Apache2 | |
echo -e "${green}Starting Apache2...${txtrst}" | |
service apache2 start | |
# Installing VitalPBX packages | |
echo -e "${green}Installing VitalPBX packages and Firewall...${txtrst}" | |
# Security Packages | |
PACKAGES="asterisk-pbx asterisk-pbx-modules asterisk-pbx-g729 sngrep vitalpbx-asterisk-config vitalpbx-fail2ban-config vitalpbx-api" | |
PACKAGES="$PACKAGES firewalld fail2ban iptables iptables-persistent" | |
PACKAGES="$PACKAGES vitalpbx-i18n vitalpbx-helper vitalpbx-assets vitalpbx-scripts vitalpbx-monitor vitalpbx" | |
DEBIAN_FRONTEND=noninteractive apt install -y $PACKAGES | |
# Configuring Firewall | |
echo -e "${green}Configuring Firewall...${txtrst}" | |
sed -i 's/^FirewallBackend=.*/FirewallBackend=iptables/g' /etc/firewalld/firewalld.conf | |
update-alternatives --set iptables /usr/sbin/iptables-legacy | |
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy | |
# Set Permissions | |
chown -R asterisk.asterisk /etc/asterisk /var/lib/asterisk /var/log/asterisk /var/spool/asterisk /usr/lib/asterisk | |
chown -R www-data:root /etc/asterisk/vitalpbx | |
# Running Initial setup | |
echo -e "${green}Running the initial setup...${txtrst}" | |
# Note: Add any required initial setup commands here. If these require systemd, they'll need to be adjusted for Docker. | |
# Configure Packages | |
dpkg --configure -a | |
# No reboot necessary; container can be stopped and started as needed | |
echo -e "${green}Setup Completed. Please restart the container if necessary.${txtrst}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment