Compare commits

..

No commits in common. "6aaf86df78f073305a6e9acca9a78bfaa1051b80" and "f858776a9e0f32b5d68f40be55d34062c09eec53" have entirely different histories.

38 changed files with 223 additions and 198 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
files/private
data/
*.secret

4
config/local/apache Normal file
View File

@ -0,0 +1,4 @@
## apache configuration
#
## uncomment if using apache
apache2_version='latest'

View File

@ -1,8 +0,0 @@
export mariadb_version='latest'
#mysql_version='latest'
export db_root_pass='9483ujtej0--=0FFFdl'
export db_name='wordpress'
export db_user='wordpress'
export db_pass='wordpress'

View File

@ -1,15 +1,10 @@
apache2_version='latest'
#nginx_version='latest'
## litespeed configuration
## uncomment if using litespeed
## specify specific version from latest, 54, 55, 56, 70, 71, 72, 73 or 74
#export litespeed_version='latest'
######################
# litespeed specific #
######################
## litespeed php version
## php version
#export ls_lsphp_version='73'
## https://openlitespeed.org/kb/1-click-install/

View File

@ -1,18 +1,9 @@
# local specific options
## export if using local development environment
export domain='thecampsitebible.home'
export url='http://thecampsitebible.home'
export domain='test123.home'
export url='http://test123.home'
# set to anything other than the empty string to set up a dev environment
export dev_env='true'
## user configuration
export user='ray'
export user_pass='ray'
export group='ray'
## ssh configuration
export ssh_root='root@thecampsitebible.home'
export ssh_user='ray@thecampsitebible.home'

4
config/local/mariadb Normal file
View File

@ -0,0 +1,4 @@
## uncomment if using mariadb
mariadb_version='latest'
db_root_pass='9483ujtej0--=0FFFdl'

3
config/local/mysql Normal file
View File

@ -0,0 +1,3 @@
## uncomment if using mysql
#mysql_version='latest'
#db_root_pass='9483ujtej0--=0FFFdl'

5
config/local/nginx Normal file
View File

@ -0,0 +1,5 @@
## nginx configuration
## uncomment if using nginx
#nginx_version='latest'

5
config/local/ssh Normal file
View File

@ -0,0 +1,5 @@
## ssh configuration
## uncomment if connecting via ssh
export ssh='root@test123.home'

6
config/local/user Normal file
View File

@ -0,0 +1,6 @@
## user configuration
## uncomment to set user
export user='ray'
export user_pass='ray'
export group='ray'

View File

@ -2,18 +2,22 @@
export wp_user='admin'
export wp_pass='admin'
export wp_email='myemail@example.com'
export wp_email='myemail@isnet.uk'
export wp_version='latest'
export wp_path='/var/www/html/wordpress'
export wp_locale='en_GB'
export wp_title='The Campsite Bible'
export wp_title='The WordPress'
export wp_db_name='wordpress'
export wp_db_user='wordpress'
export wp_db_pass='wordpress'
## list of themes to install - first one will be activated
export wp_themes="twentytwenty"
## list of plugins to install
export wp_plugins="geodirectory"
export wp_plugins="akismet all-in-one-seo-pack"
## list of plugins to install and activate
export wp_plugins_active=""

4
config/remote/apache Normal file
View File

@ -0,0 +1,4 @@
## apache configuration
#
## uncomment if using apache
# apache2_version='latest'

11
config/remote/cloudways Normal file
View File

@ -0,0 +1,11 @@
# cloudways configuration
. ./config/remote/cloudways.secret
cloudways_user='cloudways@rayelliott.dev'
cloudways_url='https://wordpress-453075-1468300.cloudwaysapps.com'
cloudways_ssh='test123@wordpress-453075-1468300.cloudwaysapps.com'
cloudways_db_name='mhhusspndh'
cloudways_db_user='mhhusspndh'

View File

@ -1,8 +0,0 @@
# export mariadb_version='latest'
# export mysql_version='latest'
# export db_root_pass='9483ujtej0--=0FFFdl'
export db_name='mhhusspndh'
export db_user='mhhusspndh'
export db_pass='w9Chzh6fR4'

