installer [rf1]

This commit is contained in:
Adrien Marquès 2018-06-10 17:16:08 +02:00
parent dab26c9ca4
commit 683ef84ab3
4 changed files with 256 additions and 0 deletions

40
install-scripts/format Normal file
View File

@ -0,0 +1,40 @@
#!/bin/bash
#*************************#
# RELEASER:formatter #
#*************************#
# Designed & Developed by #
# Adrien Marquès #
# <xdrm-brackets> #
#*************************#
# git.xdrm.io #
#*************************#
S="12"
# (1) Creates a fixed inline progress
#--------------------------------------------------------#
set_inline_progress_size(){
test ! -z "$1" && test "`expr $1 + 0 2>/dev/null`" = "$1" && export S="$1"
}
inline_progress(){
# 1. init arguments
text=""
size="$S"
sep=" "
# 2. extract text
test ! -z "$1" && text="$1";
# 3. extract size
test ! -z "$2" && test "`expr $2 + 0 2>/dev/null`" = "$2" && size="$2";
# 4. Write text
len="`echo -n \"$text\" | wc -m`";
echo -n "$text";
for i in `seq $len $size`; do echo -n "$sep"; done;
return;
}

196
install-scripts/installer Normal file
View File

@ -0,0 +1,196 @@
#!/bin/bash
#*************************#
# RELEASER:check #
#*************************#
# Designed & Developed by #
# Adrien Marquès #
# <xdrm-brackets> #
#*************************#
# git.xdrm.io #
#*************************#
source ./format;
# (1) Check if requirements are installed
#--------------------------------------------------------#
echo -e "\e[33m>\e[0m (1) required programs \e[33m<\e[0m"
requirements="curl git docker docker-compose make"
set_inline_progress_size "20";
for r in $requirements; do
inline_progress " . $r";
if which $r >/dev/null 2>&1; then
echo "ok";
else
echo "missing";
echo -e "\n\e[31m/!\\\\\e[0m you must install \e[33m$r\e[0m.";
echo -e " this program is required to install the project";
exit 1;
fi;
done;
# (2) Check docker permissions
#--------------------------------------------------------#
echo;
echo -e "\e[33m>\e[0m (2) docker \e[33m<\e[0m";
# (1) docker permissions #
inline_progress " . group";
if groups | grep 'docker' >/dev/null 2>&1; then
echo "ok";
else
echo "missing";
echo;
echo -e " you might add the current user to the \e[33mdocker\e[0m group !";
echo -e "\e[31m/!\\\\\e[0m it is safer for administrative tasks. You might want";
echo -e " to avoid using 'root' for docker.";
exit 1;
fi;
# (3) find out http installer
#--------------------------------------------------------#
echo;
echo -e "\e[33m>\e[0m (3) http installer \e[33m<\e[0m";
inline_progress " * http server";
echo;
# 1. Check for installed candidates
existing="apache2 httpd nginx"
candidates="";
ncandidates="0"
i="0"
for current in $existing; do
inline_progress " . $current";
if which $current >/dev/null 2>&1; then
echo "ok";
test -z "$candidates" && candidates="$current" || candidates="$candidates $current";
ncandidates="`expr $ncandidates + 1`";
else
echo "..";
fi;
i="`expr $i + 1`";
done;
# 2. fail if no candidate
if [ "$ncandidates" -lt 1 ]; then
echo;
echo -e " no http server has been found, you might install one.";
echo -e "\e[31m/!\\\\\e[0m the installer supports the most common ones: \e[33mnginx\e[0m"
echo -e " and \e[33mapache\e[0m (httpd)";
exit 1;
# 3. only one candidate
elif [ "$ncandidates" -eq 1 ]; then
echo;
echo -e " \e[33m$candidates\e[0m http server has been found. a reverse proxy will be"
echo -e "\e[31m/!\\\\\e[0m installed in order for the project to be remotely accessible.";
echo -e " do you want to use $candidates ? \e[33my\e[0m/\e[33mn\e[0m";
read -p " > " -n1 install; echo;
case "$install" in
Y|y) ;;
*) echo -e "\n\e[31m/!\\\\\e[0m aborting installation"; exit 1;;
esac;
http_installer="$candidates";
# 4. multiple candidates
else
echo;
echo -e " multiple http server candidates have been found. a reverse proxy will be"
echo -e "\e[31m/!\\\\\e[0m installed in order for the project to be remotely accessible.";
echo -e " please choose the http server one you want to use:"
echo -e " (0) \e[33mabort\e[0m"
i="1";
for c in $candidates; do echo -e " ($i) \e[33m$c\e[0m"; i="`expr $i + 1`"; done;
read -p " > " -n1 install; echo;
# 4.1. Abort (or invalid)
if [ "`expr $install + 0 2>/dev/null`" != "$install" -o "$install" = "0" ]; then
echo -e "\n\e[31m/!\\\\\e[0m aborting installation"; exit 1;
elif [ "$install" -gt "$ncandidates" ]; then
echo -e "\n\e[31m/!\\\\\e[0m aborting installation"; exit 1;
fi;
http_installer=$(echo $candidates | awk "{print \$$install}")
fi;
echo "http_installer: $http_installer"
# (4) information disclaimer
#--------------------------------------------------------#
echo;
echo -e "\e[33m>\e[0m (4) information \e[33m<\e[0m";
echo;
echo -e " \e[34m(!)\e[0m (1) the project will run inside docker containers (3 containers).";
echo;
echo -e " \e[34m(!)\e[0m (2) the only links it has with the host machine (this machine) are:";
echo;
echo -e " \e[34m(!)\e[0m - \e[34mweb files\e[0m (that will be shared between multiple containers)";
echo -e " \e[34m(!)\e[0m - \e[34menvironment files\e[0m (for continuous integration)";
echo -e " \e[34m(!)\e[0m - \e[34ma listening socket\e[0m (to accept incoming http requests)";
echo;
echo -e " \e[34m(!)\e[0m (3) in order for incoming requests to go follow the path:";
echo -e " \e[34m(!)\e[0m [remote] => [http server] => [docker]";
echo;
echo -e " \e[34m(!)\e[0m we will install a reverse proxy on the http server ($http_installer) to";
echo -e " \e[34m(!)\e[0m automatically redirect requests from a specific \e[34m<HOST>\e[0m to docker's";
echo -e " \e[34m(!)\e[0m listening \e[34m<PORT>\e[0m.";
echo;
echo -e " \e[34m(!)\e[0m WARNING: The \e[34m<HOST>\e[0m must be available for your server and be a sub-domain";
echo -e " \e[34m(!)\e[0m in order for your DNS to be valid.";
echo;
echo -e " \e[34m(!)\e[0m EXAMPLE: If your server has \e[33mexample.net\e[0m as a DNS.";
echo -e " \e[34m(!)\e[0m the \e[34m<HOST>\e[0m \e[33mtest.example.net\e[0m is valid";
echo -e " \e[34m(!)\e[0m the \e[34m<HOST>\e[0m \e[33mtest.google.com\e[0m is not valid";
# (5) prompt server variables
#--------------------------------------------------------#
echo;
echo -e "\e[33m>\e[0m (5) variables \e[33m<\e[0m";
# 1. Port
minport="1024"
maxport="49151"
echo -e " * what port do you want docker to use ? (between $minport and $maxport)";
echo -en " \e[34m<PORT>\e[0m = ";
read port;
if [ -z "$port" -o "`expr $port + 0 2>/dev/null`" != "$port" ]; then
echo;
echo -e "\e[31m/!\\\\\e[0m invalid port number. aborting installation"
exit 1;
elif [ "$port" -lt $minport -o "$port" -gt $maxport ]; then
echo;
echo -e "\e[31m/!\\\\\e[0m port out of range. aborting installation"
exit 1;
fi;
# 2. Host
echo -e " * what host do you want to redirect to docker ?";
echo -en " \e[34m<HOST>\e[0m = ";
read host;
if [ -z "$host" ]; then
echo;
echo -e "\e[31m/!\\\\\e[0m invalid host. aborting installation"
exit 1;
fi;

View File

@ -1,4 +1,15 @@
#!/bin/bash
#!/bin/bash
#*************************#
# RELEASER:main #
#*************************#
# Designed & Developed by #
# Adrien Marquès #
# <xdrm-brackets> #
#*************************#
# git.xdrm.io #
#*************************#
git clone --recursive https://git.xdrm.io/ptut/virtenv.git ptut.virtenv \
&& mkdir -p ./ptut.virtenv/metactl/persistent \

View File

@ -1,5 +1,14 @@
#!/bin/bash
#*************************#
# RELEASER:reverse-proxy #
#*************************#
# Designed & Developed by #
# Adrien Marquès #
# <xdrm-brackets> #
#*************************#
# git.xdrm.io #
#*************************#
install_nginx(){
echo -e "\e[33m>\e[0m nginx installer \e[33m<\e[0m\n"