From 281a68e16abaa6515b8014928074fdbf13becbac Mon Sep 17 00:00:00 2001 From: Andrii Nikitin Date: Mon, 30 Jan 2023 12:35:00 +0100 Subject: [PATCH] Add mariadb tar environ Also some rework on defaults --- .github/workflows/test.yml | 14 +++--- Makefile | 10 ++-- README.txt | 12 ++--- bin/environ | 31 +++++++++---- {product => environ.d}/ap/local/_exec.m4 | 0 {product => environ.d}/ap/local/build.sh.m4 | 0 .../ap/local/configure_add_https.sh.m4 | 0 .../ap/local/configure_ssl.sh.m4 | 0 {product => environ.d}/ap/local/curl.sh.m4 | 0 {product => environ.d}/ap/local/dir.conf.m4 | 0 {product => environ.d}/ap/local/httpd.conf.m4 | 0 .../ap/local/print_address.sh.m4 | 0 {product => environ.d}/ap/port_base.cnf | 0 {product => environ.d}/ap/t/01-smoke-00.sh | 0 .../ap/t/01-smoke-01-two-instances.sh | 0 {product => environ.d}/ap/t/02-ssl-00-only.sh | 0 .../ap/t/02-ssl-01-combined.sh | 0 {product => environ.d}/common/_lock.m4 | 0 {product => environ.d}/common/start.sh.m4 | 0 {product => environ.d}/common/status.sh.m4 | 0 {product => environ.d}/common/stop.sh.m4 | 0 {product => environ.d}/fk/description.txt | 0 {product => environ.d}/fk/local/_exec.m4 | 0 {product => environ.d}/fk/port_base.cnf | 0 {product => environ.d}/fk/t/01-smoke-00.sh | 0 .../fk/t/01-smoke-01-two-instances.sh | 0 environ.d/ma/common/build.sh.m4 | 1 + .../ma/common}/create_db.sh.m4 | 0 .../ma/common}/print_dbi.sh.m4 | 0 .../ma/common}/sql_loop.sh.m4 | 0 .../ma/common}/sql_test.sh.m4 | 0 environ.d/ma/detect_type.sh | 1 + .../ma/local/init_datadir.sh.m4 | 0 {product => environ.d}/ma/local/sql.sh.m4 | 0 {product => environ.d}/ma/local/start.sh.m4 | 0 {product => environ.d}/ma/local/status.sh.m4 | 0 {product => environ.d}/ma/local/stop.sh.m4 | 0 environ.d/ma/t/01-smoke-00-version.sh | 29 ++++++++++++ {product => environ.d}/ma/t/01-smoke-00.sh | 0 .../ma/t/01-smoke-01-two-instances.sh | 0 .../ma/t/01-smoke-02-default-db.sh | 0 environ.d/ma/version/download.sh.m4 | 46 +++++++++++++++++++ environ.d/ma/version/init_datadir.sh.m4 | 6 +++ environ.d/ma/version/sql.sh.m4 | 22 +++++++++ environ.d/ma/version/start.sh.m4 | 9 ++++ environ.d/ma/version/status.sh.m4 | 1 + environ.d/ma/version/stop.sh.m4 | 1 + {product => environ.d}/md/local/_exec.m4 | 0 {product => environ.d}/md/local/get.sh.m4 | 0 .../md/local/get_test.sh.m4 | 0 .../md/local/print_address.sh.m4 | 0 {product => environ.d}/md/local/set.sh.m4 | 0 {product => environ.d}/md/port_base.cnf | 0 {product => environ.d}/md/t/01-smoke-00.sh | 0 .../md/t/01-smoke-01-two-instances.sh | 0 {product => environ.d}/ng/local/_exec.m4 | 0 {product => environ.d}/ng/local/curl.sh.m4 | 0 {product => environ.d}/ng/local/nginx.conf.m4 | 0 .../ng/local/print_address.sh.m4 | 0 {product => environ.d}/ng/port_base.cnf | 0 {product => environ.d}/ng/t/01-smoke-00.sh | 0 .../ng/t/01-smoke-01-two-instances.sh | 0 {product => environ.d}/pg/local/backup.sh.m4 | 0 .../pg/local/create_db.sh.m4 | 0 .../pg/local/init_datadir.sh.m4 | 0 .../pg/local/print_dbi.sh.m4 | 0 .../pg/local/replicate.sh.m4 | 0 {product => environ.d}/pg/local/sql.sh.m4 | 0 .../pg/local/sql_loop.sh.m4 | 0 .../pg/local/sql_test.sh.m4 | 0 {product => environ.d}/pg/local/start.sh.m4 | 0 {product => environ.d}/pg/local/status.sh.m4 | 0 {product => environ.d}/pg/local/stop.sh.m4 | 0 {product => environ.d}/pg/t/01-smoke-00.sh | 0 .../pg/t/01-smoke-01-two-instances.sh | 0 .../pg/t/01-smoke-02-default-db.sh | 0 .../pg/t/01-smoke-03-replication.sh | 0 {product => environ.d}/rs/local/_exec.m4 | 0 .../rs/local/configure_dir.sh.m4 | 0 .../rs/local/print_address.sh.m4 | 0 .../rs/local/rsyncd.conf.m4 | 0 {product => environ.d}/rs/port_base.cnf | 0 {product => environ.d}/rs/t/01-smoke-00.sh | 0 .../rs/t/01-smoke-01-two-instances.sh | 0 product/ma/local/build.sh.m4 | 9 ---- 85 files changed, 156 insertions(+), 36 deletions(-) rename {product => environ.d}/ap/local/_exec.m4 (100%) rename {product => environ.d}/ap/local/build.sh.m4 (100%) rename {product => environ.d}/ap/local/configure_add_https.sh.m4 (100%) rename {product => environ.d}/ap/local/configure_ssl.sh.m4 (100%) rename {product => environ.d}/ap/local/curl.sh.m4 (100%) rename {product => environ.d}/ap/local/dir.conf.m4 (100%) rename {product => environ.d}/ap/local/httpd.conf.m4 (100%) rename {product => environ.d}/ap/local/print_address.sh.m4 (100%) rename {product => environ.d}/ap/port_base.cnf (100%) rename {product => environ.d}/ap/t/01-smoke-00.sh (100%) rename {product => environ.d}/ap/t/01-smoke-01-two-instances.sh (100%) rename {product => environ.d}/ap/t/02-ssl-00-only.sh (100%) rename {product => environ.d}/ap/t/02-ssl-01-combined.sh (100%) rename {product => environ.d}/common/_lock.m4 (100%) rename {product => environ.d}/common/start.sh.m4 (100%) rename {product => environ.d}/common/status.sh.m4 (100%) rename {product => environ.d}/common/stop.sh.m4 (100%) rename {product => environ.d}/fk/description.txt (100%) rename {product => environ.d}/fk/local/_exec.m4 (100%) rename {product => environ.d}/fk/port_base.cnf (100%) rename {product => environ.d}/fk/t/01-smoke-00.sh (100%) rename {product => environ.d}/fk/t/01-smoke-01-two-instances.sh (100%) create mode 100644 environ.d/ma/common/build.sh.m4 rename {product/ma/local => environ.d/ma/common}/create_db.sh.m4 (100%) rename {product/ma/local => environ.d/ma/common}/print_dbi.sh.m4 (100%) rename {product/ma/local => environ.d/ma/common}/sql_loop.sh.m4 (100%) rename {product/ma/local => environ.d/ma/common}/sql_test.sh.m4 (100%) create mode 100755 environ.d/ma/detect_type.sh rename {product => environ.d}/ma/local/init_datadir.sh.m4 (100%) rename {product => environ.d}/ma/local/sql.sh.m4 (100%) rename {product => environ.d}/ma/local/start.sh.m4 (100%) rename {product => environ.d}/ma/local/status.sh.m4 (100%) rename {product => environ.d}/ma/local/stop.sh.m4 (100%) create mode 100755 environ.d/ma/t/01-smoke-00-version.sh rename {product => environ.d}/ma/t/01-smoke-00.sh (100%) rename {product => environ.d}/ma/t/01-smoke-01-two-instances.sh (100%) rename {product => environ.d}/ma/t/01-smoke-02-default-db.sh (100%) create mode 100644 environ.d/ma/version/download.sh.m4 create mode 100644 environ.d/ma/version/init_datadir.sh.m4 create mode 100644 environ.d/ma/version/sql.sh.m4 create mode 100644 environ.d/ma/version/start.sh.m4 create mode 100644 environ.d/ma/version/status.sh.m4 create mode 100644 environ.d/ma/version/stop.sh.m4 rename {product => environ.d}/md/local/_exec.m4 (100%) rename {product => environ.d}/md/local/get.sh.m4 (100%) rename {product => environ.d}/md/local/get_test.sh.m4 (100%) rename {product => environ.d}/md/local/print_address.sh.m4 (100%) rename {product => environ.d}/md/local/set.sh.m4 (100%) rename {product => environ.d}/md/port_base.cnf (100%) rename {product => environ.d}/md/t/01-smoke-00.sh (100%) rename {product => environ.d}/md/t/01-smoke-01-two-instances.sh (100%) rename {product => environ.d}/ng/local/_exec.m4 (100%) rename {product => environ.d}/ng/local/curl.sh.m4 (100%) rename {product => environ.d}/ng/local/nginx.conf.m4 (100%) rename {product => environ.d}/ng/local/print_address.sh.m4 (100%) rename {product => environ.d}/ng/port_base.cnf (100%) rename {product => environ.d}/ng/t/01-smoke-00.sh (100%) rename {product => environ.d}/ng/t/01-smoke-01-two-instances.sh (100%) rename {product => environ.d}/pg/local/backup.sh.m4 (100%) rename {product => environ.d}/pg/local/create_db.sh.m4 (100%) rename {product => environ.d}/pg/local/init_datadir.sh.m4 (100%) rename {product => environ.d}/pg/local/print_dbi.sh.m4 (100%) rename {product => environ.d}/pg/local/replicate.sh.m4 (100%) rename {product => environ.d}/pg/local/sql.sh.m4 (100%) rename {product => environ.d}/pg/local/sql_loop.sh.m4 (100%) rename {product => environ.d}/pg/local/sql_test.sh.m4 (100%) rename {product => environ.d}/pg/local/start.sh.m4 (100%) rename {product => environ.d}/pg/local/status.sh.m4 (100%) rename {product => environ.d}/pg/local/stop.sh.m4 (100%) rename {product => environ.d}/pg/t/01-smoke-00.sh (100%) rename {product => environ.d}/pg/t/01-smoke-01-two-instances.sh (100%) rename {product => environ.d}/pg/t/01-smoke-02-default-db.sh (100%) rename {product => environ.d}/pg/t/01-smoke-03-replication.sh (100%) rename {product => environ.d}/rs/local/_exec.m4 (100%) rename {product => environ.d}/rs/local/configure_dir.sh.m4 (100%) rename {product => environ.d}/rs/local/print_address.sh.m4 (100%) rename {product => environ.d}/rs/local/rsyncd.conf.m4 (100%) rename {product => environ.d}/rs/port_base.cnf (100%) rename {product => environ.d}/rs/t/01-smoke-00.sh (100%) rename {product => environ.d}/rs/t/01-smoke-01-two-instances.sh (100%) delete mode 100644 product/ma/local/build.sh.m4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 93fd52c..a5742ab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,13 +10,13 @@ jobs: strategy: matrix: product: - - product/ap - - product/fk - - product/ma - - product/md - - product/ng - - product/pg - - product/rs + - environ.d/ap + - environ.d/fk + - environ.d/ma + - environ.d/md + - environ.d/ng + - environ.d/pg + - envrion.d/rs - '.' steps: - uses: actions/checkout@v2 diff --git a/Makefile b/Makefile index 68c8d9c..dc8db4c 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,11 @@ install: mkdir -p "${DESTDIR}"/usr/bin/ + mkdir -p "${DESTDIR}"/var/opt/environ + chmod 777 "${DESTDIR}"/var/opt/environ install bin/environ "${DESTDIR}"/usr/bin/ install -d -m 0755 "${DESTDIR}"/etc/environ.d/ - cd product && for d in * ; do \ + cd environ.d && for d in * ; do \ mkdir -p "${DESTDIR}"/etc/environ.d/$$d ;\ for f in $$d/*.{m4,cnf} ; do \ test -f $$f && install -m 0644 $$f "${DESTDIR}"/etc/environ.d/$$f ;\ @@ -19,10 +21,10 @@ install: done test: - for f in product/*/t/*.sh ; do bash -x $f && continue; echo FAIL: $f; break; done + for f in environ.d/*/t/*.sh ; do bash -x $f && continue; echo FAIL: $f; break; done test_leap: - for f in product/ap/*/*.sh; do echo starting $f; ENVIRON_TEST_IMAGE=registry.opensuse.org/opensuse/leap $f && continue; echo FAIL $f; break; done + for f in environ.d/ap/*/*.sh; do echo starting $f; ENVIRON_TEST_IMAGE=registry.opensuse.org/opensuse/leap $f && continue; echo FAIL $f; break; done test_tw: - for f in product/ap/*/*.sh; do echo starting $f; ENVIRON_TEST_IMAGE=registry.opensuse.org/opensuse/tumbleweed $f && continue; echo FAIL $f; break; done + for f in environ.d/ap/*/*.sh; do echo starting $f; ENVIRON_TEST_IMAGE=registry.opensuse.org/opensuse/tumbleweed $f && continue; echo FAIL $f; break; done diff --git a/README.txt b/README.txt index 3bbcf22..3f9c824 100644 --- a/README.txt +++ b/README.txt @@ -1,8 +1,3 @@ -#!/bin/bash -[ ! -e environ_env ] || source environ_env - -usage () { - cat <<'HELP_USAGE' Usage: environ [--rebuild 0] [--build 0] [--local 0] [--cachedir <0|path>] \ [--dir ] [-l|--localdir ] [] @@ -24,11 +19,12 @@ environ - generate a folder with helper scripts to manage and automate services --cachedir - use for cache directory location (default is /temp/environ/) --dir - path to templates (default /etc/environ.d/). + -l , --localdir - additional path to templates (default t/lib/environ/). - a service for which scripts will be generated. Currently - supported values are names of folders in --tempatedir parameter (default - /etc/environ/product). may be also followed by a digit if more - than one service is needed. + supported values are names of folders in --tempatedir parameter (default + /etc/environ.d/product). may be also followed by a digit if more + than one service is needed. - if specified, must point to a folder with source codes of the desired product. In this case templates (when available) will actually build the product from source, (unless --build option is set to 0). diff --git a/bin/environ b/bin/environ index 6bcd0a2..d986066 100755 --- a/bin/environ +++ b/bin/environ @@ -27,7 +27,7 @@ environ - generate a folder with helper scripts to manage and automate services --localdir - additional path to templates (default t/lib/environ/). - a service for which scripts will be generated. Currently supported values are names of folders in --tempatedir parameter (default - /etc/environ/product). may be also followed by a digit if more + /etc/environ.d/product). may be also followed by a digit if more than one service is needed. - if specified, must point to a folder with source codes of the desired product. In this case templates (when available) will actually @@ -112,8 +112,8 @@ HELP_USAGE set -euo pipefail : "${ENVIRON_DIR:=/etc/environ.d}" -: "${ENVIRON_LOCAL_DIR:=t/lib/environ}" -: "${ENVIRON_CACHE:=/tmp/environ}" +: "${ENVIRON_LOCAL_DIR:=./environ.d}" +: "${ENVIRON_CACHE:=/var/opt/environ}" : "${ENVIRON_REBUILD:=1}" : "${ENVIRON_BUILD:=1}" : "${ENVIRON_LOCAL:=1}" @@ -212,7 +212,8 @@ rebuild=${ENVIRON_REBUILD} local=${ENVIRON_LOCAL} template=${ENVIRON_DIR} template_local=${ENVIRON_LOCAL_DIR} -type=local +type='' + [ $# -le 1 ] || { type=source srcdir=$2 @@ -221,6 +222,17 @@ type=local [ ! -d "$srcdir"/t/lib/environ ] || [ -d t/lib/environ ] || template_local="$srcdir"/t/lib/environ } +[ -z ${env:4} ] || { + [ ! -e $template_local/$product/detect_type.sh ] || \ + type=$($template_local/$product/detect_type.sh ${1}) + + [ ! -z "$type" ] || [ ! -e $template/$product/detect_type.sh ] || \ + type=$($template/$product/detect_type.sh ${1}) +} + +[ -n "$type" ] || \ + type=local + cleanup_message=0 # try to stop existing environ, if possible if [ -x "$cache/$env/stop" ]; then @@ -294,7 +306,7 @@ else [ ! -f $filename ] || _exec_present=1 done - for filename in {$template,$template_local}/{common,$product/$type}/* ; do + for filename in {$template,$template_local}/{common,$product/common,$product/$type}/* ; do if [ -d $filename ] ; then folder=$filename mkdir -p $workdir/$(basename $folder) @@ -303,21 +315,23 @@ else dst=$workdir/$(basename $folder)/$(basename $src) dst=${dst%.m4} dst=${dst%.sh} - opts="-D__wid=$wid -D__workdir=$workdir/$(basename $folder) -D__datadir=$workdir/$(basename $folder)/dt -D__port=$port -D__user=$USER -D__lockdir=$cache -D__environ=$env -D__libdir=$folder" + opts="-D__wid=$wid -D__workdir=$workdir/$(basename $folder) -D__datadir=$workdir/$(basename $folder)/dt -D__port=$port -D__user=$USER -D__lockdir=$cache -D__cachedir=$cache -D__environ=$env -D__libdir=$folder" if [ $type == source ]; then opts="$opts -D__srcdir=$workdir/src -D__blddir=$workdir/bld -D__installdir=$workdir/install" fi + [ $type != version ] || opts="$opts -D__version=${1:4} -D__bindir=$cache/$product-version/${1:4}/bin" m4 $opts $src > $dst [[ $src != *.sh.m4 ]] || chmod +x "$dst" done else # we skip generating start/stop/status/_lock from common, unless _exec preset [[ ! $filename =~ .*/common/(((start|stop|status).sh)|_lock).m4 ]] || [ "${_exec_present}" == 1 ] || continue - opts="-D__wid=$wid -D__workdir=$workdir -D__datadir=$workdir/dt -D__port=$port -D__user=$USER -D__lockdir=$cache -D__environ=$env -D__libdir=$(dirname $filename)" + opts="-D__wid=$wid -D__workdir=$workdir -D__datadir=$workdir/dt -D__port=$port -D__user=$USER -D__lockdir=$cache -D__cachedir=$cache -D__environ=$env -D__libdir=$(dirname $filename)" if [ $type == source ]; then ln -sfn $srcdir $workdir/src opts="$opts -D__srcdir=$workdir/src -D__blddir=$workdir/bld -D__installdir=$workdir/install" fi + [ $type != version ] || opts="$opts -D__version=${1:4} -D__bindir=$cache/$product-version/${1:4}/bin" [ -f "$filename" ] || continue [ m4 == ${filename//*.} ] || [ "$filename" == .service.lst ] || continue dest=$workdir/$(basename $filename) @@ -345,10 +359,11 @@ else dst=$workdir/${service}/$(basename $src) dst=${dst%.m4} dst=${dst%.sh} - opts="-D__wid=$wid -D__workdir=$workdir -D__datadir=$workdir/dt -D__port=$port -D__user=$USER -D__lockdir=$cache -D__environ=$env" + opts="-D__wid=$wid -D__workdir=$workdir -D__datadir=$workdir/dt -D__port=$port -D__user=$USER -D__lockdir=$cache -D__cachedir=$cache -D__environ=$env" if [ $type == source ]; then opts="$opts -D__srcdir=$workdir/src -D__blddir=$workdir/bld -D__installdir=$workdir/install" fi + [ $type != version ] || opts="$opts -D__version=${1:4} -D__bindir=$cache/$product-version/${1:4}/bin" m4 $opts -D__service=$service $src > $dst [[ $src != *.sh.m4 ]] || chmod +x "$dst" done diff --git a/product/ap/local/_exec.m4 b/environ.d/ap/local/_exec.m4 similarity index 100% rename from product/ap/local/_exec.m4 rename to environ.d/ap/local/_exec.m4 diff --git a/product/ap/local/build.sh.m4 b/environ.d/ap/local/build.sh.m4 similarity index 100% rename from product/ap/local/build.sh.m4 rename to environ.d/ap/local/build.sh.m4 diff --git a/product/ap/local/configure_add_https.sh.m4 b/environ.d/ap/local/configure_add_https.sh.m4 similarity index 100% rename from product/ap/local/configure_add_https.sh.m4 rename to environ.d/ap/local/configure_add_https.sh.m4 diff --git a/product/ap/local/configure_ssl.sh.m4 b/environ.d/ap/local/configure_ssl.sh.m4 similarity index 100% rename from product/ap/local/configure_ssl.sh.m4 rename to environ.d/ap/local/configure_ssl.sh.m4 diff --git a/product/ap/local/curl.sh.m4 b/environ.d/ap/local/curl.sh.m4 similarity index 100% rename from product/ap/local/curl.sh.m4 rename to environ.d/ap/local/curl.sh.m4 diff --git a/product/ap/local/dir.conf.m4 b/environ.d/ap/local/dir.conf.m4 similarity index 100% rename from product/ap/local/dir.conf.m4 rename to environ.d/ap/local/dir.conf.m4 diff --git a/product/ap/local/httpd.conf.m4 b/environ.d/ap/local/httpd.conf.m4 similarity index 100% rename from product/ap/local/httpd.conf.m4 rename to environ.d/ap/local/httpd.conf.m4 diff --git a/product/ap/local/print_address.sh.m4 b/environ.d/ap/local/print_address.sh.m4 similarity index 100% rename from product/ap/local/print_address.sh.m4 rename to environ.d/ap/local/print_address.sh.m4 diff --git a/product/ap/port_base.cnf b/environ.d/ap/port_base.cnf similarity index 100% rename from product/ap/port_base.cnf rename to environ.d/ap/port_base.cnf diff --git a/product/ap/t/01-smoke-00.sh b/environ.d/ap/t/01-smoke-00.sh similarity index 100% rename from product/ap/t/01-smoke-00.sh rename to environ.d/ap/t/01-smoke-00.sh diff --git a/product/ap/t/01-smoke-01-two-instances.sh b/environ.d/ap/t/01-smoke-01-two-instances.sh similarity index 100% rename from product/ap/t/01-smoke-01-two-instances.sh rename to environ.d/ap/t/01-smoke-01-two-instances.sh diff --git a/product/ap/t/02-ssl-00-only.sh b/environ.d/ap/t/02-ssl-00-only.sh similarity index 100% rename from product/ap/t/02-ssl-00-only.sh rename to environ.d/ap/t/02-ssl-00-only.sh diff --git a/product/ap/t/02-ssl-01-combined.sh b/environ.d/ap/t/02-ssl-01-combined.sh similarity index 100% rename from product/ap/t/02-ssl-01-combined.sh rename to environ.d/ap/t/02-ssl-01-combined.sh diff --git a/product/common/_lock.m4 b/environ.d/common/_lock.m4 similarity index 100% rename from product/common/_lock.m4 rename to environ.d/common/_lock.m4 diff --git a/product/common/start.sh.m4 b/environ.d/common/start.sh.m4 similarity index 100% rename from product/common/start.sh.m4 rename to environ.d/common/start.sh.m4 diff --git a/product/common/status.sh.m4 b/environ.d/common/status.sh.m4 similarity index 100% rename from product/common/status.sh.m4 rename to environ.d/common/status.sh.m4 diff --git a/product/common/stop.sh.m4 b/environ.d/common/stop.sh.m4 similarity index 100% rename from product/common/stop.sh.m4 rename to environ.d/common/stop.sh.m4 diff --git a/product/fk/description.txt b/environ.d/fk/description.txt similarity index 100% rename from product/fk/description.txt rename to environ.d/fk/description.txt diff --git a/product/fk/local/_exec.m4 b/environ.d/fk/local/_exec.m4 similarity index 100% rename from product/fk/local/_exec.m4 rename to environ.d/fk/local/_exec.m4 diff --git a/product/fk/port_base.cnf b/environ.d/fk/port_base.cnf similarity index 100% rename from product/fk/port_base.cnf rename to environ.d/fk/port_base.cnf diff --git a/product/fk/t/01-smoke-00.sh b/environ.d/fk/t/01-smoke-00.sh similarity index 100% rename from product/fk/t/01-smoke-00.sh rename to environ.d/fk/t/01-smoke-00.sh diff --git a/product/fk/t/01-smoke-01-two-instances.sh b/environ.d/fk/t/01-smoke-01-two-instances.sh similarity index 100% rename from product/fk/t/01-smoke-01-two-instances.sh rename to environ.d/fk/t/01-smoke-01-two-instances.sh diff --git a/environ.d/ma/common/build.sh.m4 b/environ.d/ma/common/build.sh.m4 new file mode 100644 index 0000000..9df1e9d --- /dev/null +++ b/environ.d/ma/common/build.sh.m4 @@ -0,0 +1 @@ +[ -d __datadir ] || mkdir __datadir diff --git a/product/ma/local/create_db.sh.m4 b/environ.d/ma/common/create_db.sh.m4 similarity index 100% rename from product/ma/local/create_db.sh.m4 rename to environ.d/ma/common/create_db.sh.m4 diff --git a/product/ma/local/print_dbi.sh.m4 b/environ.d/ma/common/print_dbi.sh.m4 similarity index 100% rename from product/ma/local/print_dbi.sh.m4 rename to environ.d/ma/common/print_dbi.sh.m4 diff --git a/product/ma/local/sql_loop.sh.m4 b/environ.d/ma/common/sql_loop.sh.m4 similarity index 100% rename from product/ma/local/sql_loop.sh.m4 rename to environ.d/ma/common/sql_loop.sh.m4 diff --git a/product/ma/local/sql_test.sh.m4 b/environ.d/ma/common/sql_test.sh.m4 similarity index 100% rename from product/ma/local/sql_test.sh.m4 rename to environ.d/ma/common/sql_test.sh.m4 diff --git a/environ.d/ma/detect_type.sh b/environ.d/ma/detect_type.sh new file mode 100755 index 0000000..dcf26f5 --- /dev/null +++ b/environ.d/ma/detect_type.sh @@ -0,0 +1 @@ +echo version diff --git a/product/ma/local/init_datadir.sh.m4 b/environ.d/ma/local/init_datadir.sh.m4 similarity index 100% rename from product/ma/local/init_datadir.sh.m4 rename to environ.d/ma/local/init_datadir.sh.m4 diff --git a/product/ma/local/sql.sh.m4 b/environ.d/ma/local/sql.sh.m4 similarity index 100% rename from product/ma/local/sql.sh.m4 rename to environ.d/ma/local/sql.sh.m4 diff --git a/product/ma/local/start.sh.m4 b/environ.d/ma/local/start.sh.m4 similarity index 100% rename from product/ma/local/start.sh.m4 rename to environ.d/ma/local/start.sh.m4 diff --git a/product/ma/local/status.sh.m4 b/environ.d/ma/local/status.sh.m4 similarity index 100% rename from product/ma/local/status.sh.m4 rename to environ.d/ma/local/status.sh.m4 diff --git a/product/ma/local/stop.sh.m4 b/environ.d/ma/local/stop.sh.m4 similarity index 100% rename from product/ma/local/stop.sh.m4 rename to environ.d/ma/local/stop.sh.m4 diff --git a/environ.d/ma/t/01-smoke-00-version.sh b/environ.d/ma/t/01-smoke-00-version.sh new file mode 100755 index 0000000..7d5c825 --- /dev/null +++ b/environ.d/ma/t/01-smoke-00-version.sh @@ -0,0 +1,29 @@ +#!t/lib/test-in-image.sh mariadb-server +set -euo pipefail +ma=$(environ ma9-10.10.2) + +$ma/download + +$ma/start +$ma/status + +$ma/create_db tst +$ma/sql_tst "create table t1 as select 'x1'" + +test x1 == $($ma/sql --batch -Ne "select * from t1" tst) +test x1 == $($ma/sql_tst "select * from t1") + +$ma/sql_test x1 == "select * from t1" +$ma/sql_test x2 != "select * from t1" + +rc=0 +$ma/sql_test x2 == "select * from t1" || rc=$? +test $rc -gt 0 + +$ma/stop + +rc=0 +$ma/status || rc=$? + +test $rc -gt 0 +echo PASS $0 diff --git a/product/ma/t/01-smoke-00.sh b/environ.d/ma/t/01-smoke-00.sh similarity index 100% rename from product/ma/t/01-smoke-00.sh rename to environ.d/ma/t/01-smoke-00.sh diff --git a/product/ma/t/01-smoke-01-two-instances.sh b/environ.d/ma/t/01-smoke-01-two-instances.sh similarity index 100% rename from product/ma/t/01-smoke-01-two-instances.sh rename to environ.d/ma/t/01-smoke-01-two-instances.sh diff --git a/product/ma/t/01-smoke-02-default-db.sh b/environ.d/ma/t/01-smoke-02-default-db.sh similarity index 100% rename from product/ma/t/01-smoke-02-default-db.sh rename to environ.d/ma/t/01-smoke-02-default-db.sh diff --git a/environ.d/ma/version/download.sh.m4 b/environ.d/ma/version/download.sh.m4 new file mode 100644 index 0000000..6ec7998 --- /dev/null +++ b/environ.d/ma/version/download.sh.m4 @@ -0,0 +1,46 @@ +set -e + +# $eatmydata mysql_install_db --no-defaults --data=__datadir --log-error=__workdir/.install | head -n 3 + +# example url ftp://ftp.hosteurope.de/mirror/archive.mariadb.org/mariadb-__version/bintar-linux-x86_64/mariadb-__version-linux-x86_64.tar.gz +# + +file=ftp://ftp.hosteurope.de/mirror/archive.mariadb.org/mariadb-__version/bintar-linux-systemd-x86_64/mariadb-__version-linux-systemd-x86_64.tar.gz + +file1=http://mirrors.dotsrc.org/mariadb/mariadb-__version/bintar-linux-systemd-x86_64/mariadb-__version-linux-systemd-x86_64.tar.gz + +mkdir -p __cachedir/ma-version/__version + +( +cd __cachedir/ma-version/__version + +function cleanup { + [ -z "$wgetpid" ] || kill "$wgetpid" 2>/dev/null +} + +trap cleanup INT TERM + +if [ ! -f "$(basename $file)" ] ; then + echo downloading "$file" + ( wget -q -np -nc "$file" || wget -q -np -nc "$file1" )& + wgetpid=$! + while kill -0 $wgetpid 2>/dev/null ; do + sleep 10 + echo -n . + done + res=0 + wait $wgetpid || res=$? + wgetpid="" + if [ "$res" -ne 0 ] ; then + >&2 echo "failed to download '$file1' ($res)" + exit $res + fi +fi + +if [ -f "$(basename $file)" ] ; then + if [ ! -x bin/mysqld ] ; then + tar -zxf "$(basename $file)" ${ERN_M_TAR_EXTRA_FLAGS} --strip 1 + fi +fi +) +: diff --git a/environ.d/ma/version/init_datadir.sh.m4 b/environ.d/ma/version/init_datadir.sh.m4 new file mode 100644 index 0000000..37939df --- /dev/null +++ b/environ.d/ma/version/init_datadir.sh.m4 @@ -0,0 +1,6 @@ +set -e +[ -d __datadir ] || mkdir __datadir + +eatmydata=$(which eatmydata 2>/dev/null) || : + +$eatmydata __bindir/../scripts/mysql_install_db --no-defaults --data=__datadir --log-error=__workdir/.install | head -n 3 diff --git a/environ.d/ma/version/sql.sh.m4 b/environ.d/ma/version/sql.sh.m4 new file mode 100644 index 0000000..b15132a --- /dev/null +++ b/environ.d/ma/version/sql.sh.m4 @@ -0,0 +1,22 @@ +if [[ $1 == -* ]] ; then +__bindir/mysql --batch --socket=__workdir/.sock "$@" +elif [ -z "$2" ]; then + if [ "$(basename $0)" == sql ]; then + if [ -f __workdir/default_db.cnf ] && [ "$#" == 1 ]; then + __bindir/mysql "$(cat __workdir/default_db.cnf)" --batch --socket=__workdir/.sock -Ne "$*" + else + __bindir/mysql --batch --socket=__workdir/.sock -Ne "$*" + fi + else + db=${0#*_} + if [ "$#" == 0 ]; then + __bindir/mysql "$db" --socket=__workdir/.sock + else + __bindir/mysql $db --socket=__workdir/.sock --batch -Ne "$@" + fi + fi +else +db=$1 +shift +__bindir/mysql "$db" --batch --socket=__workdir/.sock -Ne "$@" +fi diff --git a/environ.d/ma/version/start.sh.m4 b/environ.d/ma/version/start.sh.m4 new file mode 100644 index 0000000..38e5ef2 --- /dev/null +++ b/environ.d/ma/version/start.sh.m4 @@ -0,0 +1,9 @@ +set -e +[ -d __workdir/dt ] || mkdir __workdir/dt +[ -f __datadir/ibdata1 ] || __workdir/init_datadir + +__bindir/mariadbd --datadir=__datadir --user=$USER --socket=__workdir/.sock --skip-networking --log-error=__workdir/.cerr --pid-file=__workdir/.pid "$@" & + +sleep 1 +__workdir/status >& /dev/null || sleep 1 +__workdir/status >& /dev/null || sleep 1 diff --git a/environ.d/ma/version/status.sh.m4 b/environ.d/ma/version/status.sh.m4 new file mode 100644 index 0000000..e0e28c0 --- /dev/null +++ b/environ.d/ma/version/status.sh.m4 @@ -0,0 +1 @@ +__bindir/mysqladmin --socket=__workdir/.sock status diff --git a/environ.d/ma/version/stop.sh.m4 b/environ.d/ma/version/stop.sh.m4 new file mode 100644 index 0000000..d70c2fb --- /dev/null +++ b/environ.d/ma/version/stop.sh.m4 @@ -0,0 +1 @@ +__bindir/mysqladmin --socket=__workdir/.sock shutdown diff --git a/product/md/local/_exec.m4 b/environ.d/md/local/_exec.m4 similarity index 100% rename from product/md/local/_exec.m4 rename to environ.d/md/local/_exec.m4 diff --git a/product/md/local/get.sh.m4 b/environ.d/md/local/get.sh.m4 similarity index 100% rename from product/md/local/get.sh.m4 rename to environ.d/md/local/get.sh.m4 diff --git a/product/md/local/get_test.sh.m4 b/environ.d/md/local/get_test.sh.m4 similarity index 100% rename from product/md/local/get_test.sh.m4 rename to environ.d/md/local/get_test.sh.m4 diff --git a/product/md/local/print_address.sh.m4 b/environ.d/md/local/print_address.sh.m4 similarity index 100% rename from product/md/local/print_address.sh.m4 rename to environ.d/md/local/print_address.sh.m4 diff --git a/product/md/local/set.sh.m4 b/environ.d/md/local/set.sh.m4 similarity index 100% rename from product/md/local/set.sh.m4 rename to environ.d/md/local/set.sh.m4 diff --git a/product/md/port_base.cnf b/environ.d/md/port_base.cnf similarity index 100% rename from product/md/port_base.cnf rename to environ.d/md/port_base.cnf diff --git a/product/md/t/01-smoke-00.sh b/environ.d/md/t/01-smoke-00.sh similarity index 100% rename from product/md/t/01-smoke-00.sh rename to environ.d/md/t/01-smoke-00.sh diff --git a/product/md/t/01-smoke-01-two-instances.sh b/environ.d/md/t/01-smoke-01-two-instances.sh similarity index 100% rename from product/md/t/01-smoke-01-two-instances.sh rename to environ.d/md/t/01-smoke-01-two-instances.sh diff --git a/product/ng/local/_exec.m4 b/environ.d/ng/local/_exec.m4 similarity index 100% rename from product/ng/local/_exec.m4 rename to environ.d/ng/local/_exec.m4 diff --git a/product/ng/local/curl.sh.m4 b/environ.d/ng/local/curl.sh.m4 similarity index 100% rename from product/ng/local/curl.sh.m4 rename to environ.d/ng/local/curl.sh.m4 diff --git a/product/ng/local/nginx.conf.m4 b/environ.d/ng/local/nginx.conf.m4 similarity index 100% rename from product/ng/local/nginx.conf.m4 rename to environ.d/ng/local/nginx.conf.m4 diff --git a/product/ng/local/print_address.sh.m4 b/environ.d/ng/local/print_address.sh.m4 similarity index 100% rename from product/ng/local/print_address.sh.m4 rename to environ.d/ng/local/print_address.sh.m4 diff --git a/product/ng/port_base.cnf b/environ.d/ng/port_base.cnf similarity index 100% rename from product/ng/port_base.cnf rename to environ.d/ng/port_base.cnf diff --git a/product/ng/t/01-smoke-00.sh b/environ.d/ng/t/01-smoke-00.sh similarity index 100% rename from product/ng/t/01-smoke-00.sh rename to environ.d/ng/t/01-smoke-00.sh diff --git a/product/ng/t/01-smoke-01-two-instances.sh b/environ.d/ng/t/01-smoke-01-two-instances.sh similarity index 100% rename from product/ng/t/01-smoke-01-two-instances.sh rename to environ.d/ng/t/01-smoke-01-two-instances.sh diff --git a/product/pg/local/backup.sh.m4 b/environ.d/pg/local/backup.sh.m4 similarity index 100% rename from product/pg/local/backup.sh.m4 rename to environ.d/pg/local/backup.sh.m4 diff --git a/product/pg/local/create_db.sh.m4 b/environ.d/pg/local/create_db.sh.m4 similarity index 100% rename from product/pg/local/create_db.sh.m4 rename to environ.d/pg/local/create_db.sh.m4 diff --git a/product/pg/local/init_datadir.sh.m4 b/environ.d/pg/local/init_datadir.sh.m4 similarity index 100% rename from product/pg/local/init_datadir.sh.m4 rename to environ.d/pg/local/init_datadir.sh.m4 diff --git a/product/pg/local/print_dbi.sh.m4 b/environ.d/pg/local/print_dbi.sh.m4 similarity index 100% rename from product/pg/local/print_dbi.sh.m4 rename to environ.d/pg/local/print_dbi.sh.m4 diff --git a/product/pg/local/replicate.sh.m4 b/environ.d/pg/local/replicate.sh.m4 similarity index 100% rename from product/pg/local/replicate.sh.m4 rename to environ.d/pg/local/replicate.sh.m4 diff --git a/product/pg/local/sql.sh.m4 b/environ.d/pg/local/sql.sh.m4 similarity index 100% rename from product/pg/local/sql.sh.m4 rename to environ.d/pg/local/sql.sh.m4 diff --git a/product/pg/local/sql_loop.sh.m4 b/environ.d/pg/local/sql_loop.sh.m4 similarity index 100% rename from product/pg/local/sql_loop.sh.m4 rename to environ.d/pg/local/sql_loop.sh.m4 diff --git a/product/pg/local/sql_test.sh.m4 b/environ.d/pg/local/sql_test.sh.m4 similarity index 100% rename from product/pg/local/sql_test.sh.m4 rename to environ.d/pg/local/sql_test.sh.m4 diff --git a/product/pg/local/start.sh.m4 b/environ.d/pg/local/start.sh.m4 similarity index 100% rename from product/pg/local/start.sh.m4 rename to environ.d/pg/local/start.sh.m4 diff --git a/product/pg/local/status.sh.m4 b/environ.d/pg/local/status.sh.m4 similarity index 100% rename from product/pg/local/status.sh.m4 rename to environ.d/pg/local/status.sh.m4 diff --git a/product/pg/local/stop.sh.m4 b/environ.d/pg/local/stop.sh.m4 similarity index 100% rename from product/pg/local/stop.sh.m4 rename to environ.d/pg/local/stop.sh.m4 diff --git a/product/pg/t/01-smoke-00.sh b/environ.d/pg/t/01-smoke-00.sh similarity index 100% rename from product/pg/t/01-smoke-00.sh rename to environ.d/pg/t/01-smoke-00.sh diff --git a/product/pg/t/01-smoke-01-two-instances.sh b/environ.d/pg/t/01-smoke-01-two-instances.sh similarity index 100% rename from product/pg/t/01-smoke-01-two-instances.sh rename to environ.d/pg/t/01-smoke-01-two-instances.sh diff --git a/product/pg/t/01-smoke-02-default-db.sh b/environ.d/pg/t/01-smoke-02-default-db.sh similarity index 100% rename from product/pg/t/01-smoke-02-default-db.sh rename to environ.d/pg/t/01-smoke-02-default-db.sh diff --git a/product/pg/t/01-smoke-03-replication.sh b/environ.d/pg/t/01-smoke-03-replication.sh similarity index 100% rename from product/pg/t/01-smoke-03-replication.sh rename to environ.d/pg/t/01-smoke-03-replication.sh diff --git a/product/rs/local/_exec.m4 b/environ.d/rs/local/_exec.m4 similarity index 100% rename from product/rs/local/_exec.m4 rename to environ.d/rs/local/_exec.m4 diff --git a/product/rs/local/configure_dir.sh.m4 b/environ.d/rs/local/configure_dir.sh.m4 similarity index 100% rename from product/rs/local/configure_dir.sh.m4 rename to environ.d/rs/local/configure_dir.sh.m4 diff --git a/product/rs/local/print_address.sh.m4 b/environ.d/rs/local/print_address.sh.m4 similarity index 100% rename from product/rs/local/print_address.sh.m4 rename to environ.d/rs/local/print_address.sh.m4 diff --git a/product/rs/local/rsyncd.conf.m4 b/environ.d/rs/local/rsyncd.conf.m4 similarity index 100% rename from product/rs/local/rsyncd.conf.m4 rename to environ.d/rs/local/rsyncd.conf.m4 diff --git a/product/rs/port_base.cnf b/environ.d/rs/port_base.cnf similarity index 100% rename from product/rs/port_base.cnf rename to environ.d/rs/port_base.cnf diff --git a/product/rs/t/01-smoke-00.sh b/environ.d/rs/t/01-smoke-00.sh similarity index 100% rename from product/rs/t/01-smoke-00.sh rename to environ.d/rs/t/01-smoke-00.sh diff --git a/product/rs/t/01-smoke-01-two-instances.sh b/environ.d/rs/t/01-smoke-01-two-instances.sh similarity index 100% rename from product/rs/t/01-smoke-01-two-instances.sh rename to environ.d/rs/t/01-smoke-01-two-instances.sh diff --git a/product/ma/local/build.sh.m4 b/product/ma/local/build.sh.m4 deleted file mode 100644 index 3438ad4..0000000 --- a/product/ma/local/build.sh.m4 +++ /dev/null @@ -1,9 +0,0 @@ -[ -d __datadir ] || mkdir __datadir - -# initdb --auth-local=peer -N __datadir -U "__user" >/dev/null - -# echo "listen_addresses=''" >> __datadir/postgresql.conf -# echo "unix_socket_directories='__datadir'" >> __datadir/postgresql.conf -# echo "fsync=off" >> __datadir/postgresql.conf -# echo "full_page_writes=off" >> __datadir/postgresql.conf -# sed -i "s/`#'log_statement = 'none'/log_statement = 'all'/" __datadir/postgresql.conf