modularise server installation

This commit is contained in:
Ray Elliott 2020-06-25 11:27:14 +01:00
parent 9e407d3e88
commit 5a41d6bd71
7 changed files with 155 additions and 72 deletions

39
config-local Executable file
View File

@ -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'

39
config-remote Normal file
View File

@ -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'

17
server-install-apache.sh Executable file
View File

@ -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

View File

@ -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

38
server-install-litespeed.sh Executable file
View File

@ -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

17
server-install-nginx.sh Executable file
View File

@ -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

View File

@ -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