webinoly/weby
Cristhian Martínez Ochoa b26f7ec9b6 force www redirect
Now we have a command to force redirections to www or non-www.
2018-05-02 15:41:31 -06:00

99 lines
3 KiB
Bash

#!/bin/bash
# Webinoly Installation Script.
webyversion="1.5.0-beta"
# 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
# Diplay menu to select type of server
[[ -n "$1" ]] && setup="$1" || setup=9
while ! [[ $setup -ge 0 && $setup -le 4 && $setup =~ ^[0-9]+$ ]] 2>/dev/null
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
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'}"
echo "$(tput setaf 1)"
if [[ $code == 200 ]]; then
sudo wget --timeout=15 -qrO $HOME/webinoly.tar https://qrok.es/webinoly?version=$ver
sudo rm 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."
else
echo "[ERROR] Version not found or not available! ($code) $(tput sgr0)"
exit 1
fi
echo $(tput sgr0)
else
sudo wget --timeout=15 -qrO $HOME/webinoly.tar https://qrok.es/wytar
fi
[[ ! -d /opt/webinoly ]] && sudo mkdir /opt/webinoly
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
# Check for uninstalled Webinoly conf file
[[ -a $HOME/.webinoly-conf-restore_dont-remove ]] && sudo mv $HOME/.webinoly-conf-restore_dont-remove /opt/webinoly/webinoly.conf
# Save Tools Port after library is available.
if [[ -a /opt/webinoly/webinoly.conf ]]; then
echo "${gre}Webinoly Configuration file was found, so we will use it!${end}"
else
[[ -n $2 && $2 != "-ver="* ]] && tools_port $2
fi
# Write app version
conf_write app-version $webyversion
# Stack installation
[[ $setup -gt 0 && $setup -lt 4 ]] && stack -nginx
[[ $setup -gt 1 && $setup -lt 4 ]] && stack -php
[[ $setup == 3 ]] && stack -mysql
if [[ $setup == 4 ]]; then
source /opt/webinoly/lib/webin
config_load
fi
# Remove Installation File
sudo rm weby
app_purge