shinit 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. [ -x /bin/more ] || [ -x /usr/bin/more ] || alias more=less
  2. [ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi
  3. alias ll='ls -alF --color=auto'
  4. [ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc
  5. [ -x /usr/bin/arp -o -x /sbin/arp ] || arp() { cat /proc/net/arp; }
  6. [ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
  7. service() {
  8. if [ -f "/etc/init.d/$1" ]; then
  9. /etc/init.d/$@
  10. else
  11. echo "Usage: service <service> [command]"
  12. if [ -n "$1" ]; then
  13. echo "Service "'"'"$1"'"'" not found, the following services are available:"
  14. else
  15. echo "The following services are available:"
  16. fi
  17. for F in /etc/init.d/* ; do
  18. printf "%-30s\t%10s\t%10s\n" "$F" \
  19. $( $($F enabled) && echo "enabled" || echo "disabled" ) \
  20. $( [ "$(ubus call service list "{ 'verbose': true, 'name': '$(basename $F)' }" \
  21. | jsonfilter -q -e "@['$(basename $F)'].instances[*].running" | uniq)" = "true" ] \
  22. && echo "running" || echo "stopped" )
  23. done;
  24. return 1
  25. fi
  26. }
  27. [ -n "$KSH_VERSION" -o \! -s "$HOME/.shinit" ] || . "$HOME/.shinit"
  28. [ -z "$KSH_VERSION" -o \! -s "$HOME/.mkshrc" ] || . "$HOME/.mkshrc"