From: Enrico Scholz Date: Sat, 18 Oct 2003 02:24:20 +0000 (+0000) Subject: initial checkin X-Git-Tag: VERSION_0_10~1195 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2afee371c49eebac530575881f04cef73077aa0e;p=util-vserver.git initial checkin git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@218 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/scripts/vserver-build b/util-vserver/scripts/vserver-build new file mode 100755 index 0000000..efd8d9f --- /dev/null +++ b/util-vserver/scripts/vserver-build @@ -0,0 +1,80 @@ +#! /bin/bash +# $Id$ + +# 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; version 2 of the License. +# +# 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. + +: ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars} +test -e "$UTIL_VSERVER_VARS" || { + echo "Can not find util-vserver installation; aborting..." + exit 1 +} +. "$UTIL_VSERVER_VARS" +. "$_LIB_FUNCTIONS" + +### Some local functions + +function showHelp() +{ + echo \ +$"Usage: $(basename $0) -m -n [--] * + +Possible methods are: + legacy ... the \"old\" copy-all-from-host method, which requires the + old legacy vserver-legacy script + copy ... the copy-all-from-host method which uses the recent + configuration scheme + apt -d + ... installs the base-packages of the given distribution with + help of 'vapt-get' + +Please report bugs to $PACKAGE_BUGREPORT" + exit 0 +} + +function showVersion() +{ + echo \ +$"vserver-build $PACKAGE_VERSION -- initializes a vserver +This program is part of $PACKAGE_STRING + +Copyright (C) 2003 Enrico Scholz +This program is free software; you may redistribute it under the terms of +the GNU General Public License. This program has absolutely no warranty." + exit 0 +} + +### main starts here + +set +e + +tmp=$(getopt -o +m:n: --long help,version -n "$0" -- "$@") || exit 1 +eval set -- "$tmp" + +while true; do + case "$1" in + --help) showHelp $0 ;; + --version) showVersion ;; + -m) method=$2; shift 2;; + -n) name=$2; shift 2;; + --) shift; break;; + *) echo $"vserver-build: internal error."; exit 1;; + esac +done + + + +echo "Sorry, just a prototype currently..." +exit 1 diff --git a/util-vserver/src/pipe-sync.c b/util-vserver/src/pipe-sync.c new file mode 100644 index 0000000..1c3076d --- /dev/null +++ b/util-vserver/src/pipe-sync.c @@ -0,0 +1,70 @@ +// $Id$ --*- c -*-- + +// 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; version 2 of the License. +// +// 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. + + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "util.h" +#include "wrappers.h" + +#include +#include +#include +#include +#include + +int wrapper_exit_code = 2; + +static void +sigHandler(int UNUSED sig) +{ +} + +int main(int argc, char *argv[]) +{ + int fd; + char buf[1]; + bool res; + bool is_root; + + if (argc!=4) { + WRITE_MSG(2, "Usage: minit-sync \n"); + return 1; + } + + is_root = strcmp(argv[1], "/")==0; + + if (!is_root) { + Echroot(argv[1]); + Echdir("/"); + } + + signal(SIGALRM, sigHandler); + alarm(atoi(argv[3])); + + res = ((fd=open(argv[2], O_RDONLY, 0))!=-1 && + read(fd, buf, sizeof buf)!=-1); + + if (fd!=-1) Eclose(fd); + + if (!is_root) + Eunlink(argv[2]); + + return res ? 0 : 1; +}