From e443c67c2b4bcc0ed2d4921dd3415baec3271d31 Mon Sep 17 00:00:00 2001 From: pvincent Date: Fri, 31 Jul 2026 16:14:12 +0400 Subject: [PATCH] nvim --- README.md | 7 +-- recipes/wordpress.recipe | 117 ++++++++++++++++++++------------------- resources/wp-backup | 18 +++--- 3 files changed, 72 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index 09d8719..8b6e82f 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ FEATURES * [x] files or commands from container within * [x] inner command completion from container within * [x] colored completions (link, directories...) by reusing inputrc bindings -* [x] advanced completion for miaou-{start,stop,destroy} according to container state +* [x] advanced completion for miaou-{start,stop,destroy} -TODO: +TODO ----- * [ ] install DOCUMENTATION in README @@ -21,7 +21,6 @@ TODO: * [ ] bash-completion * [ ] timer refresh template * [ ] Template erb+bash - * [ ] Tempalte erb+ruby-on-shell + * [ ] Template erb+ruby-on-shell * [ ] TOOLBOX * [ ] RUBY From Host - diff --git a/recipes/wordpress.recipe b/recipes/wordpress.recipe index 0caf491..062f65f 100644 --- a/recipes/wordpress.recipe +++ b/recipes/wordpress.recipe @@ -2,6 +2,7 @@ # CONSTANTS +MANDATORY_PACKAGES=(nginx php-cli php-fpm php-mysql php-curl php-xml php-imagick php-zip php-gd php-intl composer mariadb-client) UPLOAD_MAX_SIZE=${UPLOAD_MAX_SIZE-256M} #TODO: allow passing environment variables from `miaou-recipe` FORCE=false WP_NAME= @@ -9,65 +10,65 @@ WP_NAME= # FUNCTIONS function usage { - echo "$RECIPE_NAME {WP_NAME} [--force|-f]" - echo "install a wordpress" + echo "$RECIPE_NAME {WP_NAME} [--force|-f]" + echo "install a wordpress" } function parse_options { - while [[ $# -gt 0 ]]; do - case "$1" in - --help | -h) - usage && exit 0 - ;; - --force | -f) - FORCE=true - ;; - -*) - echo >&2 "ERROR: unknown option <$1>" && usage && exit 3 - ;; - *) - if [[ -z $WP_NAME ]]; then - WP_NAME=$1 - else - echo >&2 "ERROR: unknown argument <$1>" && usage && exit 2 - fi - ;; - esac - - shift 1 # Move to the next argument - done - [[ -z $WP_NAME ]] && echo >&2 "ERROR: expecting mandatory argument {WP_NAME}" && usage && exit 2 || true + while [[ $# -gt 0 ]]; do + case "$1" in + --help | -h) + usage && exit 0 + ;; + --force | -f) + FORCE=true + ;; + -*) + echo >&2 "ERROR: unknown option <$1>" && usage && exit 3 + ;; + *) + if [[ -z $WP_NAME ]]; then + WP_NAME=$1 + else + echo >&2 "ERROR: unknown argument <$1>" && usage && exit 2 + fi + ;; + esac + + shift 1 # Move to the next argument + done + [[ -z $WP_NAME ]] && echo >&2 "ERROR: expecting mandatory argument {WP_NAME}" && usage && exit 2 || true } function install_mariadb { - if $FORCE || ! systemctl is-active mariadb.service --quiet; then - DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server - echo mariadb installed successfully! - else - echo mariadb already installed! - fi + if $FORCE || ! systemctl is-active mariadb.service --quiet; then + DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server + echo mariadb installed successfully! + else + echo mariadb already installed! + fi } function install_php { - local php_version=php --version | head -n1 | cut -d' ' -f2 | grep -o '^[[:digit:]]*\.[[:digit:]]*' - local php_service="php$php_version-fpm" - - if $FORCE || ! systemctl is-active "$php_service" --quiet; then - apt-get install -y php-fpm php-mysql php-curl php-dom php-imagick php-mbstring php-zip php-gd php-intl - php_version=php --version | head -n1 | cut -d' ' -f2 | grep -o '^[[:digit:]]*\.[[:digit:]]*' - - sed -i "s/^post_max_size = 8M/post_max_size = $UPLOAD_MAX_SIZE/g" /etc/php/$php_version/fpm/php.ini - sed -i "s/^upload_max_filesize = 2M/upload_max_filesize = $UPLOAD_MAX_SIZE/g" /etc/php/$php_version/fpm/php.ini - systemctl enable "$php_service" --now - echo "$php_service installed successfully!" - else - echo "$php_service already installed!" - fi + local php_version=$(php --version | head -n1 | cut -d' ' -f2 | grep -o '^[[:digit:]]*\.[[:digit:]]*') + local php_service="php$php_version-fpm" + + if $FORCE || ! systemctl is-active "$php_service" --quiet; then + apt-get install -y php-fpm php-mysql php-curl php-dom php-imagick php-mbstring php-zip php-gd php-intl + sed -i "s/^post_max_size = 8M/post_max_size = $UPLOAD_MAX_SIZE/g" /etc/php/$php_version/fpm/php.ini + sed -i "s/^upload_max_filesize = 2M/upload_max_filesize = $UPLOAD_MAX_SIZE/g" /etc/php/$php_version/fpm/php.ini + systemctl enable "$php_service" --now + echo "$php_service installed successfully!" + else + echo "$php_service already installed!" + fi } function install_nginx_host { - if $FORCE || [[ ! -f /etc/nginx/sites-available/sympa.conf ]]; then - cat << EOF > /etc/nginx/sites-available/sympa.conf + local wp_conf="wp-${WP_NAME}.conf" + local conf_file="/etc/nginx/sites-available/${wp_conf}" + if $FORCE || [[ ! -f ${conf_file} ]]; then + cat <$conf_file server { listen {{ env.APP_PORT }} default_server; @@ -108,21 +109,23 @@ server { } EOF - cd /etc/nginx/sites-enabled && rm -f default && ln -sf ../sites-available/sympa.conf && cd - systemctl reload nginx - echo host for nginx installed successfully! - else - echo host for nginx already installed! - fi + cd /etc/nginx/sites-enabled && rm -f default && ln -sf ../sites-available/sympa.conf && cd + systemctl reload nginx + echo host for nginx installed successfully! + else + echo host for nginx already installed! + fi } +function install_wordpress { + apt-get install -qqy "${MANDATORY_PACKAGES[@]}" + echo mandatory OK +} # MAIN set -Eue -o pipefail parse_options "$@" -exit 0 - install_mariadb install_php -# install_wordpress -# install_nginx_host +install_wordpress +install_nginx_host diff --git a/resources/wp-backup b/resources/wp-backup index 225e060..0c69428 100644 --- a/resources/wp-backup +++ b/resources/wp-backup @@ -1,17 +1,17 @@ #!/bin/bash function detectWordpress() { - local result=$(pwd) - while [[ ! ("$result" == / || -f "$result/wp-config.php") ]]; do - result=$(dirname "$result") - done + local result=$(pwd) + while [[ ! ("$result" == / || -f "$result/wp-config.php") ]]; do + result=$(dirname "$result") + done - if [[ "$result" == / ]]; then - echo >&2 "no WORDPRESS detected from current folder <$(pwd)>!" - exit 100 - fi + if [[ "$result" == / ]]; then + echo >&2 "no WORDPRESS detected from current folder <$(pwd)>!" + exit 100 + fi - echo "$result" + echo "$result" } ## MAIN