aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile12
-rwxr-xr-xguix-container.sh9
-rwxr-xr-xrun-with-fake-mounts.sh7
4 files changed, 21 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index dd17935..fcd3471 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,7 +5,7 @@
# Available under the terms of Creative Commons Zero v1.0 Universal.
container-runner
-log/
+log
pidfile
hosts
*.touchfile
diff --git a/Makefile b/Makefile
index 2b179a2..9c02eec 100644
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,8 @@ GUIX_SHELL = $(GUIX_TM) shell
KOSZKO_ORG_WEBSITE_INFO = \
subrepos/koszko-org-website/src/koszko_org_website.egg-info/PKG-INFO
+LOGDIR = "/tmp/$$(pwd | sed 's|/|!|g')!log"
+
all: | container-runner.touchfile log
$(KOSZKO_ORG_WEBSITE_INFO):
@@ -43,18 +45,18 @@ hosts: hosts-extra /etc/hosts
cat $^ > $@
log:
- mkdir -p log
+ ln -sf $(LOGDIR) $@
start-container: guix-container.sh container-runner.touchfile | log
- unshare --mount ./run-with-fake-mounts.sh \
- ./$< start -e ./container-runner -p ./pidfile -l ./log
+ unshare --mount ./run-with-fake-mounts.sh $(LOGDIR) \
+ ./$< start -e ./container-runner -p ./pidfile -l $(LOGDIR)
stop-container: guix-container.sh
./$< stop -e ./container-runner -p ./pidfile
restart-container: guix-container.sh container-runner.touchfile | log
- unshare --mount ./run-with-fake-mounts.sh \
- ./$< restart -e ./container-runner -p ./pidfile -l ./log
+ unshare --mount ./run-with-fake-mounts.sh $(LOGDIR) \
+ ./$< restart -e ./container-runner -p ./pidfile -l $(LOGDIR)
enter-container: pidfile
nsenter -a -t "$$(cat pidfile)" \
diff --git a/guix-container.sh b/guix-container.sh
index 2430d8a..9218a54 100755
--- a/guix-container.sh
+++ b/guix-container.sh
@@ -81,14 +81,17 @@ onexit() {
start() {
KOSZKO_SIDELOAD_REAL=/var/www/koszko.org/html
KOSZKO_SIDELOAD_INSIDE=/srv/http/koszko.org
+ LOG_REAL="$LOG_DIR"/container
+ LOG_INSIDE=/var/log
HTTP_DIR_SHARE_OPT=--share="$KOSZKO_SIDELOAD_REAL"="$KOSZKO_SIDELOAD_INSIDE"
+ LOG_DIR_SHARE_OPT=--share="$LOG_REAL"="$LOG_INSIDE"
mkdir -p "$(dirname "$LOG_DIR")"
mkdir --mode=700 -p "$LOG_DIR"
+ mkdir --mode=700 -p "$LOG_DIR"/container
- "$EXECUTABLE" $HTTP_DIR_SHARE_OPT \
- >> "$LOG_DIR"/stdout.log \
- 2>> "$LOG_DIR"/stderr.log &
+ "$EXECUTABLE" "$HTTP_DIR_SHARE_OPT" "$LOG_DIR_SHARE_OPT" \
+ >> "$LOG_DIR"/stdout.log 2>> "$LOG_DIR"/stderr.log &
GUILE_PID=$!
WAIT_TIME=0
diff --git a/run-with-fake-mounts.sh b/run-with-fake-mounts.sh
index 75675ed..57b3078 100755
--- a/run-with-fake-mounts.sh
+++ b/run-with-fake-mounts.sh
@@ -8,10 +8,17 @@
set -e
+LOGDIR="$1"
+
+shift
+
mkdir -p /var/www
mount -t tmpfs dummy /var/www
mkdir -p /var/www/koszko.org/html
+rm -rf "$LOGDIR"
+mkdir -p "$LOGDIR"
+
printf ':D\n' > /var/www/koszko.org/html/index.html
"$@"