[PATCH 1/2] add SysV init scripts in centos6

now in centos6 has'nt the SysV init scripts, so add it to kimchi Signed-off-by: Ding Xiao <ssdxiao@163.com> --- contrib/kimchid.sysvinit.centos6 | 112 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 112 insertions(+), 0 deletions(-) create mode 100644 contrib/kimchid.sysvinit.centos6 diff --git a/contrib/kimchid.sysvinit.centos6 b/contrib/kimchid.sysvinit.centos6 new file mode 100644 index 0000000..ba4adff --- /dev/null +++ b/contrib/kimchid.sysvinit.centos6 @@ -0,0 +1,112 @@ +#! /bin/sh +# +#kimchid Kimchi Web Server +# +# +# Author: Ding Xiao <ssdxiao@163.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +### BEGIN INIT INFO +# Provides: kimchid +# Required-Start: libvirtd +# Required-Stop: +# Default-Start: 3 5 +# Default-Stop: 0 1 2 6 +# Description: Start the kimchid daemon +### END INIT INFO + +. /etc/rc.d/init.d/functions + +prog="kimchid" +exec="/usr/bin/kimchid" +pidfile="/var/run/kimchi.pid" + + +lockfile=/var/lock/subsys/$prog + +start() { + [ -x $exec ] || exit 5 + echo -n $"Starting $prog: " + daemon --user root --pidfile $pidfile "$exec &>/dev/null & echo \$! > $pidfile" + retval=$? + echo + [ $retval -eq 0 ] && touch $lockfile + return $retval +} + +stop() { + echo -n $"Stopping $prog: " + killproc -p $pidfile $prog + retval=$? + echo + [ $retval -eq 0 ] && rm -f $lockfile + return $retval +} + +restart() { + stop + start +} + +reload() { + restart +} + +force_reload() { + restart +} + +rh_status() { + status -p $pidfile $prog +} + +rh_status_q() { + rh_status >/dev/null 2>&1 +} + + +case "$1" in + start) + rh_status_q && exit 0 + $1 + ;; + stop) + rh_status_q || exit 0 + $1 + ;; + restart) + $1 + ;; + reload) + rh_status_q || exit 7 + $1 + ;; + force-reload) + force_reload + ;; + status) + rh_status + ;; + condrestart|try-restart) + rh_status_q || exit 0 + restart + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" + exit 2 +esac +exit $? + -- 1.7.1

need rpm support to install the SysV init scripts Signed-off-by: Ding Xiao <ssdxiao@163.com> --- contrib/Makefile.am | 1 + contrib/kimchi.spec.fedora.in | 2 ++ 2 files changed, 3 insertions(+), 0 deletions(-) diff --git a/contrib/Makefile.am b/contrib/Makefile.am index e36d4cd..8f205ba 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -18,6 +18,7 @@ SUBDIRS = DEBIAN EXTRA_DIST = \ kimchid.sysvinit \ + kimchid.sysvinit.centos6 \ kimchid.service.fedora \ kimchi.spec.fedora.in \ kimchid-upstart.conf.debian \ diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in index 7a7d5e0..c583d30 100644 --- a/contrib/kimchi.spec.fedora.in +++ b/contrib/kimchi.spec.fedora.in @@ -77,6 +77,7 @@ install -Dm 0640 src/firewalld.xml %{buildroot}%{_prefix}/lib/firewalld/services %if 0%{?rhel} == 6 # Install the upstart script install -Dm 0755 contrib/kimchid-upstart.conf.fedora %{buildroot}/etc/init/kimchid.conf +install -Dm 0755 contrib/kimchid.sysvinit.centos6 %{buildroot}%{_initrddir}/kimchid %endif %if 0%{?rhel} == 5 # Install the SysV init scripts @@ -196,6 +197,7 @@ rm -rf $RPM_BUILD_ROOT %endif %if 0%{?rhel} == 6 /etc/init/kimchid.conf +%{_initrddir}/kimchid %endif %if 0%{?rhel} == 5 %{_initrddir}/kimchid -- 1.7.1

