Patchwork [4/6] openssh: add init.d/sshd status command for LSB compliance

login
register
mail settings
Submitter jackie huang
Date Aug. 20, 2013, 3:25 a.m.
Message ID <6f2bc301767250c371bb8d927e54425bdeda6f37.1376968627.git.jackie.huang@windriver.com>
Download mbox | patch
Permalink /patch/56023/
State New
Headers show

Comments

jackie huang - Aug. 20, 2013, 3:25 a.m.
From: Jackie Huang <jackie.huang@windriver.com>

Signed-off-by: Li Wang <li.wang@windriver.com>
Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
---
 .../openssh/openssh-6.2p2/init                     |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
Khem Raj - Aug. 22, 2013, 6:42 a.m.
Hi Jackie

One thing comes to mind is that these scripts are hardcoding the binaries and may be it would be
nicer to replace the bindir, libdir and so on at install time, that would make them flexible where /usr
is not used e.g. but I guess thats a general problem with capture init scripts all around probably.

On Aug 19, 2013, at 8:25 PM, jackie.huang@windriver.com wrote:

> From: Jackie Huang <jackie.huang@windriver.com>
> 
> Signed-off-by: Li Wang <li.wang@windriver.com>
> Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
> ---
> .../openssh/openssh-6.2p2/init                     |   15 ++++++++++++++-
> 1 files changed, 14 insertions(+), 1 deletions(-)
> 
> diff --git a/meta/recipes-connectivity/openssh/openssh-6.2p2/init b/meta/recipes-connectivity/openssh/openssh-6.2p2/init
> index 6beec84..6bbc573 100644
> --- a/meta/recipes-connectivity/openssh/openssh-6.2p2/init
> +++ b/meta/recipes-connectivity/openssh/openssh-6.2p2/init
> @@ -1,6 +1,9 @@
> #! /bin/sh
> set -e
> 
> +# source function library
> +. /etc/init.d/functions
> +
> # /etc/init.d/ssh: start and stop the OpenBSD "secure shell" daemon
> 
> test -x /usr/sbin/sshd || exit 0
> @@ -46,6 +49,11 @@ check_keys() {
> 	fi
> }
> 
> +rh_status() {
> +	status /usr/sbin/sshd;
> +	return $?
> +}
> +
> export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
> 
> case "$1" in
> @@ -84,8 +92,13 @@ case "$1" in
> 	echo "."
> 	;;
> 
> +  status)
> +	rh_status;
> +	exit $?
> +  ;;
> +
>   *)
> -	echo "Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart}"
> +	echo "Usage: /etc/init.d/ssh {start|stop|status|reload|force-reload|restart}"
> 	exit 1
> esac
> 
> -- 
> 1.7.4.1
> 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
jackie huang - Aug. 22, 2013, 7:02 a.m.
On 8/22/2013 2:42 PM, Khem Raj wrote:
> Hi Jackie
>
> One thing comes to mind is that these scripts are hardcoding the binaries and may be it would be
> nicer to replace the bindir, libdir and so on at install time, that would make them flexible where /usr
> is not used e.g. but I guess thats a general problem with capture init scripts all around probably.

Yes it is general problem that almost all init scripts have these 
hardcoding binaries, maybe we need a requirement and do that for all 
these scripts with a plan.

Thanks,
Jackie

>
> On Aug 19, 2013, at 8:25 PM, jackie.huang@windriver.com wrote:
>
>> From: Jackie Huang <jackie.huang@windriver.com>
>>
>> Signed-off-by: Li Wang <li.wang@windriver.com>
>> Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
>> ---
>> .../openssh/openssh-6.2p2/init                     |   15 ++++++++++++++-
>> 1 files changed, 14 insertions(+), 1 deletions(-)
>>
>> diff --git a/meta/recipes-connectivity/openssh/openssh-6.2p2/init b/meta/recipes-connectivity/openssh/openssh-6.2p2/init
>> index 6beec84..6bbc573 100644
>> --- a/meta/recipes-connectivity/openssh/openssh-6.2p2/init
>> +++ b/meta/recipes-connectivity/openssh/openssh-6.2p2/init
>> @@ -1,6 +1,9 @@
>> #! /bin/sh
>> set -e
>>
>> +# source function library
>> +. /etc/init.d/functions
>> +
>> # /etc/init.d/ssh: start and stop the OpenBSD "secure shell" daemon
>>
>> test -x /usr/sbin/sshd || exit 0
>> @@ -46,6 +49,11 @@ check_keys() {
>> 	fi
>> }
>>
>> +rh_status() {
>> +	status /usr/sbin/sshd;
>> +	return $?
>> +}
>> +
>> export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
>>
>> case "$1" in
>> @@ -84,8 +92,13 @@ case "$1" in
>> 	echo "."
>> 	;;
>>
>> +  status)
>> +	rh_status;
>> +	exit $?
>> +  ;;
>> +
>>    *)
>> -	echo "Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart}"
>> +	echo "Usage: /etc/init.d/ssh {start|stop|status|reload|force-reload|restart}"
>> 	exit 1
>> esac
>>
>> --
>> 1.7.4.1
>>
>> _______________________________________________
>> Openembedded-core mailing list
>> Openembedded-core@lists.openembedded.org
>> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>
>
>
Qi.Chen@windriver.com - Aug. 22, 2013, 7:15 a.m.
On 08/22/2013 03:02 PM, jhuang0 wrote:
>
>
> On 8/22/2013 2:42 PM, Khem Raj wrote:
>> Hi Jackie
>>
>> One thing comes to mind is that these scripts are hardcoding the 
>> binaries and may be it would be
>> nicer to replace the bindir, libdir and so on at install time, that 
>> would make them flexible where /usr
>> is not used e.g. but I guess thats a general problem with capture 
>> init scripts all around probably.
>
> Yes it is general problem that almost all init scripts have these 
> hardcoding binaries, maybe we need a requirement and do that for all 
> these scripts with a plan.
>
> Thanks,
> Jackie
>

