# HG changeset patch # User Aleksej Bobylev # Date 1505160870 -10800 # Node ID 78038351c7c86662b744db88b80fc893ba3aa0ef # Parent 65248d132cd2af084905e0f552ef724a8b26e527 rootfs/etc/init.d/rc.functions: add cmdline_option() diff -r 65248d132cd2 -r 78038351c7c8 rootfs/etc/init.d/rc.functions --- a/rootfs/etc/init.d/rc.functions Sun Jul 23 13:51:37 2017 +0200 +++ b/rootfs/etc/init.d/rc.functions Mon Sep 11 23:14:30 2017 +0300 @@ -5,15 +5,24 @@ . /lib/libtaz.sh # Check daemon with pidfile: usage check_pidfile $PIDFILE $DAEMON -active_pidfile() -{ +active_pidfile() { if [ ! -e $1 ]; then return 1 elif grep -qs "Name:.$(basename $2)$" \ - /proc/$(sed 's/[^0-9]//g' < $1 | head -n 1)/status ; then + /proc/$(sed 's/[^0-9]//g;q' $1)/status; then return 0 else rm -f $1 return 2 fi } + +# Get specified cmdline option value +cmdline_option() { + local opt + for opt in $(cat /proc/cmdline); do + case $opt in + $1=*) echo ${opt#$1=};; + esac + done +}