#!/usr/bin/env bash

# ###################################
# -----------------------------------
#  ██████╗ ████████╗██████╗ ██╗  ██╗     
#  ██╔══██╗╚══██╔══╝██╔══██╗██║  ██║    
#  ██║  ██║   ██║   ██████╔╝███████║     
#  ██║  ██║   ██║   ██╔══██╗██╔══██║    
#  ██████╔╝   ██║   ██║  ██║██║  ██║
#  ╚═════╝    ╚═╝   ╚═╝  ╚═╝╚═╝  ╚═╝     
#          https://dtrh.net
#  ----------------------------------
#      Wordpress Auto Installer
# ###################################

# Set shell options
set -o posix
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail

# Clear terminal
clear

# Initialize magic variables
__dir="$(cd "$(dirname "${BASH_SOURCE}")" && pwd)"
__file="${__dir}/$(basename "${BASH_SOURCE}")"
__base="$(basename "${__file}" .sh)"
__me="${BASH_SOURCE}"

# Global variable initialization
__help="0"
wp_admin=""
wp_dir=""
_log="0"
log_file="/tmp/wp_auto.log"
bad_opt=""
declare -a sh_args
sql_user=""
sql_pass=""
sql_wpdb=""
wp_host=""


# Root check
[ ${EUID} -ne 0 ] &&  echo -e "${__base^^}\n\n ERROR:\nRun script with root privileges!\n\n"
case "${EUID}" in
  0) echo "Checking for root priviliges..."; sleep "0.5"; echo -e "Done.\n\n";;
  *) exit 1 ;;
esac

# Function : Banner - Display DTRH banner
__banner() {
cat <<EOF 
# ######################################
#  ------------------------------------
#    ██████╗ ████████╗██████╗ ██╗  ██╗     Title      : Wordpress Auto Installer
#    ██╔══██╗╚══██╔══╝██╔══██╗██║  ██║     Filename   : wp_auto-1.1-0.sh
#    ██║  ██║   ██║   ██████╔╝███████║     Version    : 1.1-0
#    ██║  ██║   ██║   ██╔══██╗██╔══██║     Date       : 10.06.23
#    ██████╔╝   ██║   ██║  ██║██║  ██║
#    ╚═════╝    ╚═╝   ╚═╝  ╚═╝╚═╝  ╚═╝     Additional : README.md
#            https://dtrh.net
#  ------------------------------------
# ######################################


EOF
}

# Function : Usage - Display simple usage information
__usage() {
  __banner
cat <<EOF
Usage: ${__me} [USER]

       
EOF
}

# Function : Help - Display detailed usage information 
__help() {
  __banner
  echo -e "${__base^^} HELP:\n"
  cat <<EOF

Usage: ${__me} [USER]

wp_auto.sh installs a fresh copy of the latest version of weordpress to
your /var/www/html folder, in the subfolder named 'wordpress'. It takes
one argument, a user name for the admin/ownef of the wordpress website
being installed. 

See README.md for more information on tweaking this script.

Options:
  -l [FILE]      Create logfile. Write to [FILE]
  -h             Display this text
  -v             Display script version


EOF
exit 1; }

# getopts loop : Interpret user input & sort
while getopts :hl:v opt; do
  case "${opt}" in
    h) __help="1";; 
    l) log_file="${OPTARG}" && _log="1";;
    :) bad_opt="2";;   # Missing log file
    \?) bad_opt="1";;  # Unrecognized opt
  esac
done

# Shift through options index one by one
shift $((${OPTIND} - 1))

#if [ ! command -v screen ] && [ ${_log} = "1" ]; then 
#echo -e "You are missing a dependency: screen. The script will be sure to install it momentarily. Pleaae restart the script to #continue.." && exit 1;
# elif [ command -v screen ]; then
#   if [ ! -f ${log_file} ]; then 
#     echo -e "\n\n$(date) - wp_auto log file" > ${log_file}
#     screen -L -Logfile ${log_file}
#fi

if [ $ -gt 0; do
  sh_args[$

Recents Post

Share

08

Vibe Coding with LLM Agents Friday, 6PM
PUBLIC SERVICE ANNOUNCEMENTI’m not a (total) doomster. But I’m very much well informed. And if I ...

27

Tuesday, 1AM
Context Wrangler 🚦Automated context-length hygiene • Multi-model AI prompt generator • Git-to-Ro...

Powered by Hexo