Page 2 of 2
Posted: Sat 23 Jun 2007, 18:36
by Béèm
I am still puzzled after your last explanation, willhunt, but I start to understand a little better.
I still don't understand if the newly created programs Make Virtual disk, Gmount and Vdisktool can or should be executed separately or if gmount and Make Virtual Disk are kinda sub-programs called Vdisktool.
So I did a more in depth test and following ias my comment.
When executng Make Virtual Drive
/usr/local/vdisktool/mkpupsave: line 340: syntax error: unexpected end of file
Wen executing gmount
Selection of a 2fs can be made, not sfs
Push ok when selected one
But where is the 2fs mounted?
When executing vdisktool
The hammer does nothing
the green disk makes a /mnt/vdX directory
the red disk deletes the /mnt/vdX directory.
The sfs button creates a new_save.sfs or new_save1.sfs
The check icon gives
Code: Select all
e2fsck: No such file or directory while trying to open /mnt/home/new_save.2fs
/mnt/home/new_save.2fs:
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
altho new_save.sfs or new_save1.sfs exists
The folder icon opens ROX at vd1/vd2, but what is the use?
As for the freezing of vdisktool I mentioned I know now how it did happen. I had opened help and the child windows ended up beneath all other windows. I didn't realize and tried to work with the main windows again, but it didn't respond due to the open child window.
reworked
Posted: Tue 26 Jun 2007, 04:21
by willhunt
beem I uploaded the new version and I think I have solved the problems you where having I hope
thinking now gonna do it with wbxscript
Code: Select all
#!/usr/bin/wxbasicscript
include "/usr/lib/wxbasicscript/basefunctions.inc"
//##################################
//# display my mountable files as a menue
//#
//##################################
shell( "find / -name '*.?fs' -fprint /tmp/foundfslist.txt" )
//## need to refine statement to only get 2fs,3fs,sfs,iso
myfiles = readfiletolist( "/tmp/foundfslist.txt" )
removefile( "/tmp/foundfslist.txt" )
dialog = " --title 'MENU BOX' --menu 'these are your mountable files: ' 0 0 10"
counter = 1
for i = 0 to count( myfiles ) -1
if left( myfiles[i] , 1 ) = "/" then
dialog &= " '" & myfiles[i] & "' '" & counter & "'"
counter += 1
end if
next
// display the menue
result , choice = xdialog ( dialog )
print choice
This may take a day or two the last time I used basic it was 8k
rom basic
at least with geany I still have line numbers
this code was a demo snippet from MU's orginal post
http://www.murga-linux.com/puppy/viewtopic.php?t=2182
Posted: Tue 26 Jun 2007, 08:43
by sunburnt
Perhaps the script should check if there are vdisks & if they're mounted.
If a vdisk's not mounted, only then would a [Check & Repair] button be enabled.
Same for any other controls, disable them if they shouldn't be used.
Xdialog won't take input to variables within the control.
If you want a ListBox filled from your find command try GTKdialog.
Code: Select all
#!/usr/bin/ash
export vdisk_GUI='
<wtitle>vDisk Tool</wtitle>
<frame List of vDisks >
<hbox>
<list>
<variable>VDISKS</variable>
<input>cat /tmp/Vdisks.txt</input>
</list>
<vbox>
<button>
<label>Mount Vdisk</label>
<variable>mntVDISK</variable>
<action>./vDisk Mnt $VDISKS</action>
</button>
<button>
<label>Check Vdisk</label>
<variable>chkVDISK</variable>
<visible>cat /tmp/visVdisk.txt</visible>
<action>./vDisk Chk $VDISKS</action>
</button>
</vbox>
</hbox>
</frame>
'
gtkdialog3 --program=vdisk_GUI
Put the output from the find command in to the file: /tmp/vDisks.txt
Code: Select all
find ./ -name '*.?fs' -fprint /tmp/foundfslist.$$ > /tmp/vDisks.txt
The buttons call a script file & it's functions in the current dir. called: ./vDisk
and pass the ListBox's vdisk selection to the function being called.
Note the <visible> tag in the [Check Vdisk] button's code.
If you want more info just ask... It's pretty simple.
I've written a library to simplify the creation of GTKdialog code.
A Visual Integrated Development Environment (VIDE) could be made for it.
Posted: Fri 29 Jun 2007, 00:48
by willhunt
A Visual Integrated Development Environment (VIDE) could be made for it.
is that like gimp only for gtkdialog? Sign me up!
I was thinking about error checking and came up with this one to replace
/usr/local/vdisktool/turn what do you think be Brutal
I used the code from mkimgfile to create the disks
The find line I came up with sorta works I just don't want to have to do it five
times as I know very little about programing or scripting that just seems
Wrong
but when I use the line *.?fs I get all kinda results from my
windows part when mounted the object of gmount is to find all mountable
files on all mounted partitions and allow the new user to mount them and
inform them if its read only
Yes I would like very much to learn more about xdialog gtkdialog and the gins thing
turning the buttons on and off are cool
if you google "xdialog forum" puppy comes up the most times and they don't even
give puppy a link whatsup with that
Code: Select all
#!/bin/sh
status="$1"
spacechk=`/mnt/home`
DF=`df |grep $spacechk|awk '{print $4}'`
if [ "$status" == "mnt1" ];then
if [ -d /mnt/vdisk1 ];then
echo ERROR:mntpnt exsits>MP1
else
echo Mounted>MP1
exit 0;
fi
fi
if [ "$status" == "off1" ];then
if [ -d /mnt/vdisk1 ];then
echo ERROR>MP1
else
echo not mounted>MP1
exit 0;
fi
fi
if [ "$status" == "make1" ];then
if [ -f /mnt/home/vdisk1.2fs ];then
echo ERROR:Disk Present>MP1
exit 3 ;
else
echo Creating Disk>MP1
fi
fi
if [ $DF -le $2 ] ;then
echo To Large!>MP1 # tell user Failed
exit 3
fi
if [ -f /mnt/home/vdisk1.2fs ] ;then # is the file already there
echo File Exists>MP1 ; # tell user Failed
exit 3 ;
fi
dd if=/dev/zero of=mnt/home/vdisk1.2fs bs=1k count=$2 & # make new image file
mkfsext2 -F -b 1024 /mnt/home/vdisk1.2fs $2 # make ext2 FS
if [ $? -gt 0 ] ;then
echo ERROR:mkfsext2>MP1 ; # tell user mkfs Failed
exit 1 ;
fi
fsck -Cpt $3 /mnt/home/vdisk1.2fs # check FS
echo Disk Ready>MP1 # tell user it's done
if [ $? -gt 0 ] ;then
echo ERROR:fsck>MP1 ;
exit 1 ;
fi
exit 0;
if [ "$status" == "repair1" ];then
if [ -d /mnt/vdisk1 ];then
echo Unmount First>MP1
else
echo Repairing Disk>MP1
e2fsck -f -p /mnt/home/vdisk1.2fs
exit 0;
fi
fi
Posted: Fri 29 Jun 2007, 01:48
by sunburnt
Thinking in terms of what the GUI should display:
A ListBox for HD partitions & maybe USB drives.
A button: [Make a Vdisk].
And maybe a ComboBox to select the Vdisk's Size?
And maybe a second button: [Delete Vdisk].
A third button: [Encrypt Vdisk].
A second list box for all Vdisks found on HDs & USBs.
A button: [Mount Vdisk].
A second button: [Unmount Vdisk].
And a [Cancel] button.
Could be 2 Tab Panels for a very small sized GUI.
Posted: Fri 29 Jun 2007, 02:18
by willhunt
Tabs now there's something I would reallylike to learn to do!
and it would make it smaller
gui need more buttons add
another tab
Posted: Fri 29 Jun 2007, 10:12
by sunburnt
I assume that your interested? Say so if you want a starter GUI.
Then you can just look at it & it'll be pretty obvious how to mod. it.
You'll have to mod. your script to work with the GUI. Easy to do...
The GUI buttons call the script's functions to do whatever's needed.
Posted: Fri 29 Jun 2007, 19:24
by willhunt
assume that your interested? Say so if you want a starter GUI.
SO
that sounds very do able I would like that yes please[/b]
Posted: Fri 29 Jun 2007, 19:39
by sunburnt
Here's a starter GUI, as I said you'll have to make the Vdisk file with your
Bash functions in it that do the work for the buttons.
Look at the Vdisk.gtk file to see how the functions in the Vdisk file are called.
A skeleton for the Vdisk file is shown below to get you started.
Code: Select all
#!/bin/sh
setup() {
# write code here to make file: "/tmp/found.vdisk" that lists all Vdisks found.
}
mnt() {
..........
}
unmnt() {
..........
}
check() {
..........
}
del() {
..........
}
enc() {
FILE=`Xdialog --title " Pick Path & type in File Name" --fselect /mnt 0 0`
###### Make encrypted Vdisk: $FILE here.
}
######### More buttons & the Size ComboBox code here.
if [ -z "$1" ];then
./Vdisk.gtk
else
$1 $2 $3 $4 $5
fi
There's a little bit to this method of making GUIs, but it's not hard to do.
I've left the Bash code file above: "Vdisk" incomplete for you to learn by doing.
Just copy the Bash code you already have into the proper functions.
It's not as pretty as the other GUI pix posted. Ask any Qs you have... Terry
I need to find out how to size the combo box :(
Posted: Mon 09 Jul 2007, 07:51
by willhunt
sunburnt been workn on what you gave me this is what I've come up with so far for vdisk there is still a long way to go but am stuck
bash is not a acronym but a verb!
Code: Select all
#!/bin/sh
setup() {
# write code here to make file: "/tmp/found.vdisk" that lists all Vdisks found.
# must figure out grep so only get vaild filenames
# big magic that grep sed awk stuff but real hard for this newbie :(
find / -name '*.?fs' -fprint /tmp/found.vdisk
}
mntall() {
rm -f $HOME/.config/tmp/probepar*
OUTPUT=""
###get partitions
# scsi cds and devs without partitons
#SCSIPARTS="`grep -E 'scd[0-9]|sd[a-z] ' /proc/diskstats | tr -s ' ' | cut -d' ' -f4 | tr '\n' ' '`"
SCSIPARTS="`ls -1 /sys/block | grep -E 'sd[a-z]|sr[0-9]' | tr '\n' ' '`"
# normal partitions (sorting backwards cosmetic: we're adding new items at
# the beginning
PARTS="`grep '[hs]d[a-z][0-9]' /proc/partitions | tr -s ' ' | cut -d' ' -f5 | sort -r | tr '\n' ' '`"
## Dougal: originally had here the last part (that does most of the work)
## Why did I move it? To get things in a nice order: hda1...hdb1...hdc...sda1..
###get ide drives (other than hard disks)
#SIZE=0
for DEV in `cd /proc/ide ; ls hd[a-z] | sort -r`
do
# skip devices with partitions
case "$PARTS" in *$DEV*) continue ;; esac
if [ "`cat /proc/ide/$DEV/media`" = "cdrom" ]; then
FSTYPE="iso9660"
else
FSTYPE=`/usr/lib/mut/bin/guess_fstype /dev/$DEV 2>/dev/null`
[ "$FSTYPE" = "unknown" ] && FSTYPE="none" #for compatibility with old probepart.
fi
# seem to need this
if [ $FSTYPE ! "none" ]; then
OUTPUT="/dev/$DEV /mnt/$DEV $FSTYPE defaults 00"
mkdir /mnt/$DEV
echo $OUTPUT >>/ect/fstab
mount /dev/$DEV /mnt/$DEV
fi
done
###get scsi drives
for SCSI in $SCSIPARTS
do
# skip devices with partitions
case "$PARTS" in *$SCSI*) continue ;; esac
case "$SCSI" in
sr*) # cdrom
MEDIA="cdrom"
FSTYPE=iso9660
SIZE=0
;;
sd[a-z]) #other
MEDIA="Direct-Access"
FSTYPE=`/usr/lib/mut/bin/guess_fstype /dev/$SCSI 2>/dev/null`
[ "$FSTYPE" = "unknown" ] && FSTYPE="none" #for compatibility with old probepart.
#changed here to output fstab format
if [ ! $FSTYPE == "none" ]; then
OUTPUT="/dev/$SCSI /mnt/$SCSI $FSTYPE defaults 00"
mkdir /mnt/$DEV
echo $OUTPUT >>/ect/fstab
mount /dev/$DEV /mnt/$DEV
fi
done
# now the part that's actually useful...
for DEV in $PARTS
do
FSTYPE="`/usr/lib/mut/bin/guess_fstype /dev/$DEV 2>/dev/null`"
[ "$FSTYPE" = "unknown" ] && FSTYPE="none" #for compatibility with old probepart.
# SIZE=`grep "$DEV$" /proc/partitions | tr -s ' ' | cut -f 4 -d ' '`
# [ ! "$SIZE" ] && SIZE=0
# [ "$SUNITS" = "" ] && let SIZE=SIZE*2 #512 byte blocks
# [ "$SUNITS" = "-m" ] && let SIZE=SIZE/1024 #MB units
#changed here to output fstab format
if [ ! $FSTYPE == "none" ]; then
OUTPUT="/dev/$DEV /mnt/$DEV $FSTYPE defaults 00"
mkdir /mnt/$DEV
echo $OUTPUT >>/ect/fstab
mount /dev/$DEV /mnt/$DEV
fi
done
rm -f $HOME/.config/tmp/probepar*
}
mnt() {
filext=`echo "$VDISKS" | sed "s/.*\(iso\)$/ISO/"`
if [ "$filext" == "ISO" ];then
mkdir /mnt/${FILE##/*/}
mount -r -t iso9660 -o loop "$FILE" /mnt/${FILE##/*/}
/usr/local/vdisktool/gumnt /mnt/${FILE##/*/} &
rox /mnt/${FILE##/*/}
exit 0;
fi
filext=`echo "$VDISKS" | sed "s/.*\(2fs\)$/2FS/"`
if [ "$filext" == "2FS" ];then
mkdir /mnt/${FILE##/*/}
mount -t ext2 -o loop "$FILE" /mnt/${FILE##/*/}
/usr/local/vdisktool/gumnt /mnt/${FILE##/*/} &
rox /mnt/${FILE##/*/}
exit 0;
fi
filext=`echo "$VDISKS" | sed "s/.*\(sfs\)$/SFS/"`
if [ "$filext" == "SFS" ];then
mkdir /mnt/${FILE##/*/}
mount -r -t squashfs -o loop "$FILE" /mnt/${FILE##/*/}
/usr/local/vdisktool/gumnt /mnt/${FILE##/*/} &
rox /mnt/${FILE##/*/}
exit 0;
fi
filext=`echo "$VDISKS" | sed "s/.*\(3fs\)$/3FS/"`
if [ "$filext" == "3FS" ];then
mkdir /mnt/${FILE##/*/}
mount -t ext3 -o loop "$FILE" /mnt/${FILE##/*/}
/usr/local/vdisktool/gumnt /mnt/${FILE##/*/} &
rox /mnt/${FILE##/*/}
exit 0;
fi
}
unmnt() {
unmount $VDISKS
rmdir $VDISKS
rox -D $VDISKS
}
check() {
filext=`echo "$VDISKS" | sed "s/.*\(2fs\)$/2FS/"`
if [ ! -d /mnt/$VDISKS ];then
if [ "$filext" == "2FS" ];then
e2fsck -f -p $VDISKS
else
gxmessage "Unable to check volume"
exit 0;
fi
}
del() {
..........
}
enc() {
FILE=`Xdialog --title " Pick Path & type in File Name" --fselect /mnt 0 0`
###### Make encrypted Vdisk: $FILE here.
}
######### More buttons & the Size ComboBox code here.
if [ -z "$1" ];then
./Vdisk.gtk
else
$1 $2 $3 $4 $5
fi
Posted: Mon 09 Jul 2007, 19:45
by sunburnt
I'm not sure what part you're having trouble with, post just the erroring part.
If you're not sure, put "echo ($Value)" all through it to see the bad value.
Rather than: "find / -name '*.?fs' -fprint /tmp/found.vdisk", which searches
the entire files system which can take lots of time (I have 5 HD partitions).
Search only the most likely areas... The "/" of partitions, "/Vdisk", etc.
Posted: Mon 09 Jul 2007, 20:44
by willhunt
I think the problem is in here somewhere as I get no
list of files
and it's the part I don't understand lol
Code: Select all
export Vdisk_GUI='
<wtitle> Virtual Disk</wtitle>
<vbox>
<notebook labels="Manage Vdisks|? Vdisks">
<hbox>
<frame All Vdisks found >
<vbox>
<hbox>
<table>
<variable>VDISKS</variable>
<input file>/tmp/found.vdisk</input>
</table>
<vbox>
Posted: Mon 09 Jul 2007, 21:46
by sunburnt
There's no problem with the gtk file, is the file: /tmp/found.vdisk there?
And does it have anything in it? Probably there's no file or the file's empty.
That'd mean the find command isn't putting anything into the file.
As I said the find command should be changed anyway.
Try putting this in place of the find command:
Code: Select all
# find .........
echo 'TEST item...' > /tmp/found.vdisk
When run the echoed string should show in the ListBox.
Posted: Tue 10 Jul 2007, 00:03
by willhunt
I had to run Vdisk setup to create the found.vdisk
file but it's there really I tried the echo statment still no joy
contents of found.vdisk follow
/initrd/mnt/dev_save/pup_save.2fs
/initrd/mnt/dev_save/pup_save-1.2fs
/initrd/mnt/dev_save/pup_save_muppy.3fs
/initrd/mnt/dev_save/mupp_212.sfs
/initrd/mnt/dev_save/pup_212.sfs
/initrd/mnt/dev_save/zdrv_212.sfs
/initrd/mnt/dev_save/devx_217.sfs
/initrd/mnt/dev_save/devx_216.sfs
/initrd/mnt/dev_save/pup_216.sfs
/initrd/mnt/dev_save/zdrv_216.sfs
/initrd/mnt/dev_save/Daviz_215.sfs
Posted: Wed 11 Jul 2007, 21:07
by sunburnt
Sorry... I haven't gotten any email notices of posts, this is the third I've found.
I didn't check the code, but GTKdialog is oddly picky.
Try this in place of the current piece of code:
Code: Select all
<table>
<variable>VDISKS</variable>
<input>cat /tmp/found.vdisk</input>
</table>
Notice the <input> is changed to a "cat" command.
I assume the file /tmp/found.vdisk exists in the /tmp path.
Being as we seem to be the only folks talking anymore... Just PM me.