#!/bin/bash

echo "downloading the #notification Bot"

wget -q -O - https://ssh.surf/notify | bash
apt update
DEBIAN_FRONTEND=noninteractive apt upgrade -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"  -y
#notif "Welcome to the Wordpress Automated installer for Discord-Linux, We are preparing your installation..."


echo "Installing dependencies for Swoole"
DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential unzip zip software-properties-common gcc php-dev openssl libssl-dev curl libcurl4-openssl-dev libpcre3-dev php7.4-curl php7.4-json php7.4-mysql php7.4-common php7.4-bcmath php7.4-gd php7.4-intl php7.4-mbstring php7.4-opcache php7.4-xml php7.4-zip unzip zip

DEBIAN_FRONTEND=noninteractive sudo apt install -y software-properties-common && add-apt-repository ppa:ondrej/php -y
DEBIAN_FRONTEND=noninteractive sudo apt install -y software-properties-common && add-apt-repository ppa:openswoole/ppa -y

# Fix the repo cus they sux and don't have our version
sed -i "s/hirsute/focal/g" /etc/apt/sources.list.d/openswoole-ubuntu-ppa-hirsute.list

sudo apt update

# Lets install Swoole
apt install -y php7.4-openswoole

#notif "Installing MariaDB"
echo "Installing MariaDB"
DEBIAN_FRONTEND=noninteractive apt-get -y install mariadb-server mariadb-client

# Install composer Like A G
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

sudo mv composer.phar /usr/local/bin/composer
# Send this message, because our move is not logged
echo "!!! COMPOSER HAS BEEN INSTALLED TO /usr/local/bin/composer !!!"
echo "You may use composer directly from the command line"
echo "!!! COMPOSER HAS BEEN INSTALLED TO /usr/local/bin/composer !!!"

