home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / ROOTDSKS.12 / UMSDOS12 / usr / lib / setup / SeTswap < prev    next >
Encoding:
Text File  |  1995-02-27  |  3.2 KB  |  76 lines

  1. #!/bin/sh
  2. rm -f /tmp/SeTswap
  3. SWAPLIST="`fdisk -l | fgrep "Linux swap" 2> /dev/null`" 
  4. if [ "$SWAPLIST" = "" ]; then
  5.  dialog --title "NO SWAP SPACE DETECTED" --yesno "You have not created a swap partition with Linux fdisk. \
  6. Do you want to continue without a swapfile? " 8 40
  7.  if [ "$?" = "1" ]; then
  8.   dialog --title "ABORTING INSTALLATION" --msgbox "Create a swap partition with Linux fdisk, and then try this again." \
  9. 6 40
  10.   exit
  11.  fi
  12. else
  13.  echo > /tmp/swapmsg 
  14.  if [ "`echo "$SWAPLIST" | sed -n '2 p'`" = "" ]; then
  15.   echo "Slackware Setup has detected a swap partition:" >> /tmp/swapmsg
  16.   echo >> /tmp/swapmsg
  17.   echo "   Device Boot  Begin   Start     End  Blocks   Id  System" >> /tmp/swapmsg
  18.   echo "`echo "$SWAPLIST" | sed -n '1 p'`" >> /tmp/swapmsg
  19.   echo >> /tmp/swapmsg
  20.   echo "Do you wish to install this as your swap partition?" >> /tmp/swapmsg
  21.   dialog --title "SWAP SPACE DETECTED" --yesno "`cat /tmp/swapmsg`" 12 70
  22.   REPLY=$?
  23.  else
  24.   echo "Slackware Setup has detected the following swap partitions:" >> /tmp/swapmsg
  25.   echo >> /tmp/swapmsg
  26.   echo "   Device Boot  Begin   Start     End  Blocks   Id  System" >> /tmp/swapmsg
  27.   echo "$SWAPLIST" >> /tmp/swapmsg
  28.   echo >> /tmp/swapmsg
  29.   echo "Do you wish to install these as your swap partitions? " >> /tmp/swapmsg
  30.   dialog --title "SWAP SPACE DETECTED" --yesno "`cat /tmp/swapmsg`" 15 70
  31.   REPLY=$?
  32.  fi
  33.  rm -f /tmp/swapmsg
  34.  if [ $REPLY = 0 ]; then # yes
  35.    cat << EOF > /tmp/swapmsg
  36. IMPORTANT NOTE: If you have already made any of your swap 
  37. partitions active (using the swapon command), then you 
  38. should not allow Setup to use mkswap on your swap partitions,
  39. because it may corrupt memory pages that are currently 
  40. swapped out. Instead, you will have to make sure that your 
  41. swap partitions have been prepared (with mkswap) before they
  42. will work. You might want to do this to any inactive swap 
  43. partitions before you reboot.
  44. EOF
  45.    dialog --title "MKSWAP WARNING" --msgbox "`cat /tmp/swapmsg`" 12 67
  46.    rm -f /tmp/swapmsg
  47.    dialog --title "USE MKSWAP?" --yesno "Do you want Setup to use mkswap on your swap partitions?" \
  48.   5 65
  49.    USE_SWAP=$?
  50.    dialog --title "ACTIVATE SWAP SPACE?" --yesno "If you have not already activated your swap partitions with \
  51. 'swapon', you should do so at this time. Activate swap partitions with 'swapon'?" \
  52.    7 60
  53.    ACTIVATE=$?
  54.   CURRENT_SWAP="1" 
  55.   while [ ! "`echo "$SWAPLIST" | sed -n "$CURRENT_SWAP p"`" = "" ]; do 
  56.    SWAP_SIZE="`fdisk -l | fgrep "Linux swap" | sed -n "$CURRENT_SWAP p" | cut -b38-45 2> /dev/null`"
  57.    SWAP_PART="`fdisk -l | fgrep "Linux swap" | sed -n "$CURRENT_SWAP p" | cut -b1-10 2> /dev/null`"
  58.    if [ $USE_SWAP = 0 ]; then 
  59.     mkswap -c $SWAP_PART $SWAP_SIZE 1> /dev/null 2> /dev/null
  60.    fi
  61.    if [ $ACTIVATE = 0 ]; then
  62.     swapon $SWAP_PART 1> /dev/null 2> /dev/null
  63.    fi 
  64.    SWAP_IN_USE="`echo "$SWAP_PART       swap        swap        defaults   1   1"`"
  65.    echo "$SWAP_IN_USE" >> /tmp/SeTswap
  66.    CURRENT_SWAP="`expr $CURRENT_SWAP + 1`"
  67.   done
  68.   echo "Your swapspace has been configured. This information will" > /tmp/swapmsg
  69.   echo "be added to your /etc/fstab:" >> /tmp/swapmsg
  70.   echo >> /tmp/swapmsg
  71.   echo "$SWAP_IN_USE" >> /tmp/swapmsg 
  72.   dialog --title "SWAP SPACE CONFIGURED" --msgbox "`cat /tmp/swapmsg`" 13 72
  73.   rm /tmp/swapmsg
  74.  fi
  75. fi  
  76.