%pre # tests to verify that correct disk is used for install # if tests fail, want to stop installer # ! this is pretty flakey. Maybe should skip if the install disk is uniquely # ! specified by path # Max allowed disk size in GB MAXSIZE=999 # a place to put a log LOGDIR="/tmp/anaconda-pre" LOGFILE="\$LOGDIR/pre-check-install-disk-maxsize.out" mkdir \$LOGDIR # get the size. ask parted for size in GB, grep for 1 or more digits in result # parted print fails if disk has no label, so OK for reinstalls, but a # problem for fresh systems or new vdisks #SIZE=`parted $disk unit gb print | awk '/^Disk.*GB/ {print \$3}' | sed 's/GB//' | grep '^[0-9][0-9]*\$'` # fdisk works? SIZE=`fdisk -l $disk | head -2 | awk '/Disk/ {print int($3)}' | grep '^[0-9][0-9]*\$'` SIZEEXIT=$? if [ "\$SIZEEXIT" -ne "0" ]; then echo "failed to get disk size" >> \$LOGFILE # send output to console chvt 3 exec < /dev/tty3 > /dev/tty3 echo "failed to get disk size, pausing installer, please correct and retry." # want to stop install, this "cat" should just wait forever... cat fi if [ "\$SIZE" -gt "\$MAXSIZE" ]; then echo "disk size \$SIZE greater than \$MAXSIZE stop installer" >> \$LOGFILE # send output to console chvt 3 exec < /dev/tty3 > /dev/tty3 echo "disk size \$SIZE GB greater than \$MAXSIZE, pausing installer, please correct and retry." # want to stop install, this "cat" should just wait forever... cat # this should kill the installer (tested interactively), leaves at # "enter Ctrl-C or Ctrl-Alt-Delete prompt" # killall anaconda fi echo "disk size \$SIZE is OK" >> \$LOGFILE %end