From: Marcin Krol Date: Tue, 21 May 2024 16:43:46 +0000 (+0200) Subject: - drop unused vserver stuff X-Git-Tag: 0.5.4~16 X-Git-Url: https://git.tld-linux.org/?a=commitdiff_plain;h=4404a269deb7ef3202edfe76ce89af0fb81c5bf2;p=rc-scripts.git - drop unused vserver stuff --- diff --git a/lib/functions b/lib/functions index 8f08dc6..012f59c 100644 --- a/lib/functions +++ b/lib/functions @@ -59,52 +59,6 @@ CCHARS="$WHITE" # Color of these characters (look at /etc/sysconfig/init-colors [ -r /etc/sysconfig/system ] && . /etc/sysconfig/system [ -r /etc/sysconfig/bootsplash ] && . /etc/sysconfig/bootsplash -if [ -z "$VSERVER" -o "$VSERVER" = "detect" ]; then - { - while read _f _ctx; do - [ "$_f" = "VxID:" -o "$_f" = "s_context:" ] && break - done /dev/null - if [ -z "$_ctx" -o "$_ctx" = "0" ]; then - VSERVER=no - else - VSERVER=yes - fi - unset _f _ctx -fi - -# VSERVER_ISOLATION_NET = isolation only inside of vserver guests -if [ -z "$VSERVER_ISOLATION_NET" -o "$VSERVER_ISOLATION_NET" = "detect" ]; then - VSERVER_ISOLATION_NET=no - if [ "$VSERVER" = "yes" ]; then - if [ -f /proc/self/nsproxy ]; then - # older kernels - { - while read _t _data; do - [ "$_t" = "net:" ] && break - done < /proc/self/nsproxy - } 2> /dev/null - if [ "${_data##*\(}" = "I)" ]; then - VSERVER_ISOLATION_NET=yes - fi - elif [ -f /proc/self/ninfo ]; then - # newer kernels - { - while read _t _data; do - [ "$_t" = "NCaps:" ] && break - done < /proc/self/ninfo - } 2> /dev/null - if [ "${_t}" = "NCaps:" ]; then - VSERVER_ISOLATION_NET=yes - fi - else - # assume (very?) old kernel mode - VSERVER_ISOLATION_NET=yes - fi - unset _f _data - fi -fi - # we need to know in functions if we were called from a terminal if [ -z "$ISATTY" ]; then [ -t ] && ISATTY=yes || ISATTY=no @@ -358,7 +312,7 @@ nls() { rc_splash() { local action="$1" - if ! is_no "$BOOT_SPLASH" && ! is_yes "$VSERVER"; then + if ! is_no "$BOOT_SPLASH"; then [ -x /bin/splash ] && /bin/splash "$action" fi @@ -472,7 +426,6 @@ checkpid() { # - inside chroot get only those processes, which are inside chroot. # - don't filter out pids which do not have corresponding running processes (process died etc) # (note: some processes like named are chrooted but run outside chroot) -# - do nothing inside vserver filter_chroot() { # no pids, exit early [ $# -eq 0 ] && return @@ -484,11 +437,6 @@ filter_chroot() { pids=$(filter_ns "$@") && set -- "$pids" fi - if is_yes "$VSERVER"; then - echo $@ - return - fi - if [ $# -lt 1 -o ! -d /proc/1 ]; then echo $@ return diff --git a/rc.d/init.d/netfs b/rc.d/init.d/netfs index ab00e6d..19738b7 100755 --- a/rc.d/init.d/netfs +++ b/rc.d/init.d/netfs @@ -15,7 +15,7 @@ . /etc/rc.d/init.d/cryptsetup . /etc/sysconfig/network -if is_yes "$VSERVER" || [[ "$container" = lxc* ]]; then +if [[ "$container" = lxc* ]]; then exit 0 fi @@ -173,28 +173,16 @@ RETVAL=0 # See how we were called. case "$1" in start) - if is_yes "$VSERVER_ISOLATION_NET"; then - exit 0 - fi start ;; stop) - if is_yes "$VSERVER_ISOLATION_NET"; then - exit 0 - fi stop ;; restart) - if is_yes "$VSERVER_ISOLATION_NET"; then - exit 0 - fi stop start ;; reload) - if is_yes "$VSERVER_ISOLATION_NET"; then - exit 0 - fi start ;; status) diff --git a/rc.d/init.d/network b/rc.d/init.d/network index b44e291..cf670a7 100755 --- a/rc.d/init.d/network +++ b/rc.d/init.d/network @@ -356,11 +356,7 @@ find_boot_interfaces # See how we were called. case "$1" in start) - if is_yes "$VSERVER_ISOLATION_NET"; then - touch /var/lock/subsys/network - else - start - fi + start ;; start_init) network_init @@ -374,11 +370,7 @@ case "$1" in rm -f /var/lock/subsys/network ;; stop) - if is_yes "$VSERVER_ISOLATION_NET"; then - rm -f /var/lock/subsys/network >/dev/null 2>&1 - else - stop - fi + stop ;; status) @@ -394,18 +386,11 @@ case "$1" in ;; reload) - if is_yes "$VSERVER_ISOLATION_NET"; then - exit 0 - fi shift reload ${1:+"$@"} ;; restart) - if is_yes "$VSERVER_ISOLATION_NET"; then - exit 0 - fi - stop start ;; diff --git a/rc.d/init.d/random b/rc.d/init.d/random index 342dcdc..6c7e411 100755 --- a/rc.d/init.d/random +++ b/rc.d/init.d/random @@ -11,11 +11,6 @@ # Source function library. . /etc/rc.d/init.d/functions -# do nothing in vserver -if is_yes "$VSERVER"; then - return -fi - random_seed=/var/run/random-seed poolfile=/proc/sys/kernel/random/poolsize diff --git a/rc.d/rc b/rc.d/rc index 04d6f38..4bf8cb2 100755 --- a/rc.d/rc +++ b/rc.d/rc @@ -68,7 +68,7 @@ fi # virtual console, and send messages to /dev/console # (it can be serial console too) if [ "$COLUMNS" -gt 0 ]; then - if [ "$argv2" != "chroot" ] && ! is_yes "$VSERVER" && \ + if [ "$argv2" != "chroot" ] && \ [ "$runlevel" = "0" -o "$runlevel" = "6" ]; then CONSOLE=/dev/tty1 [ -x /usr/bin/chvt ] && /usr/bin/chvt 1 && echo > $CONSOLE @@ -82,7 +82,7 @@ fi # See if we want to be in user confirmation mode if [ "$previous" = "N" ]; then - if ! is_yes "$VSERVER" && grep -qi confirm /proc/cmdline >/dev/null 2>/dev/null \ + if grep -qi confirm /proc/cmdline >/dev/null 2>/dev/null \ || [ -f /var/run/confirm ]; then rm -f /var/run/confirm CONFIRM="yes" @@ -129,14 +129,6 @@ else export progress=0 fi -if is_yes "$VSERVER"; then - # if runlevel is not 0 (halt) or 6 (reboot) run rc.sysinit - # BUT only if rc is run standalone (not run by init, as init will run rc.sysinit) - if [ "$previous" != "N" -a "$runlevel" != "0" -a "$runlevel" != "6" ]; then - /etc/rc.d/rc.sysinit $runlevel - fi -fi - # set onlcr to avoid staircase effect and do not lock scrolling stty onlcr -ixon 0>&1 2>/dev/null diff --git a/rc.d/rc.shutdown b/rc.d/rc.shutdown index d86f962..96d7864 100755 --- a/rc.d/rc.shutdown +++ b/rc.d/rc.shutdown @@ -54,93 +54,89 @@ fi # Write to wtmp file before unmounting /var halt -w -if ! is_yes "$VSERVER"; then - # Turn off swap, then unmount file systems. - run_cmd "Turning off swap" swapoff -a +# Turn off swap, then unmount file systems. +run_cmd "Turning off swap" swapoff -a - [ -x /etc/rc.d/rc.acct ] && /etc/rc.d/rc.acct stop +[ -x /etc/rc.d/rc.acct ] && /etc/rc.d/rc.acct stop - if [ -x /sbin/quotaoff ]; then - run_cmd "Turning off quotas for local filesystems" /sbin/quotaoff -a - fi +if [ -x /sbin/quotaoff ]; then + run_cmd "Turning off quotas for local filesystems" /sbin/quotaoff -a +fi + +# grab kexec_loaded state before we umount /sys +kexec_loaded=`cat /sys/kernel/kexec_loaded 2>/dev/null` - # grab kexec_loaded state before we umount /sys - kexec_loaded=`cat /sys/kernel/kexec_loaded 2>/dev/null` +# Unmount file systems, killing processes if we have to. +sig=-15 +retry=3 +force= +if [ -z "$UMOUNT_IGNORE" ]; then + UMOUNT_IGNORE="/" +else + UMOUNT_IGNORE="/ $UMOUNT_IGNORE" +fi +remaining=$(awk -v ig="^($UMOUNT_IGNORE)$" 'BEGIN { gsub(/[\t ]+/, "|", ig); } \ + $3 !~ /^(proc|loopfs|devpts|devtmpfs|shm|iso9660|ramfs|tmpfs|sysfs|securityfs|squashfs)$/ \ + && $1 !~ /^(none|\/dev\/root)$/ \ + && $2 !~ ig {print $2}' /proc/mounts) +while [ -n "$remaining" -a "$retry" -gt 0 ]; do + show "Unmounting file systems"; busy + ERRORS=$(umount -a $force -t noproc 2>&1); rc=$? + + # we might had unmounted /usr, recheck $TPUT availability + # but well. we need tput only for show() and busy() (ok() and fail() messages are already cached) + # TODO: look ahead the messages? + if is_yes "$TPUT"; then + TPUT= + rc_gettext_init + fi - # Unmount file systems, killing processes if we have to. - sig=-15 - retry=3 - force= - if [ -z "$UMOUNT_IGNORE" ]; then - UMOUNT_IGNORE="/" + if [ $rc = 0 ]; then + ok else - UMOUNT_IGNORE="/ $UMOUNT_IGNORE" + fail + [ -n "$ERRORS" ] && echo "$ERRORS" fi + + sleep 2 remaining=$(awk -v ig="^($UMOUNT_IGNORE)$" 'BEGIN { gsub(/[\t ]+/, "|", ig); } \ $3 !~ /^(proc|loopfs|devpts|devtmpfs|shm|iso9660|ramfs|tmpfs|sysfs|securityfs|squashfs)$/ \ && $1 !~ /^(none|\/dev\/root)$/ \ && $2 !~ ig {print $2}' /proc/mounts) - while [ -n "$remaining" -a "$retry" -gt 0 ]; do - show "Unmounting file systems"; busy - ERRORS=$(umount -a $force -t noproc 2>&1); rc=$? - - # we might had unmounted /usr, recheck $TPUT availability - # but well. we need tput only for show() and busy() (ok() and fail() messages are already cached) - # TODO: look ahead the messages? - if is_yes "$TPUT"; then - TPUT= - rc_gettext_init - fi - - if [ $rc = 0 ]; then - ok - else - fail - [ -n "$ERRORS" ] && echo "$ERRORS" - fi - - sleep 2 - remaining=$(awk -v ig="^($UMOUNT_IGNORE)$" 'BEGIN { gsub(/[\t ]+/, "|", ig); } \ - $3 !~ /^(proc|loopfs|devpts|devtmpfs|shm|iso9660|ramfs|tmpfs|sysfs|securityfs|squashfs)$/ \ - && $1 !~ /^(none|\/dev\/root)$/ \ - && $2 !~ ig {print $2}' /proc/mounts) - [ -z "$remaining" ] && break - fuser -k -m $sig $remaining > /dev/null - sleep 5 - retry=$(($retry-1)) - sig=-9 - force="-f" - done - - run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro / - - if [ -x /sbin/vgchange ]; then - lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}') - if [ "$lvmversion" = "2" ]; then - lvmsysinit="--sysinit" - else - lvmsysinit="" - fi - /sbin/vgchange -a n $lvmsysinit > /dev/null 2>&1 - fi + [ -z "$remaining" ] && break + fuser -k -m $sig $remaining > /dev/null + sleep 5 + retry=$(($retry-1)) + sig=-9 + force="-f" +done - if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then - if grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null; then - /sbin/mdadm --stop --scan > /dev/null 2>&1 - rc=$? - fi - fi +run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro / - show "Remounting remaining filesystems ro mode"; busy - if mount | awk '/ext2|ext3|reiserfs|xfs|jfs/ { print $3 }' | while read line; do mount -n -o ro,remount $line; done; then - ok +if [ -x /sbin/vgchange ]; then + lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}') + if [ "$lvmversion" = "2" ]; then + lvmsysinit="--sysinit" else - fail + lvmsysinit="" fi - _rebootwhat="system" + /sbin/vgchange -a n $lvmsysinit > /dev/null 2>&1 +fi + +if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then + if grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null; then + /sbin/mdadm --stop --scan > /dev/null 2>&1 + rc=$? + fi +fi + +show "Remounting remaining filesystems ro mode"; busy +if mount | awk '/ext2|ext3|reiserfs|xfs|jfs/ { print $3 }' | while read line; do mount -n -o ro,remount $line; done; then + ok else - _rebootwhat="vserver" + fail fi +_rebootwhat="system" if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then . /etc/rc.d/init.d/cryptsetup diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit index b01b9d3..b6bfb29 100755 --- a/rc.d/rc.sysinit +++ b/rc.d/rc.sysinit @@ -197,17 +197,6 @@ enable_swap() { is_yes "$AUTOSWAP" && enable_autoswap } -# Remove duplicate entries from mtab (for vserver guest use only) -clean_vserver_mtab() { - > /etc/mtab.clean - while read device mountpoint line; do - grep -qs "$mountpoint" /etc/mtab.clean || \ - echo "$device $mountpoint $line" >> /etc/mtab.clean - done < /etc/mtab - cat /etc/mtab.clean > /etc/mtab - rm -f /etc/mtab.clean -} - # Loads modules from /etc/modules, /etc/modules.X.Y and /etc/modules.X.Y.Z load_kernel_modules() { local modules_file=$1 @@ -365,7 +354,7 @@ else RC_BOOTLOG= fi -if ! is_yes "$VSERVER" && [[ "$container" != lxc* ]]; then +if [[ "$container" != lxc* ]]; then # we need /proc mounted before everything is_fsmounted proc /proc || mount -n /proc || mount -n -o gid=17,hidepid=2 -t proc /proc /proc @@ -437,7 +426,7 @@ else domainname "" fi -if ! is_yes "$VSERVER" && [[ "$container" != lxc* ]]; then +if [[ "$container" != lxc* ]]; then # Set console loglevel if [ -n "$CONSOLE_LOGLEVEL" ]; then dmesg -n $CONSOLE_LOGLEVEL @@ -629,7 +618,7 @@ if [ -n "$IN_INITLOG" ]; then IN_INITLOG="" fi -if ! is_yes "$VSERVER" && [[ "$container" != lxc* ]]; then +if [[ "$container" != lxc* ]]; then # Clear mtab > /etc/mtab [ -f /etc/cryptomtab ] && > /etc/cryptomtab @@ -930,7 +919,6 @@ else killall -IO blogd fi - clean_vserver_mtab fi is_yes "$SELINUX" && [ -f /.autorelabel ] && relabel_selinux @@ -989,37 +977,35 @@ is_yes "$SELINUX" && restorecon /tmp/.ICE-unix >/dev/null 2>&1 test -d /var/run/netreport || mkdir -m 770 /var/run/netreport -if ! is_yes "$VSERVER"; then - enable_swap +enable_swap - # If a SCSI tape has been detected, load the st module unconditionally - # since many SCSI tapes don't deal well with st being loaded and unloaded - if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then - if grep -qv ' 9 st' /proc/devices 2>/dev/null; then - if [ -n "$USEMODULES" ] ; then - # Try to load the module. If it fails, ignore it... - insmod -p st >/dev/null 2>&1 && modprobe -s st - fi +# If a SCSI tape has been detected, load the st module unconditionally +# since many SCSI tapes don't deal well with st being loaded and unloaded +if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then + if grep -qv ' 9 st' /proc/devices 2>/dev/null; then + if [ -n "$USEMODULES" ] ; then + # Try to load the module. If it fails, ignore it... + insmod -p st >/dev/null 2>&1 && modprobe -s st fi fi +fi - # Now that we have all of our basic modules loaded and the kernel going, - # let's dump the syslog ring somewhere so we can find it later - mode=0600 - if [ "$(cat /proc/sys/kernel/dmesg_restrict)" = 0 ]; then - mode=0644 - fi - dmesg --raw > /var/log/dmesg - chmod $mode /var/log/dmesg - i=5 - while [ $i -ge 0 ]; do - if [ -f /var/log/dmesg.$i ]; then - mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1)) - fi - i=$(($i-1)) - done - cp -pf /var/log/dmesg /var/log/dmesg.0 +# Now that we have all of our basic modules loaded and the kernel going, +# let's dump the syslog ring somewhere so we can find it later +mode=0600 +if [ "$(cat /proc/sys/kernel/dmesg_restrict)" = 0 ]; then + mode=0644 fi +dmesg --raw > /var/log/dmesg +chmod $mode /var/log/dmesg +i=5 +while [ $i -ge 0 ]; do + if [ -f /var/log/dmesg.$i ]; then + mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1)) + fi + i=$(($i-1)) +done +cp -pf /var/log/dmesg /var/log/dmesg.0 if ! is_no "$RC_PROMPT"; then while :; do @@ -1031,8 +1017,8 @@ if ! is_no "$RC_PROMPT"; then fi } & -# /proc extra check if the background process we just spawned is still running, -# as in case of vserver bootup it finishes quite instantly. +# /proc extra check if the background process we just spawned is still running +# as it may finish quite instantly. if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then /sbin/getkey i && touch /var/run/confirm touch /var/run/getkey_done diff --git a/sysconfig/system b/sysconfig/system index a4f125d..096747a 100644 --- a/sysconfig/system +++ b/sysconfig/system @@ -113,12 +113,6 @@ RC_PROMPT=yes # Enable cpusets support? CPUSETS=no -# Enable this system as vserver guest (yes/no/detect) -VSERVER=detect - -# Vserver isolation only networking inside of guest (yes/no/detect) -VSERVER_ISOLATION_NET=detect - # Enable selinux support (yes/no/detect) # 'yes' behaves as 'detect' SELINUX=detect