On 06/19/2014 07:43 AM, ssdxiao wrote:
need rpm support to install the SysV init scripts
Signed-off-by: Ding Xiao <ssdxiao@163.com> --- contrib/Makefile.am | 1 + contrib/kimchi.spec.fedora.in | 2 ++ 2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/contrib/Makefile.am b/contrib/Makefile.am index e36d4cd..8f205ba 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -18,6 +18,7 @@ SUBDIRS = DEBIAN
EXTRA_DIST = \ kimchid.sysvinit \ + kimchid.sysvinit.centos6 \ kimchid.service.fedora \ kimchi.spec.fedora.in \ kimchid-upstart.conf.debian \ diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in index 7a7d5e0..c583d30 100644 --- a/contrib/kimchi.spec.fedora.in +++ b/contrib/kimchi.spec.fedora.in @@ -77,6 +77,7 @@ install -Dm 0640 src/firewalld.xml %{buildroot}%{_prefix}/lib/firewalld/services
%if 0%{?rhel} == 6 # Install the upstart script install -Dm 0755 contrib/kimchid-upstart.conf.fedora %{buildroot}/etc/init/kimchid.conf +install -Dm 0755 contrib/kimchid.sysvinit.centos6 %{buildroot}%{_initrddir}/kimchid %endif
So 2 startup scripts will be installed in the system when it is rhel 6? Instead of doing that, we should be able to recognize when system uses upstart or not And based on that install the right startup script
%if 0%{?rhel} == 5 # Install the SysV init scripts @@ -196,6 +197,7 @@ rm -rf $RPM_BUILD_ROOT %endif %if 0%{?rhel} == 6 /etc/init/kimchid.conf +%{_initrddir}/kimchid %endif %if 0%{?rhel} == 5 %{_initrddir}/kimchid

I found that SysV init scripts can't work on centos6. Because the kimchid.sysvinit use /etc/rc.status and SysV init script use /etc/init.d/functions in centos6. so I commit a patch to add it I have modified the spec file, so the file "kimchid.sysvinit.centos6" will be only installed when the system is centos6. At 2014-07-02 04:40:51, "Aline Manera" <alinefm@linux.vnet.ibm.com> wrote:
On 06/19/2014 07:43 AM, ssdxiao wrote:
need rpm support to install the SysV init scripts
Signed-off-by: Ding Xiao <ssdxiao@163.com> --- contrib/Makefile.am | 1 + contrib/kimchi.spec.fedora.in | 2 ++ 2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/contrib/Makefile.am b/contrib/Makefile.am index e36d4cd..8f205ba 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -18,6 +18,7 @@ SUBDIRS = DEBIAN
EXTRA_DIST = \ kimchid.sysvinit \ + kimchid.sysvinit.centos6 \ kimchid.service.fedora \ kimchi.spec.fedora.in \ kimchid-upstart.conf.debian \ diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in index 7a7d5e0..c583d30 100644 --- a/contrib/kimchi.spec.fedora.in +++ b/contrib/kimchi.spec.fedora.in @@ -77,6 +77,7 @@ install -Dm 0640 src/firewalld.xml %{buildroot}%{_prefix}/lib/firewalld/services
%if 0%{?rhel} == 6 # Install the upstart script install -Dm 0755 contrib/kimchid-upstart.conf.fedora %{buildroot}/etc/init/kimchid.conf +install -Dm 0755 contrib/kimchid.sysvinit.centos6 %{buildroot}%{_initrddir}/kimchid %endif
So 2 startup scripts will be installed in the system when it is rhel 6?
Instead of doing that, we should be able to recognize when system uses upstart or not And based on that install the right startup script
%if 0%{?rhel} == 5 # Install the SysV init scripts @@ -196,6 +197,7 @@ rm -rf $RPM_BUILD_ROOT %endif %if 0%{?rhel} == 6 /etc/init/kimchid.conf +%{_initrddir}/kimchid %endif %if 0%{?rhel} == 5 %{_initrddir}/kimchid

