Skip to content

Commit 5be08bf

Browse files
committed
feat: add check for pi user home directory before modifying .bash_profile for auto-start
1 parent 77abb8c commit 5be08bf

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

pi-node/setup.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,12 @@ ExecStart=
144144
ExecStart=-/sbin/agetty --autologin pi --noclear %I $TERM
145145
CONF
146146

147-
if ! grep -q "startx" /home/pi/.bash_profile 2>/dev/null; then
148-
echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor' >> /home/pi/.bash_profile
147+
# only add auto‑start line if the pi user exists and has a home
148+
if [[ -d /home/pi ]]; then
149+
if ! grep -q "startx" /home/pi/.bash_profile 2>/dev/null; then
150+
# >> will create the file if it doesn't already exist
151+
echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor' >> /home/pi/.bash_profile
152+
fi
149153
fi
150154

151155
mkdir -p /home/pi/.config/openbox

0 commit comments

Comments
 (0)