#!/bin/sh # setup-cfdisk # Launch cfdisk to edit the harddisk # vdir=$(dirname $0) . $vdir/setup-functions build_disk_menu() { dbug "HD detection" fdisk -l | grep -e "^Disk /dev" | while read line; do disk=$( echo $line | cut -f 1 -d ':' | cut -f 2 -d ' ') desc=$( echo $line | cut -f 2 -d ':') echo "$disk" "'$desc' \\" let ii=$ii+1 dbug $ii $line done } ########################################### # Hints and choose partitions menuA() { TITLE="HARDDISK PARTITION" DIMENSION="21 76 4" TEXT="\n We are going to make Linux and Linux-swap partitions using cfdisk. Before starting, here are a brief how-to:\n - If necessary, use [Delete] menu to free some space.\n - Point a free space then use [New] menu to create a partition.\n By default, it will be a Linux partition.\n - Point a partition, then use [Type] menu to change it to Linux-swap.\n - To finish, use [Write] menu then [Quit].\n Do not forget to [Write] unless you want to discard the changes !\n\n That's it. Now select your harddisk then hit :" echo '$DCMD --backtitle "$BACKTITLE" --title "$TITLE" \' > $fmenu echo '--menu "$TEXT" $DIMENSION \' >> $fmenu build_disk_menu >> $fmenu if [ $? != 0 ]; then errorbox "Can not find any harddisk. Check your hardware." "FATAL ERROR" clean_exit fi echo '2> $freply' >> $fmenu . $fmenu status=$? [ $status != 0 ] && return $status FDISK_DEV=$(cat $freply) dbug "launching fdisk $FDISK_DEV" cfdisk $FDISK_DEV return 0 } ########################################### # REBOOT, restart menuB() { TITLE="FDISK FINISHED" TEXT="\n I wish you have the good partitions now. In that case choose REBOOT as the system needs to reboot for the changes to take place. But if you made an error during the partition program and canceled or exited then choose 'RETURN'. Choose RESTART only if you did not make any modification and want to continue the installation.\n The choice is yours:" $WCMD --backtitle "$BACKTITLE" --title "$TITLE" \ --menu "$TEXT" $DIMENSION \ "REBOOT" "Reboot the system to add the new partitions." \ "RETURN" "Return to the partition program. I want to try again." \ "RESTART" "Don't know how I got here but I want out." \ 2> $freply status=$? [ $status != 0 ] && return $status choice=$(cat $freply) dbug choice=$choice case $choice in "RETURN") return 3 ;; "REBOOT") clear echo "Rebooting the system in 3 seconds....................." sleep 2 reboot clean_exit 1 echo "Nah ... this is only a demo ! :)" echo "but we are going to quit" sleep 3 clean_exit 1 ;; "RESTART") infobox "As you wish ..., back to the main menu" sleep 2 clean_exit 0 ;; esac return 0 } ############################################################# # Main Program wizard menuA menuB clean_exit $?