standard syntax for commands

Commands syntax updated: root, parked, toolsport, configcache with "=" and brackets "[ ]" .
This commit is contained in:
Cristhian Martínez Ochoa 2018-02-18 19:59:21 -07:00
parent ab31ea704d
commit 34d341341f
4 changed files with 66 additions and 48 deletions

View file

@ -8,10 +8,8 @@ source /opt/webinoly/lib/general
site_ssl_on() { site_ssl_on() {
local cermail=$(conf_read mail) local cermail=$(conf_read mail)
local root="$domain" local root="$domain"
if [[ "$cache" == "-root" ]]; then [[ $cache == "-root" && -n $value ]] && root="$value"
root="$domroot"
fi
echo "${gre}" echo "${gre}"
echo "*************************************************************************************************" echo "*************************************************************************************************"
echo "** Please, be careful with the number of intents or certificates you try to get. **" echo "** Please, be careful with the number of intents or certificates you try to get. **"

View file

@ -11,7 +11,6 @@ shopt -s extglob
domain="$1" domain="$1"
type="$2" type="$2"
cache="$3" cache="$3"
domroot="$4"
source /opt/webinoly/lib/general source /opt/webinoly/lib/general
source /opt/webinoly/lib/sites source /opt/webinoly/lib/sites
@ -38,36 +37,46 @@ else
subdomflag="1" subdomflag="1"
fi fi
wp="0" # Evaluate if site to create is WP ( 0 = noWP, 1 = WP, 2 = WP with default values, 3 = WP with custom values ) # Extract value if exist
if [[ "$type" == "-wp" || "$type" == "-wpsubdir" || "$type" == "-wpsubdom" ]]; then if [[ $type == "-parked="* || $type == "-proxy="* || $type == "-wp="* || $type == "-wpsubdir="* || $type == "-wpsubdom="* ]]; then
wp="1" value=$(echo "${type}" | cut -d'=' -f 2 -s)
type=$(echo "${type}" | cut -d'=' -f 1 -s)
fi fi
if [[ "$type" == "-wp="* || "$type" == "-wpsubdir="* || "$type" == "-wpsubdom="* ]]; then if [[ $cache == "-root="* ]]; then
wpunat=$(echo "${type}" | cut -d'=' -f 2 -s) value=$(echo "${cache}" | cut -d'=' -f 2 -s)
if [[ $wpunat == "default" ]]; then cache=$(echo "${cache}" | cut -d'=' -f 1 -s)
wp="2" fi
type=$(echo "${type}" | cut -d'=' -f 1 -s)
else
# -wp=[setupmysql,setupwp,dbhost,dbname,dbuser,dbpass,dbpref,extdbuser,extdbpass] # Evaluate if site to create is WP ( 0 = noWP, 1 = WP, 2 = WP with default values, 3 = WP with custom values )
custombegin=$(echo "${wpunat}" | cut -c-1) wp="0"
customlast=$(echo "${wpunat}" | rev | cut -c-1) if [[ $type == "-wp" || $type == "-wpsubdir" || $type == "-wpsubdom" ]]; then
wpdata=${wpunat:1:-1} wp="1"
# Double coma is for lower case convertion if [[ -n $value ]]; then
setmsqcustom=$(echo "${wpdata,,}" | cut -d',' -f 1 -s) if [[ $value == "default" ]]; then
setpwpcustom=$(echo "${wpdata,,}" | cut -d',' -f 2 -s) wp="2"
else
dbhostcustom=$(echo "${wpdata}" | cut -d',' -f 3 -s) # -wp=[setupmysql,setupwp,dbhost,dbname,dbuser,dbpass,dbpref,extdbuser,extdbpass]
dbnamecustom=$(echo "${wpdata}" | cut -d',' -f 4 -s) custombegin=$(echo "${value}" | cut -c-1)
dbusercustom=$(echo "${wpdata}" | cut -d',' -f 5 -s) customlast=$(echo "${value}" | rev | cut -c-1)
dbpasscustom=$(echo "${wpdata}" | cut -d',' -f 6 -s) wpdata=${value:1:-1}
dbprefcustom=$(echo "${wpdata}" | cut -d',' -f 7 -s)
exusercustom=$(echo "${wpdata}" | cut -d',' -f 8 -s) # Double coma is for lower case convertion
expasscustom=$(echo "${wpdata}" | cut -d',' -f 9 -s) setmsqcustom=$(echo "${wpdata,,}" | cut -d',' -f 1 -s)
setpwpcustom=$(echo "${wpdata,,}" | cut -d',' -f 2 -s)
if [[ $custombegin == "[" && $customlast == "]" && ((($setmsqcustom == "true" || $setpwpcustom == "true") && -n $dbhostcustom && -n $dbnamecustom && -n $dbusercustom && -n $dbpasscustom && -n $dbprefcustom) || ($setmsqcustom == "false" && $setpwpcustom == "false")) ]]; then
wp="3" dbhostcustom=$(echo "${wpdata}" | cut -d',' -f 3 -s)
type=$(echo "${type}" | cut -d'=' -f 1 -s) dbnamecustom=$(echo "${wpdata}" | cut -d',' -f 4 -s)
dbusercustom=$(echo "${wpdata}" | cut -d',' -f 5 -s)
dbpasscustom=$(echo "${wpdata}" | cut -d',' -f 6 -s)
dbprefcustom=$(echo "${wpdata}" | cut -d',' -f 7 -s)
exusercustom=$(echo "${wpdata}" | cut -d',' -f 8 -s)
expasscustom=$(echo "${wpdata}" | cut -d',' -f 9 -s)
if [[ $custombegin == "[" && $customlast == "]" && ((($setmsqcustom == "true" || $setpwpcustom == "true") && -n $dbhostcustom && -n $dbnamecustom && -n $dbusercustom && -n $dbpasscustom && -n $dbprefcustom) || ($setmsqcustom == "false" && $setpwpcustom == "false")) ]]; then
wp="3"
fi
fi fi
fi fi
fi fi
@ -168,9 +177,7 @@ elif [ "$type" == "-wpsubdom" ]; then
# Parked Domain # Parked Domain
elif [ "$type" == "-parked" ]; then elif [ "$type" == "-parked" ]; then
mapto="NeverMatchAtFirstDotCom" mapto="NeverMatchAtFirstDotCom"
if [[ -n $cache ]]; then [[ -n $value ]] && mapto="$value"
mapto="$cache"
fi
while [[ ! -a /etc/nginx/sites-available/$mapto ]] while [[ ! -a /etc/nginx/sites-available/$mapto ]]
do do
@ -198,16 +205,17 @@ elif [ "$type" == "-parked" ]; then
echo "${end}" echo "${end}"
# Reverse proxy # Reverse proxy
elif [[ "$type" == "-proxy" || "$type" == "-proxy="* ]]; then elif [[ "$type" == "-proxy" ]]; then
createsite createsite
sudo sed -i '/include /d' /etc/nginx/sites-available/$domain sudo sed -i '/include /d' /etc/nginx/sites-available/$domain
sudo sed -i '/root /d' /etc/nginx/sites-available/$domain sudo sed -i '/root /d' /etc/nginx/sites-available/$domain
sudo sed -i '/index /d' /etc/nginx/sites-available/$domain sudo sed -i '/index /d' /etc/nginx/sites-available/$domain
sudo sed -i '/error_log /r /opt/webinoly/templates/template-site-proxy' /etc/nginx/sites-available/$domain sudo sed -i '/error_log /r /opt/webinoly/templates/template-site-proxy' /etc/nginx/sites-available/$domain
rparg=$(echo "${type}" | cut -d'=' -f 2 -s) if [[ -n $value ]]; then
rphost=$(echo "${rparg}" | cut -d':' -f 1 -s) rphost=$(echo "${value}" | cut -d':' -f 1 -s)
rpport=$(echo "${rparg}" | cut -d':' -f 2 -s) rpport=$(echo "${value}" | cut -d':' -f 2 -s)
fi
echo "${gre}" echo "${gre}"
if [[ -n $rphost ]]; then if [[ -n $rphost ]]; then

View file

@ -9,6 +9,14 @@ arg="$2"
source /opt/webinoly/lib/install source /opt/webinoly/lib/install
# Extract value if exist
if [[ $opt == "-tools-port="* || $opt == "-config-cache="* ]]; then
value=$(echo "${opt}" | cut -d'=' -f 2 -s)
opt=$(echo "${opt}" | cut -d'=' -f 1 -s)
fi
if [ "$opt" == "-update" ]; then if [ "$opt" == "-update" ]; then
if [[ $arg == '-vbeta' ]]; then if [[ $arg == '-vbeta' ]]; then
sudo wget --timeout=15 -qrO weby https://qrok.es/wyupdb && sudo bash weby -vbeta sudo wget --timeout=15 -qrO weby https://qrok.es/wyupdb && sudo bash weby -vbeta
@ -53,7 +61,7 @@ elif [ "$opt" == "-dbpass" ]; then
elif [ "$opt" == "-tools-port" ]; then elif [ "$opt" == "-tools-port" ]; then
if [[ $(conf_read nginx-tool) == "true" && $(conf_read nginx) == "true" ]]; then if [[ $(conf_read nginx-tool) == "true" && $(conf_read nginx) == "true" ]]; then
oldport="$(conf_read tools-port)" oldport="$(conf_read tools-port)"
tools_port $arg [[ -n $value ]] && tools_port $value || tools_port
newport="$(conf_read tools-port)" newport="$(conf_read tools-port)"
if [[ $oldport != $newport ]]; then if [[ $oldport != $newport ]]; then
sudo mv /var/www/$oldport /var/www/$newport sudo mv /var/www/$oldport /var/www/$newport
@ -149,7 +157,7 @@ elif [ "$opt" == "-config-cache" ]; then
othline=$( grep -F "fastcgi_cache_valid 301 302 307 404" /etc/nginx/conf.d/fastcgi.conf ) othline=$( grep -F "fastcgi_cache_valid 301 302 307 404" /etc/nginx/conf.d/fastcgi.conf )
othval=$(echo "${othline//;}" | rev | cut -d' ' -f 1 | rev) othval=$(echo "${othline//;}" | rev | cut -d' ' -f 1 | rev)
if [[ -z $arg ]]; then if [[ -z $value ]]; then
echo "${gre}" echo "${gre}"
echo "**********************************************************************" echo "**********************************************************************"
echo "************* Set FastCGI Cache new time values **************" echo "************* Set FastCGI Cache new time values **************"
@ -168,9 +176,13 @@ elif [ "$opt" == "-config-cache" ]; then
read -p " Set new value: " oth read -p " Set new value: " oth
oth=${oth:-$othval} oth=${oth:-$othval}
else else
hit=$(echo "${arg}" | cut -d',' -f 1 ) custombegin=$(echo "${value}" | cut -c-1)
ina=$(echo "${arg}" | cut -d',' -f 2 ) customlast=$(echo "${value}" | rev | cut -c-1)
oth=$(echo "${arg}" | cut -d',' -f 3 ) cachedata=${value:1:-1}
hit=$(echo "${cachedata}" | cut -d',' -f 1 )
ina=$(echo "${cachedata}" | cut -d',' -f 2 )
oth=$(echo "${cachedata}" | cut -d',' -f 3 )
fi fi
if [[ "$hit" =~ ^[0-9]+[smhdwMy]$ && "$ina" =~ ^[0-9]+[smhdwMy]$ && "$oth" =~ ^[0-9]+[smhdwMy]$ ]]; then if [[ "$hit" =~ ^[0-9]+[smhdwMy]$ && "$ina" =~ ^[0-9]+[smhdwMy]$ && "$oth" =~ ^[0-9]+[smhdwMy]$ ]]; then

4
weby
View file

@ -2,7 +2,7 @@
# Webinoly script. # Webinoly script.
# This script is designed to install latest Webinoly. # This script is designed to install latest Webinoly.
webyversion="1.3.0-beta" webyversion="1.3.0"
# Check OS support # Check OS support
@ -49,7 +49,7 @@ if [[ $setup == '-vbeta' ]]; then
echo "" echo ""
sudo wget --timeout=15 -qrO $HOME/webinoly.tar https://qrok.es/wytarb sudo wget --timeout=15 -qrO $HOME/webinoly.tar https://qrok.es/wytarb
echo "$(tput setaf 1)" echo "$(tput setaf 1)"
echo " [WARNING] You are installing a BETA version of Webinoly and it's not recommended for production enviroments. $(tput sgr0)" echo "[WARNING] You are installing a BETA version of Webinoly and it's not recommended for production enviroments. $(tput sgr0)"
else else
sudo wget --timeout=15 -qrO $HOME/webinoly.tar https://qrok.es/wytar sudo wget --timeout=15 -qrO $HOME/webinoly.tar https://qrok.es/wytar
fi fi