View File

@ -1,15 +1,10 @@
# apache2_version='latest'
#nginx_version='latest'
## litespeed configuration
## uncomment if using litespeed
## specify specific version from latest, 54, 55, 56, 70, 71, 72, 73 or 74
#export litespeed_version='latest'
######################
# litespeed specific #
######################
## litespeed php version
## php version
#export ls_lsphp_version='73'
## https://openlitespeed.org/kb/1-click-install/

4
config/remote/mariadb Normal file
View File

@ -0,0 +1,4 @@
## uncomment if using mariadb
# mariadb_version='latest'
# db_root_pass='9483ujtej0--=0FFFdl'

3
config/remote/mysql Normal file
View File

@ -0,0 +1,3 @@
## uncomment if using mysql
#mysql_version='latest'
#db_root_pass='9483ujtej0--=0FFFdl'

5
config/remote/nginx Normal file
View File

@ -0,0 +1,5 @@
## nginx configuration
## uncomment if using nginx
#nginx_version='latest'

View File

@ -1,15 +1,6 @@
# remote specific options
export domain='wordpress-453075-1468300.cloudwaysapps.com.example.com'
export url='https://wordpress-453075-1468300.cloudwaysapps.com.example.com'
## user configuration
## uncomment to set user
# export user='ray'
# export user_pass='ray'
# export group='ray'
## ssh configuration
# export ssh_root='root@wordpress-453075-1468300.cloudwaysapps.com' # we do not have root access
export ssh_user='test123@wordpress-453075-1468300.cloudwaysapps.com'
## export if using local development environment
#export domain='test123.example.com'
#export url='http://test123.example.com'

5
config/remote/ssh Normal file
View File

@ -0,0 +1,5 @@
## ssh configuration
## uncomment if connecting via ssh
# export ssh='root@test123.isnet.uk'

6
config/remote/user Normal file
View File

@ -0,0 +1,6 @@
## user configuration
## uncomment to set user
# export user='ray'
# export user_pass='ray'
# export group='ray'

View File

@ -1,19 +1,23 @@
## wordpress configuration - uncomment if using wordpress
export wp_user='cloudways@rayelliott.dev'
export wp_pass='McXNn4vgua'
export wp_email='myemail@example.com'
# export wp_user='admin'
# export wp_pass='admin'
# export wp_email='myemail@isnet.uk'
export wp_version='latest'
export wp_path='/home/453075.cloudwaysapps.com/mhhusspndh/public_html'
export wp_locale='en_GB'
export wp_title='The Campsite Bible'
# export wp_version='latest'
# export wp_path='/var/www/html/wordpress'
# export wp_locale='en_GB'
# export wp_title='The WordPress'
# export wp_db_name='wordpress'
# export wp_db_user='wordpress'
# export wp_db_pass='wordpress'
## list of themes to install - first one will be activated
export wp_themes="twentytwenty"
# export wp_themes="twentytwenty"
## list of plugins to install
export wp_plugins="geodirectory breeze malcare-security"
# export wp_plugins="akismet all-in-one-seo-pack"
## list of plugins to install and activate
# export wp_plugins_active=""

View File

