On 11/21/2012 10:57 PM, [email protected] wrote:
> Hi!
>> +flag=0
>> +# running under systemd?
>> +if command -v systemctl >/dev/null 2>&1; then
>> +    HAVE_SYSTEMCTL=1
>> +else
>> +    HAVE_SYSTEMCTL=0
>> +fi
>> +
>> +if [ $HAVE_SYSTEMCTL -eq 1 ]; then
>> +    systemctl status vsftpd.service > /dev/null 2>&1 || flag=$?
>> +    if [ $flag -ne 0 ]; then
>> +            systemctl start vsftpd.service > /dev/null 2>&1
>> +    fi
>> +else
>> +    service vsftpd status > /dev/null 2>&1 || flag=$?
>> +    if [ $flag -ne 0 ]; then
>> +            service vsftpd start > /dev/null 2>&1
>> +    fi
>> +fi
> 
> Hmm, what is the reason of using the flag variable instead of $?
> directly?
> 

flag is used to restore the status of vsftpd service.
If the case start vsftpd service, the case will stop vsftpd service.

> And this snippet of code makes me wonder if it would be better to have a
> small shell library to restart the system services by a given name. Do
> we have other places with similar pieces of code?
> 

Yes.
I will try to make a shell library:)

-- 
Best Regards,
Peng

------------------------------------------------------------------------------
Keep yourself connected to Go Parallel: 
TUNE You got it built. Now make it sing. Tune shows you how.
http://goparallel.sourceforge.net
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to