base-files: honor CONFIG_TARGET_INIT_PATH
[openwrt/openwrt.git] / package / base-files / files / etc / profile
index 8aac3b752779ecd3df5bf87f82220cc21731ebe1..ad8fe12b66acdde9ab9c1b627b1fb38b47fb7463 100644 (file)
@@ -1,14 +1,27 @@
 #!/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 HOME=/tmp
+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
+[ -x /bin/more ] || alias more=less
+[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi
 
 [ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc
 
-arp() { cat /proc/net/arp; }
-[ -z /bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
+[ -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
+}