Changeset 2471

Show
Ignore:
Timestamp:
01/23/07 17:41:03 (2 years ago)
Author:
hollow
Message:

cleanup gentoo/initpost; add fixes for syslog-ng.conf and net dependency in baselayout >= 1.13

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/distrib/Makefile.am

    r2360 r2471  
    3434                           gentoo/initpost \ 
    3535                           gentoo/initpre \ 
    36                            gentoo/init-vserver.sh 
     36                           gentoo/init-vserver.sh \ 
     37                           gentoo/net.vserver 
    3738 
    3839nobase_distrib_DATA     =  defaults/devs \ 
  • trunk/distrib/gentoo/initpost

    r2465 r2471  
    1818## Called as: initpost <cfgdir> <path of util-vserver-vars> 
    1919 
     20# finish notice from initpre 
     21echo "ok" 
     22 
     23 
     24#setup environment 
    2025cfgdir="$1" 
    2126vdir="$cfgdir"/vdir 
    2227. "$2" 
    2328 
     29 
     30# go to vdir for chroot-sh 
     31pushd "$vdir" &>/dev/null 
     32 
     33 
     34# helper for sed in chroot 
     35chrootsed() { 
     36        local file="$1" 
     37        shift 
     38         
     39        sedtmp=$($_MKTEMP chrootsed.XXXXXX) 
     40         
     41        $_CHROOT_SH cat "$file" | $_SED "$@" > $sedtmp 
     42        $_CHROOT_SH truncate "$file"  < $sedtmp 
     43         
     44        $_RM -f $sedtmp 
     45} 
     46 
     47 
    2448# portage stuff 
    25 pushd "$vdir" &>/dev/null 
    2649$_CHROOT_SH mkdir /usr         2>/dev/null || : 
    2750$_CHROOT_SH mkdir /usr/portage 2>/dev/null || : 
    28 popd &>/dev/null 
    2951 
    3052 
     
    3456 
    3557if test "$initstyle" == "gentoo"; then 
    36         pushd "$vdir" &>/dev/null 
    37  
    3858        echo ">>> Installing special init-style magic ... " 
    3959 
     
    4161        $_CHROOT_SH truncate   /lib/rcscripts/sh/init-vserver.sh 
    4262        $_CHROOT_SH chmod 0755 /lib/rcscripts/sh/init-vserver.sh 
    43  
    44         popd &>/dev/null 
    4563 
    4664        echo "!!!" 
     
    5674 
    5775# unneeded runlevel scripts 
    58 pushd "$vdir" &>/dev/null 
    5976echo ">>> Fixing default runlevel scripts ... " 
    6077$_CHROOT_SH rm /etc/runlevels/boot/{clock,consolefont,keymaps,modules,net.lo} 2>/dev/null || : 
    6178$_CHROOT_SH rm /etc/runlevels/default/{hdparm,netmount} 2>/dev/null || : 
    62 popd &>/dev/null 
    6379 
    6480 
    6581# setting hostname 
    66 pushd "$vdir" &>/dev/null 
    67  
    6882if test -r "$cfgdir"/uts/nodename && $_CHROOT_SH testfile /etc/conf.d/hostname; then 
    6983        echo ">>> Setting hostname ... " 
    70         hostnametmp=$($_MKTEMP hostname.XXXXXX) 
    71  
    72         $_CHROOT_SH cat /etc/conf.d/hostname | \ 
    73         $_SED "s:HOSTNAME=\"\(.*\)\":HOSTNAME=\"$(< "$cfgdir"/uts/nodename)\":" > $hostnametmp 
    74         $_CHROOT_SH truncate /etc/conf.d/hostname  < $hostnametmp 
    75  
    76         $_RM -f $hostnametmp 
     84        chrootsed /etc/conf.d/hostname \ 
     85                -e "s:HOSTNAME=\"\(.*\)\":HOSTNAME=\"$(< "$cfgdir"/uts/nodename)\":" 
    7786fi 
    7887 
    79 popd &>/dev/null 
    8088 
    81  
    82 # check for baselayout >= 1.13 
    83 pushd "$vdir" &>/dev/null 
    84 basever=$($_CHROOT_SH cat /etc/gentoo-release | $_AWK '{print $5}') 
    85 popd &>/dev/null 
    86  
    87 echo ">>> Found baselayout-$basever" 
    88  
    89 basemaj=${basever/.*} 
    90 basemin=${basever#*.} 
    91 basemin=${basemin/.*} 
    92  
    93 if test "$basemaj" -lt 1 -o "$basemin" -lt 13; then 
    94         echo "!!! Will not do automagic changes to baselayout < 1.13" 
    95         echo "!!! You have to take care for yourself ..." 
    96         exit 0 
     89# fix syslog-ng.conf 
     90if $_CHROOT_SH testfile /etc/syslog-ng/syslog-ng.conf; then 
     91        echo ">>> Fixing syslog-ng.conf ... " 
     92        chrootsed /etc/syslog-ng/syslog-ng.conf \ 
     93                -e 's:pipe("/proc/kmsg"); ::' \ 
     94                -e 's:\(.*console_all.*\):#\1:g' 
    9795fi 
    9896 
    9997 
    10098# fix gettys in inittab 
    101 pushd "$vdir" &>/dev/null 
    102  
    10399if $_CHROOT_SH testfile /etc/inittab; then 
    104100        echo ">>> Fixing inittab ... " 
    105         inittabtmp=$($_MKTEMP inittab.XXXXXX) 
    106  
    107         $_CHROOT_SH cat /etc/inittab | \ 
    108         $_SED 's/\(^[^#].*getty.*$\)/#\1/' > $inittabtmp 
    109         $_CHROOT_SH truncate /etc/inittab  < $inittabtmp 
    110  
    111         $_RM -f $inittabtmp 
     101        chrootsed /etc/inittab \ 
     102                -e 's/\(^[^#].*getty.*$\)/#\1/' 
    112103fi 
    113104 
    114 popd &>/dev/null 
     105 
     106# fix fstab for checkfs/localmount in baselayout >= 1.13 
     107# (does not affect any previous versions) 
     108echo ">>> Fixing fstab ... " 
     109echo "/dev/hdv1 / ufs defaults 0 0" | $_CHROOT_SH truncate /etc/fstab 
    115110 
    116111 
    117 # fix fstab for checkfs/localmount 
    118 pushd "$vdir" &>/dev/null 
    119 echo ">>> Fixing fstab ... " 
    120 echo "/dev/hdv1 / ufs defaults 0 0" | $_CHROOT_SH truncate /etc/fstab 
     112# always satisfy net dependency in baselayout >= 1.13 
     113# (does not affect any previous versions) 
     114echo ">>> Providing dummy net dependency ... " 
     115$_CAT "$__DISTRIBDIR"/gentoo/net.vserver | \ 
     116$_CHROOT_SH truncate /etc/init.d/net.vserver 
     117$_CHROOT_SH chmod 0755 /etc/init.d/net.vserver 
     118 
    121119popd &>/dev/null 
  • trunk/distrib/gentoo/initpre

    r2360 r2471  
    2222 
    2323# portage stuff 
    24  
    2524echo ">>> Adding shared /usr/portage to fstab ... " 
    2625 
    27 if test -d /usr/portage; then 
     26hash portageq &>/dev/null 
     27 
     28if test $? -eq 0; then 
     29        _PORTDIR=$(portageq portdir) 
     30else 
     31        _PORTDIR=/usr/portage 
     32fi 
     33 
     34if test -d $_PORTDIR; then 
    2835        ( echo 
    2936          echo "# shared portage tree" 
    30           echo "/usr/portage           /usr/portage           none bind,ro 0 0" 
    31           echo "/usr/portage/distfiles /usr/portage/distfiles none bind,rw 0 0" 
     37          echo "${_PORTDIR}           /usr/portage           none bind,ro 0 0" 
     38          echo "${_PORTDIR}/distfiles /usr/portage/distfiles none bind,rw 0 0" 
    3239        ) >> "$1"/fstab 
    3340else 
    34         echo "!!! Cannot find /usr/portage! You should definitely use a" 
     41        echo "!!! Cannot find a portage tree! You should definitely use a" 
    3542        echo "!!! shared portage tree if you have multiple Gentoo guests!" 
    3643fi 
     
    4754        echo "!!! Please use one of: plain, gentoo" 
    4855fi 
     56 
     57echo -n ">>> Unpacking template ... "