#!/bin/sh # #!F:switch_kernel # #!P:/usr/local/sbin # #!D:Kernel 2.0/2.1/2.2/2.3 depended link switcher # #!I:Should be called by /etc/init.d/rc.sysinit after mounting #!I: the filesystems #!I:Following files are supported at the moment: #!I: /etc/conf.modules (because some module names/information differs) #!I: /etc/printcap (because the lpx assign mechanism has changed) # #!C:Copyright 1998-1999 Peter Bieringer # #!V:Version 1.20 1999-01-19 # # Changes to # 1.20: New running scheme # 1.12: Minor fix # 1.11: Now also for kernel 2.3 (for the future) # 1.10: Now also for kernel 2.2 # Changing of the filenames # 1.01: Stand-alone version ### Info for switching configuration files ## modules configuration # Switching /etc/conf.modules enabled? MODULES_SWITCH=yes # Filenames MODULES_20=/etc/conf.modules-2.0 MODULES_21=/etc/conf.modules-2.1 MODULES_22=/etc/conf.modules-2.2 MODULES_23=/etc/conf.modules-2.3 MODULES_ORIG=/etc/conf.modules ## printcap # Switching /etc/printcap enabled? PRINTCAP_SWITCH=yes # Filenames PRINTCAP_20=/etc/printcap-2.0 PRINTCAP_21=/etc/printcap-2.1 PRINTCAP_22=/etc/printcap-2.2 PRINTCAP_23=/etc/printcap-2.3 PRINTCAP_ORIG=/etc/printcap ## Functions # Display information info() { grep "^#!D" $0 | awk -F: '{ print $2}' grep "^#!C" $0 | awk -F: '{ print " " $2}' grep "^#!V" $0 | awk -F: '{ print " " $2}' } usage() { echo "Syntax: switch_kernel {2.0|2.1|2.2|2.3|auto}" exit 1 } ### Start info if [ "$1" = "auto" ]; then KERNELVERSION=`cat /proc/version | awk '{ print $3 }' | awk -F. '{ print $1 "." $2 }'` echo " Automatic detected kernel version is '$KERNELVERSION'" else if [ "$1" != "" ]; then KERNELVERSION=$1 else usage fi fi ## Get version depending files case $KERNELVERSION in 2.0) MODULES_NEW=$MODULES_20 PRINTCAP_NEW=$PRINTCAP_20 ;; 2.1) MODULES_NEW=$MODULES_21 PRINTCAP_NEW=$PRINTCAP_21 ;; 2.2) MODULES_NEW=$MODULES_22 PRINTCAP_NEW=$PRINTCAP_22 ;; 2.3) MODULES_NEW=$MODULES_23 PRINTCAP_NEW=$PRINTCAP_23 ;; *) usage ;; esac ## Test if new file exists if [ "$MODULES_SWITCH" = "yes" ]; then if [ ! -f $MODULES_NEW ]; then echo " File '$MODULES_NEW' doesn't exist!" MODULES_SWITCH="no" fi fi if [ "$PRINTCAP_SWITCH" = "yes" ]; then if [ ! -f $PRINTCAP_NEW ]; then echo " File '$PRINTCAP_NEW' doesn't exist!" PRINTCAP_SWITCH="no" fi fi ## Now do the work if [ "$MODULES_SWITCH" = "yes" ]; then # Change softlink to a conf.modules, # which has specific entries # Make backup of the existing file, if not a link if [ -f $MODULES_ORIG -a ! -L $MODULES_ORIG ]; then mv -bV t $MODULES_ORIG $MODULES_ORIG.bak fi echo " Link '$MODULES_ORIG' to '$MODULES_NEW' for $KERNELVERSION.x usage." # Create new or change link ln -f -s $MODULES_NEW $MODULES_ORIG fi if [ "$PRINTCAP_SWITCH" = "yes" ]; then # Change softlink to a printcap, # which has specific entries # Make backup of the existing file, if not a link if [ -f $PRINTCAP_ORIG -a ! -L $PRINTCAP_ORIG ]; then mv -bV t $PRINTCAP_ORIG $PRINTCAP_ORIG.bak fi echo " Link '$PRINTCAP_ORIG' to '$PRINTCAP_NEW' for $KERNELVERSION.x usage." # Create new or change link ln -f -s $PRINTCAP_NEW $PRINTCAP_ORIG fi exit 0