From 5a41d6bd717133e88f16a2d3476b66fa536b1200 Mon Sep 17 00:00:00 2001 From: ray Date: Thu, 25 Jun 2020 11:27:14 +0100 Subject: [PATCH] modularise server installation --- config-local | 39 ++++++++++++++++++++++++ config-remote | 39 ++++++++++++++++++++++++ server-install-apache.sh | 17 +++++++++++ server-install-base.sh | 18 ++++------- server-install-litespeed.sh | 38 ++++++++++++++++++++++++ server-install-nginx.sh | 17 +++++++++++ server-install-web.sh | 59 ------------------------------------- 7 files changed, 155 insertions(+), 72 deletions(-) create mode 100755 config-local create mode 100644 config-remote create mode 100755 server-install-apache.sh create mode 100755 server-install-litespeed.sh create mode 100755 server-install-nginx.sh delete mode 100755 server-install-web.sh diff --git a/config-local b/config-local new file mode 100755 index 0000000..0bc4729 --- /dev/null +++ b/config-local @@ -0,0 +1,39 @@ +#!/bin/sh +export domain='test123.home' +export url='http://test123.home' + +export ssh='root@test123.home' + +export username='root' +export webuser='' +export db_root_pass='39dn,s9889d89--sdj_UUUY' +export wp_db_name='wordpress' +export wp_db_user='wordpress' +export wp_db_pass='wordpress' +export wp_path='/var/www/html/wordpress' +export wp_user='admin' +export wp_pass='admin' + +# list of themes to install - first one will be activate +export wp_themes="twentytwenty" +export wp_plugins="" +export wp_plugins_active="block-lab" +export wp_plugins_uninstall="hello aksimet" + +export php_version='' + +# set one of +export mariadb_version='' +export mysql_version='' + +# set one of +export apache2_version='' +export nginx_version='' +# LSPHPVERLIST=(54 55 56 70 71 72 73 74) +export litespeed_version='latest' + +#set if using litespeed +# https://openlitespeed.org/kb/1-click-install/ +# password used to log into litespeed web interface) +export ls_webadmin_pass='admin' +export ls_lsphp_version='73' diff --git a/config-remote b/config-remote new file mode 100644 index 0000000..d3b706a --- /dev/null +++ b/config-remote @@ -0,0 +1,39 @@ +#!/bin/sh +export domain='test123.isnet.uk' +export url='http://test123.isnet.uk' + +export ssh='root@test123.isnet.uk' + +export username='root' +export webuser='' +export db_root_pass='39dn,s9889d89--sdj_UUUY' +export wp_db_name='wordpress' +export wp_db_user='wordpress' +export wp_db_pass='39fhi3nkjdf__dlk8-ddWEs' +export wp_path='/var/www/html/wordpress' +export wp_user='admin' +export wp_pass='f988888--3XSD' + +# list of themes to install - first one will be activate +export wp_themes="twentytwenty" +export wp_plugins="" +export wp_plugins_active="" +export wp_plugins_uninstall="hello aksimet" + +export php_version='' + +# set one of +export mariadb_version='' +export mysql_version='' + +# set one of +export apache2_version='' +export nginx_version='' +# LSPHPVERLIST=(54 55 56 70 71 72 73 74) +export litespeed_version='latest' + +#set if using litespeed +# https://openlitespeed.org/kb/1-click-install/ +# password used to log into litespeed web interface) +export ls_webadmin_pass='x7856----DD' +export ls_lsphp_version='73' diff --git a/server-install-apache.sh b/server-install-apache.sh new file mode 100755 index 0000000..b169b57 --- /dev/null +++ b/server-install-apache.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ -z "$1" ] ; then + echo "error: must specify configuration file to use" + exit 5 +fi + +. ./"$1" + +ssh -T $src_ssh << EOSSH + +ufw allow http && ufw allow https + +echo "TODO install apache" +exit 1 + +EOSSH diff --git a/server-install-base.sh b/server-install-base.sh index 0afe7fd..4bbf6ff 100755 --- a/server-install-base.sh +++ b/server-install-base.sh @@ -1,21 +1,13 @@ #!/bin/sh -. ./config - -if [ "$1" = 'local' ] ; then - src_url="$local_url"; - dest_url="$remote_url"; - src_ssh="$local_ssh" -elif [ "$1" = 'remote' ] ; then - src_url="$remote_url"; - dest_url="$local_url"; - src_ssh="$remote_ssh" -else - echo "error: must specify local or remote" +if [ -z "$1" ] ; then + echo "error: must specify configuration file to use" exit 5 fi -ssh -T $src_ssh << EOSSH +. ./"$1" + +ssh -T $ssh << EOSSH apt update || exit 5 apt upgrade -y || exit 10 diff --git a/server-install-litespeed.sh b/server-install-litespeed.sh new file mode 100755 index 0000000..d4b6653 --- /dev/null +++ b/server-install-litespeed.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +if [ -z "$1" ] ; then + echo "error: must specify configuration file to use" + exit 5 +fi + +. ./"$1" + +ssh -T $ssh << EOSSH + +ufw allow http && ufw allow https + +if [ "$litespeed_version" != 'latest' ] ; then + echo "TODO install specific litespeed version" + echo "" + echo "Specify \"litespeed_version='latest'\" to install current version." + exit 1 +fi +if [ -n "$wp_user" ] ; then + wget --no-check-certificate https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh && bash ols1clk.sh \ + --adminpassword "$ls_webadmin_pass" \ + --lsphp "$ls_lsphp_version" \ + --wordpressplus "$url" \ + --wordpresspath "$wp_path" \ + --dbrootpassword "$db_root_pass" \ + --dbpassword "$wp_db_pass" \ + --dbname "$wp_db_name" \ + --dbuser "$wp_db_user" \ + --wpuser "$wp_user" \ + --wppassword "$wp_pass" \ + && ufw allow 7080 + else + echo "TODO install litespeed without WordPress" + exit 1 +fi + +EOSSH diff --git a/server-install-nginx.sh b/server-install-nginx.sh new file mode 100755 index 0000000..d67a78b --- /dev/null +++ b/server-install-nginx.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ -z "$1" ] ; then + echo "error: must specify configuration file to use" + exit 5 +fi + +. ./"$1" + +ssh -T $src_ssh << EOSSH + +ufw allow http && ufw allow https + +echo "TODO install nginx" +exit 1 + +EOSSH diff --git a/server-install-web.sh b/server-install-web.sh deleted file mode 100755 index f8b301f..0000000 --- a/server-install-web.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh - -. ./config - -if [ "$1" = 'local' ] ; then - src_url="$local_url"; - dest_url="$remote_url"; - src_ssh="$local_ssh" -elif [ "$1" = 'remote' ] ; then - src_url="$remote_url"; - dest_url="$local_url"; - src_ssh="$remote_ssh" -else - echo "error: must specify local or remote" - exit 5 -fi - -ssh -T $src_ssh << EOSSH - -ufw allow http && ufw allow https - -if [ -n "$apache2_version" ] ; then - echo "TODO install apache" - exit 1 - -elif [ -n "$nginx_version" ] ; then - echo "TODO install nginx" - exit 1 - -elif [ -n "$litespeed_version" ] ; then - if [ "$litespeed_version" != 'latest' ] ; then - echo "TODO install specific litespeed version" - echo "" - echo "Specify \"litespeed_version='latest'\" to install current version." - exit 1 - fi - if [ -n "$wp_user" ] ; then - wget --no-check-certificate https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh && bash ols1clk.sh \ - --adminpassword "$ls_webadmin_pass" \ - --lsphp "$ls_lsphp_version" \ - --wordpressplus "$src_url" \ - --wordpresspath "$wp_path" \ - --dbrootpassword "$db_root_pass" \ - --dbpassword "$wp_db_pass" \ - --dbname "$wp_db_name" \ - --dbuser "$wp_db_user" \ - --wpuser "$wp_user" \ - --wppassword "$wp_pass" \ - && ufw allow 7080 - else - echo "TODO install litespeed without WordPress" - exit 1 - fi - -else - echo "$0: Error - no webserver specified in configuration" - exit 5 -fi -EOSSH