base-files: fix check for empty password warning
[openwrt/staging/mkresin.git] / package / base-files / files / etc / profile
index c5d7e025804b63ae2c8eb80246441ebf3b201de6..f241ab2ef38658cfbb2476a087a2a6eba403351a 100644 (file)
@@ -1,14 +1,43 @@
 #!/bin/sh
 [ -f /etc/banner ] && cat /etc/banner
+[ -e /tmp/.failsafe ] && cat /etc/banner.failsafe
+fgrep -sq '/ overlay ro,' /proc/mounts && {
+       echo 'Your JFFS2-partition seems full and overlayfs is mounted read-only.'
+       echo 'Please try to remove files from /overlay/upper/... and reboot!'
+}
 
-export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+export PATH="%PATH%"
+export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6)
+export HOME=${HOME:-/root}
 export PS1='\u@\h:\w\$ '
 
-alias more=less
-[ -x /usr/bin/vim ] || alias vim=vi
+[ "$TERM" = "xterm" ] && export PS1='\[\e]0;\u@\h: \w\a\]'$PS1
+
+[ -x /bin/more ] || alias more=less
+[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi
+
+alias ll='ls -alF --color=auto'
 
 [ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc
 
-arp() { cat /proc/net/arp; }
-[ -z /bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
-reboot() { ifdown wan 2>&1 >/dev/null ; /sbin/reboot; }
+[ -x /usr/bin/arp ] || arp() { cat /proc/net/arp; }
+[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
+
+[ -n "$FAILSAFE" ] || {
+       for FILE in /etc/profile.d/*.sh; do
+               [ -e "$FILE" ] && . "$FILE"
+       done
+       unset FILE
+}
+
+if ( grep -qs '^root::' /etc/shadow && \
+     [ -z "$FAILSAFE" ] )
+then
+cat << EOF
+=== WARNING! =====================================
+There is no root password defined on this device!
+Use the "passwd" command to set up a new password
+in order to prevent unauthorized SSH logins.
+--------------------------------------------------
+EOF
+fi