some modification on instpkg
[cmdllinux.git] / scripts / manage / createswap
blob6ff5872d304ab0cf6d09fa42d9a40bf98501029e
1 #! /bin/sh
3 : ${DIALOG=dialog}
5 tempfile=`mktemp 2> /dev/null` || tempfile=/tmp/test$$
6 trap "rm -f $tempfile" 0 1 2 5 15
8 lsswappart()
10 for drv in $(find /dev -maxdepth 1 -name "[hs]d[a-z]" -o -name "ub[a-z]" | sort); do
11 LC_ALL=C sfdisk -d $drv 2> /dev/null | grep "^/dev/" | \
12 while read LINE; do
13 if echo "$LINE" | grep -q "type=82\|type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F"; then
14 echo -n "$(echo "$LINE" | cut -d : -f 1 | tr -d " ") "
15 eval $(echo "$LINE" | cut -d : -f 2 | cut -d , -f 2 | tr -d " ")
16 echo -n "$(expr $size \* 512 / 1048576)MB "
18 done
19 done
22 $DIALOG --backtitle "Create swap on device" \
23 --title "" --clear \
24 --menu "Select partition" 20 61 15 \
25 `lsswappart` 2> $tempfile
27 retval=$?
29 choice=`cat $tempfile`
30 case $retval in
32 [ ! -z "$choice" ] && mkswap $choice
35 #cancel pressed
37 255)
38 #ESC pressed
40 esac