6
0
Fork 0

Compare commits

..

No commits in common. "4dd5960dbc6f3876052a8ddb771d49e87a747bd6" and "b09138937fb43feaf6fca13529a476aa3357d37e" have entirely different histories.

18 changed files with 43 additions and 144 deletions

View file

@ -4,7 +4,7 @@ cat << EOF
; Start a new pool named 'www'. ; Start a new pool named 'www'.
; the variable \$pool can be used in any directive and will be replaced by the ; the variable \$pool can be used in any directive and will be replaced by the
; pool name ('www' here) ; pool name ('www' here)
[$POOL_NAME] [www]
; Per pool prefix ; Per pool prefix
; It only applies on the following directives: ; It only applies on the following directives:
@ -439,13 +439,8 @@ env[TEMP] = /tmp
;php_admin_value[error_log] = /var/log/php7/\$pool.error.log ;php_admin_value[error_log] = /var/log/php7/\$pool.error.log
;php_admin_flag[log_errors] = on ;php_admin_flag[log_errors] = on
EOF EOF
if [ -f "${__object:?}/parameter/memory-limit" ]; then if [ -f "${__object:?}/parameter/memory-limit" ]; then
echo "php_admin_value[memory_limit] = $(cat "$__object/parameter/memory-limit")" echo "php_admin_value[memory_limit] = $(cat "$__object/parameter/memory-limit")"
else else
echo ";php_admin_value[memory_limit] = 32M" echo ";php_admin_value[memory_limit] = 32M"
fi fi
if [ -f "${__object:?}/parameter/open-basedir" ]; then
echo "php_admin_value[open_basedir] = $(cat "${__object:?}/parameter/open-basedir")"
fi

View file

@ -24,12 +24,24 @@ if [ -f "${__object:?}/parameter/enable-opcache" ]; then
__package "$opcache_package" __package "$opcache_package"
fi fi
POOL_USER=$(cat "${__object:?}/parameter/pool-user")
POOL_GROUP=$(cat "${__object:?}/parameter/pool-group")
POOL_LISTEN_ADDR=$(cat "${__object:?}/parameter/pool-listen-addr")
POOL_LISTEN_OWNER=$(cat "${__object:?}/parameter/pool-listen-owner")
export POOL_USER POOL_GROUP POOL_LISTEN_ADDR POOL_LISTEN_OWNER
UPLOAD_MAX_FILESIZE=$(cat "${__object:?}/parameter/upload-max-filesize") UPLOAD_MAX_FILESIZE=$(cat "${__object:?}/parameter/upload-max-filesize")
export UPLOAD_MAX_FILESIZE export UPLOAD_MAX_FILESIZE
mkdir -p "${__object:?}/files" mkdir -p "${__object:?}/files"
"${__type:?}/files/www.conf.sh" > "${__object:?}/files/www.conf"
"${__type:?}/files/php.ini.sh" > "${__object:?}/files/php.ini" "${__type:?}/files/php.ini.sh" > "${__object:?}/files/php.ini"
require="__package/$package" __file /etc/php7/php.ini\ require="__package/$package" __file /etc/php7/php.ini\
--mode 644 --source "${__object:?}/files/php.ini" \ --mode 644 --source "${__object:?}/files/php.ini" \
--onchange "service $service restart" --onchange "service $service restart"
require="__package/$package" __file /etc/php7/php-fpm.d/www.conf \
--mode 644 --source "${__object:?}/files/www.conf" \
--onchange "service $service restart"

View file

@ -1 +1,2 @@
memory-limit
upload-max-filesize upload-max-filesize

View file

@ -1,35 +0,0 @@
#!/bin/sh
os=$(cat "${__global:?}/explorer/os")
name=${__object_id:?}
case "$os" in
'alpine')
package="php7-fpm"
service="php-fpm7"
;;
*)
printf "Your operating system (%s) is currently not supported by this type\n" "$os" >&2
printf "Please contribute an implementation for it if you can.\n" >&2
exit 1
;;
esac
__package "$package"
require="__package/$package" __service "$service" --action start
require="__package/$package" __start_on_boot "$service"
POOL_NAME="$name"
POOL_USER=$(cat "${__object:?}/parameter/pool-user")
POOL_GROUP=$(cat "${__object:?}/parameter/pool-group")
POOL_LISTEN_ADDR=$(cat "${__object:?}/parameter/pool-listen-addr")
POOL_LISTEN_OWNER=$(cat "${__object:?}/parameter/pool-listen-owner")
export POOL_USER POOL_GROUP POOL_LISTEN_ADDR POOL_LISTEN_OWNER POOL_NAME
mkdir -p "${__object:?}/files"
"${__type:?}/files/www.conf.sh" > "${__object:?}/files/www.conf"
require="__package/$package" __file "/etc/php7/php-fpm.d/$name.conf" \
--mode 644 --source "${__object:?}/files/www.conf" \
--onchange "service $service reload"

View file

@ -1,2 +0,0 @@
memory-limit
open-basedir

View file