@ -18,6 +18,11 @@ for _file in ./config/$_target/* ; do
. "$_file"
done
if [ "$_target" = remote ] && [ -n "$cloudways_user" ] ; then
echo "Using Cloudways - nothing to install"
exit
fi
# source script files
if [ -n "$_target_os" ] ; then
_script_dir="./scripts/$_target_os"
@ -30,11 +35,11 @@ fi
echo "Using Scripts in: $_script_dir"
# check we have ssh access
[ -z "$ssh_root" ] && echo "Error: no root ssh configuration specified" && exit 5
[ -z "$ssh" ] && echo "Error: no ssh configuration specified" && exit 5
# update
echo "Updating .."
ssh -T $ssh_root << EOSSH
ssh -T $ssh << EOSSH
export DEBIAN_FRONTEND=noninteractive
apt-get -qq -y update && apt-get -qq -y upgrade
EOSSH

View File

@ -7,10 +7,7 @@ fi
. ./"$1"
# check we have ssh access
[ -z "$ssh_root" ] && echo "Error: no root ssh configuration specified" && exit 5
ssh -T $ssh_root << EOSSH
ssh -T $ssh << EOSSH
ufw allow http && ufw allow https
@ -27,9 +24,9 @@ if [ -n "$wp_user" ] ; then
--wordpressplus "$url" \
--wordpresspath "$wp_path" \
--dbrootpassword "$db_root_pass" \
--dbpassword "$db_pass" \
--dbname "$db_name" \
--dbuser "$db_user" \
--dbpassword "$wp_db_pass" \
--dbname "$wp_db_name" \
--dbuser "$wp_db_user" \
--wpuser "$wp_user" \
--wppassword "$wp_pass" \
&& ufw allow 7080

View File

@ -16,7 +16,7 @@
db_file="$wp_path/data.sql"
wp db export --dbuser=wordpress --dbpass=$db_pass --add-drop-table --alow-root "$db_file"
wp db export --dbuser=wordpress --dbpass=$wp_db_pass --add-drop-table --alow-root "$db_file"
tar czf /tmp/wordpress.tar.gz "$wp_path"
# scp
rm "$db_file"

View File

@ -16,7 +16,7 @@ for _file in ./config/$_target/* ; do
done
# check we have ssh access
[ -z "$ssh_user" ] && echo "Error: no user ssh configuration specified" && exit 5
[ -z "$ssh" ] && echo "Error: no ssh configuration specified" && exit 5
if [ -n "$wp_user" ] ; then
. ./scripts/export-wp.sh

View File

@ -29,6 +29,9 @@ fi
echo "Using Scripts in: $_script_dir"
# check we have ssh access
[ -z "$ssh" ] && echo "Error: no ssh configuration specified" && exit 5
if [ -n "$wp_user" ] ; then
# TODO - confirmation prompt
echo "IMPORTANT - we need a confirmation prompt here"

View File

@ -5,10 +5,7 @@ if [ "$apache2_version" != 'latest' ] ; then
exit 30
fi
# check we have ssh access
[ -z "$ssh_root" ] && echo "Error: no root ssh configuration specified" && exit 5
ssh -T $ssh_root << EOSSH
ssh -T $ssh << EOSSH
echo "Installing Apache2"
export DEBIAN_FRONTEND=noninteractive
echo "Installing packages .."

View File

@ -1,9 +1,6 @@
#!/bin/sh
# check we have ssh access
[ -z "$ssh_root" ] && echo "Error: no root ssh configuration specified" && exit 5
ssh -T $ssh_root << EOSSH
ssh -T $ssh << EOSSH
sed -i '/PubkeyAuthentication/c\PubkeyAuthentication yes' /etc/ssh/sshd_config
sed -i '/PasswordAuthentication/c\PasswordAuthentication no' /etc/ssh/sshd_config

View File

@ -2,10 +2,7 @@
_home_dir="/home/$user"
# check we have ssh access
[ -z "$ssh_user" ] || [ -z "$ssh_root" ] && echo "Error: user and root ssh configuration must be specified" && exit 5
ssh -T $ssh_root << EOSSH
ssh -T $ssh << EOSSH
echo "Installing packages .."
export DEBIAN_FRONTEND=noninteractive
@ -39,7 +36,7 @@ if command -v php ; then
fi
EOSSH
ssh -T $ssh_root << EOSSH
ssh -T $ssh << EOSSH
su "$user"
@ -49,14 +46,16 @@ echo 'export NVM_DIR="\$HOME/.nvm"' >> "$_home_dir/.profile"
echo '[ -s "\$NVM_DIR/nvm.sh" ] && \. "\$NVM_DIR/nvm.sh"' >> "$_home_dir/.profile"
EOSSH
ssh -T $ssh_root << EOSSH
ssh -T $ssh << EOSSH
su --login "$user"
. ./.profile
nvm install --lts --latest-npm
EOSSH
ssh -T $ssh_user << EOSSH
ssh -T $ssh << EOSSH
su --login "$user"
. ./.profile
echo "Configuring neovim ..."
npm install -g neovim

View File

@ -5,12 +5,9 @@ if [ "$mariadb_version" != 'latest' ] ; then
exit 30
fi
# check we have ssh access
[ -z "$ssh_root" ] && echo "Error: no root ssh configuration specified" && exit 5
_mysql_cmd="mysql -uroot -e "
ssh -T $ssh_root << EOSSH
ssh -T $ssh << EOSSH
if mysql --version ; then
echo "ERROR: unable to install MariaDb, 'mysql' already installed - aborting install"
exit 35
@ -27,10 +24,6 @@ ssh -T $ssh_root << EOSSH
$_mysql_cmd "DROP DATABASE IF EXISTS test;"
$_mysql_cmd "DELETE FROM mysql.db WHERE Db='test' OR Db='"'test\\_%'"'"
$_mysql_cmd "CREATE DATABASE $db_name;"
$_mysql_cmd "GRANT ALL PRIVILEGES ON $db_name.* TO '$db_user'@'localhost' IDENTIFIED BY '$db_pass';"
$_mysql_cmd "FLUSH PRIVILEGES;"
mysqladmin --user=root password "$db_root_pass"
mysqladmin --user=root --password="$db_root_pass" flush-privileges
EOSSH

View File

@ -5,12 +5,9 @@ if [ "$mysql_version" != 'latest' ] ; then
exit 30
fi
# check we have ssh access
[ -z "$ssh_root" ] && echo "Error: no root ssh configuration specified" && exit 5
_mysql_cmd="mysql -uroot -e "
ssh -T $ssh_root << EOSSH
ssh -T $ssh << EOSSH
if mysql --version ; then
echo "ERROR: unable to install MySQL, 'mysql' already installed - aborting install"
exit 35
@ -27,10 +24,6 @@ ssh -T $ssh_root << EOSSH
$_mysql_cmd "DROP DATABASE IF EXISTS test;"
$_mysql_cmd "DELETE FROM mysql.db WHERE Db='test' OR Db='"'test\\_%'"'"
$_mysql_cmd "CREATE DATABASE $db_name;"
$_mysql_cmd "GRANT ALL PRIVILEGES ON $db_name.* TO '$db_user'@'localhost' IDENTIFIED BY '$db_pass';"
$_mysql_cmd "FLUSH PRIVILEGES;"
mysqladmin --user=root password "$db_root_pass"
mysqladmin --user=root --password="$db_root_pass" flush-privileges
EOSSH

View File

@ -5,13 +5,10 @@ if [ "$php_version" != 'latest' ] ; then
exit 30
fi
# check we have ssh access
[ -z "$ssh_root" ] && echo "Error: no root ssh configuration specified" && exit 5
if [ -n "$wp_user" ] ; then
echo 'Installing PHP for WordPress ...'
ssh -T $ssh_root << 'EOSSH'
ssh -T $ssh << 'EOSSH'
export DEBIAN_FRONTEND=noninteractive
echo "Installing packages .."
apt-get install -qq -y php libapache2-mod-php php-fpm php-bcmath php-curl php-gd php-imagick php-mbstring \
@ -28,7 +25,7 @@ EOSSH
else
echo 'Installing default PHP ...'
ssh -T $ssh_root << EOSSH
ssh -T $ssh << EOSSH
export DEBIAN_FRONTEND=noninteractive
echo "Installing packages .."
apt-get install -qq -y php libapache2-mod-php php-mysql

View File

@ -1,11 +1,8 @@
#!/bin/sh
# check we have ssh access
[ -z "$ssh_root" ] && echo "Error: no root ssh configuration specified" && exit 5
_home_dir="/home/$user"
ssh -T $ssh_root << EOSSH
ssh -T $ssh << EOSSH
echo "Creating user .."
useradd -m -d "$_home_dir" "$user"
echo "$user:$user_pass" | chpasswd
@ -14,12 +11,12 @@ EOSSH
echo "Configuring ssh .."
ssh $ssh_root mkdir -v -p "$_home_dir/.ssh"
scp files/private/id_rsa "$ssh_root:$_home_dir/.ssh/"
scp files/id_rsa.pub "$ssh_root:$_home_dir/.ssh/"
scp files/known_hosts "$ssh_root:$_home_dir/.ssh/"
ssh $ssh mkdir -v -p "$_home_dir/.ssh"
scp files/private/id_rsa "$ssh:$_home_dir/.ssh/"
scp files/id_rsa.pub "$ssh:$_home_dir/.ssh/"
scp files/known_hosts "$ssh:$_home_dir/.ssh/"
ssh -T $ssh_root << EOSSH
ssh -T $ssh << EOSSH
cp -v /root/.ssh/authorized_keys "$_home_dir/.ssh/authorized_keys"
chown -v -R "$user:$group" "$_home_dir/.ssh"
@ -64,7 +61,7 @@ ssh -T $ssh_root << EOSSH
"$_home_dir/.config/zsh/install.sh"
EOSSH
ssh -T $ssh_root << EOSSH
ssh -T $ssh << EOSSH
chsh -s /usr/bin/zsh "$user"
EOSSH

View File

@ -1,25 +1,29 @@
echo "Installing WordPress .."
# check we have ssh access
[ -z "$ssh_user" ] || [ -z "$ssh_root" ] && echo "Error: user and root ssh configuration must be specified" && exit 5
_mysql_cmd="mysql -uroot -p$db_root_pass -e "
ssh -T $ssh << EOSSH
ssh -T $ssh_root << EOSSH
# install wp-cli first
if [ ! -f /usr/local/bin/wp ] ; then
wget -nv -O /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
&& chmod +x /usr/local/bin/wp
fi
EOSSH
ssh -T $ssh_user << EOSSH
su "$user"
if wp core is-installed --quiet --path="$wp_path" ; then
echo "WordPress already installed"
else
echo "wp core download \
--version=$wp_version \
--path=$wp_path \
--skip-content \
--locale=$wp_locale"
# first create database and user
if command -v mysql ; then
$_mysql_cmd "CREATE DATABASE $wp_db_name;"
$_mysql_cmd "GRANT ALL PRIVILEGES ON $wp_db_name.* TO '$wp_db_user'@'localhost' IDENTIFIED BY '$wp_db_pass';"
$_mysql_cmd "FLUSH PRIVILEGES;"
else
echo "ERROR: mysql not found - aborting WordPress install"
exit 40
fi
wp core download \
--version="$wp_version" \
--path="$wp_path" \
@ -27,9 +31,9 @@ echo "wp core download \
--locale="$wp_locale"
wp config create \
--path="$wp_path" \
--dbname="$db_name" \
--dbuser="$db_user" \
--dbpass="$db_pass" \
--dbname="$wp_db_name" \
--dbuser="$wp_db_user" \
--dbpass="$wp_db_pass" \
--locale="$wp_locale" \
--extra-php <<PHP
define( 'WP_DEBUG', true );
@ -50,7 +54,8 @@ printf "\nInstalling themes ..."
option='--activate'
for theme in $wp_themes ; do
echo " installing $theme ..."
ssh -T $ssh_user << EOSSH
ssh -T $ssh << EOSSH
su "$user"
wp theme install $theme "$option" --path="$wp_path"
EOSSH
option=''
@ -61,7 +66,8 @@ if [ -n "$wp_plugins" ] ; then
printf "\nInstalling plugins ..."
for plugin in $wp_plugins ; do
echo " installing $plugin ..."
ssh -T $ssh_user << EOSSH
ssh -T $ssh << EOSSH
su "$user"
wp plugin install $plugin --path="$wp_path"
EOSSH
done
@ -71,17 +77,30 @@ if [ -n "$wp_plugins_active" ] ; then
printf "\nInstalling plugins to activate ..."
for plugin in $wp_plugins_active ; do
echo " installing $plugin ..."
ssh -T $ssh_user << EOSSH
ssh -T $ssh << EOSSH
su "$user"
wp plugin install $plugin --activate --path="$wp_path"
EOSSH
done
fi
if [ -n "$_apache2_version" ] ; then
ssh -T $ssh_root << EOSSH
if [ -n "$wp_plugins_active" ] ; then
printf "\nUninstalling plugins ..."
for plugin in $wp_plugins_uninstall ; do
echo " installing $plugin ..."
ssh -T $ssh << EOSSH
su "$user"
wp plugin deactivate $plugin --path="$wp_path"
wp plugin uninstall $plugin --path="$wp_path"
EOSSH
done
fi
config_path='/etc/apache2/sites-available/wordpress.conf'
ssh -T $ssh << EOSSH
if [ -n "$apache2_version" ] ; then
mkdir -p /var/log/wordpress/
cat << EOF > /etc/apache2/sites-available/wordpress.conf
cat << EOF > $config_path
<VirtualHost *:80>
ServerName $domain
DocumentRoot $wp_path
@ -103,12 +122,5 @@ EOF
a2ensite wordpress
a2dissite 000-default
systemctl reload apache2
elif [ -n "nginx_version" ] ; then
echo "TODO - nginx wordpress config"
elif [ -n "litespeed_version" ] ; then
echo "TODO - litespeed wordpress config"
else
echo "Warning: no webserver configuration found"
fi
EOSSH
fi

View File

@ -0,0 +1,15 @@
echo "Removing WordPress .."
_mysql_cmd="mysql -uroot -p$db_root_pass -e "
ssh -T $ssh << EOSSH
# remove database
if command -v mysql ; then
$_mysql_cmd "DROP DATABASE $wp_db_name;"
else
echo "ERROR: no installed database found - aborting WordPress removal"
exit 40
fi
# remove files
rm -Rf $wp_path
EOSSH

View File

@ -7,26 +7,23 @@ _db_filename="wordpress-$_timestamp.db"
_archive_filename="wordpress-$_timestamp.tar.gz"
_local_dest_dir="./data/$_target"
# check we have ssh access
[ -z "$ssh_user" ] && echo "Error: no user ssh configuration specified" && exit 5
ssh -T $ssh_user << EOSSH
ssh -T $ssh << EOSSH
cd "$wp_path"
wp db export \
--path="$wp_path" \
--dbuser="$db_user" \
--dbpass="$db_pass" \
--dbuser="$wp_db_user" \
--dbpass="$wp_db_pass" \
--add-drop-table \
--allow-root \
"/tmp/$_db_filename"
tar czf "/tmp/$_archive_filename" "$wp_path"
EOSSH
scp "$ssh_user:/tmp/$_archive_filename" "$_local_dest_dir/$_archive_filename"
scp "$ssh_user:/tmp/$_db_filename" "$_local_dest_dir/$_db_filename"
scp "$ssh:/tmp/$_archive_filename" "$_local_dest_dir/$_archive_filename"
scp "$ssh:/tmp/$_db_filename" "$_local_dest_dir/$_db_filename"
exit
ssh -T $ssh_user << EOSSH
ssh -T $ssh << EOSSH
rm "/tmp/$_db_filename"
rm "/tmp/$_archive_filename"
EOSSH

View File

@ -1,19 +1,13 @@
#!/bin/sh
echo "Removing WordPress .."
# check we have ssh access
[ -z "$ssh_user" ] && echo "Error: no user ssh configuration specified" && exit 5
_mysql_cmd="mysql -uroot -p$db_root_pass -e "
_mysql_cmd="mysql -u$db_user -p$db_pass -e "
ssh -T $ssh_user << EOSSH
ssh -T $ssh << EOSSH
# remove database
if command -v mysql ; then
$_mysql_cmd "DROP DATABASE $db_name;"
$_mysql_cmd "CREATE DATABASE $db_name;"
$_mysql_cmd "DROP DATABASE $wp_db_name;"
else
echo "ERROR: mysql not found - aborting WordPress removal"
echo "ERROR: no installed database found - aborting WordPress removal"
exit 40
fi
# remove files