From e4debd6b7dac71bcda05d24f7fda633fefa517fd Mon Sep 17 00:00:00 2001 From: onysd Date: Sun, 13 Sep 2026 02:02:19 +0300 Subject: [PATCH] linux server installer quickfix --- owpengram-server.sh | 20 ++++++++++++++++---- scripts/install-prereqs.sh | 14 ++++++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/owpengram-server.sh b/owpengram-server.sh index 10c7f302..a3f41aee 100755 --- a/owpengram-server.sh +++ b/owpengram-server.sh @@ -128,7 +128,10 @@ if [[ -z "${OWPENGRAM_SG_DOCKER:-}" && $EUID -ne 0 ]] && command -v docker >/dev # because the newgrp branch below runs this after `exec`, and exec takes no # assignment prefix -- it would look for a command called # "OWPENGRAM_SG_DOCKER=1". - RELAUNCH="$(printf '%q ' env OWPENGRAM_SG_DOCKER=1 "$0" "$@")" + # Absolute: this script cd'd to its own directory at the top, so a relative + # $0 that carried a directory component no longer resolves from here. + SELF="$PWD/$(basename "$0")" + RELAUNCH="$(printf '%q ' env OWPENGRAM_SG_DOCKER=1 "$SELF" "$@")" if command -v sg >/dev/null 2>&1; then echo "[..] Applying your new 'docker' group membership for this run" exec sg docker -c "$RELAUNCH" @@ -141,9 +144,18 @@ if [[ -z "${OWPENGRAM_SG_DOCKER:-}" && $EUID -ne 0 ]] && command -v docker >/dev echo "[..] Applying your new 'docker' group membership for this run" exec newgrp docker <<< "exec ${RELAUNCH} < /dev/tty" fi - # Neither helper is guaranteed: Arch has no sg at all, and Ubuntu moved it - # into util-linux-extra. Logging out is the one instruction that always - # works, so lead with it and only mention newgrp when it is actually there. + # Neither helper is guaranteed: Arch has no sg at all, Debian moved it into + # util-linux-extra, and recent Ubuntu images were seen shipping neither it + # nor newgrp. sudo is the one thing that is certainly here by now -- the + # installer just used it to install Docker -- and `sudo -g` sets the group + # directly, with no login shell and no extra package. Last rather than first + # because it can prompt for a password, which sg and newgrp do not. + if command -v sudo >/dev/null 2>&1; then + echo "[..] Applying your new 'docker' group membership for this run" + exec sudo -u "$USER" -g docker env OWPENGRAM_SG_DOCKER=1 \ + PATH="$PATH" "$SELF" "$@" + fi + # Nothing left to try: logging out is the one instruction that always works. echo if command -v newgrp >/dev/null 2>&1; then die "you were added to the 'docker' group, but this shell still has the old one -- diff --git a/scripts/install-prereqs.sh b/scripts/install-prereqs.sh index 3c050ca6..6938135e 100755 --- a/scripts/install-prereqs.sh +++ b/scripts/install-prereqs.sh @@ -293,6 +293,16 @@ if needs docker; then if [[ $EUID -ne 0 ]] && ! id -nG "$USER" | tr ' ' '\n' | grep -qx docker; then $SUDO usermod -aG docker "$USER" DOCKER_NEEDS_RELOGIN=1 + # The new group only reaches a *new* login, so owpengram-server.sh re-enters + # itself with `sg docker` to make this run work without one. Debian split sg + # out of util-linux into util-linux-extra, and recent Ubuntu images ship + # neither it nor newgrp -- on those the launcher had no way back in and could + # only tell the user to log out. Pulling it in here is the difference between + # install-then-start working in one go and not. + if [[ "$FAMILY" == "debian" ]] && ! have sg; then + info "Installing util-linux-extra (provides sg)" + pkg_install util-linux-extra || warn "could not install util-linux-extra" + fi fi ok "Docker installed: $(docker --version)" fi @@ -336,7 +346,7 @@ if [[ "$GO_NEEDS_NEW_SHELL" -eq 1 ]]; then fi if [[ "$DOCKER_NEEDS_RELOGIN" -eq 1 ]]; then echo " You were added to the 'docker' group. Already-running shells keep the" - echo " old one -- owpengram-server.sh re-enters itself with 'sg docker' so this" - echo " run works anyway, but log out and back in before using docker elsewhere." + echo " old one -- owpengram-server.sh re-enters itself so this run works" + echo " anyway, but log out and back in before using docker elsewhere." fi echo " Then start the server with: ./owpengram-server.sh"