home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- rm -f /tmp/SeTswap
- SWAPLIST="`fdisk -l | fgrep "Linux swap" 2> /dev/null`"
- if [ "$SWAPLIST" = "" ]; then
- dialog --title "NO SWAP SPACE DETECTED" --yesno "You have not created a swap partition with Linux fdisk. \
- Do you want to continue without a swapfile? " 8 40
- if [ "$?" = "1" ]; then
- dialog --title "ABORTING INSTALLATION" --msgbox "Create a swap partition with Linux fdisk, and then try this again." \
- 6 40
- exit
- fi
- else
- echo > /tmp/swapmsg
- if [ "`echo "$SWAPLIST" | sed -n '2 p'`" = "" ]; then
- echo "Slackware Setup has detected a swap partition:" >> /tmp/swapmsg
- echo >> /tmp/swapmsg
- echo " Device Boot Begin Start End Blocks Id System" >> /tmp/swapmsg
- echo "`echo "$SWAPLIST" | sed -n '1 p'`" >> /tmp/swapmsg
- echo >> /tmp/swapmsg
- echo "Do you wish to install this as your swap partition?" >> /tmp/swapmsg
- dialog --title "SWAP SPACE DETECTED" --yesno "`cat /tmp/swapmsg`" 12 70
- REPLY=$?
- else
- echo "Slackware Setup has detected the following swap partitions:" >> /tmp/swapmsg
- echo >> /tmp/swapmsg
- echo " Device Boot Begin Start End Blocks Id System" >> /tmp/swapmsg
- echo "$SWAPLIST" >> /tmp/swapmsg
- echo >> /tmp/swapmsg
- echo "Do you wish to install these as your swap partitions? " >> /tmp/swapmsg
- dialog --title "SWAP SPACE DETECTED" --yesno "`cat /tmp/swapmsg`" 15 70
- REPLY=$?
- fi
- rm -f /tmp/swapmsg
- if [ $REPLY = 0 ]; then # yes
- cat << EOF > /tmp/swapmsg
- IMPORTANT NOTE: If you have already made any of your swap
- partitions active (using the swapon command), then you
- should not allow Setup to use mkswap on your swap partitions,
- because it may corrupt memory pages that are currently
- swapped out. Instead, you will have to make sure that your
- swap partitions have been prepared (with mkswap) before they
- will work. You might want to do this to any inactive swap
- partitions before you reboot.
- EOF
- dialog --title "MKSWAP WARNING" --msgbox "`cat /tmp/swapmsg`" 12 67
- rm -f /tmp/swapmsg
- dialog --title "USE MKSWAP?" --yesno "Do you want Setup to use mkswap on your swap partitions?" \
- 5 65
- USE_SWAP=$?
- dialog --title "ACTIVATE SWAP SPACE?" --yesno "If you have not already activated your swap partitions with \
- 'swapon', you should do so at this time. Activate swap partitions with 'swapon'?" \
- 7 60
- ACTIVATE=$?
- CURRENT_SWAP="1"
- while [ ! "`echo "$SWAPLIST" | sed -n "$CURRENT_SWAP p"`" = "" ]; do
- SWAP_SIZE="`fdisk -l | fgrep "Linux swap" | sed -n "$CURRENT_SWAP p" | cut -b38-45 2> /dev/null`"
- SWAP_PART="`fdisk -l | fgrep "Linux swap" | sed -n "$CURRENT_SWAP p" | cut -b1-10 2> /dev/null`"
- if [ $USE_SWAP = 0 ]; then
- mkswap -c $SWAP_PART $SWAP_SIZE 1> /dev/null 2> /dev/null
- fi
- if [ $ACTIVATE = 0 ]; then
- swapon $SWAP_PART 1> /dev/null 2> /dev/null
- fi
- SWAP_IN_USE="`echo "$SWAP_PART swap swap defaults 1 1"`"
- echo "$SWAP_IN_USE" >> /tmp/SeTswap
- CURRENT_SWAP="`expr $CURRENT_SWAP + 1`"
- done
- echo "Your swapspace has been configured. This information will" > /tmp/swapmsg
- echo "be added to your /etc/fstab:" >> /tmp/swapmsg
- echo >> /tmp/swapmsg
- echo "$SWAP_IN_USE" >> /tmp/swapmsg
- dialog --title "SWAP SPACE CONFIGURED" --msgbox "`cat /tmp/swapmsg`" 13 72
- rm /tmp/swapmsg
- fi
- fi
-