api feature
now we have an API for installation and purge progress.
This commit is contained in:
parent
b26f7ec9b6
commit
b2b1e3ba5f
13
lib/general
13
lib/general
|
@ -117,16 +117,19 @@ pre_install() {
|
|||
sudo apt-get -qq update
|
||||
if [[ $(conf_read pre-packs) != true ]]; then
|
||||
# Check for missing essential packages
|
||||
api_update i1
|
||||
sudo apt-get -y -qq install software-properties-common
|
||||
sudo apt-get -y -qq install python-software-properties
|
||||
sudo apt-get -y -qq install pwgen
|
||||
sudo apt-get -y -qq install unzip
|
||||
conf_write pre-packs true
|
||||
api_update i2
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
mysql_client_install() {
|
||||
api_update im2
|
||||
local osname=$(check_osname)
|
||||
# Cases with MariaDB v10.2 support
|
||||
case "$osname" in
|
||||
|
@ -143,6 +146,7 @@ mysql_client_install() {
|
|||
sudo apt-get -y install mariadb-client
|
||||
conf_write mysql-client true
|
||||
echo "${gre}MySQL Client has been successfully installed!${end}"
|
||||
api_update im3
|
||||
}
|
||||
|
||||
|
||||
|
@ -163,6 +167,15 @@ tools_port() {
|
|||
}
|
||||
|
||||
|
||||
api_update() {
|
||||
conf_write status-api $1
|
||||
if [[ -a /opt/webinoly/lib/myapi ]]; then
|
||||
source /opt/webinoly/lib/myapi
|
||||
api_catch_status $1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
conf_read() {
|
||||
local val=$(grep -w "^${1}:.*" /opt/webinoly/webinoly.conf | cut -f 2 -d ':')
|
||||
echo $val
|
||||
|
|
26
lib/install
26
lib/install
|
@ -15,6 +15,7 @@ app_purge() {
|
|||
|
||||
|
||||
linux_optim() {
|
||||
api_update in4
|
||||
if [[ $(conf_read linux-optim) == "true" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
@ -83,11 +84,13 @@ net.ipv4.tcp_max_syn_backlog = 3240000
|
|||
sudo kill $(cat /run/nginx.pid)
|
||||
conf_write linux-optim true
|
||||
sudo nginx -t && sudo service nginx start
|
||||
api_update in7
|
||||
}
|
||||
|
||||
|
||||
linux_purge() {
|
||||
if [[ $(conf_read linux-optim) == "true" ]]; then
|
||||
api_update pn7
|
||||
sudo sed -i '/WebinolyStart/,/WebinolyEnd/{/.*/d}' /etc/security/limits.conf
|
||||
sudo sed -i '/WebinolyStart/,/WebinolyEnd/{/.*/d}' /etc/sysctl.conf
|
||||
sudo rm -rf /etc/systemd/system/nginx.service.d
|
||||
|
@ -96,6 +99,7 @@ linux_purge() {
|
|||
sudo sysctl -p
|
||||
sudo systemctl daemon-reload
|
||||
conf_write linux-optim purged
|
||||
api_update pn8
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -119,6 +123,7 @@ messagend_install() {
|
|||
|
||||
|
||||
nginx_install() {
|
||||
api_update in1
|
||||
if [[ ($(conf_read nginx-ppa) == "mainline" || $value == "mainline") && $value != "stable" ]]; then
|
||||
echo | sudo add-apt-repository ppa:nginx/development
|
||||
conf_write nginx-ppa mainline
|
||||
|
@ -137,10 +142,12 @@ nginx_install() {
|
|||
sudo nginx -t && sudo service nginx start
|
||||
conf_write nginx true
|
||||
echo "${gre}Nginx has been installed successfully! ${end}"
|
||||
api_update in2
|
||||
}
|
||||
|
||||
|
||||
php_install() {
|
||||
api_update ip1
|
||||
if [[ -n $(conf_read php-ver) && ($(conf_read php-ver) == "7.2" || $(conf_read php-ver) == "7.1" || $(conf_read php-ver) == "7.0" || $(conf_read php-ver) == "5.6") ]]; then
|
||||
echo "${gre} Custom PHP version '$(conf_read php-ver)' detected!${end}"
|
||||
else
|
||||
|
@ -169,10 +176,12 @@ php_install() {
|
|||
|
||||
conf_write php true
|
||||
echo "${gre}PHP has been installed successfully! ${end}"
|
||||
api_update ip2
|
||||
}
|
||||
|
||||
|
||||
mysql_install() {
|
||||
api_update im1
|
||||
[[ $(conf_read mysql-client) != "true" ]] && mysql_client_install
|
||||
|
||||
pre_install
|
||||
|
@ -208,11 +217,13 @@ _EOF_
|
|||
|
||||
conf_write mysql true
|
||||
echo "${gre}MySQL has been installed successfully! ${end}"
|
||||
api_update im4
|
||||
}
|
||||
|
||||
|
||||
#NGINX OPTIM
|
||||
nginx_optim() {
|
||||
api_update in3
|
||||
sudo cp -R /opt/webinoly/templates/nginx/common /etc/nginx/common
|
||||
sudo cp -R /opt/webinoly/templates/nginx/conf.d/* /etc/nginx/conf.d/
|
||||
|
||||
|
@ -236,12 +247,14 @@ nginx_optim() {
|
|||
linux_optim
|
||||
server_version
|
||||
conf_write nginx-optim true
|
||||
api_update in8
|
||||
}
|
||||
|
||||
|
||||
|
||||
# PHP OPTIM
|
||||
php_optim() {
|
||||
api_update ip3
|
||||
if [[ -n $(conf_read max-mb-uploads) && $(conf_read max-mb-uploads) =~ ^[0-9]+$ ]]; then
|
||||
local maxuploads=$(conf_read max-mb-uploads)
|
||||
else
|
||||
|
@ -292,6 +305,7 @@ php_optim() {
|
|||
|
||||
conf_write php-optim true
|
||||
sudo service php*-fpm reload
|
||||
api_update ip4
|
||||
}
|
||||
|
||||
|
||||
|
@ -305,6 +319,7 @@ nginx_tool_site() {
|
|||
|
||||
|
||||
nginx_tool() {
|
||||
api_update in9
|
||||
[[ -z $(conf_read tools-port) ]] && tools_port 22222
|
||||
[[ $(conf_read php) == "true" ]] && nginx_tool_site
|
||||
# in case php was installed before nginx
|
||||
|
@ -319,10 +334,12 @@ nginx_tool() {
|
|||
|
||||
conf_write web-tool true
|
||||
conf_write nginx-tool true
|
||||
api_update in10
|
||||
}
|
||||
|
||||
|
||||
php_tool_site() {
|
||||
api_update ip6
|
||||
# Status pages
|
||||
sudo mkdir -p /var/www/$(conf_read tools-port)/htdocs/fpm/status
|
||||
sudo touch /var/www/$(conf_read tools-port)/htdocs/fpm/status/php
|
||||
|
@ -332,10 +349,12 @@ php_tool_site() {
|
|||
sudo mkdir -p /var/www/$(conf_read tools-port)/htdocs/php
|
||||
sudo touch /var/www/$(conf_read tools-port)/htdocs/php/index.php
|
||||
sudo echo '<?php phpinfo(); ?>' >> /var/www/$(conf_read tools-port)/htdocs/php/index.php
|
||||
api_update ip7
|
||||
}
|
||||
|
||||
|
||||
php_tool() {
|
||||
api_update ip5
|
||||
# in case nginx was installed before php
|
||||
if [[ $(conf_read nginx-tool) == "true" && ! -a /etc/nginx/sites-available/$(conf_read tools-port) ]]; then
|
||||
nginx_tool_site
|
||||
|
@ -360,10 +379,12 @@ php_tool() {
|
|||
sudo service php*-fpm reload
|
||||
conf_write web-tool true
|
||||
conf_write php-tool true
|
||||
api_update ip8
|
||||
}
|
||||
|
||||
|
||||
mysql_tool() {
|
||||
api_update im5
|
||||
#PhpMyAdmin unattended script installation
|
||||
local AUTOGENPASS_PMA=`pwgen -s -1`
|
||||
echo "phpmyadmin phpmyadmin/dbconfig-install boolean true" | debconf-set-selections
|
||||
|
@ -379,17 +400,20 @@ mysql_tool() {
|
|||
|
||||
conf_write mysql-tool true
|
||||
echo "${gre}PhpMyAdmin has been installed successfully! ${end}"
|
||||
api_update im6
|
||||
}
|
||||
|
||||
|
||||
swap_delete() {
|
||||
local swapkb=$(grep SwapTotal /proc/meminfo | cut -f 2 -d ':' | tr -d ' ' | cut -f 1 -d 'k')
|
||||
if [[ -n $swapkb && $swapkb =~ ^[0-9]+$ && $swapkb -gt 0 && $(conf_read swap-owner) == "webinoly" ]]; then
|
||||
api_update pn9
|
||||
sudo swapoff -a -v > /dev/null
|
||||
sudo rm /swapfile
|
||||
sudo sed -i '/\/swapfile/d' /etc/fstab
|
||||
sudo sed -i '/vm.swappiness/d' /etc/sysctl.conf
|
||||
conf_delete swap-owner
|
||||
api_update pn10
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -407,6 +431,7 @@ swap_create() {
|
|||
fi
|
||||
|
||||
if [[ -z $swapkb || $swapkb == "0" ]]; then
|
||||
api_update in5
|
||||
if [[ -n $(conf_read swap-mem) && $(conf_read swap-mem) =~ ^[0-9]+$ ]]; then
|
||||
local newswap=$(conf_read swap-mem)
|
||||
elif [[ $ram -le 2 ]]; then
|
||||
|
@ -451,6 +476,7 @@ swap_create() {
|
|||
|
||||
echo "${gre} A new SWAP Partion (${newswap}Gb) has been created! ${end}"
|
||||
fi
|
||||
api_update in6
|
||||
else
|
||||
if [[ $(conf_read swap-owner) != "webinoly" ]]; then
|
||||
conf_write swap-owner system
|
||||
|
|
60
lib/myapi-sample
Normal file
60
lib/myapi-sample
Normal file
|
@ -0,0 +1,60 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Installation process
|
||||
#
|
||||
# i1 - Common Packages
|
||||
# i2 - Common Packages Finished
|
||||
#
|
||||
# in1 - NGINX Installation
|
||||
# in2 - NGINX Installation Finished
|
||||
# in3 - NGINX Optimization
|
||||
# in4 - Ubuntu Optimization
|
||||
# in5 - SWAP Creation
|
||||
# in6 - SWAP Creation Finished
|
||||
# in7 - Ubuntu Optimization Finished
|
||||
# in8 - NGINX Optimization Finished
|
||||
# in9 - NGINX Tools
|
||||
# in10 - NGINX Tools Finished
|
||||
#
|
||||
# ip1 - PHP Installation
|
||||
# ip2 - PHP Installation Finished
|
||||
# ip3 - PHP Optimization
|
||||
# ip4 - PHP Optimization Finished
|
||||
# ip5 - PHP Tools
|
||||
# ip6 - PHP Tools site creation
|
||||
# ip7 - PHP Tools site creation Finished
|
||||
# ip8 - PHP Tools Finished
|
||||
#
|
||||
# im1 - MySQL Installation
|
||||
# im2 - MySQL Client Installation
|
||||
# im3 - MySQL Client Installation Finished
|
||||
# im4 - MySQL Installation Finished
|
||||
# im5 - MySQL Tool (PhpMyAdmin)
|
||||
# im6 - MySQL Tool (PhpMyAdmin) Finished
|
||||
#
|
||||
#
|
||||
# Purge (UnInstall)
|
||||
#
|
||||
# pn1 - NGINX Purge
|
||||
# pn2 - NGINX Delete All Sites
|
||||
# pn3 - NGINX Delete All Sites Finished
|
||||
# pn4 - NGINX Purge Finished
|
||||
# pn5 - NGINX Purge Tools
|
||||
# pn6 - NGINX Purge Tools Finished
|
||||
# pn7 - Ubuntu Optimization Purge
|
||||
# pn8 - Ubuntu Optimization Purge Finished
|
||||
# pn9 - SWAP Purge
|
||||
# pn10 - SWAP Purge Finished
|
||||
#
|
||||
# pp1 - PHP Purge
|
||||
# pp2 - PHP Purge Finished
|
||||
#
|
||||
# pm1 - MySQL Purge
|
||||
# pm2 - MySQL Tool (PhpMyAdmin) Purge
|
||||
# pm3 - MySQL Tool (PhpMyAdmin) Purge Finished
|
||||
# pm4 - MySQL Purge Finished
|
||||
|
||||
|
||||
api_catch_status() {
|
||||
echo "${blu}API Status: $1 ${end}"
|
||||
}
|
|
@ -53,6 +53,7 @@ if [[ $arg == "-noptim" && $opt == "-lemp" ]]; then
|
|||
|
||||
# Delete some stack
|
||||
elif [[ $arg == "-purge" && ( $opt == "-html" || $opt == "-nginx" ) ]]; then
|
||||
api_update pn1
|
||||
if [[ $(conf_read nginx) != "true" ]]; then
|
||||
echo "${red}Nginx is not installed, hence can not be deleted! ${end}"
|
||||
clear_force_flag
|
||||
|
@ -85,18 +86,23 @@ elif [[ $arg == "-purge" && ( $opt == "-html" || $opt == "-nginx" ) ]]; then
|
|||
fi
|
||||
if [[ $answer == [Yy] ]]; then
|
||||
[[ $(conf_read mysql-tool) == "true" ]] && stack -pma -purge
|
||||
api_update pn2
|
||||
site -delete-all
|
||||
sudo rm -rf /var/www/$(conf_read tools-port)
|
||||
sudo rm -rf /var/www/html
|
||||
api_update pn3
|
||||
fi
|
||||
|
||||
sudo service nginx stop
|
||||
sudo apt-get -y purge nginx nginx-common
|
||||
sudo apt-get -y purge letsencrypt python-boto duplicity duply
|
||||
[[ $(conf_read nginx-ppa) == "mainline" ]] && echo | sudo add-apt-repository --remove 'ppa:nginx/development' || echo | sudo add-apt-repository --remove 'ppa:nginx/stable'
|
||||
api_update pn4
|
||||
api_update pn5
|
||||
sudo apt-get -y purge letsencrypt python-boto duplicity duply
|
||||
sudo apt-get -y autoremove
|
||||
sudo rm $HOME/www
|
||||
sudo rm $HOME/sites-available
|
||||
sudo rm $HOME/sites-available
|
||||
api_update pn6
|
||||
linux_purge
|
||||
|
||||
[[ $(conf_read php-tool) != "true" ]] && conf_write web-tool purged
|
||||
|
@ -114,6 +120,7 @@ elif [[ $arg == "-purge" && ( $opt == "-html" || $opt == "-nginx" ) ]]; then
|
|||
echo ""
|
||||
|
||||
elif [[ $arg == "-purge" && $opt == "-php" ]]; then
|
||||
api_update pp1
|
||||
if [[ $(conf_read php) != "true" ]]; then
|
||||
echo "${red}PHP is not installed, hence can not be deleted! ${end}"
|
||||
clear_force_flag
|
||||
|
@ -164,8 +171,10 @@ elif [[ $arg == "-purge" && $opt == "-php" ]]; then
|
|||
echo ""
|
||||
fi
|
||||
echo ""
|
||||
api_update pp2
|
||||
|
||||
elif [[ $arg == "-purge" && $opt == "-mysql" ]]; then
|
||||
api_update pm1
|
||||
if [[ $(conf_read mysql) != "true" ]]; then
|
||||
echo "${red}MySQL is not installed, hence can not be deleted! ${end}"
|
||||
clear_force_flag
|
||||
|
@ -222,8 +231,10 @@ elif [[ $arg == "-purge" && $opt == "-mysql" ]]; then
|
|||
echo ""
|
||||
fi
|
||||
echo ""
|
||||
api_update pm4
|
||||
|
||||
elif [[ $arg == "-purge" && $opt == "-pma" ]]; then
|
||||
api_update pm2
|
||||
if [[ $(conf_read mysql-tool) != "true" ]]; then
|
||||
echo "${red} PhpMyAdmin is not installed, hence can not be deleted! ${end}"
|
||||
clear_force_flag
|
||||
|
@ -260,6 +271,7 @@ elif [[ $arg == "-purge" && $opt == "-pma" ]]; then
|
|||
echo ""
|
||||
fi
|
||||
echo ""
|
||||
api_update pm3
|
||||
|
||||
elif [[ $arg == "-purge" && $opt == "-web-tools" ]]; then
|
||||
if [[ $(conf_read web-tool) != "true" ]]; then
|
||||
|
|
Loading…
Reference in a new issue