0026-base-files-add-etc-profile.d-support.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Sun, 11 Oct 2015 18:13:35 +0200
  3. Subject: base-files: add /etc/profile.d support
  4. OpenWrt should support an optional /etc/profile.d directory like
  5. most other Linux distributions. This allows packages to install
  6. their own scripts into /etc/profile.d/ directory.
  7. The file suffix should make clear, that these scripts
  8. are (sourced) shell-snippets. If the user needs e.g. php or lua,
  9. one must make sure that the interpreter is called.
  10. The reverse failsafe test makes sure, that the effective returncode is 0.
  11. A typcal usecase is the inclusion of private helpers,
  12. special variables or aliases, which at the moment needs
  13. patching the sourcecode and is not well maintainable.
  14. Now the builder can simply add there files.
  15. v1 initial work of Hendrik Lüth <hendrik@linux-nerds.de>
  16. v2 changes regarding RFC (e.g. thomas.langer@lantiq.com)
  17. v3 changes regarding RFC (e.g. mschiffer@universe-factory.net)
  18. v4 keep it simple and mimic OpenWrt style
  19. Signed-off-by: Bastian Bittorf <bittorf@bluebottle.com>
  20. diff --git a/package/base-files/files/etc/profile b/package/base-files/files/etc/profile
  21. index 3dd58e1..577b63b 100644
  22. --- a/package/base-files/files/etc/profile
  23. +++ b/package/base-files/files/etc/profile
  24. @@ -14,3 +14,10 @@ export PS1='\u@\h:\w\$ '
  25. [ -x /usr/bin/arp ] || arp() { cat /proc/net/arp; }
  26. [ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
  27. +
  28. +[ -n "$FAILSAFE" ] || {
  29. + for FILE in /etc/profile.d/*.sh; do
  30. + [ -e "$FILE" ] && . "$FILE"
  31. + done
  32. + unset FILE
  33. +}