2017-09-16 20:37:13 +00:00
#!/bin/bash
2018-03-24 01:27:00 +00:00
# Webinoly Installation Script.
webyversion="1.4.0-beta"
2017-09-16 20:37:13 +00:00
2017-11-30 04:33:55 +00:00
# Check OS support
distr=`echo $(lsb_release -i | cut -d':' -f 2)`
osver=`echo $(lsb_release -c | cut -d':' -f 2)`
if ! [[ $distr == "Ubuntu" && $osver =~ ^(xenial)$ ]]; then
echo "$(tput setaf 1)"
echo "****************************************************************************"
echo "**** This OS is not supported by Webinoly and could not work properly ****"
echo "****************************************************************************"
echo "$(tput sgr0)"
read -p "Press [Enter] key to continue..."
fi
2017-09-16 20:37:13 +00:00
# Diplay menu to select type of server
2018-03-01 19:16:16 +00:00
[[ -n "$1" ]] && setup="$1" || setup=9
2018-03-24 01:27:00 +00:00
while ! [[ $setup -ge 0 && $setup -le 4 && $setup =~ ^[0-9]+$ ]] 2>/dev/null
2017-09-16 20:37:13 +00:00
do
echo ""
echo " 1 - HTML Server"
echo " 2 - PHP Server"
echo " 3 - LEMP Server (Default)"
echo " 4 - Custom Configuration"
echo " 0 - Maybe later..."
echo ""
read -p "Select the desired option to configure your server: " setup
echo ""
echo "------------------------------------------------"
setup=${setup:-3}
done
# Download and install Webinoly
2018-03-24 01:27:00 +00:00
if [[ $2 == "-ver="* ]]; then
ver=$(echo "$2" | cut -d'=' -f 2 -s)
# Be sure we have a valid server response for the requested version
code=$(wget --server-response https://qrok.es/webinoly?version=$ver 2>&1 | awk '/^ HTTP/{print $2}')
# Get the last code (redirections)
code="${code##*$'\n'}"
2018-03-01 19:16:16 +00:00
2017-11-07 04:10:50 +00:00
echo "$(tput setaf 1)"
2018-03-24 01:27:00 +00:00
if [[ $code == 200 ]]; then
sudo wget --timeout=15 -qrO $HOME/webinoly.tar https://qrok.es/webinoly?version=$ver
webyversion="$ver"
[[ $ver == "beta" ]] && echo "[WARNING] You are installing a BETA version of Webinoly and it's not recommended for production enviroments. $(tput sgr0)"
else
echo "[ERROR] Version not found or not available! ($code) $(tput sgr0)"
exit 1
fi
2017-11-07 04:10:50 +00:00
else
sudo wget --timeout=15 -qrO $HOME/webinoly.tar https://qrok.es/wytar
fi
2018-03-24 01:27:00 +00:00
[[ ! -d /opt/webinoly ]] && sudo mkdir /opt/webinoly
2017-09-16 20:37:13 +00:00
sudo tar -xf $HOME/webinoly.tar -C /opt/webinoly
sudo find /opt/webinoly -type d -exec chmod 755 {} \;
sudo find /opt/webinoly -type f -exec chmod 644 {} \;
# Install plugins
sudo chmod 755 /opt/webinoly/plugins/*
sudo mv /opt/webinoly/plugins/* /usr/bin/
source /opt/webinoly/lib/install
2018-01-17 01:10:22 +00:00
# Check for uninstalled Webinoly conf file
2018-03-01 19:16:16 +00:00
[[ -a $HOME/.webinoly-conf-restore_dont-remove ]] && sudo mv $HOME/.webinoly-conf-restore_dont-remove /opt/webinoly/webinoly.conf
2018-01-17 01:10:22 +00:00
# Save Tools Port after library is available.
if [[ -a /opt/webinoly/webinoly.conf && -n $(conf_read tools-port) ]]; then
2017-09-16 20:37:13 +00:00
echo "${gre}Webinoly Configuration file was found, so we will use it!${end}"
else
2018-01-17 01:10:22 +00:00
portools="22222"
2018-03-24 01:27:00 +00:00
[[ -n $2 && $2 != "-ver="* ]] && portools="$2"
echo $portools
2017-09-16 20:37:13 +00:00
tools_port $portools
fi
2017-11-07 04:10:50 +00:00
# Write app version
conf_write app-version $webyversion
2017-09-16 20:37:13 +00:00
2018-03-01 19:16:16 +00:00
# Stack installation
2018-03-24 01:27:00 +00:00
[[ $setup -gt 0 && $setup -lt 4 ]] && stack -nginx
[[ $setup -gt 1 && $setup -lt 4 ]] && stack -php
[[ $setup == 3 ]] && stack -mysql
2018-03-27 16:58:09 +00:00
if [[ $setup == 4 ]]; then
source /opt/webinoly/lib/webin
config_load
fi
2017-09-16 20:37:13 +00:00
2017-11-28 21:48:16 +00:00
# Remove Installation File
2017-11-07 04:10:50 +00:00
sudo rm weby
2017-09-16 20:37:13 +00:00
app_purge