mirror of
				git://git.openwrt.org/openwrt/openwrt.git
				synced 2025-10-31 05:54:26 -04:00 
			
		
		
		
	If service() is called w/o parameter then the status display for services with multiple instances is incorrect. E.g. samba4 or wpad have 2 instances. root@OpenWrt:~# /etc/init.d/samba4 status running root@OpenWrt:~# /etc/init.d/wpad status running Before change: /etc/init.d/samba4 enabled stopped /etc/init.d/wpad enabled stopped After change: /etc/init.d/samba4 enabled running /etc/init.d/wpad enabled running Signed-off-by: Alexander Egorenkov <egorenar-dev@posteo.net>
		
			
				
	
	
		
			34 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| [ -x /bin/more ] || [ -x /usr/bin/more ] || alias more=less
 | |
| [ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi
 | |
| 
 | |
| alias ll='ls -alF --color=auto'
 | |
| 
 | |
| [ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc
 | |
| 
 | |
| [ -x /usr/bin/arp -o -x /sbin/arp ] || arp() { cat /proc/net/arp; }
 | |
| [ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
 | |
| 
 | |
| service() {
 | |
| 	if [ -f "/etc/init.d/$1" ]; then
 | |
| 		/etc/init.d/$@
 | |
| 	else
 | |
| 		echo "Usage: service <service> [command]"
 | |
| 		if [ -n "$1" ]; then
 | |
| 			echo "Service "'"'"$1"'"'" not found, the following services are available:"
 | |
| 		else
 | |
| 			echo "The following services are available:"
 | |
| 		fi
 | |
| 		for F in /etc/init.d/* ; do
 | |
| 			printf "%-30s\t%10s\t%10s\n"  "$F" \
 | |
| 			$( $($F enabled) && echo "enabled" || echo "disabled" ) \
 | |
| 			$( [ "$(ubus call service list "{ 'verbose': true, 'name': '$(basename $F)' }" \
 | |
| 			| jsonfilter -q -e "@.$(basename $F).instances[*].running" | uniq)" = "true" ] \
 | |
| 			&& echo "running" || echo "stopped" )
 | |
| 		done;
 | |
| 		return 1
 | |
| 	fi
 | |
| }
 | |
| 
 | |
| [ -n "$KSH_VERSION" -o \! -s "$HOME/.shinit" ] || . "$HOME/.shinit"
 | |
| [ -z "$KSH_VERSION" -o \! -s "$HOME/.mkshrc" ] || . "$HOME/.mkshrc"
 |