Valentin Lab
9 years ago
9 changed files with 1166 additions and 299 deletions
-
2apache/build/etc/php/php.ini
-
4apache/hooks/install.old
-
70apache/hooks/publish_dir-relation-joined
-
48apache/hooks/web_proxy-relation-joined
-
552apache/lib/common
-
20apache/metadata.yml
-
166apache/test/libtest
-
360apache/test/vhost
-
243apache/test/vhost_files
@ -0,0 +1,2 @@ |
|||||
|
|
||||
|
max_execution_time = 900 |
@ -0,0 +1,20 @@ |
|||||
|
description: "Apache Web Server" |
||||
|
maintainer: "Valentin Lab <valentin.lab@kalysto.org>" |
||||
|
## XXXvlab: currently only used when building LXC along with hooks/install |
||||
|
## XXXvlab: docker uses the 'build' directory or the 'image:' option here. |
||||
|
inherit: base-0k |
||||
|
compatiblity: ## 'hooks/install' script was run on a these images without issues |
||||
|
- ubuntu/15.10 |
||||
|
docker-compose: |
||||
|
## XXXvlab: should move to global lxc/docker compatible option |
||||
|
ports: |
||||
|
- "0.0.0.0:80:80" |
||||
|
- "0.0.0.0:443:443" |
||||
|
data-resources: |
||||
|
- /var/www/html |
||||
|
- /var/log/apache2 |
||||
|
config-resources: |
||||
|
- /etc/apache2/sites-enabled |
||||
|
provides: |
||||
|
web-proxy: |
||||
|
tech-dep: "reversed" |
@ -0,0 +1,166 @@ |
|||||
|
# -*- mode: shell-script -*- |
||||
|
|
||||
|
exname="$(basename $0)" |
||||
|
|
||||
|
if [ -t 1 ]; then |
||||
|
GRAY=$(echo -en "\e[1;30m") |
||||
|
RED=$(echo -en "\e[1;31m") |
||||
|
GREEN=$(echo -en "\e[1;32m") |
||||
|
YELLOW=$(echo -en "\e[1;33m") |
||||
|
BLUE=$(echo -en "\e[1;34m") |
||||
|
PINK=$(echo -en "\e[1;35m") |
||||
|
CYAN=$(echo -en "\e[1;36m") |
||||
|
WHITE=$(echo -en "\e[1;37m") |
||||
|
|
||||
|
DARKGRAY=$(echo -en "\e[0;30m") |
||||
|
DARKRED=$(echo -en "\e[0;31m") |
||||
|
DARKGREEN=$(echo -en "\e[0;32m") |
||||
|
DARKYELLOW=$(echo -en "\e[0;33m") |
||||
|
DARKBLUE=$(echo -en "\e[0;34m") |
||||
|
DARKPINK=$(echo -en "\e[0;35m") |
||||
|
DARKCYAN=$(echo -en "\e[0;36m") |
||||
|
|
||||
|
NORMAL=$(echo -en "\e[0m") |
||||
|
fi |
||||
|
|
||||
|
function out() { cat "$tmp_out"; } |
||||
|
function err() { cat "$tmp_err"; } |
||||
|
function errlvl() { cat "$tmp_errlvl"; } |
||||
|
function var() { echo "${$1}"; } |
||||
|
|
||||
|
|
||||
|
function time_note() { |
||||
|
echo "scale=1 ; l($1 - $empty_try_time) / l(10)" | bc -l |
||||
|
} |
||||
|
|
||||
|
function swallow_last_time() { |
||||
|
if test "$sum_time" == "0" -a -z "$cmd"; then ## catches first empty try '' |
||||
|
empty_try_time="$(echo "scale=0 ; $time_diff / 2" | bc -l )" |
||||
|
return 0 |
||||
|
fi |
||||
|
test -z "$test_counter" && test_counter=0 || test_counter=$[$test_counter + 1] |
||||
|
test -z "$sum_time" && sum_time=0 |
||||
|
test_name=${exname}_${test_counter} |
||||
|
if test "$time_diff"; then |
||||
|
test_time_note=$(time_note $time_diff) |
||||
|
profiler_info="$(echo -en "$profiler_info\n- $test_name\t$test_time_note")" |
||||
|
sum_time=$(echo "scale=3; $sum_time + $time_diff" | bc -l ) |
||||
|
fi |
||||
|
|
||||
|
} |
||||
|
|
||||
|
function time_exec() { |
||||
|
beg_exec=$(date +%s.%N) |
||||
|
( echo "$*" | bash ) |
||||
|
errorlevel=$? |
||||
|
end_exec=$(date +%s.%N) |
||||
|
time_diff="$(echo "scale=3; ($end_exec - $beg_exec)*1000000" | bc | cut -f 1 -d ".")" |
||||
|
return $errorlevel |
||||
|
} |
||||
|
|
||||
|
|
||||
|
function try() { |
||||
|
swallow_last_time |
||||
|
cmd="$*" |
||||
|
desc=$(echo ; echo "$ $cmd" ) |
||||
|
time_exec "$prefix_cmd$cmd" 1> "$tmp_out" 2> "$tmp_err" |
||||
|
echo $? > "$tmp_errlvl" |
||||
|
} |
||||
|
|
||||
|
function apply_opt() { |
||||
|
code=$(cat -) |
||||
|
for opt in $*; do |
||||
|
code=$(echo "$code" | $opt) |
||||
|
done |
||||
|
echo "$code" |
||||
|
} |
||||
|
|
||||
|
function NOCOLOR() { |
||||
|
esc_char=$(echo -en "\e") |
||||
|
cat - | sed -r "s/$esc_char\[[0-9]+(;[0-9]+)*m//g" |
||||
|
} |
||||
|
|
||||
|
function NOPOS() { |
||||
|
esc_char=$(echo -en "\e\\[[0-9]\\+[GA]") |
||||
|
cat - | sed "s/$esc_char//g" |
||||
|
} |
||||
|
|
||||
|
function TRIM() { |
||||
|
cat - | sed -r "s/^ +//g" | sed -r "s/ +\$//g" |
||||
|
} |
||||
|
|
||||
|
function RTRIM() { |
||||
|
cat - | sed -r "s/ +\$//g" |
||||
|
} |
||||
|
|
||||
|
function SIZE() { |
||||
|
cat - | wc -c |
||||
|
} |
||||
|
|
||||
|
## usage: |
||||
|
## is ACTION [reg] CODE [OPTION ...] |
||||
|
is() { |
||||
|
local act="$1" type code msg |
||||
|
test -z "$total" && total=0 |
||||
|
shift |
||||
|
|
||||
|
case "$1" in |
||||
|
reg|part) |
||||
|
type="$1" |
||||
|
shift |
||||
|
;; |
||||
|
*) |
||||
|
type="" |
||||
|
;; |
||||
|
esac |
||||
|
|
||||
|
code="$1" |
||||
|
shift |
||||
|
#code=$(echo "$code" | apply_opt $*) |
||||
|
msg=$(echo "$type $code" | cut -c -30) |
||||
|
|
||||
|
output=$($act | apply_opt $*) |
||||
|
case "$type" in |
||||
|
"") |
||||
|
test "$code" == "$output" |
||||
|
;; |
||||
|
"part") |
||||
|
[[ "$output" == *"$code"* ]] |
||||
|
;; |
||||
|
("reg") |
||||
|
echo -n "$output" | egrep -- "$code" >/dev/null 2>&1 |
||||
|
;; |
||||
|
esac && total=$[$total + 1] && |
||||
|
echo "[v] is $act $msg" >/dev/null && return 0 |
||||
|
echo "$desc" |
||||
|
echo "[ ] is $act $msg" |
||||
|
echo "--- $*" |
||||
|
echo -n "$output" |
||||
|
echo |
||||
|
echo "--- DIFF" |
||||
|
diff -u <(echo "$code") <(echo "$output") | egrep -v '^(---|\+\+\+) /' |
||||
|
exit 1 |
||||
|
|
||||
|
} |
||||
|
|
||||
|
function summary() { |
||||
|
swallow_last_time |
||||
|
|
||||
|
echo "$profiler_info" |
||||
|
echo |
||||
|
echo "$total tests conducted in $(echo "scale=3;$sum_time/1000000" | bc) s ($(time_note $sum_time))" |
||||
|
} |
||||
|
function noerror() { |
||||
|
is err '' |
||||
|
is errlvl 0 |
||||
|
} |
||||
|
|
||||
|
pid=$$ |
||||
|
tmp_dir="/tmp" |
||||
|
tmp_out="$tmp_dir/test.$pid.out.tmp" |
||||
|
tmp_err="$tmp_dir/test.$pid.err.tmp" |
||||
|
tmp_errlvl="$tmp_dir/test.$pid.errlvl.tmp" |
||||
|
|
||||
|
try '' |
||||
|
try '' |
||||
|
try '' |
@ -0,0 +1,360 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
exname=$(basename $0) |
||||
|
|
||||
|
prefix_cmd=" |
||||
|
. /etc/shlib |
||||
|
|
||||
|
include common |
||||
|
include parse |
||||
|
|
||||
|
. ../lib/common |
||||
|
|
||||
|
" |
||||
|
[ "$DEBUG" ] && echo "Loading testlib..." |
||||
|
if ! . ./libtest ; then |
||||
|
echo 'libtest failed to load.' |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
export COLUMNS=50 |
||||
|
|
||||
|
|
||||
|
test_pid_file="$tmp_dir/test.$$pid.tmp" |
||||
|
rm -f "$test_pid_file" |
||||
|
|
||||
|
|
||||
|
## |
||||
|
## print_bytes |
||||
|
## |
||||
|
|
||||
|
# mock |
||||
|
relation-get() { |
||||
|
local key="$1" |
||||
|
echo "$CFG" | shyaml get-value "$key" 2>/dev/null |
||||
|
} |
||||
|
export -f relation-get |
||||
|
|
||||
|
try " |
||||
|
DOMAIN=www.example.com |
||||
|
DOCKER_SITE_PATH=/var/www/\$DOMAIN |
||||
|
apache_vhost_statement ,http," |
||||
|
noerror |
||||
|
is out '<VirtualHost *:80> |
||||
|
|
||||
|
ServerAdmin contact@www.example.com |
||||
|
ServerName www.example.com |
||||
|
|
||||
|
ServerSignature Off |
||||
|
CustomLog /var/log/apache2/www.example.com_access.log combined |
||||
|
ErrorLog /var/log/apache2/www.example.com_error.log |
||||
|
ErrorLog syslog:local2 |
||||
|
|
||||
|
## |
||||
|
## Publish directory /var/www/www.example.com |
||||
|
## |
||||
|
|
||||
|
DocumentRoot /var/www/www.example.com |
||||
|
|
||||
|
<Directory /> |
||||
|
Options FollowSymLinks |
||||
|
AllowOverride None |
||||
|
</Directory> |
||||
|
|
||||
|
<Directory /var/www/www.example.com> |
||||
|
Options Indexes FollowSymLinks MultiViews |
||||
|
AllowOverride all |
||||
|
Allow from all |
||||
|
</Directory> |
||||
|
|
||||
|
|
||||
|
## Forbid any cache, this is only usefull on dev server. |
||||
|
#Header set Cache-Control "no-cache" |
||||
|
#Header set Access-Control-Allow-Origin "*" |
||||
|
#Header set Access-Control-Allow-Methods "POST, GET, OPTIONS" |
||||
|
#Header set Access-Control-Allow-Headers "origin, content-type, accept" |
||||
|
|
||||
|
|
||||
|
</VirtualHost>' RTRIM |
||||
|
|
||||
|
## |
||||
|
## Aliases |
||||
|
## |
||||
|
|
||||
|
try " |
||||
|
DOMAIN=www.example.com |
||||
|
DOCKER_SITE_PATH=/var/www/\$DOMAIN |
||||
|
CFG=' |
||||
|
server-aliases: |
||||
|
- toto |
||||
|
' |
||||
|
apache_vhost_statement ,http," |
||||
|
noerror |
||||
|
is out reg 'ServerAlias toto' |
||||
|
|
||||
|
|
||||
|
try " |
||||
|
DOMAIN=www.example.com |
||||
|
DOCKER_SITE_PATH=/var/www/\$DOMAIN |
||||
|
CFG=' |
||||
|
server-aliases: |
||||
|
- toto |
||||
|
- titi |
||||
|
' |
||||
|
apache_vhost_statement ,http," |
||||
|
noerror |
||||
|
is out reg 'ServerAlias toto' |
||||
|
is out reg 'ServerAlias titi' |
||||
|
|
||||
|
|
||||
|
## |
||||
|
## Creds |
||||
|
## |
||||
|
|
||||
|
try " |
||||
|
DOMAIN=www.example.com |
||||
|
DOCKER_SITE_PATH=/var/www/\$DOMAIN |
||||
|
CFG='' |
||||
|
apache_vhost_statement ,http," |
||||
|
noerror |
||||
|
is out reg 'Allow from all' |
||||
|
|
||||
|
|
||||
|
try " |
||||
|
DOMAIN=www.example.com |
||||
|
DOCKER_SITE_PATH=/var/www/\$DOMAIN |
||||
|
CFG=' |
||||
|
creds: |
||||
|
toto: xxx |
||||
|
titi: yyy |
||||
|
' |
||||
|
apache_vhost_statement ,http," |
||||
|
noerror |
||||
|
is out reg 'AuthType basic' |
||||
|
is out reg 'Require valid-user' |
||||
|
|
||||
|
|
||||
|
## |
||||
|
## proxy |
||||
|
## |
||||
|
|
||||
|
try " |
||||
|
DOMAIN=www.example.com |
||||
|
DOCKER_SITE_PATH=/var/www/\$DOMAIN |
||||
|
CFG=' |
||||
|
target: popo:3333 |
||||
|
creds: |
||||
|
toto: titi |
||||
|
' |
||||
|
proxy=yes apache_vhost_statement ,http," |
||||
|
noerror |
||||
|
is out reg 'ProxyPass / http://popo:3333/' |
||||
|
is out part ' |
||||
|
<Location / > |
||||
|
AuthType basic |
||||
|
AuthName "private" |
||||
|
AuthUserFile /etc/apache2/sites-enabled/www.example.com.passwd |
||||
|
Require valid-user |
||||
|
ProxyPassReverse / |
||||
|
</Location> |
||||
|
' |
||||
|
|
||||
|
## |
||||
|
## ssl |
||||
|
## |
||||
|
|
||||
|
try " |
||||
|
DOMAIN=www.example.com |
||||
|
DOCKER_SITE_PATH=/var/www/\$DOMAIN |
||||
|
CFG=' |
||||
|
ssl: true |
||||
|
target: popo:3333 |
||||
|
' |
||||
|
proxy=yes apache_vhost_statement ,https," |
||||
|
noerror |
||||
|
is out reg 'VirtualHost \*:443' |
||||
|
is out reg '<IfModule mod_ssl.c>' |
||||
|
is out reg 'SSLEngine On' |
||||
|
is out reg 'SSLProxyEngine On' |
||||
|
is out reg 'ssl-cert-snakeoil' |
||||
|
is out reg 'CustomLog /var/log/apache2/s-www.example.com_access.log combined' |
||||
|
|
||||
|
|
||||
|
try " |
||||
|
DOMAIN=www.example.com |
||||
|
DOCKER_SITE_PATH=/var/www/\$DOMAIN |
||||
|
CFG=' |
||||
|
ssl: |
||||
|
ca-cert: a |
||||
|
key: b |
||||
|
cert: c |
||||
|
target: popo:3333 |
||||
|
' |
||||
|
proxy=yes apache_vhost_statement ,https," |
||||
|
noerror |
||||
|
is out reg 'SSLCertificateFile /etc/ssl/certs/www.example.com.pem' |
||||
|
is out reg 'SSLCertificateKeyFile /etc/ssl/private/www.example.com.key' |
||||
|
is out reg 'SSLCACertificateFile /etc/ssl/certs/www.example.com-ca.pem' |
||||
|
|
||||
|
|
||||
|
## |
||||
|
## CustomRules |
||||
|
## |
||||
|
|
||||
|
try " |
||||
|
DOMAIN=www.example.com |
||||
|
DOCKER_SITE_PATH=/var/www/\$DOMAIN |
||||
|
CFG=' |
||||
|
ssl: |
||||
|
ca-cert: a |
||||
|
key: b |
||||
|
cert: c |
||||
|
apache-custom-rules: | |
||||
|
RewriteEngine On |
||||
|
RewriteCond %{QUERY_STRING} !skin=formanoo |
||||
|
RewriteRule ^(/web/webclient/home.*)$ $1?skin=formanoo [L,QSA,R=302] |
||||
|
target: popo:3333 |
||||
|
' |
||||
|
proxy=yes apache_vhost_statement ,https," |
||||
|
noerror |
||||
|
is out reg 'RewriteEngine On' |
||||
|
|
||||
|
|
||||
|
## |
||||
|
## double def |
||||
|
## |
||||
|
|
||||
|
try " |
||||
|
DOMAIN=www.example.com |
||||
|
DOCKER_SITE_PATH=/var/www/\$DOMAIN |
||||
|
CFG=' |
||||
|
ssl: |
||||
|
ca-cert: a |
||||
|
key: b |
||||
|
cert: c |
||||
|
apache-custom-rules: | |
||||
|
RewriteEngine On |
||||
|
RewriteCond %{QUERY_STRING} !skin=formanoo |
||||
|
RewriteRule ^(/web/webclient/home.*)$ $1?skin=formanoo [L,QSA,R=302] |
||||
|
target: popo:3333 |
||||
|
' |
||||
|
proxy=yes apache_vhost_statement ,https,http," |
||||
|
noerror |
||||
|
is out '<VirtualHost *:80> |
||||
|
|
||||
|
ServerAdmin contact@www.example.com |
||||
|
ServerName www.example.com |
||||
|
|
||||
|
ServerSignature Off |
||||
|
CustomLog /var/log/apache2/www.example.com_access.log combined |
||||
|
ErrorLog /var/log/apache2/www.example.com_error.log |
||||
|
ErrorLog syslog:local2 |
||||
|
|
||||
|
## |
||||
|
## Proxy declaration towards popo:3333 |
||||
|
## |
||||
|
|
||||
|
<IfModule mod_proxy.c> |
||||
|
ProxyRequests Off |
||||
|
<Proxy *> |
||||
|
Order deny,allow |
||||
|
Allow from all |
||||
|
</Proxy> |
||||
|
ProxyVia On |
||||
|
ProxyPass / http://popo:3333/ retry=0 |
||||
|
<Location / > |
||||
|
Allow from all |
||||
|
ProxyPassReverse / |
||||
|
</Location> |
||||
|
|
||||
|
</IfModule> |
||||
|
|
||||
|
RequestHeader set "X-Forwarded-Proto" "https" |
||||
|
|
||||
|
## Fix IE problem (httpapache proxy dav error 408/409) |
||||
|
SetEnv proxy-nokeepalive 1 |
||||
|
|
||||
|
## Forbid any cache, this is only usefull on dev server. |
||||
|
#Header set Cache-Control "no-cache" |
||||
|
#Header set Access-Control-Allow-Origin "*" |
||||
|
#Header set Access-Control-Allow-Methods "POST, GET, OPTIONS" |
||||
|
#Header set Access-Control-Allow-Headers "origin, content-type, accept" |
||||
|
|
||||
|
|
||||
|
|
||||
|
## |
||||
|
## Custom rules |
||||
|
## |
||||
|
|
||||
|
RewriteEngine On |
||||
|
RewriteCond %{QUERY_STRING} !skin=formanoo |
||||
|
RewriteRule ^(/web/webclient/home.*)$ ?skin=formanoo [L,QSA,R=302] |
||||
|
|
||||
|
</VirtualHost> |
||||
|
|
||||
|
<IfModule mod_ssl.c> |
||||
|
<VirtualHost *:443> |
||||
|
|
||||
|
ServerAdmin contact@www.example.com |
||||
|
ServerName www.example.com |
||||
|
|
||||
|
ServerSignature Off |
||||
|
CustomLog /var/log/apache2/s-www.example.com_access.log combined |
||||
|
ErrorLog /var/log/apache2/s-www.example.com_error.log |
||||
|
ErrorLog syslog:local2 |
||||
|
|
||||
|
## |
||||
|
## Proxy declaration towards popo:3333 |
||||
|
## |
||||
|
|
||||
|
<IfModule mod_proxy.c> |
||||
|
ProxyRequests Off |
||||
|
<Proxy *> |
||||
|
Order deny,allow |
||||
|
Allow from all |
||||
|
</Proxy> |
||||
|
ProxyVia On |
||||
|
ProxyPass / http://popo:3333/ retry=0 |
||||
|
<Location / > |
||||
|
Allow from all |
||||
|
ProxyPassReverse / |
||||
|
</Location> |
||||
|
SSLProxyEngine On |
||||
|
</IfModule> |
||||
|
|
||||
|
RequestHeader set "X-Forwarded-Proto" "https" |
||||
|
|
||||
|
## Fix IE problem (httpapache proxy dav error 408/409) |
||||
|
SetEnv proxy-nokeepalive 1 |
||||
|
|
||||
|
## Forbid any cache, this is only usefull on dev server. |
||||
|
#Header set Cache-Control "no-cache" |
||||
|
#Header set Access-Control-Allow-Origin "*" |
||||
|
#Header set Access-Control-Allow-Methods "POST, GET, OPTIONS" |
||||
|
#Header set Access-Control-Allow-Headers "origin, content-type, accept" |
||||
|
|
||||
|
## |
||||
|
## SSL Configuration |
||||
|
## |
||||
|
|
||||
|
SSLEngine On |
||||
|
|
||||
|
SSLCertificateFile /etc/ssl/certs/www.example.com.pem |
||||
|
SSLCertificateKeyFile /etc/ssl/private/www.example.com.key |
||||
|
SSLCACertificateFile /etc/ssl/certs/www.example.com-ca.pem |
||||
|
SSLVerifyClient None |
||||
|
|
||||
|
|
||||
|
## |
||||
|
## Custom rules |
||||
|
## |
||||
|
|
||||
|
RewriteEngine On |
||||
|
RewriteCond %{QUERY_STRING} !skin=formanoo |
||||
|
RewriteRule ^(/web/webclient/home.*)$ ?skin=formanoo [L,QSA,R=302] |
||||
|
|
||||
|
</VirtualHost> |
||||
|
</IfModule>' RTRIM |
||||
|
|
||||
|
|
||||
|
summary |
@ -0,0 +1,243 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
exname=$(basename $0) |
||||
|
|
||||
|
prefix_cmd=" |
||||
|
. /etc/shlib |
||||
|
|
||||
|
include common |
||||
|
include parse |
||||
|
|
||||
|
. ../lib/common |
||||
|
|
||||
|
" |
||||
|
[ "$DEBUG" ] && echo "Loading testlib..." |
||||
|
if ! . ./libtest ; then |
||||
|
echo 'libtest failed to load.' |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
export COLUMNS=50 |
||||
|
|
||||
|
|
||||
|
test_pid_file="$tmp_dir/test.$$pid.tmp" |
||||
|
rm -f "$test_pid_file" |
||||
|
|
||||
|
## |
||||
|
## Mocks |
||||
|
## |
||||
|
|
||||
|
relation-get() { |
||||
|
local key="$1" |
||||
|
echo "$CFG" | shyaml get-value "$key" 2>/dev/null |
||||
|
} |
||||
|
export -f relation-get |
||||
|
|
||||
|
|
||||
|
file_put() { |
||||
|
echo "file_put $1" |
||||
|
cat - | prefix " | " |
||||
|
} |
||||
|
export -f file_put |
||||
|
|
||||
|
docker() { |
||||
|
echo "docker" "$@" |
||||
|
echo stdin: |
||||
|
cat - | prefix " | " |
||||
|
} |
||||
|
export -f docker |
||||
|
|
||||
|
config-add() { |
||||
|
echo "config-add" |
||||
|
echo "$1" | prefix " | " |
||||
|
} |
||||
|
export -f config-add |
||||
|
|
||||
|
mkdir() { |
||||
|
echo "called: $FUNCNAME $@" >&2 |
||||
|
} |
||||
|
export -f mkdir |
||||
|
|
||||
|
setfacl() { |
||||
|
echo "called: $FUNCNAME $@" >&2 |
||||
|
} |
||||
|
export -f setfacl |
||||
|
|
||||
|
chgrp() { |
||||
|
echo "called: $FUNCNAME $@" >&2 |
||||
|
} |
||||
|
export -f chgrp |
||||
|
|
||||
|
chmod() { |
||||
|
echo "called: $FUNCNAME $@" >&2 |
||||
|
} |
||||
|
export -f chmod |
||||
|
|
||||
|
|
||||
|
|
||||
|
cached_cmd_on_base_image() { |
||||
|
echo "called: $FUNCNAME $@" >&2 |
||||
|
echo "stdout:" >&2 |
||||
|
echo "<GID>" | prefix " | " >&2 |
||||
|
echo "<GID>" |
||||
|
} |
||||
|
export -f cached_cmd_on_base_image |
||||
|
|
||||
|
|
||||
|
## |
||||
|
## apache_vhost_create |
||||
|
## |
||||
|
|
||||
|
|
||||
|
try " |
||||
|
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE' |
||||
|
DOMAIN=www.example.com |
||||
|
DOCKER_SITE_PATH=/var/www/\$DOMAIN |
||||
|
apache_vhost_create" |
||||
|
noerror |
||||
|
is out reg '^file_put \$SERVICE_CONFIGSTORE/.*/www.example.com.conf' |
||||
|
|
||||
|
try " |
||||
|
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE' |
||||
|
DOMAIN=www.example.com |
||||
|
DOCKER_SITE_PATH=/var/www/\$DOMAIN |
||||
|
CFG=' |
||||
|
ssl: true |
||||
|
' |
||||
|
apache_vhost_create" |
||||
|
noerror |
||||
|
is out reg '^file_put \$SERVICE_CONFIGSTORE/.*/www.example.com.conf' |
||||
|
is err '' |
||||
|
|
||||
|
|
||||
|
try " |
||||
|
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE' |
||||
|
export CONFIGSTORE='\$CONFIGSTORE' |
||||
|
export BASE_CHARM_NAME='\$BASE_CHARM_NAME' |
||||
|
export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME' |
||||
|
DOMAIN=www.example.com |
||||
|
DOCKER_SITE_PATH=/var/www/\$DOMAIN |
||||
|
CFG=' |
||||
|
ssl: |
||||
|
key: | |
||||
|
a |
||||
|
b |
||||
|
cert: c |
||||
|
' |
||||
|
apache_vhost_create" |
||||
|
noerror |
||||
|
is out part 'file_put $CONFIGSTORE/$BASE_CHARM_NAME/etc/ssl/certs/www.example.com.pem |
||||
|
| c' |
||||
|
is out part 'file_put $CONFIGSTORE/$BASE_CHARM_NAME/etc/ssl/private/www.example.com.key |
||||
|
| a |
||||
|
| b' |
||||
|
is out reg 'config-add' |
||||
|
is out reg ' - \$CONFIGSTORE/\$BASE_CHARM_NAME/etc/ssl/certs/www.example.com.pem:/etc/ssl/certs/www.example.com.pem:ro' |
||||
|
is out reg ' - \$CONFIGSTORE/\$BASE_CHARM_NAME/etc/ssl/private/www.example.com.key:/etc/ssl/private/www.example.com.key:ro' |
||||
|
|
||||
|
|
||||
|
try " |
||||
|
export DOCKER_BASE_IMAGE=docker/apache |
||||
|
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE' |
||||
|
export CONFIGSTORE='\$CONFIGSTORE' |
||||
|
export BASE_CHARM_NAME='\$BASE_CHARM_NAME' |
||||
|
export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME' |
||||
|
DOMAIN=www.example.com |
||||
|
DOCKER_SITE_PATH=/var/www/\$DOMAIN |
||||
|
export CFG=' |
||||
|
creds: |
||||
|
toto: xxx |
||||
|
' |
||||
|
apache_vhost_create" |
||||
|
noerror |
||||
|
is out reg "htpasswd -bc '/etc/apache2/sites-enabled/www.example.com.passwd' 'toto' 'xxx'" |
||||
|
is out reg 'docker run -i --entrypoint /bin/bash .* docker/apache' |
||||
|
|
||||
|
|
||||
|
## |
||||
|
## apache_proxy_dir |
||||
|
## |
||||
|
|
||||
|
try " |
||||
|
export DOCKER_BASE_IMAGE=docker/apache |
||||
|
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE' |
||||
|
export CONFIGSTORE='\$CONFIGSTORE' |
||||
|
export BASE_CHARM_NAME='\$BASE_CHARM_NAME' |
||||
|
export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME' |
||||
|
export CFG=' |
||||
|
creds: |
||||
|
toto: xxx |
||||
|
' |
||||
|
apache_publish_dir" |
||||
|
is errlvl 1 ## no domain |
||||
|
|
||||
|
|
||||
|
try " |
||||
|
export DATASTORE='\$DATASTORE' |
||||
|
export DOCKER_BASE_IMAGE=docker/apache |
||||
|
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE' |
||||
|
export CONFIGSTORE='\$CONFIGSTORE' |
||||
|
export BASE_CHARM_NAME='\$BASE_CHARM_NAME' |
||||
|
export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME' |
||||
|
export CFG=' |
||||
|
domain: www.example.com |
||||
|
creds: |
||||
|
toto: xxx |
||||
|
' |
||||
|
apache_publish_dir" |
||||
|
is errlvl 0 |
||||
|
is err reg 'setfacl -R -m g:<GID>:rx \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com' |
||||
|
is err reg 'cached_cmd_on_base_image apache id -g www-data' |
||||
|
|
||||
|
|
||||
|
try " |
||||
|
export DATASTORE='\$DATASTORE' |
||||
|
export DOCKER_BASE_IMAGE=docker/apache |
||||
|
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE' |
||||
|
export CONFIGSTORE='\$CONFIGSTORE' |
||||
|
export BASE_CHARM_NAME='\$BASE_CHARM_NAME' |
||||
|
export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME' |
||||
|
export CFG=' |
||||
|
domain: www.example.com |
||||
|
creds: |
||||
|
toto: xxx |
||||
|
data-dirs: |
||||
|
- a |
||||
|
- b |
||||
|
- c |
||||
|
' |
||||
|
apache_publish_dir" |
||||
|
is errlvl 0 |
||||
|
is err reg 'setfacl -R -m g:<GID>:rwx \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/a \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/b \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/c' |
||||
|
is err reg 'setfacl -R -d -m g:<GID>:rwx \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/a \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/b \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/c' |
||||
|
|
||||
|
|
||||
|
try " |
||||
|
export DATASTORE='\$DATASTORE' |
||||
|
export DOCKER_BASE_IMAGE=docker/apache |
||||
|
export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE' |
||||
|
export CONFIGSTORE='\$CONFIGSTORE' |
||||
|
export BASE_CHARM_NAME='\$BASE_CHARM_NAME' |
||||
|
export MASTER_BASE_CHARM_NAME='\$MASTER_BASE_CHARM_NAME' |
||||
|
export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME' |
||||
|
export CFG=' |
||||
|
domain: www.example.com |
||||
|
location: /opt/apps/newlocation |
||||
|
creds: |
||||
|
toto: xxx |
||||
|
data-dirs: |
||||
|
- a |
||||
|
- b |
||||
|
- c |
||||
|
' |
||||
|
apache_publish_dir" |
||||
|
is errlvl 0 |
||||
|
is err reg 'mkdir -p /opt/apps/newlocation' |
||||
|
is err reg 'setfacl -R -m g:<GID>:rx /opt/apps/newlocation' |
||||
|
is out part ' | $MASTER_BASE_CHARM_NAME: |
||||
|
| volumes: |
||||
|
| - /opt/apps/newlocation:/var/www/www.example.com' |
||||
|
|
||||
|
|
||||
|
summary |
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue