more sudo removals

This commit is contained in:
shocknet-justin 2025-08-26 14:23:04 -04:00
parent 99af2fe7dd
commit c015bf7991
2 changed files with 11 additions and 6 deletions

View file

@ -9,7 +9,7 @@ install_nodejs() {
USER_NAME=$(whoami) USER_NAME=$(whoami)
fi fi
NVM_DIR="$USER_HOME/.nvm" export NVM_DIR="$USER_HOME/.nvm"
log "${PRIMARY_COLOR}Checking${RESET_COLOR} for Node.js..." log "${PRIMARY_COLOR}Checking${RESET_COLOR} for Node.js..."
MINIMUM_VERSION="18.0.0" MINIMUM_VERSION="18.0.0"
@ -19,7 +19,7 @@ install_nodejs() {
if ! command -v nvm &> /dev/null; then if ! command -v nvm &> /dev/null; then
NVM_VERSION=$(wget -qO- https://api.github.com/repos/nvm-sh/nvm/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")') NVM_VERSION=$(wget -qO- https://api.github.com/repos/nvm-sh/nvm/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
sudo -u $USER_NAME bash -c "wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh | bash > /dev/null 2>&1" wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh | bash > /dev/null 2>&1
export NVM_DIR="${NVM_DIR}" export NVM_DIR="${NVM_DIR}"
[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh" [ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh"
fi fi
@ -36,7 +36,7 @@ install_nodejs() {
log "Node.js is not installed. ${PRIMARY_COLOR}Installing the LTS version...${RESET_COLOR}" log "Node.js is not installed. ${PRIMARY_COLOR}Installing the LTS version...${RESET_COLOR}"
fi fi
if ! sudo -u $USER_NAME bash -c "source ${NVM_DIR}/nvm.sh && nvm install --lts"; then if ! bash -c "source ${NVM_DIR}/nvm.sh && nvm install --lts"; then
log "${PRIMARY_COLOR}Failed to install Node.js.${RESET_COLOR}" log "${PRIMARY_COLOR}Failed to install Node.js.${RESET_COLOR}"
return 1 return 1
fi fi

View file

@ -12,10 +12,15 @@ start_services() {
USER_NAME=$(whoami) USER_NAME=$(whoami)
fi fi
# Ensure NVM_DIR is set
if [ -z "$NVM_DIR" ]; then
export NVM_DIR="$USER_HOME/.nvm"
fi
if [ "$OS" = "Linux" ]; then if [ "$OS" = "Linux" ]; then
if [ "$SYSTEMCTL_AVAILABLE" = true ]; then if [ "$SYSTEMCTL_AVAILABLE" = true ]; then
mkdir -p "$HOME/.config/systemd/user" mkdir -p "$USER_HOME/.config/systemd/user"
cat > "$HOME/.config/systemd/user/lnd.service" <<EOF cat > "$USER_HOME/.config/systemd/user/lnd.service" <<EOF
[Unit] [Unit]
Description=LND Service Description=LND Service
After=network.target After=network.target
@ -28,7 +33,7 @@ Restart=always
WantedBy=default.target WantedBy=default.target
EOF EOF
cat > "$HOME/.config/systemd/user/lightning_pub.service" <<EOF cat > "$USER_HOME/.config/systemd/user/lightning_pub.service" <<EOF
[Unit] [Unit]
Description=Lightning.Pub Service Description=Lightning.Pub Service
After=network.target After=network.target