Skip to content

Commit 0eaeb46

Browse files
Fix DAppNode profile sourcing in all shell environments
Co-authored-by: pablomendezroyo <[email protected]>
1 parent abe0fe4 commit 0eaeb46

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

scripts/dappnode_install.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,21 @@ dappnode_start() {
266266

267267
# Show credentials to the user on login
268268
USER=$(grep 1000 /etc/passwd | cut -f 1 -d:)
269-
[ -n "$USER" ] && PROFILE=/home/$USER/.profile || PROFILE=/root/.profile
270-
271-
if ! grep -q "${DAPPNODE_PROFILE}" "$PROFILE"; then
272-
echo "######## DAPPNODE PROFILE ########" >>$PROFILE
273-
echo -e "source ${DAPPNODE_PROFILE}\n" >>$PROFILE
274-
fi
269+
[ -n "$USER" ] && USER_HOME=/home/$USER || USER_HOME=/root
270+
271+
# Add profile sourcing to both .profile and .bashrc for maximum compatibility
272+
for config_file in .profile .bashrc; do
273+
CONFIG_PATH="$USER_HOME/$config_file"
274+
275+
# Create config file if it doesn't exist
276+
[ ! -f "$CONFIG_PATH" ] && touch "$CONFIG_PATH"
277+
278+
# Add profile sourcing if not already present
279+
if ! grep -q "${DAPPNODE_PROFILE}" "$CONFIG_PATH"; then
280+
echo "######## DAPPNODE PROFILE ########" >>"$CONFIG_PATH"
281+
echo -e "source ${DAPPNODE_PROFILE}\n" >>"$CONFIG_PATH"
282+
fi
283+
done
275284

276285
# Remove return from profile
277286
sed -i '/return/d' $DAPPNODE_PROFILE | tee -a $LOGFILE

scripts/dappnode_uninstall.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,17 @@ uninstall() {
4545
echo -e "\e[32mRemoving DAppNode directory\e[0m"
4646
rm -rf /usr/src/dappnode
4747

48-
# Remove profile file
48+
# Remove profile file references from shell config files
4949
USER=$(grep 1000 /etc/passwd | cut -f 1 -d:)
50-
[ -n "$USER" ] && PROFILE=/home/$USER/.profile || PROFILE=/root/.profile
51-
sed -i '/######## DAPPNODE PROFILE ########/g' $PROFILE
52-
sed -i '/.*dappnode_profile/g' $PROFILE
50+
[ -n "$USER" ] && USER_HOME=/home/$USER || USER_HOME=/root
51+
52+
for config_file in .profile .bashrc; do
53+
CONFIG_PATH="$USER_HOME/$config_file"
54+
if [ -f "$CONFIG_PATH" ]; then
55+
sed -i '/######## DAPPNODE PROFILE ########/d' "$CONFIG_PATH"
56+
sed -i '/.*dappnode_profile/d' "$CONFIG_PATH"
57+
fi
58+
done
5359

5460
echo -e "\e[32mDAppNode uninstalled!\e[0m"
5561
}

0 commit comments

Comments
 (0)