On 07/02/2014 05:52 AM, ssdxiao wrote:
I found that SysV init scripts can't work on centos6. Because the kimchid.sysvinit use /etc/rc.status and SysV init script use /etc/init.d/functions in centos6. so I commit a patch to add it
OK.
I have modified the spec file, so thefile "kimchid.sysvinit.centos6" will be only installed when the system is centos6.
From the below code it is not true:
%if 0%{?rhel} == 6 # Install the upstart script install -Dm 0755 contrib/kimchid-upstart.conf.fedora %{buildroot}/etc/init/kimchid.conf +install -Dm 0755 contrib/kimchid.sysvinit.centos6 %{buildroot}%{_initrddir}/kimchid %endif
If I am running on a rhel6 or centos, those 2 scripts will be installed.
At 2014-07-02 04:40:51, "Aline Manera" <alinefm@linux.vnet.ibm.com> wrote:
On 06/19/2014 07:43 AM, ssdxiao wrote:
need rpm support to install the SysV init scripts
Signed-off-by: Ding Xiao <ssdxiao@163.com> --- contrib/Makefile.am | 1 + contrib/kimchi.spec.fedora.in | 2 ++ 2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/contrib/Makefile.am b/contrib/Makefile.am index e36d4cd..8f205ba 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -18,6 +18,7 @@ SUBDIRS = DEBIAN
EXTRA_DIST = \ kimchid.sysvinit \ + kimchid.sysvinit.centos6 \ kimchid.service.fedora \ kimchi.spec.fedora.in \ kimchid-upstart.conf.debian \ diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in index 7a7d5e0..c583d30 100644 --- a/contrib/kimchi.spec.fedora.in +++ b/contrib/kimchi.spec.fedora.in @@ -77,6 +77,7 @@ install -Dm 0640 src/firewalld.xml %{buildroot}%{_prefix}/lib/firewalld/services
%if 0%{?rhel} == 6 # Install the upstart script install -Dm 0755 contrib/kimchid-upstart.conf.fedora %{buildroot}/etc/init/kimchid.conf +install -Dm 0755 contrib/kimchid.sysvinit.centos6 %{buildroot}%{_initrddir}/kimchid %endif
So 2 startup scripts will be installed in the system when it is rhel 6?
Instead of doing that, we should be able to recognize when system uses upstart or not And based on that install the right startup script
%if 0%{?rhel} == 5 # Install the SysV init scripts @@ -196,6 +197,7 @@ rm -rf $RPM_BUILD_ROOT %endif %if 0%{?rhel} == 6 /etc/init/kimchid.conf +%{_initrddir}/kimchid %endif %if 0%{?rhel} == 5 %{_initrddir}/kimchid

