#!/bin/sh set -e VERBOSE=true # If softlinks are maintained, then either under /boot or otherwise /. If # neither location contains a vmlinuz, then no softlinks are maintained. if [ -L /boot/vmlinu? ]; then dir="/boot/" elif [ -L /vmlinu? ]; then dir="/" else dir="" fi if [ "$dir" = "" ]; then exit 0 fi $VERBOSE && echo "Testing softlinks in $dir..." for f in $(find $dir -maxdepth 1 -regex '.*vmlinu.\(\.old\)?'); do if [ -e $f ]; then kernel=$(basename $f) initrd="initrd.img${kernel#vmlinu?}" tgt_kernel="$(readlink $f)" tgt_initrd="initrd.img${tgt_kernel#vmlinu?}" if [ ! -L "${dir}${initrd}" ]; then $VERBOSE && echo "${dir}${initrd} does not exist or is not a link" ln -sf ${tgt_initrd} ${dir}${initrd} else cur_initrd=$(readlink ${dir}${initrd}) if [ "${cur_initrd}" != "${tgt_initrd}" ]; then $VERBOSE && echo "${dir}${initrd} invalid target (${cur_initrd})" ln -sf ${tgt_initrd} ${dir}${initrd} else $VERBOSE && echo "${dir}${initrd} -> ${tgt_initrd} (ok)" fi fi else $VERBOSE && echo "Broken link: $f (skip)" fi done exit 0