pvincent 1 week ago
parent
commit
e443c67c2b
  1. 7
      README.md
  2. 117
      recipes/wordpress.recipe
  3. 18
      resources/wp-backup

7
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

117
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 <<EOF >$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

18
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

Loading…
Cancel
Save