fine tuning

This commit is contained in:
2026-03-07 00:52:20 +00:00
parent 60230ccfec
commit 6c4595279a
5 changed files with 56 additions and 31 deletions
+35 -12
View File
@@ -20,6 +20,13 @@ has() { command -v "$1" &>/dev/null; }
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
# Resolve the real user's home even when running under sudo
if [[ -n "${SUDO_USER:-}" ]]; then
REAL_HOME=$(getent passwd "$SUDO_USER" | cut -d: -f6)
else
REAL_HOME="$HOME"
fi
# ─── detect package manager ────────────────────────────────────────────────────
if has apt; then
PM=apt
@@ -239,7 +246,7 @@ esac
# symlink fdfind → fd (apt installs as fdfind)
if has fdfind && ! has fd; then
sudo ln -sf "$(which fdfind)" /usr/local/bin/fd
sudo ln -sf "$(command -v fdfind)" /usr/local/bin/fd
ok "Symlinked fdfind → fd"
fi
@@ -310,11 +317,11 @@ echo ""
echo "── Auto-suspend (disable for server) ──"
# Disable system suspend/hibernate
if systemctl is-enabled sleep.target 2>/dev/null | grep -q "enabled\|masked"; then
if systemctl is-enabled sleep.target 2>/dev/null | grep -q "masked"; then
skip "sleep targets already masked"
else
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target 2>/dev/null
ok "Masked sleep/suspend targets"
else
skip "sleep targets already masked"
fi
# Configure logind to ignore idle — patch individual keys, don't overwrite the file
@@ -375,8 +382,8 @@ case $PM in
install_node22_apt
if [ -f "$SYSTEM_NODE" ] && [ "$("$SYSTEM_NODE" -v 2>/dev/null | cut -d. -f1 | tr -d 'v')" = "22" ]; then
ok "node v$("$SYSTEM_NODE" -v) installed at $SYSTEM_NODE"
if has node && [ "$(which node)" != "$SYSTEM_NODE" ]; then
warn "Shell resolves 'node' to $(which node) — system node is at $SYSTEM_NODE"
if has node && [ "$(command -v node)" != "$SYSTEM_NODE" ]; then
warn "Shell resolves 'node' to $(command -v node) — system node is at $SYSTEM_NODE"
warn "nvm may shadow it in interactive shells; systemd services will use $SYSTEM_NODE"
fi
else
@@ -449,8 +456,9 @@ install_go() {
esac
echo " Installing Go ${GOLANG_VERSION} from official tarball..."
curl -fsSL "https://go.dev/dl/go${GOLANG_VERSION}.linux-${GO_ARCH}.tar.gz" -o /tmp/go.tar.gz
rm -rf "$HOME/.local/go"
mkdir -p "$HOME/.local"
# Only remove old installation after successful download
rm -rf "$HOME/.local/go"
tar -C "$HOME/.local" -xzf /tmp/go.tar.gz
rm /tmp/go.tar.gz
export GOPATH="$HOME/.local/go-path"
@@ -522,6 +530,21 @@ case $PM in
brew) ;; # not needed on macOS
esac
# Vorbis/OGG/FLAC dev headers (needed by cliamp's Go dependencies)
case $PM in
apt)
for pkg in libvorbis-dev libogg-dev libflac-dev; do
if dpkg -s "$pkg" &>/dev/null 2>&1; then skip "$pkg"; else PULSE_PKGS+=("$pkg"); fi
done
;;
pacman)
for pkg in libvorbis libogg flac; do
if pacman -Qi "$pkg" &>/dev/null 2>&1; then skip "$pkg"; else PULSE_PKGS+=("$pkg"); fi
done
;;
brew) ;; # not needed on macOS
esac
if [ ${#PULSE_PKGS[@]} -gt 0 ]; then
install_pkg "${PULSE_PKGS[@]}"
ok "Installed: ${PULSE_PKGS[*]}"
@@ -535,7 +558,7 @@ GOPATH_BIN="${GOPATH:-$HOME/.local/go-path}/bin"
export PATH="$GOPATH_BIN:$PATH"
if has cliamp; then
skip "cliamp ($(which cliamp))"
skip "cliamp ($(command -v cliamp))"
else
if ! has go; then
warn "Go not installed — skipping cliamp build"
@@ -548,7 +571,7 @@ else
if [ -f "$GOPATH_BIN/cliamp" ]; then
ok "cliamp installed at $GOPATH_BIN/cliamp"
else
fail "cliamp build failed"
warn "cliamp build failed"
fi
fi
fi
@@ -708,7 +731,7 @@ else
# Use explicit path to system npm if available, to avoid nvm conflicts
SYSTEM_NPM="/usr/bin/npm"
if [ ! -f "$SYSTEM_NPM" ]; then
SYSTEM_NPM="$(which npm)"
SYSTEM_NPM="$(command -v npm)"
fi
# Set npm prefix to system location so all users can access packages
@@ -817,9 +840,9 @@ if [ "$GENERATE_ENV" = true ]; then
read -r ENV_PUBLIC_URL
done
echo -n " DATA_PATH [/mnt/data]: "
echo -n " DATA_PATH [$REAL_HOME/.local/data]: "
read -r ENV_DATA_PATH
ENV_DATA_PATH="${ENV_DATA_PATH:-/mnt/data}"
ENV_DATA_PATH="${ENV_DATA_PATH:-$REAL_HOME/.local/data}"
MAIL_DEFAULT="${DOCKER_MAIL_TRANSPORT:-smtp://127.0.0.1:1025}"
echo -n " MAIL_TRANSPORT [$MAIL_DEFAULT]: "