#!/bin/bash
# script by fanthom

menu() {
y=2
modules() { for x in `grep /mnt/live/memory/images /proc/mounts | egrep -v '000-kernel.xzm|001-core.xzm' | cut -d " " -f2 | cut -d/ -f6`; do echo $y $x off; let y=y+1; done }
list=`modules | tr "\n" "\t"`
Xdialog --checklist "Select modules for deactivation:" 350x400 0 $list 2>/tmp/choice$$
for x in `cat /tmp/choice$$ | tr "/" "\n" | sort -r`; do grep /mnt/live/memory/images /proc/mounts | cut -d " " -f2 | cut -d/ -f6 | awk NR==$(($x+1)) >>/tmp/name$$; done
if [ -e /tmp/name$$ ]; then
    for x in `cat /tmp/name$$`; do
	deactivate /mnt/live/memory/images/$x
    done
    rm /tmp/name$$ /tmp/choice$$
    ans=1
else
    rm /tmp/choice$$
    ans=2
fi
}

menu
while [ $ans = 1 ]; do
    menu
done