Agree.

If we're going to do this, we need to take the postinst scripts into 
consideration, as the postinst scripts have the same problem.

Best Regards,
Chen Qi

>>
>> On Aug 19, 2013, at 8:25 PM, jackie.huang@windriver.com wrote:
>>
>>> From: Jackie Huang <jackie.huang@windriver.com>
>>>
>>> Signed-off-by: Li Wang <li.wang@windriver.com>
>>> Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
>>> ---
>>> .../openssh/openssh-6.2p2/init                     |   15 
>>> ++++++++++++++-
>>> 1 files changed, 14 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/meta/recipes-connectivity/openssh/openssh-6.2p2/init 
>>> b/meta/recipes-connectivity/openssh/openssh-6.2p2/init
>>> index 6beec84..6bbc573 100644
>>> --- a/meta/recipes-connectivity/openssh/openssh-6.2p2/init
>>> +++ b/meta/recipes-connectivity/openssh/openssh-6.2p2/init
>>> @@ -1,6 +1,9 @@
>>> #! /bin/sh
>>> set -e
>>>
>>> +# source function library
>>> +. /etc/init.d/functions
>>> +
>>> # /etc/init.d/ssh: start and stop the OpenBSD "secure shell" daemon
>>>
>>> test -x /usr/sbin/sshd || exit 0
>>> @@ -46,6 +49,11 @@ check_keys() {
>>>     fi
>>> }
>>>
>>> +rh_status() {
>>> +    status /usr/sbin/sshd;
>>> +    return $?
>>> +}
>>> +
>>> export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
>>>
>>> case "$1" in
>>> @@ -84,8 +92,13 @@ case "$1" in
>>>     echo "."
>>>     ;;
>>>
>>> +  status)
>>> +    rh_status;
>>> +    exit $?
>>> +  ;;
>>> +
>>>    *)
>>> -    echo "Usage: /etc/init.d/ssh 
>>> {start|stop|reload|force-reload|restart}"
>>> +    echo "Usage: /etc/init.d/ssh 
>>> {start|stop|status|reload|force-reload|restart}"
>>>     exit 1
>>> esac
>>>
>>> -- 
>>> 1.7.4.1
>>>
>>> _______________________________________________
>>> Openembedded-core mailing list
>>> Openembedded-core@lists.openembedded.org
>>> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>>
>>
>>
>

Patch

diff --git a/meta/recipes-connectivity/openssh/openssh-6.2p2/init b/meta/recipes-connectivity/openssh/openssh-6.2p2/init
index 6beec84..6bbc573 100644
--- a/meta/recipes-connectivity/openssh/openssh-6.2p2/init
+++ b/meta/recipes-connectivity/openssh/openssh-6.2p2/init
@@ -1,6 +1,9 @@ 
 #! /bin/sh
 set -e
 
+# source function library
+. /etc/init.d/functions
+
 # /etc/init.d/ssh: start and stop the OpenBSD "secure shell" daemon
 
 test -x /usr/sbin/sshd || exit 0
@@ -46,6 +49,11 @@  check_keys() {
 	fi
 }
 
+rh_status() {
+	status /usr/sbin/sshd;
+	return $?
+}
+
 export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
 
 case "$1" in
@@ -84,8 +92,13 @@  case "$1" in
 	echo "."
 	;;
 
+  status)
+	rh_status;
+	exit $?
+  ;;
+
   *)
-	echo "Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart}"
+	echo "Usage: /etc/init.d/ssh {start|stop|status|reload|force-reload|restart}"
 	exit 1
 esac