linux server installer quickfix

This commit is contained in:
onysd 2026-09-13 02:02:19 +03:00
parent 22b308483d
commit e4debd6b7d
2 changed files with 28 additions and 6 deletions

View file

@ -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 # because the newgrp branch below runs this after `exec`, and exec takes no
# assignment prefix -- it would look for a command called # assignment prefix -- it would look for a command called
# "OWPENGRAM_SG_DOCKER=1". # "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 if command -v sg >/dev/null 2>&1; then
echo "[..] Applying your new 'docker' group membership for this run" echo "[..] Applying your new 'docker' group membership for this run"
exec sg docker -c "$RELAUNCH" 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" echo "[..] Applying your new 'docker' group membership for this run"
exec newgrp docker <<< "exec ${RELAUNCH} < /dev/tty" exec newgrp docker <<< "exec ${RELAUNCH} < /dev/tty"
fi fi
# Neither helper is guaranteed: Arch has no sg at all, and Ubuntu moved it # Neither helper is guaranteed: Arch has no sg at all, Debian moved it into
# into util-linux-extra. Logging out is the one instruction that always # util-linux-extra, and recent Ubuntu images were seen shipping neither it
# works, so lead with it and only mention newgrp when it is actually there. # 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 echo
if command -v newgrp >/dev/null 2>&1; then 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 -- die "you were added to the 'docker' group, but this shell still has the old one --

View file

@ -293,6 +293,16 @@ if needs docker; then
if [[ $EUID -ne 0 ]] && ! id -nG "$USER" | tr ' ' '\n' | grep -qx docker; then if [[ $EUID -ne 0 ]] && ! id -nG "$USER" | tr ' ' '\n' | grep -qx docker; then
$SUDO usermod -aG docker "$USER" $SUDO usermod -aG docker "$USER"
DOCKER_NEEDS_RELOGIN=1 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 fi
ok "Docker installed: $(docker --version)" ok "Docker installed: $(docker --version)"
fi fi
@ -336,7 +346,7 @@ if [[ "$GO_NEEDS_NEW_SHELL" -eq 1 ]]; then
fi fi
if [[ "$DOCKER_NEEDS_RELOGIN" -eq 1 ]]; then if [[ "$DOCKER_NEEDS_RELOGIN" -eq 1 ]]; then
echo " You were added to the 'docker' group. Already-running shells keep the" 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 " old one -- owpengram-server.sh re-enters itself so this run works"
echo " run works anyway, but log out and back in before using docker elsewhere." echo " anyway, but log out and back in before using docker elsewhere."
fi fi
echo " Then start the server with: ./owpengram-server.sh" echo " Then start the server with: ./owpengram-server.sh"