Files
The-World-Is-Yours/install
T
2019-05-07 21:07:42 +02:00

86 lines
4.1 KiB
Bash

#!/bin/bash
if [ "$1" == "install" ]; then
case "`grep DISTRIB_CODENAME /etc/*-release | awk -F '=' '{print $2}'`" in
bionic)
if [ "$(whoami)" != "root" ]
then
echo "You should Login as root to use this script!";
echo "sudo -i";
exit 1
fi
if [ -d "/nginx/" ]; then
echo "We've detect a folder '/nginx/'"
echo "Please to a fresh reinstallation of your server this is a whole new release you can't update!"
exit 1
fi
if [ -d "/etc/nginx" ]; then
echo "We've detect a folder '/etc/nginx' which means"
echo "Maybe you have installed nginx on your system!"
echo "Please remove everything related to nginx apache or any other web server using port 80/443"
exit 1
fi
if [ -d "/opt/nginx/" ]; then
echo "We've detect a folder '/opt/nginx/' which means"
echo "Maybe you have use this script before!"
exit 1
fi
apt-get update; apt-get upgrade -y; apt-get dist-upgrade -y; apt-get autoremove -y
apt-get install build-essential libssl-dev curl nano wget zip unzip git sudo iftop htop -y
sudo add-apt-repository ppa:maxmind/ppa -y
apt-get update; apt-get upgrade -y; apt-get autoremove -y
apt-get install libmaxminddb0 libmaxminddb-dev mmdb-bin -y
apt-get install libgd-dev -y
useradd nginx
mkdir -p /usr/local/nginx/
cd /; wget https://github.com/theraw/The-World-Is-Yours/raw/v2/OS/Ubuntu/18.04/source/nginx16.zip; unzip nginx16.zip; rm -Rf nginx16.zip
curl -s https://raw.githubusercontent.com/theraw/The-World-Is-Yours/v2/OS/Ubuntu/18.04/nginx.service > /etc/systemd/system/nginx.service
killall nginx
systemctl daemon-reload
sudo systemctl start nginx.service && sudo systemctl enable nginx.service
service nginx stop
# create dirs
mkdir /hostdata
mkdir -p /nginx/live
mkdir -p /nginx/conf.d
mkdir -p /nginx/db/
mkdir -p /nginx/modules
mkdir -p /hostdata/default/logs
mkdir -p /hostdata/default/public_html
curl -s https://raw.githubusercontent.com/theraw/The-World-Is-Yours/v2/static/html/index.html > /hostdata/default/public_html/index.html
mkdir -p /hostdata/default/public_html/L7
cd /hostdata/default/public_html/L7; wget https://github.com/theraw/The-World-Is-Yours/raw/v2/static/html/loading.gif
cd /hostdata/default/public_html/L7; wget https://raw.githubusercontent.com/theraw/The-World-Is-Yours/v2/static/html/aes.min.js
curl -s https://raw.githubusercontent.com/theraw/The-World-Is-Yours/v2/static/live/default > /nginx/live/default
curl -s https://raw.githubusercontent.com/theraw/The-World-Is-Yours/v2/static/nginx.conf > /nginx/nginx.conf
cd /nginx/db/; wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz; tar xf GeoLite2-City.tar.gz; rm -Rf GeoLite2-City.tar.gz
mv /nginx/db/GeoLite2-City_*/GeoLite2-City.mmdb /nginx/db/; rm -Rf /nginx/db/GeoLite2-City_*
cd /nginx/db/; wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz; tar xf GeoLite2-Country.tar.gz; rm -Rf GeoLite2-Country.tar.gz
mv /nginx/db/GeoLite2-Country_*/GeoLite2-Country.mmdb /nginx/db/; rm -Rf /nginx/db/GeoLite2-Country_*
;;
esac
fi
if [ "$1" == 'clean' ]; then
service nginx stop
systemctl disable nginx.service
rm -Rf /nginx
rm -Rf /usr/local/nginx
rm -Rf /usr/sbin/nginx
rm -Rf /etc/init.d/nginx
rm -Rf /hostdata/
rm -Rf /opt/nginx
rm -Rf /etc/systemd/system/nginx.service
systemctl daemon-reload
clear
echo "We've just removed /nginx and /hostdata and /opt/nginx"
fi