diff --git a/README.md b/README.md index 21fd7ab..a5fb99f 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,4 @@ Development environment base packages: ## TODO -* get remote working with cloudways +* make sure to use export in all config files (the newer ones aren't) diff --git a/data/.gitkeep b/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/reset.sh b/reset.sh new file mode 100755 index 0000000..8e0fddb --- /dev/null +++ b/reset.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +_target="$1" +_target_os="$2" +# default scripts to use +_script_dir='./scripts/debian10' + +if ! [ "$_target" = local ] && ! [ "$_target" = remote ] ; then + echo "Error: must specify 'local' or 'remote' target" + exit 1 +fi + +echo "Loading $_target configuration" + +# source our config files +for _file in ./config/$_target/* ; do + [ -e "$_file" ] || continue + . "$_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" + if ! [ -d "$_script_dir" ] ; then + echo "Error: script directory not found '$_script_dir'" + exit 1 + fi +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" + echo "You are about to reinstall the $_target WordPress installation" + echo "Reinstall WordPress (y/N): " + . "$_script_dir/reset-wordpress.sh" + . "$_script_dir/install-wordpress.sh" +fi diff --git a/scripts/debian10/reset-wordpress.sh b/scripts/debian10/reset-wordpress.sh new file mode 100755 index 0000000..547975f --- /dev/null +++ b/scripts/debian10/reset-wordpress.sh @@ -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