Skip to content

Commit 2393940

Browse files
committed
fix: optimise installer for edge cases
in Go container, `sudo ./build.sh --install` fails to inherit environment variables and can't find Go installation. `sudo` must be omitted in that case.
1 parent 0d66812 commit 2393940

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

core/build.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ do_install() {
412412
# set capabilities for cc and setup wireguard runtime dir
413413
setcap cap_net_admin=eip "$data_dir/emp3r0r-cc" || error "setcap"
414414
mkdir -p /var/run/wireguard || error "mkdir wireguard"
415-
chown "${SUDO_USER:-$USER}":"${SUDO_USER:-$USER}" /var/run/wireguard || error "chown wireguard"
415+
chown "$(id -nu):$(id -ng)" /var/run/wireguard || error "chown wireguard"
416416

417417
# tmpfiles.d entry to persist the directory
418418
if [[ -d "/etc/tmpfiles.d" ]]; then
@@ -555,7 +555,6 @@ case "$1" in
555555
exit 0
556556
fi
557557
error "install failed"
558-
exit 0
559558

560559
;;
561560

install.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ cd emp3r0r-source/core || error "Failed to enter core directory"
122122
warn "Building and installing emp3r0r $tag (this may take a while)..."
123123
# build.sh will handle zig and other internal dependencies
124124
export TAG="$tag"
125-
GOROOT="$GOROOT" PATH="$PATH" GOTOOLCHAIN="$GOTOOLCHAIN" sudo ./build.sh --install || error "Build and installation failed"
125+
if "$EUID" -eq 0; then
126+
./build.sh --install || error "Build and installation failed"
127+
else
128+
sudo ./build.sh --install || error "Build and installation failed"
129+
fi
126130

127131
info "emp3r0r installed successfully!"

0 commit comments

Comments
 (0)