Skip to content

Commit

Permalink
base-files: add /etc/profile.d support
Browse files Browse the repository at this point in the history
OpenWrt should support an optional /etc/profile.d directory like
most other Linux distributions. This allows packages to install
their own scripts into /etc/profile.d/ directory.

The file suffix should make clear, that these scripts
are (sourced) shell-snippets. If the user needs e.g. php or lua,
one must make sure that the interpreter is called.
The reverse failsafe test makes sure, that the effective returncode is 0.

A typcal usecase is the inclusion of private helpers,
special variables or aliases, which at the moment needs
patching the sourcecode and is not well maintainable.
Now the builder can simply add there files.

v1 initial work of Hendrik Lüth <hendrik@linux-nerds.de>
v2 changes regarding RFC (e.g. thomas.langer@lantiq.com)
v3 changes regarding RFC (e.g. mschiffer@universe-factory.net)
v4 keep it simple and mimic OpenWrt style

Signed-off-by: Bastian Bittorf <bittorf@bluebottle.com>

Backport of r46965

git-svn-id: svn://svn.openwrt.org/openwrt/branches/chaos_calmer@48862 3c298f89-4303-0410-b956-a3cf2f4a3e73
  • Loading branch information
blogic committed Mar 1, 2016
1 parent 3c3e506 commit e624035
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions package/base-files/files/etc/profile
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ export PS1='\u@\h:\w\$ '

[ -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
}

0 comments on commit e624035

Please sign in to comment.