From 5a436c3339d4caf3af1175ed41fcaab75206a59c Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Mon, 29 Jan 2007 23:37:07 +0000 Subject: [PATCH] Add Gentoo initscripts. Force sysv initscripts for the RPMs. git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2482 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- Makefile.am | 1 + configure.ac | 20 ++++++++++++++ gentoo/Makefile-files | 31 +++++++++++++++++++++ gentoo/util-vserver | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ gentoo/vprocunhide | 20 ++++++++++++++ gentoo/vservers.default | 19 +++++++++++++ util-vserver.spec.in | 3 ++- 7 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 gentoo/Makefile-files create mode 100644 gentoo/util-vserver create mode 100644 gentoo/vprocunhide create mode 100644 gentoo/vservers.default diff --git a/Makefile.am b/Makefile.am index 635c594..2017e46 100644 --- a/Makefile.am +++ b/Makefile.am @@ -226,6 +226,7 @@ include $(top_srcdir)/ensc_wrappers/Makefile-files include $(top_srcdir)/ensc_fmt/Makefile-files include $(top_srcdir)/lib_internal/Makefile-files include $(top_srcdir)/vserver-start/Makefile-files +include $(top_srcdir)/gentoo/Makefile-files include $(top_srcdir)/m4/gpgsig.am include $(top_srcdir)/m4/validate.am diff --git a/configure.ac b/configure.ac index ba09dba..c1c51ad 100644 --- a/configure.ac +++ b/configure.ac @@ -336,6 +336,26 @@ dnl dnl ######################## +dnl Check what distro this is, use Gentoo initscripts if appropriate +AC_MSG_CHECKING([for host initscripts]) +AC_ARG_WITH(initscripts, [force host initscripts (valid values are: gentoo, sysv)], [ + case "$withval" in + gentoo) ensc_with_init=gentoo;; + sysv) ensc_with_init=sysv;; + *) AC_MSG_ERROR([invalid initscripts value, only gentoo and sysv are supported]);; + esac + ], [ + if test -e /etc/gentoo-release; then + ensc_with_init=gentoo + else + ensc_with_init=sysv + fi + ]) +AC_MSG_RESULT([$ensc_with_init]) +AM_CONDITIONAL(HAVE_GENTOO_INIT, test x"$ensc_with_init" = xgentoo) +AM_CONDITIONAL(HAVE_SYSV_INIT, test x"$ensc_with_init" = xsysv) + + dnl BIG HACK! Do some autodetection here! AC_DEFINE(UTMP_GID, [22], [The utmp gid-number]) diff --git a/gentoo/Makefile-files b/gentoo/Makefile-files new file mode 100644 index 0000000..fb03479 --- /dev/null +++ b/gentoo/Makefile-files @@ -0,0 +1,31 @@ +## $Id$ -*- makefile -*- + +## Copyright (C) 2003 Enrico Scholz +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2, or (at your option) +## any later version. +## +## This program 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 General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +## + +AM_INSTALLCHECK_STD_OPTIONS_EXEMPT += \ + $(gentoo_src_SCRPTS) + +gentoo_src_SCRPTS = gentoo/vprocunhide \ + gentoo/vservers.default \ + gentoo/util-vserver + +EXTRA_DIST += $(gentoo_src_SCRPTS) + +if HAVE_GENTOO_INIT +initrd_SCRIPTS += $(gentoo_src_SCRPTS) +endif diff --git a/gentoo/util-vserver b/gentoo/util-vserver new file mode 100644 index 0000000..3fae9f2 --- /dev/null +++ b/gentoo/util-vserver @@ -0,0 +1,72 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +set_helper() { + local f="/proc/sys/kernel/vshelper" + if [ -e "$f" ]; then + echo "$_VSHELPER" > "$f" + fi + return 0 +} + +kill_contexts() { + local xid + for xid in `ls -1 /proc/virtual`; do + [ "$xid" = "info" -o "$xid" = "status" ] && continue + $_VATTRIBUTE --xid $xid --set --flag ~persistent + $_VKILL --xid $xid -s 15 + sleep 3 + $_VKILL --xid $xid -s 9 + done + local alive=0 + for xid in `ls -1 /proc/virtual`; do + [ "$xid" = "info" -o "$xid" = "status" ] && continue + let alive+=1 + done + return $alive +} + +start() { + : ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars} + if [[ ! -e ${UTIL_VSERVER_VARS} ]]; then + eerror "Cannot find util-vserver installation" + eerror "(the file '$UTIL_VSERVER_VARS' would be expected)" + return 1 + fi + + source ${UTIL_VSERVER_VARS} + source "$_LIB_FUNCTIONS" + source "$__PKGLIBDIR/vserver.functions" + + ebegin "Setting path to vshelper" + set_helper + eend $? + + ebegin "Loading default device map" + loadDeviceMap 0 "$__CONFDIR/.defaults/apps/vdevmap" + eend $? +} + +stop() { + : ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars} + if [[ ! -e ${UTIL_VSERVER_VARS} ]]; then + eerror "Cannot find util-vserver installation" + eerror "(the file '$UTIL_VSERVER_VARS' would be expected)" + return 1 + fi + + source ${UTIL_VSERVER_VARS} + source "$_LIB_FUNCTIONS" + source "$__PKGLIBDIR/vserver.functions" + + ebegin "Stopping all running guests" + $_START_VSERVERS -j 1 --all --stop + eend $? + + ebegin "Killing all running contexts" + kill_contexts + eend $? +} + +# vim:ts=4:filetype=gentoo-init-d diff --git a/gentoo/vprocunhide b/gentoo/vprocunhide new file mode 100644 index 0000000..d7199ca --- /dev/null +++ b/gentoo/vprocunhide @@ -0,0 +1,20 @@ +#!/sbin/runscript +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +start() { + : ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars} + if [[ ! -e ${UTIL_VSERVER_VARS} ]]; then + eerror "Cannot find util-vserver installation" + eerror "(the file '$UTIL_VSERVER_VARS' would be expected)" + return 1 + fi + + source ${UTIL_VSERVER_VARS} + + ebegin "Fixing /proc entries visibility" + ${_VPROCUNHIDE} + eend $? +} + +# vim:ts=4:filetype=gentoo-init-d diff --git a/gentoo/vservers.default b/gentoo/vservers.default new file mode 100644 index 0000000..f4416eb --- /dev/null +++ b/gentoo/vservers.default @@ -0,0 +1,19 @@ +#!/sbin/runscript +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() { + need util-vserver vprocunhide +} + +start() { + MARK=${SVCNAME#vservers.} /usr/lib/util-vserver/vserver-wrapper start +} + +stop() { + MARK=${SVCNAME#vservers.} /usr/lib/util-vserver/vserver-wrapper stop +} + + + +# vim:ts=4:filetype=gentoo-init-d diff --git a/util-vserver.spec.in b/util-vserver.spec.in index 59ecaaa..386134a 100644 --- a/util-vserver.spec.in +++ b/util-vserver.spec.in @@ -172,7 +172,8 @@ develop VServer related applications. %build %configure --with-initrddir=%_initrddir --enable-release \ %{?_without_dietlibc:--disable-dietlibc} \ - %{?_with_legacy:--enable-apis=NOLEGACY} + %{?_with_legacy:--enable-apis=NOLEGACY} \ + --with-initscripts=sysv %__make %{?_smp_mflags} all %{!?_without_doc:%__make %{?_smp_mflags} doc} -- 1.8.1.5