Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 4, 2025

DAppNode commands were not available in some installations because the .dappnode_profile file was only being added to .profile, but many interactive shell sessions use .bashrc instead.

Problem

The installation script only added profile sourcing to the .profile file:

echo -e "source ${DAPPNODE_PROFILE}\n" >>$PROFILE

This caused issues because:

  • Interactive bash sessions (SSH, terminal apps) typically source .bashrc
  • Login shells source .profile
  • Different shell configurations have varying sourcing behaviors

As a result, users would find that DAppNode commands like dappnode_help, dappnode_status, etc. were not available in their shell sessions.

Solution

Enhanced both installation and uninstallation scripts to handle both .profile and .bashrc files:

Installation (scripts/dappnode_install.sh):

# Add profile sourcing to both .profile and .bashrc for maximum compatibility
for config_file in .profile .bashrc; do
    CONFIG_PATH="$USER_HOME/$config_file"
    
    # Create config file if it doesn't exist
    [ ! -f "$CONFIG_PATH" ] && touch "$CONFIG_PATH"
    
    # Add profile sourcing if not already present
    if ! grep -q "${DAPPNODE_PROFILE}" "$CONFIG_PATH"; then
        echo "########          DAPPNODE PROFILE          ########" >>"$CONFIG_PATH"
        echo -e "source ${DAPPNODE_PROFILE}\n" >>"$CONFIG_PATH"
    fi
done

Uninstallation (scripts/dappnode_uninstall.sh):

# Remove profile file references from shell config files
for config_file in .profile .bashrc; do
    CONFIG_PATH="$USER_HOME/$config_file"
    if [ -f "$CONFIG_PATH" ]; then
        sed -i '/########          DAPPNODE PROFILE          ########/d' "$CONFIG_PATH"
        sed -i '/.*dappnode_profile/d' "$CONFIG_PATH"
    fi
done

Benefits

  • Universal Compatibility: Works with both login shells (.profile) and interactive shells (.bashrc)
  • Idempotent: Running installation multiple times doesn't create duplicate entries
  • Clean Removal: Uninstallation removes all references from both files
  • Shell Agnostic: Works regardless of default shell (bash, zsh, etc.)
  • Backwards Compatible: Enhances existing behavior without breaking current functionality

Users will now have access to all DAppNode commands in any shell environment without requiring manual configuration.

Fixes #664.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Contributor Author

Copilot AI commented Sep 4, 2025

@pablomendezroyo 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Co-authored-by: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com>
Copilot AI changed the title [WIP] Make sure .dappnode_profile is sourced Ensure .dappnode_profile is sourced in all shell environments Sep 4, 2025
@pablomendezroyo pablomendezroyo marked this pull request as ready for review September 4, 2025 09:25
@pablomendezroyo pablomendezroyo requested a review from a team as a code owner September 4, 2025 09:25
@pablomendezroyo pablomendezroyo merged commit a0a2a46 into master Sep 4, 2025
8 checks passed
@pablomendezroyo pablomendezroyo deleted the copilot/fix-664 branch September 4, 2025 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make sure .dappnode_profile is sourced

2 participants