#!/bin/bash #################################################### CONFIGURATION ### BUILD=202112181 PASS=$(openssl rand -base64 32|sha256sum|base64|head -c 32| tr '[:upper:]' '[:lower:]') DBPASS=$(openssl rand -base64 24|sha256sum|base64|head -c 32| tr '[:upper:]' '[:lower:]') SERVERID=$(openssl rand -base64 12|sha256sum|base64|head -c 32| tr '[:upper:]' '[:lower:]') REPO=andreapollastri/cipi if [ -z "$1" ]; BRANCH=latest then BRANCH=$1 fi #################################################### CLI TOOLS ### reset=$(tput sgr0) bold=$(tput bold) underline=$(tput smul) black=$(tput setaf 0) white=$(tput setaf 7) red=$(tput setaf 1) green=$(tput setaf 2) yellow=$(tput setaf 3) blue=$(tput setaf 4) purple=$(tput setaf 5) bgblack=$(tput setab 0) bgwhite=$(tput setab 7) bgred=$(tput setab 1) bggreen=$(tput setab 2) bgyellow=$(tput setab 4) bgblue=$(tput setab 4) bgpurple=$(tput setab 5) #################################################### CIPI SETUP ###### # LOGO clear echo "${green}${bold}" echo "" echo " ██████ ██ ██████  ██"  echo "██      ██ ██   ██ ██"  echo "██  ██ ██████  ██"  echo "██  ██ ██      ██"  echo " ██████ ██ ██  ██"  echo "" echo "Installation has been started... Hold on!" echo "${reset}" sleep 3s # OS CHECK clear clear echo "${bggreen}${black}${bold}" echo "OS check..." echo "${reset}" sleep 1s ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"') VERSION=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"') if [ "$ID" = "ubuntu" ]; then case $VERSION in 20.04) break ;; *) echo "${bgred}${white}${bold}" echo "Cipi requires Linux Ubuntu 20.04 LTS" echo "${reset}" exit 1; break ;; esac else echo "${bgred}${white}${bold}" echo "Cipi requires Linux Ubuntu 20.04 LTS" echo "${reset}" exit 1 fi # ROOT CHECK clear clear echo "${bggreen}${black}${bold}" echo "Permission check..." echo "${reset}" sleep 1s if [ "$(id -u)" = "0" ]; then clear else clear echo "${bgred}${white}${bold}" echo "You have to run Cipi as root. (In AWS use 'sudo -s')" echo "${reset}" exit 1 fi # BASIC SETUP clear clear echo "${bggreen}${black}${bold}" echo "Base setup..." echo "${reset}" sleep 1s sudo apt-get update sudo apt-get -y install software-properties-common curl wget nano vim rpl sed zip unzip openssl expect dirmngr apt-transport-https lsb-release ca-certificates dnsutils dos2unix zsh htop ffmpeg # GET IP clear clear echo "${bggreen}${black}${bold}" echo "Getting IP..." echo "${reset}" sleep 1s IP=$(curl -s https://checkip.amazonaws.com) # MOTD WELCOME MESSAGE clear echo "${bggreen}${black}${bold}" echo "Motd settings..." echo "${reset}" sleep 1s WELCOME=/etc/motd sudo touch $WELCOME sudo cat > "$WELCOME" < "$JAIL" < "$PHPINI" < "$PHPINI" < "$PHPINI" < "$NGINX" < "$NODE" < $CIPIBULD < $CIPIPING < $PUBKEYGH <> /usr/lib/systemd/system/user@.service sudo echo 'DefaultStartLimitBurst=50' >> /usr/lib/systemd/system/user@.service sudo echo 'StartLimitBurst=0' >> /usr/lib/systemd/system/user@.service sudo systemctl daemon-reload TASK=/etc/cron.d/cipi.crontab touch $TASK cat > "$TASK" < /proc/sys/vm/drop_caches && swapoff -a && swapon -a * * * * * cd /var/www/html && php artisan schedule:run >> /dev/null 2>&1 5 2 * * * cd /var/www/html/utility/cipi-update && sh run.sh >> /dev/null 2>&1 EOF crontab $TASK sudo systemctl restart nginx.service sudo rpl -i -w "#PasswordAuthentication" "PasswordAuthentication" /etc/ssh/sshd_config sudo rpl -i -w "# PasswordAuthentication" "PasswordAuthentication" /etc/ssh/sshd_config sudo rpl -i -w "PasswordAuthentication no" "PasswordAuthentication yes" /etc/ssh/sshd_config sudo rpl -i -w "PermitRootLogin yes" "PermitRootLogin no" /etc/ssh/sshd_config sudo service sshd restart TASK=/etc/supervisor/conf.d/cipi.conf touch $TASK cat > "$TASK" <