#!/bin/sh # Given a ramdisk filename in $1, and a syslinux or other config file on # stdin, substitutes ${RAMDISK_SIZE} in the input with an appropriave # ramdisk_size value for the given initrd. If a second ramdisk is given as # $2, then ${RAMDISK_SIZE_26} is replaced with its size. If a third one is # given in $3 then ${RAMDISK_SIZE_GTK} is replaced with its size. set -e # expr's round down is ok, I think; ext2 disks are a multiple of 1024 bytes ramdisk_size=$(expr $(zcat "$1" | wc --bytes) / 1024) if [ -n "$2" ]; then ramdisk_size_26=$(expr $(zcat "$2" | wc --bytes) / 1024) fi if [ -n "$3" ]; then ramdisk_size_gtk=$(expr $(zcat "$3" | wc --bytes) / 1024) fi sed -e s/'${RAMDISK_SIZE}'/$ramdisk_size/g \ -e s/'${RAMDISK_SIZE_26}'/$ramdisk_size_26/g \ -e s/'${RAMDISK_SIZE_GTK}'/$ramdisk_size_gtk/g