Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions scripts/dappnode_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,21 @@ dappnode_start() {

# Show credentials to the user on login
USER=$(grep 1000 /etc/passwd | cut -f 1 -d:)
[ -n "$USER" ] && PROFILE=/home/$USER/.profile || PROFILE=/root/.profile

if ! grep -q "${DAPPNODE_PROFILE}" "$PROFILE"; then
echo "######## DAPPNODE PROFILE ########" >>$PROFILE
echo -e "source ${DAPPNODE_PROFILE}\n" >>$PROFILE
fi
[ -n "$USER" ] && USER_HOME=/home/$USER || USER_HOME=/root

# 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

# Remove return from profile
sed -i '/return/d' $DAPPNODE_PROFILE | tee -a $LOGFILE
Expand Down
14 changes: 10 additions & 4 deletions scripts/dappnode_uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,17 @@ uninstall() {
echo -e "\e[32mRemoving DAppNode directory\e[0m"
rm -rf /usr/src/dappnode

# Remove profile file
# Remove profile file references from shell config files
USER=$(grep 1000 /etc/passwd | cut -f 1 -d:)
[ -n "$USER" ] && PROFILE=/home/$USER/.profile || PROFILE=/root/.profile
sed -i '/######## DAPPNODE PROFILE ########/g' $PROFILE
sed -i '/.*dappnode_profile/g' $PROFILE
[ -n "$USER" ] && USER_HOME=/home/$USER || USER_HOME=/root

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

echo -e "\e[32mDAppNode uninstalled!\e[0m"
}
Expand Down
Loading