Results 1 to 3 of 3

Thread: Modding knoppix.sh

  1. #1
    Member registered user
    Join Date
    Jun 2004
    Location
    Canada
    Posts
    67

    Modding knoppix.sh

    I can't find any mention of this method described anywhere on this board so here's a way to modify the knoppix.sh file which will allow you to do some customizing even while running from the CD. In my case, I still boot from the CD but I needed the system to do "modprobe ehci-hcd" each time the system is booted so that it will run my USB2 compactflash reader at USB2 speeds instead of chugging along at USB1 speed. So I just added this command to my modified knoppix.sh and now I don't have to remember to type in that command when I want to transfer lots of photos from my 1GB CF card.

    To use this method you must save the Knoppix configuration to a hard drive and use the cheatcode myconfig=scan at boot time.
    When Knoppix boots up with the cheatcode myconfig=scan, the init process executes /etc/init.d/rcS.d/S00knoppix-autoconfig which is a symbolic link to the file /etc/init.d/knoppix-autoconfig. One of the things this script does is to scan for the file knoppix.sh. When it is found, knoppix.sh is executed and passed the path name of the device on which it was found. Knoppix.sh then accesses the configs.tbz file on the specified device and restores the saved configuration.
    So this process assumes that configs.tbz and knoppix.sh will be on the same device. We can use this fact to make the system use our own modded knoppix.sh. But to do this you must have at least C: and D: hard drives/partitions on your windows system because we also take advantage of the order in which the drives are searched when knoppix.sh looks for configs.tbz. The trick is to save the knoppix configuration on one windows partition and to put the modified knoppix.sh on a partition which occurs before that in the search sequence. E.G. do a save configuration to D: and put the modified knoppix.sh on C:.
    The new knoppix.sh must contain extra code to make it find configs.tbz on D: instead of assuming that its on C:.
    It might also be possible to put the modified knoppix.sh on a compact flash card because those drives are searched before hard drives but on my system the CF card reader hasn't been mounted when knoppix.sh is executed.
    When this modded knoppix.sh is installed, knoppix-autoconfig will find the modded version on, for example, C: (/dev/hda1) and will run knoppix.sh from there. The modded version ignores the argument passed to it by knoppix-autoconfig and does its own search for configs.tbz which will be found on D: (/dev/hda5 on my system) and it restores the configuration from there.

    Here's my modified knopppix.sh which I put on C: (/dev/hda1).

    Code:
    #!/bin/sh
    # Modified knoppix.sh - PAH
    
    # ANSI COLORS
    CRE="
    "
    NORMAL=""
    # RED: Failure or error message
    RED=""
    # GREEN: Success message
    GREEN=""
    # YELLOW: Descriptions
    YELLOW=""
    # BLUE: System messages
    BLUE=""
    # MAGENTA: Found devices or drivers
    MAGENTA=""
    # CYAN: Questions
    CYAN=""
    # BOLD WHITE: Hint
    WHITE=""
    
    [ "`id -u`" = "0" ] || { echo "${RED}You need root privileges to modify the system!${NORMAL}" >&2 ; exit 1; }
    
    findfile(){
    FOUND=""
    # search all partitions for a file in the root directory
    for i in /mnt/[sh]d[a-z] /mnt/[sh]d[a-z][1-9] /mnt/[sh]d[a-z][1-9]?*; do
    # See if it's already mounted
    [ -f "$i/$1" ] &&  { echo "$i/$1"; return 0; }
    if [ -d "$i" ] && mount -r "$i" 2>/dev/null; then
    [ -f "$i/$1" ] && FOUND="$i/$1"
    umount -l "$i" 2>/dev/null
    [ -n "$FOUND" ] && { echo "$FOUND"; return 0; }
    fi
    done
    return 2
    }
    
    # Simple shell grep
    stringinfile(){
    case "$(cat $2)" in *$1*) return 0;; esac
    return 1
    }
    
    
    FOUND_CONFIG=""
    MYCONFDIR="$(findfile configs.tbz)"
    if [ -n "$MYCONFDIR" ]; then
    MYCONFDEVICEA="${MYCONFDIR##/mnt/}"
    MYCONFDEVICE="/dev/${MYCONFDEVICEA%%/*}"
    MYCONFMOUNTPOINT="/mnt/${MYCONFDEVICE##/dev/}"
    MYCONFDIR="${MYCONFMOUNTPOINT}"
    else
    FOUND_CONFIG="none"
    fi
    
    [ -d "$MYCONFDIR" ] && CONFIGS="$MYCONFDIR/configs.tbz"
    [ -f "$CONFIGS" ] || CONFIGS="/cdrom/KNOPPIX/configs.tbz"
    [ -f "$CONFIGS" ] || CONFIGS="/mnt/floppy/configs.tbz"
    
    if [ -f "$CONFIGS" ]; then
    echo "Extracting config archive 
    $CONFIGS..."
    tar -jpPtf "$CONFIGS" | while read i; do rm -f "$i"; done
    tar -jpPxf "$CONFIGS" ; chown -R knoppix.knoppix /home/knoppix
    fi
    
    # Add your mods here. At this point /home/knoppix is mounted and the saved configuration 
    # has already been restored
    
    # My mod to fire up USB2
    #echo "${MAGENTA}Set up USB2${NORMAL}"
    #modprobe ehci-hcd
    #mkdir /mnt/sda1
    # Add an entry for the USB CF reader in /etc/fstab if there isn't one there already
    #stringinfile "sda" "/etc/fstab" || echo "/dev/sda1 /mnt/sda1 vfat noauto,users,noexec" >> /etc/fstab
    
    killall pump 2>/dev/null && sleep 2 && killall -9 pump 2>/dev/null && sleep 2
    echo "Starting daemons..."
    for i in  ifupdown networking cupsys; do [ -x /etc/init.d/$i ] && /etc/init.d/$i start; done
    As long as you specify the cheatcode myconfig=scan at the boot prompt this modded script will be used but you can always revert to the default script by specifying the specific drive where you save the configuration (e.g. myconfig=/dev/hda5 which is my drive D: ).

    Pete

  2. #2
    Senior Member
    Join Date
    Nov 2003
    Posts
    171
    If you include knoppix.sh in the /KNOPPIX of your cd filesystem and forge a new iso, the script will run by default!

  3. #3
    Member registered user
    Join Date
    Jun 2004
    Location
    Canada
    Posts
    67
    Quote Originally Posted by kelmo
    If you include knoppix.sh in the /KNOPPIX of your cd filesystem and forge a new iso, the script will run by default!
    If you mean burn another CD, that's what I wanted to avoid.

    Pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Dell PowerEdge FX2s + 8x FC430 Blades 16x E5-2630v4 160 Cores Rails No PSU/RAM picture

