From e4a968f22428ca690a2c4e56ea655fb7e6baa59b Mon Sep 17 00:00:00 2001 From: Zen Date: Wed, 16 Mar 2022 20:12:54 -0600 Subject: [PATCH] testing this whole local branch thing --- ingredients/iron | 50 ++++++++++++++++++++++++++++----- recipes/wordpress.sh | 67 ++++++-------------------------------------- 2 files changed, 52 insertions(+), 65 deletions(-) diff --git a/ingredients/iron b/ingredients/iron index ab5da98..b70f0b4 100644 --- a/ingredients/iron +++ b/ingredients/iron @@ -10,9 +10,32 @@ # our society as a whole. # This ingredient contains functions for building web applications and -# running them frm your server. Expect to use this one a lot if you're +# running them from your server. Expect to use this one a lot if you're # writing alchemy recipes! +# ------------------- Databases ------------------- + +install_database() { + if [ -n "$ALCHEMY_DB" ]; then + say "Alchemy has already installed ${ALCHEMY_DB} as the database" + fi + + if [ -z "${1}" ]; then + say "Okay, let's get you set up with a database" + say "But I'm too tired of this to write this atm" + fi + + case ${1} in + "postgres" | "postgresql") + install_if_needed postgresql + ;; + "mysql" | "mariadb") + install_if_needed mariadb-server + ;; + esac +} + + # ------------------- NodeJS Ecosystem ------------------- if [ -d "$NVM_DIR" ]; then @@ -91,12 +114,25 @@ build_service_from_template() { activate_service() { SERVICE=$1 - SERVICE_FILE=/etc/systemd/system/${SERVICE}.service - if [ -f "$SERVICE_FILE" ]; then - say "Enabling and starting ${GREEN}${SERVICE}${RESET}" - sudo systemctl enable ${SERVICE} - sudo systemctl start ${SERVICE} - fi + sudo systemctl status ${SERVICE} &> /dev/null + return_code=$? + + case $return_code in + 0) + say "${BLUE}${SERVICE}${RESET} is already running" + ;; + 3) + say "Enabling and starting ${GREEN}${SERVICE}${RESET}" + sudo systemctl enable ${SERVICE} + sudo systemctl start ${SERVICE} + ;; + 4) + say "Hmm, I don't see a service for ${SERVICE}" + ;; + *) + say "whoa what the heck is $return_code" + ;; + esac } IRON=1 diff --git a/recipes/wordpress.sh b/recipes/wordpress.sh index 25c8ef4..f2e52ee 100755 --- a/recipes/wordpress.sh +++ b/recipes/wordpress.sh @@ -3,78 +3,29 @@ # Downloads and configures Wordpress onto the current system # Zen, 2022 -# Font decoration for better a e s t h e t i c -RED="\e[0;91m" -GREEN="\e[0;92m" -BLUE="\e[0;94m" -BOLD="\e[1m" -ULINE="\e[4m" -NC="\e[0m" - -# ------------------- Step 1 - Installing / Configuring MariaDB ------------------- - -if [ -f "/etc/debian_version" ]; then - DISTRO="debian" - echo "Debian, Ubuntu, or Raspbian OS detected." -elif [ -f "/etc/arch-release" ]; then - DISTRO="arch" - echo "Arch- or Manjaro-based OS detected." -elif [ $(uname | grep -c "Darwin") -eq 1 ]; then - DISTRO="mac" - echo "MacOS detected." -else - echo "I don't know what OS you're running! Cancelling this operation." - exit 1 -fi - -echo "" - -install_if_needed() { - for package in "$@" - do - if [ -z $(which $package) ]; then - echo "installing" $package - - case $DISTRO in - "debian") - sudo apt install -y $package - ;; - "arch") - sudo pacman -S $package - ;; - "mac") - brew install $package - ;; - esac - - else - echo $package 'already installed!' - fi - done - -} +source ingredients/lead install_if_needed mariadb-server php php-fpm php-mysql nginx echo "" -read -p "Do you want to secure the database for production deployment? (y/n): " -n1 boot -echo "" +ask_for boot "Do you want to secure the database for production deployment? (y/n): " +say "" case $boot in y | Y) - echo "Securing database..." + say "Securing database..." sudo mysql_secure_installation ;; esac echo "" MATCH=0 -while [[ MATCH -eq 0 ]]; do - read -sp "Enter the password that you would like to use for MariaDB: " pass - echo "" - read -sp "Please confirm your password: " pass2 +while [ $MATCH -eq 0 ]; do + ask_for pass "Enter the password that you would like to use for MariaDB: " + say "" + ask_for pass2 "Please confirm your password: " echo "" - if [[ "$pass" == "$pass2" ]]; then + if [ "$pass" != "$pass2" ]; then MATCH=1 sudo mariadb -e "CREATE DATABASE wordpress;" sudo mariadb -e "GRANT ALL ON wordpress.* TO '${USER}'@'localhost' IDENTIFIED BY '${pass}' WITH GRANT OPTION;"