Sorry , I have misstake I fount kimchid can start and stop in Centos6 by initctl. so my patch is not useful unless we need add sysV init in Centos6. Maybe somebody will ignore how to start kimchid in centos6 like me, so could we add the startup mode in README.md. 在 2014-07-02 08:26:17,"Aline Manera" <alinefm@linux.vnet.ibm.com> 写道: On 07/02/2014 05:52 AM, ssdxiao wrote: I found that SysV init scripts can't work on centos6. Because the kimchid.sysvinit use /etc/rc.status and SysV init script use /etc/init.d/functions in centos6. so I commit a patch to add it OK. I have modified the spec file, so the file "kimchid.sysvinit.centos6" will be only installed when the system is centos6. From the below code it is not true:
%if 0%{?rhel} == 6 # Install the upstart script install -Dm 0755 contrib/kimchid-upstart.conf.fedora %{buildroot}/etc/init/kimchid.conf +install -Dm 0755 contrib/kimchid.sysvinit.centos6 %{buildroot}%{_initrddir}/kimchid %endif
If I am running on a rhel6 or centos, those 2 scripts will be installed. At 2014-07-02 04:40:51, "Aline Manera" <alinefm@linux.vnet.ibm.com> wrote:
On 06/19/2014 07:43 AM, ssdxiao wrote:
need rpm support to install the SysV init scripts
Signed-off-by: Ding Xiao <ssdxiao@163.com> --- contrib/Makefile.am | 1 + contrib/kimchi.spec.fedora.in | 2 ++ 2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/contrib/Makefile.am b/contrib/Makefile.am index e36d4cd..8f205ba 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -18,6 +18,7 @@ SUBDIRS = DEBIAN
EXTRA_DIST = \ kimchid.sysvinit \ + kimchid.sysvinit.centos6 \ kimchid.service.fedora \ kimchi.spec.fedora.in \ kimchid-upstart.conf.debian \ diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in index 7a7d5e0..c583d30 100644 --- a/contrib/kimchi.spec.fedora.in +++ b/contrib/kimchi.spec.fedora.in @@ -77,6 +77,7 @@ install -Dm 0640 src/firewalld.xml %{buildroot}%{_prefix}/lib/firewalld/services
%if 0%{?rhel} == 6 # Install the upstart script install -Dm 0755 contrib/kimchid-upstart.conf.fedora %{buildroot}/etc/init/kimchid.conf +install -Dm 0755 contrib/kimchid.sysvinit.centos6 %{buildroot}%{_initrddir}/kimchid %endif
So 2 startup scripts will be installed in the system when it is rhel 6?
Instead of doing that, we should be able to recognize when system uses upstart or not And based on that install the right startup script
%if 0%{?rhel} == 5 # Install the SysV init scripts @@ -196,6 +197,7 @@ rm -rf $RPM_BUILD_ROOT %endif %if 0%{?rhel} == 6 /etc/init/kimchid.conf +%{_initrddir}/kimchid %endif %if 0%{?rhel} == 5 %{_initrddir}/kimchid

On 07/03/2014 04:40 AM, ssdxiao wrote:
Sorry , I have misstake I fount kimchid can start and stop in Centos6 by initctl. so my patch is not useful unless we need add sysV init in Centos6.
Maybe somebody will ignore how to start kimchid in centos6 like me, so could we add the startup mode in README.md.
It is always good to have it documented. Do you want to send a patch to update the README.md for centos6?
在 2014-07-02 08:26:17,"Aline Manera" <alinefm@linux.vnet.ibm.com> 写道:
On 07/02/2014 05:52 AM, ssdxiao wrote:
I found that SysV init scripts can't work on centos6. Because the kimchid.sysvinit use /etc/rc.status and SysV init script use /etc/init.d/functions in centos6. so I commit a patch to add it
OK.
I have modified the spec file, so thefile "kimchid.sysvinit.centos6" will be only installed when the system is centos6.
From the below code it is not true:
>> %if 0%{?rhel} == 6 >> # Install the upstart script >> install -Dm 0755 contrib/kimchid-upstart.conf.fedora %{buildroot}/etc/init/kimchid.conf >> +install -Dm 0755 contrib/kimchid.sysvinit.centos6 %{buildroot}%{_initrddir}/kimchid >> %endif
If I am running on a rhel6 or centos, those 2 scripts will be installed.
At 2014-07-02 04:40:51, "Aline Manera"<alinefm@linux.vnet.ibm.com> wrote: > >On 06/19/2014 07:43 AM, ssdxiao wrote: >> need rpm support to install the SysV init scripts >> >> Signed-off-by: Ding Xiao<ssdxiao@163.com> >> --- >> contrib/Makefile.am | 1 + >> contrib/kimchi.spec.fedora.in | 2 ++ >> 2 files changed, 3 insertions(+), 0 deletions(-) >> >> diff --git a/contrib/Makefile.am b/contrib/Makefile.am >> index e36d4cd..8f205ba 100644 >> --- a/contrib/Makefile.am >> +++ b/contrib/Makefile.am >> @@ -18,6 +18,7 @@ SUBDIRS = DEBIAN >> >> EXTRA_DIST = \ >> kimchid.sysvinit \ >> + kimchid.sysvinit.centos6 \ >> kimchid.service.fedora \ >> kimchi.spec.fedora.in \ >> kimchid-upstart.conf.debian \ >> diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in >> index 7a7d5e0..c583d30 100644 >> --- a/contrib/kimchi.spec.fedora.in >> +++ b/contrib/kimchi.spec.fedora.in >> @@ -77,6 +77,7 @@ install -Dm 0640 src/firewalld.xml %{buildroot}%{_prefix}/lib/firewalld/services > >> %if 0%{?rhel} == 6 >> # Install the upstart script >> install -Dm 0755 contrib/kimchid-upstart.conf.fedora %{buildroot}/etc/init/kimchid.conf >> +install -Dm 0755 contrib/kimchid.sysvinit.centos6 %{buildroot}%{_initrddir}/kimchid >> %endif > >So 2 startup scripts will be installed in the system when it is rhel 6? > >Instead of doing that, we should be able to recognize when system uses >upstart or not >And based on that install the right startup script > >> %if 0%{?rhel} == 5 >> # Install the SysV init scripts >> @@ -196,6 +197,7 @@ rm -rf $RPM_BUILD_ROOT >> %endif >> %if 0%{?rhel} == 6 >> /etc/init/kimchid.conf >> +%{_initrddir}/kimchid >> %endif >> %if 0%{?rhel} == 5 >> %{_initrddir}/kimchid >

