#!/bin/bash
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
apt --fix-missing update
apt -y install dialog apt-utils zip lzma curl git systemctl telnet aptitude perl6-readline iputils-ping apt-transport-https
apt install -y build-essential libtool libxml2-dev libcurl4-gnutls-dev libwebp-dev libjpeg-dev libxpm-dev libfreetype6-dev libbz2-dev pkg-config libssl-dev libsqlite3-dev libonig-dev libtidy-dev libzip-dev libenchant-2-dev libiodbc2-dev libsodium-dev libxslt1-dev
apt -y install ssh nano vim mc nginx php php-dev php-fpm
apt -y install php-mbstring php-bcmath php-redis php-pgsql
apt -y install php-mysql
apt -y install php-curl
apt -y install php-simplexml
apt -y install php-gd
apt -y install php-zip
phpenmod -s fpm mbstring
phpenmod -s fpm bcmath
phpenmod -s fpm redis
phpenmod -s fpm pgsql
phpenmod -s fpm mysqli
phpenmod -s fpm curl
phpenmod -s fpm simplexml
phpenmod -s fpm gd
phpenmod -s fpm zip

apt -y install rabbitmq-server
apt -y install redis-server
rabbitmq-plugins enable rabbitmq_management
systemctl enable rabbitmq-server

mkdir /var/www/lib
cd /var/www/lib
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
mv composer.phar /usr/local/bin/composer
wget https://github.com/FriendsOfPHP/pickle/releases/latest/download/pickle.phar
chmod +x pickle.phar
mv pickle.phar /usr/local/bin/pickle

#git clone https://github.com/php-amqplib/php-amqplib
#git clone https://github.com/phpredis/phpredis
#git clone https://github.com/walkor/Workerman
#git clone https://github.com/erikdubbelboer/phpRedisAdmin
#git clone https://github.com/PHPOffice/PHPWord
#git clone https://github.com/PHPOffice/PhpSpreadsheet
#git clone https://github.com/PHPOffice/PHPPresentation
#
#composer require php-amqplib/php-amqplib
#mv vendor php-amqplib/vendor
#composer require workerman/workerman
#mv vendor Workerman/vendor
#composer require phpoffice/phpword
#mv vendor PHPWord/vendor
#composer require phpoffice/phpspreadsheet
#mv vendor PhpSpreadsheet/vendor
#composer require phpoffice/phppresentation
#mv vendor PHPPresentation/vendor



wget http://humanattention.net/install/answer
pickle install redis <answer
pickle install stomp <answer

wget http://humanattention.net/install/set.config.php-fpm
chmod +x ./set.config.php-fpm
wget http://humanattention.net/install/set.config.redis
chmod +x ./set.config.redis
wget http://humanattention.net/install/set.config.nginx
chmod +x ./set.config.nginx
./set.config.php-fpm
./set.config.redis
./set.config.nginx
unlink ./set.config.php-fpm
unlink ./set.config.redis
unlink ./set.config.nginx
unlink answer
unlink composer.json
unlink composer.lock
unlink composer-setup.php
mkdir /var/www/services/
cd /var/www/services/
echo "#!/bin/php" >./start.php
echo "<?php echo 'I am start';" >>./start.php
echo 'echo "\n";' >>./start.php
chmod +x ./start.php
cd /
wget http://humanattention.net/install/start.sh
chmod +x /start.sh
./start.sh
