8ac9d6dbb5e0d92f040480d738771f50d586d470
[openwrt/openwrt.git] / package / base-files / files / etc / profile
1 #!/bin/sh
2 [ -e /tmp/.failsafe ] && export FAILSAFE=1
3
4 [ -f /etc/banner ] && cat /etc/banner
5 [ -n "$FAILSAFE" ] || cat /etc/banner.failsafe
6
7 fgrep -sq '/ overlay ro,' /proc/mounts && {
8 echo 'Your JFFS2-partition seems full and overlayfs is mounted read-only.'
9 echo 'Please try to remove files from /overlay/upper/... and reboot!'
10 }
11
12 export PATH="%PATH%"
13 export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6)
14 export HOME=${HOME:-/root}
15 export PS1='\u@\h:\w\$ '
16
17 [ "$TERM" = "xterm" ] && export PS1='\[\e]0;\u@\h: \w\a\]'$PS1
18
19 [ -x /bin/more ] || alias more=less
20 [ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi
21
22 alias ll='ls -alF --color=auto'
23
24 [ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc
25
26 [ -x /usr/bin/arp -o -x /sbin/arp ] || arp() { cat /proc/net/arp; }
27 [ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
28
29 [ -n "$FAILSAFE" ] || {
30 for FILE in /etc/profile.d/*.sh; do
31 [ -e "$FILE" ] && . "$FILE"
32 done
33 unset FILE
34 }
35
36 if ( grep -qs '^root::' /etc/shadow && \
37 [ -z "$FAILSAFE" ] )
38 then
39 cat << EOF
40 === WARNING! =====================================
41 There is no root password defined on this device!
42 Use the "passwd" command to set up a new password
43 in order to prevent unauthorized SSH logins.
44 --------------------------------------------------
45 EOF
46 fi
47
48 service() {
49 [ -f "/etc/init.d/$1" ] || {
50 echo "service "'"'"$1"'"'" not found, the following services are available:"
51 ls "/etc/init.d"
52 return 1
53 }
54 /etc/init.d/$@
55 }