Skip to content

Commit eb71d10

Browse files
rockdrillarobimarko
authored andcommitted
base-files: split /etc/profile
- move extra parts to /etc/profile.d/* - improve syntax and messages Signed-off-by: Konstantin Demin <[email protected]> Link: openwrt/openwrt#19953 Signed-off-by: Robert Marko <[email protected]>
1 parent f7d6e73 commit eb71d10

File tree

3 files changed

+54
-45
lines changed

3 files changed

+54
-45
lines changed
Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,38 @@
1+
unset FAILSAFE
12
[ -e /tmp/.failsafe ] && export FAILSAFE=1
23

34
[ -f /etc/banner ] && cat /etc/banner
4-
[ -n "$FAILSAFE" ] && cat /etc/banner.failsafe
5+
[ -n "$FAILSAFE" ] && [ -f /etc/banner.failsafe ] && cat /etc/banner.failsafe
56

6-
grep -Fsq '/ overlay ro,' /proc/mounts && {
7-
echo 'Your JFFS2-partition seems full and overlayfs is mounted read-only.'
8-
echo 'Please try to remove files from /overlay/upper/... and reboot!'
9-
}
7+
if grep -Fsq '/ overlay ro,' /proc/mounts ; then
8+
cat << EOF
9+
10+
=== WARNING! ======================================
11+
Your JFFS2-partition seems full and overlayfs is
12+
mounted as READ-ONLY!
13+
Please try to remove files from /overlay/upper/...
14+
and reboot!
15+
---------------------------------------------------
16+
17+
EOF
18+
fi
1019

1120
export PATH="%PATH%"
12-
export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6)
13-
export HOME=${HOME:-/root}
21+
HOME=$(grep -E "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6)
22+
HOME=${HOME:-/root}
23+
export HOME
1424
export PS1='\u@\h:\w\$ '
1525
export ENV=/etc/shinit
1626

1727
case "$TERM" in
1828
xterm*|rxvt*)
19-
export PS1='\[\e]0;\u@\h: \w\a\]'$PS1
20-
;;
29+
export PS1='\[\e]0;\u@\h: \w\a\]'"$PS1"
30+
;;
2131
esac
2232

23-
[ -n "$FAILSAFE" ] || {
24-
for FILE in /etc/profile.d/*.sh; do
25-
[ -e "$FILE" ] && . "$FILE"
33+
if [ -z "$FAILSAFE" ] ; then
34+
for FILE in /etc/profile.d/*.sh ; do
35+
[ -f "$FILE" ] && . "$FILE"
2636
done
2737
unset FILE
28-
}
29-
30-
if ( grep -qs '^root::' /etc/shadow && \
31-
[ -z "$FAILSAFE" ] )
32-
then
33-
cat << EOF
34-
=== WARNING! =====================================
35-
There is no root password defined on this device!
36-
Use the "passwd" command to set up a new password
37-
in order to prevent unauthorized SSH logins.
38-
--------------------------------------------------
39-
EOF
40-
fi
41-
42-
if [ -x /usr/bin/apk ]; then
43-
cat << EOF
44-
45-
OpenWrt recently switched to the "apk" package manager!
46-
47-
OPKG Command APK Equivalent Description
48-
------------------------------------------------------------------
49-
opkg install <pkg> apk add <pkg> Install a package
50-
opkg remove <pkg> apk del <pkg> Remove a package
51-
opkg upgrade apk upgrade Upgrade all packages
52-
opkg files <pkg> apk info -L <pkg> List package contents
53-
opkg list-installed apk info List installed packages
54-
opkg update apk update Update package lists
55-
opkg search <pkg> apk search <pkg> Search for packages
56-
------------------------------------------------------------------
57-
58-
For more https://openwrt.org/docs/guide-user/additional-software/opkg-to-apk-cheatsheet
59-
60-
EOF
6138
fi
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if grep -Esq '^root::' /etc/shadow ; then
2+
cat << EOF
3+
4+
=== WARNING! =====================================
5+
There is no root password defined on this device!
6+
Use the "passwd" command to set up a new password
7+
in order to prevent unauthorized SSH logins.
8+
--------------------------------------------------
9+
10+
EOF
11+
fi
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if [ -x /usr/bin/apk ] ; then
2+
cat << EOF
3+
4+
OpenWrt recently switched to the "apk" package manager!
5+
6+
OPKG Command APK Equivalent Description
7+
------------------------------------------------------------------
8+
opkg install <pkg> apk add <pkg> Install a package
9+
opkg remove <pkg> apk del <pkg> Remove a package
10+
opkg upgrade apk upgrade Upgrade all packages
11+
opkg files <pkg> apk info -L <pkg> List package contents
12+
opkg list-installed apk info List installed packages
13+
opkg update apk update Update package lists
14+
opkg search <pkg> apk search <pkg> Search for packages
15+
------------------------------------------------------------------
16+
17+
For more information visit:
18+
https://openwrt.org/docs/guide-user/additional-software/opkg-to-apk-cheatsheet
19+
20+
EOF
21+
fi

0 commit comments

Comments
 (0)