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