We already have a sysv init script in contrib/kimchid.sysvinit It should work for centos as well You just need to adjust the build process On 06/19/2014 07:43 AM, ssdxiao wrote:
now in centos6 has'nt the SysV init scripts, so add it to kimchi
Signed-off-by: Ding Xiao <ssdxiao@163.com> --- contrib/kimchid.sysvinit.centos6 | 112 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 112 insertions(+), 0 deletions(-) create mode 100644 contrib/kimchid.sysvinit.centos6
diff --git a/contrib/kimchid.sysvinit.centos6 b/contrib/kimchid.sysvinit.centos6 new file mode 100644 index 0000000..ba4adff --- /dev/null +++ b/contrib/kimchid.sysvinit.centos6 @@ -0,0 +1,112 @@ +#! /bin/sh +# +#kimchid Kimchi Web Server +# +# +# Author: Ding Xiao <ssdxiao@163.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +### BEGIN INIT INFO +# Provides: kimchid +# Required-Start: libvirtd +# Required-Stop: +# Default-Start: 3 5 +# Default-Stop: 0 1 2 6 +# Description: Start the kimchid daemon +### END INIT INFO + +. /etc/rc.d/init.d/functions + +prog="kimchid" +exec="/usr/bin/kimchid" +pidfile="/var/run/kimchi.pid" + + +lockfile=/var/lock/subsys/$prog + +start() { + [ -x $exec ] || exit 5 + echo -n $"Starting $prog: " + daemon --user root --pidfile $pidfile "$exec &>/dev/null & echo \$! > $pidfile" + retval=$? + echo + [ $retval -eq 0 ] && touch $lockfile + return $retval +} + +stop() { + echo -n $"Stopping $prog: " + killproc -p $pidfile $prog + retval=$? + echo + [ $retval -eq 0 ] && rm -f $lockfile + return $retval +} + +restart() { + stop + start +} + +reload() { + restart +} + +force_reload() { + restart +} + +rh_status() { + status -p $pidfile $prog +} + +rh_status_q() { + rh_status >/dev/null 2>&1 +} + + +case "$1" in + start) + rh_status_q && exit 0 + $1 + ;; + stop) + rh_status_q || exit 0 + $1 + ;; + restart) + $1 + ;; + reload) + rh_status_q || exit 7 + $1 + ;; + force-reload) + force_reload + ;; + status) + rh_status + ;; + condrestart|try-restart) + rh_status_q || exit 0 + restart + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" + exit 2 +esac +exit $? +
participants (2)
-
Aline Manera
-
ssdxiao