@ -1,44 +1,13 @@
#!/bin/sh #!/bin/sh
instance="${__object_id:?}" archive=wordpress.tar.gz
user="$instance"
group="$instance"
install_dir="/var/www/$instance"
wp_cli=/usr/local/bin/wp
mysql_database=$instance
if [ -f "${__object:?}/parameter/mysql-database" ]; then
mysql_database=$(cat "${__object:?}/parameter/mysql-database")
fi
mysql_user=$instance
if [ -f "${__object:?}/parameter/mysql-user" ]; then
mysql_user=$(cat "${__object:?}/parameter/mysql-user")
fi
mysql_password="$(cat "${__object:?}/parameter/mysql-password")"
domain="$(cat "${__object:?}/parameter/domain")"
url="https://$domain/"
admin_username="$(cat "${__object:?}/parameter/admin-username")"
admin_password="$(cat "${__object:?}/parameter/admin-password")"
admin_email="$(cat "${__object:?}/parameter/admin-email")"
cat << EOF cat << EOF
if [ ! -d "$install_dir" ]; then if [ ! -f /var/www/wordpress ]; then
mkdir -p "$install_dir" cd /var/www
chown -R $user:$group "$install_dir" curl https://wordpress.org/latest.tar.gz -o $archive
cd "$install_dir" tar xf $archive
sudo -u $user $wp_cli core download rm $archive
sudo -u $user $wp_cli config create \ chown -R wordpress:wordpress wordpress
--dbname="$mysql_database" \
--dbuser="$mysql_user" \
--dbpass="$mysql_password"
sudo -u $user $wp_cli core install \
--url="$url" \
--title="$instance" \
--admin_user="$admin_username" \
--admin_password="$admin_password" \
--admin_email="$admin_email"
fi fi
EOF EOF

View file

@ -1,46 +1,36 @@
#!/bin/sh #!/bin/sh
# TODO: set max upload size in PHP configuration (php.ini).
os=$(cat "${__global:?}/explorer/os") os=$(cat "${__global:?}/explorer/os")
instance="${__object_id:?}"
user=$instance
group=$user
if [ "$os" != "alpine" ]; then if [ "$os" != "alpine" ]; then
echo "This type is expected to run on Alpine Linux, not $os. Exiting." >&2 echo "This type is expected to run on Alpine Linux, not $os. Exiting." >&2
exit 1 exit 1
fi fi
# Type parameters. # Type parameters.
nginx_domain="$(cat "${__object:?}/parameter/domain")" mysql_password="$(cat "${__object:?}/parameter/mysql-password")"
nginx_domain="$(cat "${__object:?}/parameter/nginx-domain")"
altdomains= altdomains=
if [ -f "${__object:?}/parameter/altdomains" ]; then while read -r altdomain;
while read -r altdomain; do
do altdomains="--altdomain $altdomain $altdomains"
altdomains="--altdomain $altdomain $altdomains" done < "${__object:?}/parameter/altdomains"
done < "${__object:?}/parameter/altdomains"
fi
max_upload_size=100M max_upload_size=100M
php_fpm_socket="/run/php-fpm7/php-fpm-$instance.sock" php_fpm_socket=/run/php-fpm7/php-fpm.sock
# Wordpress CLI management tool. # Wordpress user.
__wp_cli __user wordpress --home /var/www/wordpress
# Wordpress user & group.
homedir="/var/www/$instance"
__user "$user" --home "$homedir"
# Basic PHP FPM setup + Wordpress dependencies. # Basic PHP FPM setup + Wordpress dependencies.
__recycledcloud_php_fpm \ require="__user/wordpress" __recycledcloud_php \
--upload-max-filesize $max_upload_size \ --pool-user wordpress \
--enable-opcache --pool-group wordpress \
require="__user/$user __recycledcloud_php_fpm" __recycledcloud_php_fpm_pool "$instance" \ --pool-listen-addr $php_fpm_socket \
--pool-user "$user" \
--pool-group "$group" \
--pool-listen-addr "$php_fpm_socket" \
--pool-listen-owner nginx \ --pool-listen-owner nginx \
--memory-limit 128M \ --upload-max-filesize $max_upload_size
--open-basedir "/var/www/$instance:/tmp"
wordpress_dependencies="php7-fpm php7-iconv php7-json php7-gd php7-curl \ wordpress_dependencies="php7-fpm php7-iconv php7-json php7-gd php7-curl \
php7-xml php7-mysqli php7-imap php7-cgi php7-pdo php7-pdo_mysql php7-soap \ php7-xml php7-mysqli php7-imap php7-cgi php7-pdo php7-pdo_mysql php7-soap \
@ -52,23 +42,17 @@ do
__package "$dependency" __package "$dependency"
done done
# Daily database backup/export. # MySQL/MariaDB database
require="__user/$user" __cron "$instance-db-export" \ __recycledcloud_mysql
--user "$user" \ require="__recycledcloud_mysql" __mysql_database wordpress \
--command "/usr/local/bin/wp db export" \ --user wordpress --password "$mysql_password"
--minute 0 \
--hour 2
require="__user/$user" __cron "$instance-db-export-cleanup" \
--user "$user" \
--command "find *.sql -maxdepth 1 -mtime +5 -delete"
# NGINX vhost for wordpress hosting. # NGINX vhost for wordpress hosting.
# shellcheck disable=SC2086 # shellcheck disable=SC2086
__nginx "$nginx_domain" \ __nginx "$nginx_domain" \
$altdomains \ $altdomains \
--config - <<- EOF --config - <<- EOF
root "$homedir"; root /var/www/wordpress;
index index.php; index index.php;
client_max_body_size $max_upload_size; client_max_body_size $max_upload_size;

View file

@ -1,4 +1 @@
altdomains altdomains
mysql-user
mysql-databse
admin-username

View file

@ -1,5 +1,2 @@
domain nginx-domain
mysql-password mysql-password
admin-password
admin-email

View file

@ -1,7 +0,0 @@
#!/bin/sh
cat << EOF
curl https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -o wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp
EOF

View file

@ -1,11 +0,0 @@
#!/bin/sh
os=$(cat "${__global:?}/explorer/os")
if [ "$os" != "alpine" ]; then
echo "This type is expected to run on Alpine Linux, not $os. Exiting." >&2
exit 1
fi
for pkg in curl php7 php7-phar less; do
__package $pkg
done