kadischi/rc userhome.sh,1.2,1.3
Jasper O'neal Hartline (autopsy)
fedora-extras-commits at redhat.com
Sun Jul 9 17:45:07 UTC 2006
Author: autopsy
Update of /cvs/devel/kadischi/rc
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2741/kadischi/rc
Modified Files:
userhome.sh
Log Message:
A few bugfixes, merged Zenity+Dialog+Shell userhome.sh scripts
Index: userhome.sh
===================================================================
RCS file: /cvs/devel/kadischi/rc/userhome.sh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- userhome.sh 8 Jul 2006 22:51:15 -0000 1.2
+++ userhome.sh 9 Jul 2006 17:45:05 -0000 1.3
@@ -1,244 +1,330 @@
#!/bin/bash
-#
+
# Choose a disk, partition, filesystem type and mount it under /home
-# set -x
-get_fstype() {
+#variables
+TITLE="Kadischi User Data"
+TEXT="Kadischi data configuration and save"
- if [ -f /tmp/.disk.partition ]; then
- PARTITION=$(cat /tmp/.disk.partition)
- ### Begin filesytsem type choices
- dialog --backtitle "Kadischi User Data" --title "Kadischi user partition filesystem selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the filesystem type on $PARTITION to be mounted under /home" 20 60 3 ext2 "Extended Second Filesystem" ext3 "Extended Third Filesystem" vfat "Virtual FAT Filesystems" 2>/tmp/.disk.partition.fstype
- else
- exit 1
- fi
+get_fstype() {
+ fstype="$fstype $(zenity --list --title "$TITLE" --radiolist --text "$Please choose the filesystem type on $partition to be mounted under /home" \
+ --column "" --column "Device" --column "Description" --separator " " \
+ "" "ext2" "Extended Second Filesystem" \
+ "" "ext3" "Extended Third Filesystem" \
+ "" "vfat" "Virtual FAT Filesystems" \
+ --height=300 --width=300)"
+ [ "$(echo $?)" != "0" ] && exit 1
}
+select_device () {
+ device="$device $(zenity --list --title "$TITLE" --radiolist --text "$TEXT" \
+ --column "" --column "Device" --column "Description" --separator " " \
+ "" "/dev/hda" "First IDE disk" \
+ "" "/dev/hdb" "Second IDE disk" \
+ "" "/dev/hdc" "Third IDE disk" \
+ "" "/dev/hdd" "Fourth IDE disk" \
+ "" "/dev/sda" "First USB/SCSI disk" \
+ "" "/dev/sdb" "Second USB/SCSI disk" \
+ "" "/dev/sdc" "Third USB/SCSI disk" \
+ "" "/dev/sdd" "Fourth USB/SCSI disk" \
+ --height=400 --width=300)"
+ [ "$(echo $?)" != "0" ] && exit 1
+}
+select_partitions () {
+ partition="$partition $(zenity --list --title "$TITLE" --radiolist --text "$TEXT" \
+ --column "" --column "Partition" --column "Description" --separator " " \
+ "" "/dev/$1d$21" "First partition" \
+ "" "/dev/$1d$22" "Second partition" \
+ "" "/dev/$1d$23" "Third partition" \
+ "" "/dev/$1d$24" "Fourth partition" \
+ --height=300 --width=300)"
+ [ "$(echo $?)" != "0" ] && exit 1
+}
do_mount() {
- if [ -f /tmp/.disk.partition.fstype ]; then
- FSTYPE=$(cat /tmp/.disk.partition.fstype)
- umount /home
- mount -t $FSTYPE $PARTITION /home
- if [ "$?" -eq "0" ]; then
- dialog --backtitle "Kadischi User Data" --begin 6 9 --aspect 0 --shadow --msgbox "Success! Mounted $DISK$PARTITION on /home as $FSTYPE , Done! If a non-root user doesn't already exist, create one now and logout, then log back in as your user." 12 60
- sleep 20
- exit 0
- else
-
- echo "There was an error processing your request!"
- sleep 20
- exit 1
- fi
+ umount /home
+ mount -t $fstype $partition /home
+ if [ "$?" -eq "0" ]; then
+ zenity --title "Kadischi User Data" --info --text "Success! Mounted $partition on /home as $fstype, Done! If a non-root user doesn't already exist, create one now and logout, then log back in as your user."
+ sleep 20
+ exit 0
else
+ zenity --error --text "There was an error processing your request"
exit 1
fi
}
+if [ "$UID" -eq "0" ]; then
+ if [ -x /usr/bin/zenity ]; then
+ select_device
+ case $device in
+ /dev/hda) select_partitions h a
+ ;;
+ /dev/hdb) select_partitions h b
+ ;;
+ /dev/hdc) select_partitions h c
+ ;;
+ /dev/hdd) select_partitions h d
+ ;;
+ /dev/sda) select_partitions s a
+ ;;
+ /dev/sdb) select_partitions s b
+ ;;
+ /dev/sdc) select_partitions s c
+ ;;
+ /dev/sdd) select_partitions s d
+ ;;
+ esac
+ get_fstype
+ do_mount
+ else
+ ### Begin dialog and shell sections
+ get_fstype() {
+ if [ -f /tmp/.disk.partition ]; then
+ PARTITION=$(cat /tmp/.disk.partition)
+ ### Begin filesytsem type choices
+ dialog --backtitle "Kadischi User Data" --title "Kadischi user partition filesystem selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the filesystem type on $PARTITION to be mounted under /home" 20 60 3 ext2 "Extended Second Filesystem" ext3 "Extended Third Filesystem" vfat "Virtual FAT Filesystems" 2>/tmp/.disk.partition.fstype
+ else
+ exit 1
+ fi
+ }
-do_cleanup() {
- ### Cleanup
- rm -rf /tmp/.disk
- rm -rf /tmp/.disk.partition
- rm -rf /tmp/.disk.partition.fstype
-}
+ do_mount() {
+ if [ -f /tmp/.disk.partition.fstype ]; then
+ FSTYPE=$(cat /tmp/.disk.partition.fstype)
+ umount /home
+ mount -t $FSTYPE $PARTITION /home
+ if [ "$?" -eq "0" ]; then
+ dialog --backtitle "Kadischi User Data" --begin 6 9 --aspect 0 --shadow --msgbox "Success! Mounted $PARTITION on /home as $FSTYPE , Done! If a non-root user doesn't already exist, create one now and logout, then log back in as your user." 12 60
+ sleep 20
+ exit 0
+ else
-if [ "$UID" -eq "0" ]; then
- if [ -x /usr/bin/dialog ]; then
+ echo "There was an error processing your request!"
+ sleep 20
+ exit 1
+ fi
+ else
+ exit 1
+ fi
+ }
- dialog --backtitle "Kadischi User Data" --title "Kadischi data configuration and save" --begin 6 9 --aspect 0 --shadow --yesno \
- "This menu system is designed to allow a user to mount a partition as /home under the LiveCD environment to save user data and configurations.
-Would you like to continue?" 10 80
- if [ "$?" -eq "0" ]; then
- ### Begin user disk and partition selections
- dialog --backtitle "Kadischi User Data" --title "Kadischi user disk selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the
-disk that contains our mountable partition" 20 60 8 /dev/hda "First IDE disk" /dev/hdb "Second IDE disk" /dev/hdc "Third IDE disk" /dev/hdd "Fourth IDE disk" /dev/sda "First SCSI disk" /dev/sdb "Second SCSI disk" /dev/sdc "Third SCSI disk" /dev/sdd "Fourth SCSI disk" 2>/tmp/.disk
-
- if [ -f /tmp/.disk ]; then
- DISK=$(cat /tmp/.disk)
- if [ "$DISK" == "/dev/hda" ]; then
- dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/hda1 "First partition" /dev/hda2 "Second partition" /dev/hda3 "Third partition" /dev/hda4 "Fourth partition" 2>/tmp/.disk.partition
- if [ "$?" -eq "0" ]; then
- get_fstype
- do_mount
- do_cleanup
- else
- do_cleanup
- exit 1
- fi
+ do_cleanup() {
+ ### Cleanup
+ rm -rf /tmp/.disk
+ rm -rf /tmp/.disk.partition
+ rm -rf /tmp/.disk.partition.fstype
+ }
- elif [ "$DISK" == "/dev/hdb" ]; then
- dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/hdb1 "First partition" /dev/hdb2 "Second partition" /dev/hdb3 "Third partition" /dev/hdb4 "Fourth partition" 2>/tmp/.disk.partition
- if [ "$?" -eq "0" ]; then
- get_fstype
- do_mount
- do_cleanup
- else
- do_cleanup
- exit 1
- fi
-
- elif [ "$DISK" == "/dev/hdc" ]; then
- dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/hdc1 "First partition" /dev/hdc2 "Second partition" /dev/hdc3 "Third partition" /dev/hdc4 "Fourth partition" 2>/tmp/.disk.partition
- if [ "$?" -eq "0" ]; then
- get_fstype
- do_mount
- do_cleanup
- else
- do_cleanup
- exit 1
- fi
- elif [ "$DISK" == "/dev/hdd" ]; then
- dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/hdd1 "First partition" /dev/hdd2 "Second partition" /dev/hdd3 "Third partition" /dev/hdd4 "Fourth partition" 2>/tmp/.disk.partition
- if [ "$?" -eq "0" ]; then
- get_fstype
- do_mount
- do_cleanup
- else
- do_cleanup
- exit 1
- fi
-
- elif [ "$DISK" == "/dev/sda" ]; then
- dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/sda1 "First partition" /dev/sda2 "Second partition" /dev/sda3 "Third partition" /dev/sda4 "Fourth partition" 2>/tmp/.disk.partition
- if [ "$?" -eq "0" ]; then
- get_fstype
- do_mount
- do_cleanup
- else
- do_cleanup
- exit 1
- fi
-
- elif [ "$DISK" == "/dev/sdb" ]; then
- dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/sdb1 "First partition" /dev/sdb2 "Second partition" /dev/sdb3 "Third partition" /dev/sdb4 "Fourth partition" 2>/tmp/.disk.partition
- if [ "$?" -eq "0" ]; then
- get_fstype
- do_mount
- do_cleanup
- else
- do_cleanup
- exit 1
- fi
- elif [ "$DISK" == "/dev/sdc" ]; then
- dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/sdc1 "First partition" /dev/sdc2 "Second partition" /dev/sdc3 "Third partition" /dev/sdc4 "Fourth partition" 2>/tmp/.disk.partition
- if [ "$?" -eq "0" ]; then
- get_fstype
- do_mount
- do_cleanup
+ if [ "$UID" -eq "0" ]; then
+ if [ -x /usr/bin/dialog ]; then
+
+ dialog --backtitle "Kadischi User Data" --title "Kadischi data configuration and save" --begin 6 9 --aspect 0 --shadow --yesno \
+ "This menu system is designed to allow a user to mount a partition as /home under the LiveCD environment to save user data and configurations.
+
+Would you like to continue?" 10 80
+
+ if [ "$?" -eq "0" ]; then
+ ### Begin user disk and partition selections
+ dialog --backtitle "Kadischi User Data" --title "Kadischi user disk selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the
+disk that contains our mountable partition" 20 60 8 /dev/hda "First IDE disk" /dev/hdb "Second IDE disk" /dev/hdc "Third IDE disk" /dev/hdd "Fourth IDE disk" /dev/sda "First SCSI disk" /dev/sdb "Second SCSI disk" /dev/sdc "Third SCSI disk" /dev/sdd "Fourth SCSI disk" 2>/tmp/.disk
+
+ if [ -f /tmp/.disk ]; then
+ DISK=$(cat /tmp/.disk)
+ if [ "$DISK" == "/dev/hda" ]; then
+ dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/hda1 "First partition" /dev/hda2 "Second partition" /dev/hda3 "Third partition" /dev/hda4 "Fourth partition" 2>/tmp/.disk.partition
+ if [ "$?" -eq "0" ]; then
+ get_fstype
+ do_mount
+ do_cleanup
+ else
+ do_cleanup
+ exit 1
+ fi
+
+ elif [ "$DISK" == "/dev/hdb" ]; then
+ dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/hdb1 "First partition" /dev/hdb2 "Second partition" /dev/hdb3 "Third partition" /dev/hdb4 "Fourth partition" 2>/tmp/.disk.partition
+ if [ "$?" -eq "0" ]; then
+ get_fstype
+ do_mount
+ do_cleanup
+ else
+ do_cleanup
+ exit 1
+ fi
+
+ elif [ "$DISK" == "/dev/hdc" ]; then
+ dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/hdc1 "First partition" /dev/hdc2 "Second partition" /dev/hdc3 "Third partition" /dev/hdc4 "Fourth partition" 2>/tmp/.disk.partition
+ if [ "$?" -eq "0" ]; then
+ get_fstype
+ do_mount
+ do_cleanup
+ else
+ do_cleanup
+ exit 1
+ fi
+
+ elif [ "$DISK" == "/dev/hdd" ]; then
+ dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/hdd1 "First partition" /dev/hdd2 "Second partition" /dev/hdd3 "Third partition" /dev/hdd4 "Fourth partition" 2>/tmp/.disk.partition
+ if [ "$?" -eq "0" ]; then
+ get_fstype
+ do_mount
+ do_cleanup
+ else
+ do_cleanup
+ exit 1
+ fi
+
+ elif [ "$DISK" == "/dev/sda" ]; then
+ dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/sda1 "First partition" /dev/sda2 "Second partition" /dev/sda3 "Third partition" /dev/sda4 "Fourth partition" 2>/tmp/.disk.partition
+ if [ "$?" -eq "0" ]; then
+ get_fstype
+ do_mount
+ do_cleanup
+ else
+ do_cleanup
+ exit 1
+ fi
+
+ elif [ "$DISK" == "/dev/sdb" ]; then
+ dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/sdb1 "First partition" /dev/sdb2 "Second partition" /dev/sdb3 "Third partition" /dev/sdb4 "Fourth partition" 2>/tmp/.disk.partition
+ if [ "$?" -eq "0" ]; then
+ get_fstype
+ do_mount
+ do_cleanup
+ else
+ do_cleanup
+ exit 1
+ fi
+
+ elif [ "$DISK" == "/dev/sdc" ]; then
+ dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/sdc1 "First partition" /dev/sdc2 "Second partition" /dev/sdc3 "Third partition" /dev/sdc4 "Fourth partition" 2>/tmp/.disk.partition
+ if [ "$?" -eq "0" ]; then
+ get_fstype
+ do_mount
+ do_cleanup
+ else
+ do_cleanup
+ exit 1
+ fi
+
+ elif [ "$DISK" == "/dev/sdd" ]; then
+ dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/sdd1 "First partition" /dev/sdd2 "Second partition" /dev/sdd3 "Third partition" /dev/sdd4 "Fourth partition" 2>/tmp/.disk.partition
+ if [ "$?" -eq "0" ]; then
+ get_fstype
+ do_mount
+ do_cleanup
+ else
+ do_cleanup
+ exit 1
+ fi
else
+ dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --msgbox "There was an error processing the arguments provided, bailing!" 8 70
do_cleanup
- exit 1
+ sleep 20
fi
-
- elif [ "$DISK" == "/dev/sdd" ]; then
- dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --menu "Please choose the partition on $DISK to be mounted under /home" 20 60 4 /dev/sdd1 "First partition" /dev/sdd2 "Second partition" /dev/sdd3 "Third partition" /dev/sdd4 "Fourth partition" 2>/tmp/.disk.partition
+ else
+ exit 1
+ fi
+ else
+ exit 1
+ fi
+ else
+ ### Begin standard shell menu procedure and menu
+ while [ -z $DONE ]; do
+ clear
+ echo "---------------------------------------------------------------------"
+ echo " Kadischi User Configuration and Save "
+ echo " "
+ echo " 1) Disk "
+ echo " 2) Partition "
+ echo " 3) Filesystem type "
+ echo " 4) exit "
+ echo " "
+ echo " Please choose your disk, partition and filesystem type to mount "
+ echo " as /home in the LiveCD environment or exit now! "
+ echo " "
+ echo " "
+ echo "---------------------------------------------------------------------"
+ echo -n "Selection: "
+ read CHOICE
+ case $CHOICE in
+ 1) echo "Please provide the disk in which our mountable partition resides"
+ echo -n "[/dev/hda]: "
+ read DISK
+ if [ ! "$DISK" ]; then
+ DISK=/dev/hda
+ fi
+ ;;
+
+ 2) echo "Please provide the partition number of which is our mountable partition"
+ echo -n "[1]: "
+ read PARTITION
+ if [ ! "$PARTITION" ]; then
+ PARTITION=1
+ fi
+ ;;
+
+ 3) echo "Please provide the filesystem type of which our mountable partition is"
+ echo -n "[ext2]: "
+ read FSTYPE
+ if [ ! "$FSTYPE" ]; then
+ FSTYPE=ext2
+ fi
+ ;;
+
+ 4) echo "Bye!"
+ exit 0
+ ;;
+
+ *) echo "Unrecognized option!"
+ esac
+ if [ -n "$DISK" ] && [ -n "$PARTITION" ] && [ -n "$FSTYPE" ]; then
+ umount /home
+ mount -t $FSTYPE $PARTITION /home
if [ "$?" -eq "0" ]; then
- get_fstype
- do_mount
+ echo "Successfully mounted $PARTITION on /home as $FSTYPE!"
+ echo "If a non-root user doesn't already exist, create one now."
+ echo "Done! Please logout and back ins as your user."
do_cleanup
+ sleep 20
+ exit 0
else
+ echo "There was an error processing your request to mount $PARTITION as $FSTYPE"
do_cleanup
+ sleep 20
exit 1
fi
- else
- dialog --backtitle "Kadischi User Data" --title "Kadischi user partition selection" --begin 6 9 --aspect 0 --shadow --msgbox "There was an error processing the arguments provided, bailing!" 8 70
- do_cleanup
- sleep 20
- fi
- else
- exit 1
- fi
- else
- exit 1
- fi
+ else
+ echo "Still choices left!"
+ echo " "
+ echo " "
+ fi
+ done
+ exit 0
+ fi
else
- ### Begin standard shell menu procedure and menu
- while [ -z $DONE ]; do
- echo "---------------------------------------------------------------------"
- echo " Kadischi User Configuration and Save "
- echo " "
- echo " 1) Disk "
- echo " 2) Partition "
- echo " 3) Filesystem type "
- echo " 4) exit "
- echo " "
- echo " Please choose your disk, partition and filesystem type to mount "
- echo " as /home in the LiveCD environment or exit now! "
- echo " "
- echo " "
- echo "---------------------------------------------------------------------"
- echo -n "Selection: "
- read CHOICE
- case $CHOICE in
- 1) echo "Please provide the disk in which our mountable partition resides"
- echo -n "[/dev/hda]: "
- read DISK
- if [ ! "$DISK" ]; then
- DISK=/dev/hda
- fi
- ;;
-
- 2) echo "Please provide the partition number of which is our mountable partition"
- echo -n "[1]: "
- read PARTITION
- if [ ! "$PARTITION" ]; then
- PARTITION=1
- fi
- ;;
-
- 3) echo "Please provide the filesystem type of which our mountable partition is"
- echo -n "[ext2]: "
- read FSTYPE
- if [ ! "$FSTYPE" ]; then
- FSTYPE=ext2
- fi
- ;;
-
- 4) echo "Bye!"
- exit 0
- ;;
-
- *) echo "Unrecognized option!"
- esac
- if [ -n "$DISK" ] && [ -n "$PARTITION" ] && [ -n "$FSTYPE" ]; then
- umount /home
- mount -t $FSTYPE $PARTITION /home
- if [ "$?" -eq "0" ]; then
- echo "Successfully mounted $PARTITION on /home as $FSTYPE!"
- echo "If a non-root user doesn't already exist, create one now."
- echo "Done! Please logout and back ins as your user."
- do_cleanup
- sleep 20
- exit 0
- else
- echo "There was an error processing your request to mount $PARTITION as $FSTYPE"
- do_cleanup
- sleep 20
- exit 1
- fi
- else
- echo "Still choices left!"
- echo " "
- echo " "
- fi
- done
+ if [ -x /usr/bin/dialog ]; then
+ dialog --backtitle "Kadischi User Data" --begin 6 9 --aspect 0 --shadow --msgbox "You cannot run this application as non superuser (root)!" 6 60
exit 0
+ else
+ echo "You cannot run this application as non superuser (root)!"
+ exit 0
+ fi
fi
-else
- if [ -x /usr/bin/dialog ]; then
- dialog --backtitle "Kadischi User Data" --begin 6 9 --aspect 0 --shadow --msgbox "You cannot run this application as non superuser (root)!" 6 60
- exit 0
- else
- echo "You cannot run this application as non superuser (root)!"
- exit 0
+
+ #### End dialog and shell sections
fi
+else
+ zenity --error --text "You cannot run this application as non superuser (root)!"
+ exit 0
fi
+
More information about the fedora-extras-commits
mailing list