Dell PowerEdge FX2s + 8x FC430 Blades 16x E5-2630v4 160 Cores Rails No PSU/RAM

$699.00



Dell PowerEdge FC430 Blade Server 2x Xeon E5-2630v4 20 Cores FX2 FX2s No RAM/HDD picture

Dell PowerEdge FC430 Blade Server 2x Xeon E5-2630v4 20 Cores FX2 FX2s No RAM/HDD

$119.99



Dell PowerEdge M620 Blade Server 2x Xeon E5-2680v2 2.8ghz 20-Cores | 128GB picture

Dell PowerEdge M620 Blade Server 2x Xeon E5-2680v2 2.8ghz 20-Cores | 128GB

$149.99



Dell PowerEdge M640 Blade Barebone Server Dell P/N: HHB006 Tested Working picture

Dell PowerEdge M640 Blade Barebone Server Dell P/N: HHB006 Tested Working

$149.99



Dell Poweredge C6400 24x 2.5’’ 2x 2400W 4x C6420 Nodes H330 | 2x SFP | 8x Trays picture

Dell Poweredge C6400 24x 2.5’’ 2x 2400W 4x C6420 Nodes H330 | 2x SFP | 8x Trays

$799.99



NETAPP HCI NAF-1701 SuperMicro Server 4X BLADE H410C 8X GOLD 5120 4 NODE SERVER picture

NETAPP HCI NAF-1701 SuperMicro Server 4X BLADE H410C 8X GOLD 5120 4 NODE SERVER

$1499.97



Cisco B200 M3 2x E5-2670V2 10 Core 8x 16GB-128GB Ram Blade Server VIC1240 14900R picture

Cisco B200 M3 2x E5-2670V2 10 Core 8x 16GB-128GB Ram Blade Server VIC1240 14900R

$399.00



Dell PowerEdge VRTX 2.5

Dell PowerEdge VRTX 2.5"x25 Bay Blade Enclosure 4x1600W + 4X M640 (4X Blades)

$1599.99



Dell PowerEdge M630 Blade Server 2x Xeon E5-2680 v4, 2F3MP , 4GDP5 ,R10KJ ,JVFVR picture

Dell PowerEdge M630 Blade Server 2x Xeon E5-2680 v4, 2F3MP , 4GDP5 ,R10KJ ,JVFVR

$95.20



HP ProLiant BL460c Gen8 Blade Chassis w/2x Xeon E5-2630L 2.0GHz, 32GB RAM, No H picture

HP ProLiant BL460c Gen8 Blade Chassis w/2x Xeon E5-2630L 2.0GHz, 32GB RAM, No H

$144.99