diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-11-23 16:37:52 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-11-23 16:37:52 +0100 |
commit | 28ba79385cd1b80a99629d35bd535adc5f817497 (patch) | |
tree | 4ab3a4a3d738887120be604f66a100b6453b224f | |
parent | 19168e8f7447183aa9bb57f8a961396765d2bd74 (diff) | |
download | koszko-org-server-28ba79385cd1b80a99629d35bd535adc5f817497.tar.gz koszko-org-server-28ba79385cd1b80a99629d35bd535adc5f817497.zip |
do little refactoring to the way host system testing directories are prepared and passed to `guix-container.sh`
-rw-r--r-- | Makefile | 30 | ||||
-rwxr-xr-x | guix-container.sh | 16 |
2 files changed, 19 insertions, 27 deletions
@@ -28,10 +28,6 @@ HYDRILLA_WEBSITE_INFO = \ subrepos/hydrilla-website/src/hydrilla_website.egg-info/PKG-INFO TEST_ROOT_DIR = "/tmp/$$(pwd | sed 's|/|!|g')!!test-root" -TEST_WWW_DIR=$(TEST_ROOT_DIR)/var/www -TEST_ALL_LOGS_DIR = $(TEST_ROOT_DIR)/var/log -TEST_LOG_DIR = $(TEST_ALL_LOGS_DIR)/guix-container -TEST_ETC_DIR = $(TEST_ROOT_DIR)/etc/guix-container all: | container-runner.touchfile log @@ -56,26 +52,24 @@ hosts: hosts-extra /etc/hosts cat $^ > $@ log: - ln -sf $(TEST_LOG_DIR) $@ + ln -sf $(TEST_ROOT_DIR)/var/log/guix-container $@ + +HYDRILLA_WEBSITE_ETC_DIR = $(TEST_ROOT_DIR)/etc/guix-container/hydrilla-website prepare-test-root: rm -rf $(TEST_ROOT_DIR) @# Prepare replacement `/var/www` - mkdir -p $(TEST_WWW_DIR)/koszko.org/html - printf ':D\n' > $(TEST_WWW_DIR)/koszko.org/html/index.html + mkdir -p $(TEST_ROOT_DIR)/var/www/koszko.org/html + printf ':D\n' > $(TEST_ROOT_DIR)/var/www/koszko.org/html/index.html @# Prepare replacement `/var/log` - mkdir -p $(TEST_ALL_LOGS_DIR) + mkdir -p $(TEST_ROOT_DIR)/var/log @# Prepare replacement `/etc` - mkdir --mode=750 -p $(TEST_ETC_DIR)/hydrilla-website - printf 'test non-secret\n' > $(TEST_ETC_DIR)/hydrilla-website/secret.txt - chgrp -R 133 $(TEST_ETC_DIR)/hydrilla-website - chmod 640 $(TEST_ETC_DIR)/hydrilla-website/secret.txt - -GUIX_CONTAINER_FLAGS = \ - -e ./container-runner -p ./pidfile \ - -l $(TEST_LOG_DIR) \ - -w $(TEST_WWW_DIR) \ - -t $(TEST_ETC_DIR) + mkdir --mode=750 -p $(HYDRILLA_WEBSITE_ETC_DIR) + printf 'test non-secret\n' > $(HYDRILLA_WEBSITE_ETC_DIR)/secret.txt + chgrp -R 133 $(HYDRILLA_WEBSITE_ETC_DIR) + chmod 640 $(HYDRILLA_WEBSITE_ETC_DIR)/secret.txt + +GUIX_CONTAINER_FLAGS = -e ./container-runner -p ./pidfile -r $(TEST_ROOT_DIR) start-container: guix-container.sh container-runner.touchfile \ prepare-test-root | log diff --git a/guix-container.sh b/guix-container.sh index 064d4c9..afede73 100755 --- a/guix-container.sh +++ b/guix-container.sh @@ -26,22 +26,18 @@ fi PIDFILE=/run/guix-container.pid EXECUTABLE=/usr/local/bin/guix-container -WWW_DIR=/var/www -LOG_DIR=/var/log/guix-container -ETC_DIR=/etc/guix-container +HOST_SYSTEM_ROOT= MAX_CONTAINER_SPINUP_WAIT=60 ACTION="$1" shift OPTIND=1 -while getopts p:e:w:l:t:s: OPTION_LETTER ; do +while getopts p:e:r:s: OPTION_LETTER ; do case "$OPTION_LETTER" in p) PIDFILE="$OPTARG" ;; e) EXECUTABLE="$OPTARG" ;; - w) WWW_DIR="$OPTARG" ;; - l) LOG_DIR="$OPTARG" ;; - t) ETC_DIR="$OPTARG" ;; + r) HOST_SYSTEM_ROOT="$OPTARG" ;; s) MAX_CONTAINER_SPINUP_WAIT="$OPTARG" ;; esac done @@ -83,9 +79,11 @@ onexit() { } start() { - KOSZKO_SIDELOAD_REAL="$WWW_DIR"/koszko.org/html + LOG_DIR="$HOST_SYSTEM_ROOT"/var/log/guix-container + + KOSZKO_SIDELOAD_REAL="$HOST_SYSTEM_ROOT"/var/www/koszko.org/html LOG_REAL="$LOG_DIR"/container - ETC_REAL="$ETC_DIR" + ETC_REAL="$HOST_SYSTEM_ROOT"/etc/guix-container HTTP_DIR_SHARE_OPT=--share="$KOSZKO_SIDELOAD_REAL"=/srv/http/koszko.org LOG_DIR_SHARE_OPT=--share="$LOG_REAL"=/var/log |