From 97c3e79c6db206459e1d6c0ec831c1095d23a75a Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Mon, 10 Mar 2008 22:15:50 +0000 Subject: [PATCH] Changed sheba/util-vserver integration to use pkgs/util-vserver as overlay directory --- pkg_util-vserver.conf | 67 ++----------------- ...r_vservers_.defaults_scripts_post-start.sh | 29 ++++++++ ...ir_vservers_.defaults_scripts_pre-start.sh | 38 +++++++++++ pkgs/util-vserver/etc_init.d_vserver.sh | 24 +++++++ pkgs/util-vserver/etc_runit_1.d_20vserver.ln | 1 + .../etc_runit_1.d_26vprocunhide.ln | 1 + .../etc_runit_1.d_98vservers-default.ln | 1 + .../etc_runit_3.d_02vservers-default.ln | 1 + 8 files changed, 100 insertions(+), 62 deletions(-) create mode 100644 pkgs/util-vserver/D%sysconfdir_vservers_.defaults_scripts_post-start.sh create mode 100644 pkgs/util-vserver/D%sysconfdir_vservers_.defaults_scripts_pre-start.sh create mode 100644 pkgs/util-vserver/etc_init.d_vserver.sh create mode 100644 pkgs/util-vserver/etc_runit_1.d_20vserver.ln create mode 100644 pkgs/util-vserver/etc_runit_1.d_26vprocunhide.ln create mode 100644 pkgs/util-vserver/etc_runit_1.d_98vservers-default.ln create mode 100644 pkgs/util-vserver/etc_runit_3.d_02vservers-default.ln diff --git a/pkg_util-vserver.conf b/pkg_util-vserver.conf index 91ebc09..76447f8 100644 --- a/pkg_util-vserver.conf +++ b/pkg_util-vserver.conf @@ -1,77 +1,20 @@ # --- SDE-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. -# +# # Filename: target/sheba/pkg_util-vserver.conf -# Copyright (C) 2007 The OpenSDE Project +# Copyright (C) 2007 - 2008 The OpenSDE Project # Copyright (C) 2004 - 2006 Alejandro Mery -# +# # More information can be found in the files COPYING and README. -# +# # 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. A copy of the # GNU General Public License can be found in the file COPYING. # --- SDE-COPYRIGHT-NOTE-END --- -sheba_activate_vserver() { - local runitdir=$root/etc/runit - local initddir=$root/etc/init.d - local defaults=$root/$sysconfdir/vservers/.defaults - - cat <<-EOT > $initddir/vserver - #!/bin/sh - - case "\$1" in - start) mkdir -p /var/run/vservers{,.rev} - mkdir -p /var/run/vshelper - sysctl kernel.vshelper=$libdir/util-vserver/vshelper - ;; - esac - EOT - chmod +x $initddir/vserver - - mkdir -p $defaults/scripts - cat <<-EOT > $defaults/scripts/pre-start - #!/bin/sh - - # interesting nodes from the host - # - for x in console full log null ptmx random tty urandom zero; do - cp -a /dev/\$x dev/ - done - - # some friendly symlinks - # - ln -s /proc/self/fd dev/fd - ln -s fd/0 dev/stdin - ln -s fd/1 dev/stdout - ln -s fd/2 dev/stderr - - # and a place to mount devpts - # - mkdir dev/pts - EOT - - cat <<-EOT > $defaults/scripts/post-start - #!/bin/sh - - . $libdir/util-vserver/util-vserver-vars - - # mount devpts after /dev was populated - # - \$_SECURE_MOUNT -t devpts -o gid=5,mode=620,dev --chroot none /dev/pts - EOT - - chmod +x $defaults/scripts/{pre,post}-start - - ln -snfv ${initddir#$root}/vserver $runitdir/1.d/20vserver - ln -snfv ${initddir#$root}/vprocunhide $runitdir/1.d/26vprocunhide - ln -snfv ${initddir#$root}/vservers-default $runitdir/1.d/98vservers-default - ln -snfv ${initddir#$root}/vservers-default $runitdir/3.d/02vservers-default -} - . $confdir/$pkg.conf -hook_add postmake 5 'sheba_activate_vserver' +hook_add postmake 5 "overlay_apply '$base/target/$target/pkgs/$pkg'" var_append patchfiles ' ' $base/target/$target/patches/$pkg.patch diff --git a/pkgs/util-vserver/D%sysconfdir_vservers_.defaults_scripts_post-start.sh b/pkgs/util-vserver/D%sysconfdir_vservers_.defaults_scripts_post-start.sh new file mode 100644 index 0000000..7409e0f --- /dev/null +++ b/pkgs/util-vserver/D%sysconfdir_vservers_.defaults_scripts_post-start.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: target/sheba/pkgs/util-vserver/D%sysconfdir_vservers_.defaults_scripts_post-start.sh +# Copyright (C) 2008 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# 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. A copy of the +# GNU General Public License can be found in the file COPYING. +# --- SDE-COPYRIGHT-NOTE-END --- + +. D_libdir/util-vserver/util-vserver-vars + +if grep -q '[ ]/dev[ ]' "$__CONFDIR/$2/fstab"; then + # guest has /dev as tmpfs + # + + # mount devpts after /dev was populated + # + $_SECURE_MOUNT -t devpts -o gid=5,mode=620,dev --chroot none /dev/pts + + # 144 is what qemu wants... I know it's wrong to hardcode this here, but + # I don't have the time for a better implementation (fstab) yet + $_SECURE_MOUNT -t tmpfs -o size=144m --chroot none /dev/shm +fi diff --git a/pkgs/util-vserver/D%sysconfdir_vservers_.defaults_scripts_pre-start.sh b/pkgs/util-vserver/D%sysconfdir_vservers_.defaults_scripts_pre-start.sh new file mode 100644 index 0000000..a2f81ae --- /dev/null +++ b/pkgs/util-vserver/D%sysconfdir_vservers_.defaults_scripts_pre-start.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: target/sheba/pkgs/util-vserver/D%sysconfdir_vservers_.defaults_scripts_pre-start.sh +# Copyright (C) 2008 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# 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. A copy of the +# GNU General Public License can be found in the file COPYING. +# --- SDE-COPYRIGHT-NOTE-END --- + +. D_libdir/util-vserver/util-vserver-vars + +if grep -q '[ ]/dev[ ]' "$__CONFDIR/$2/fstab"; then + # guest has /dev as tmpfs + # + + install_nodes() + { + local dir="$1" x= + + for x in $dir/*; do + y=dev/${x##*/} + + [ ! -e "$y" ] || rm -f "$y" + + cp -a "$x" "$y" + done + } + + for x in .defaults "$2"; do + [ ! -d "$__CONFDIR/$x/dev" ] || install_nodes "$__CONFDIR/$x/dev" + done +fi diff --git a/pkgs/util-vserver/etc_init.d_vserver.sh b/pkgs/util-vserver/etc_init.d_vserver.sh new file mode 100644 index 0000000..591f21f --- /dev/null +++ b/pkgs/util-vserver/etc_init.d_vserver.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: target/sheba/pkgs/util-vserver/etc_init.d_vserver.sh +# Copyright (C) 2008 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# 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. A copy of the +# GNU General Public License can be found in the file COPYING. +# --- SDE-COPYRIGHT-NOTE-END --- + +case "$1" in +start) + # FIXME: var/run gets wiped out on each boot, the directories should be preserved + mkdir -p /var/run/vservers{,.rev} + mkdir -p /var/run/vshelper + + sysctl kernel.vshelper=D_libdir/util-vserver/vshelper + ;; +esac diff --git a/pkgs/util-vserver/etc_runit_1.d_20vserver.ln b/pkgs/util-vserver/etc_runit_1.d_20vserver.ln new file mode 100644 index 0000000..4f8d628 --- /dev/null +++ b/pkgs/util-vserver/etc_runit_1.d_20vserver.ln @@ -0,0 +1 @@ +/etc/init.d/vserver diff --git a/pkgs/util-vserver/etc_runit_1.d_26vprocunhide.ln b/pkgs/util-vserver/etc_runit_1.d_26vprocunhide.ln new file mode 100644 index 0000000..ecdf2a0 --- /dev/null +++ b/pkgs/util-vserver/etc_runit_1.d_26vprocunhide.ln @@ -0,0 +1 @@ +/etc/init.d/vprocunhide diff --git a/pkgs/util-vserver/etc_runit_1.d_98vservers-default.ln b/pkgs/util-vserver/etc_runit_1.d_98vservers-default.ln new file mode 100644 index 0000000..baa1da0 --- /dev/null +++ b/pkgs/util-vserver/etc_runit_1.d_98vservers-default.ln @@ -0,0 +1 @@ +/etc/init.d/vservers-default diff --git a/pkgs/util-vserver/etc_runit_3.d_02vservers-default.ln b/pkgs/util-vserver/etc_runit_3.d_02vservers-default.ln new file mode 100644 index 0000000..baa1da0 --- /dev/null +++ b/pkgs/util-vserver/etc_runit_3.d_02vservers-default.ln @@ -0,0 +1 @@ +/etc/init.d/vservers-default