| Author |
Message |
big_bass

Joined: 13 Aug 2007 Posts: 1736
|
Posted: Tue 26 Oct 2010, 22:59 Post subject:
Mount_all3: bash script automounts drives at startup Subject description: Place it in /root/Startup. No user interaction |
|
this is a script I wrote to auto mount drives at start up
and then place the folders mounted on the desktop
make it executable and
place it in /root/Startup no user interaction
cd and dvd drives are not mounted
the writing to the desktop was tricky generating a new PuppyPin
for whatever drives you have and doing all this without it being event driven fully automatic
if you notice that the code to mount and draw to the desktop is very compact and doesnt use any of these listed below
pmount
gtkdialog
eventmanager
partprobe,
probedisk and a few other small scripts/apps that are used while mounting
special features will be added
here's a nice little trick if you used my code in the mount_all3
a file got generated called PuppyPin-old
so if you need or want to toggle off the folder icons you could by doing this code snip
| Code: | | rox --pinboard=/root/Choices/ROX-Filer/PuppyPin-old |
and to get the folders back again
| Code: | | rox --pinboard=/root/Choices/ROX-Filer/PuppyPin |
MOUNT_ALL3
| Code: |
#!/bin/bash
# call it mount_all3 updated 11-06-2010 Joe Arose
# auto_mount all drives non cd and dvd
# now if you have to mount stuff from the command line only here's one
# don't unmount a drive that has your save file !
# this doesnt depend on xdialog
# added folders to be auto drawn and updated on the desktop
# with auto generating of the xml PuppyPin depending
# on whichever drives are used note that this is not event driven
# it is meant to be placed in /root/Startup so there is no user interaction
# major changes in how a list of drives is generated and multiple
# screen displays are detected
# special thanks to aragon for this code snip below to detect the width and height
#SCW=`xwininfo -root | grep '\geometry' | cut -f4 -d ' ' | cut -f1 -d 'x'`
#SCH=`xwininfo -root | grep '\geometry' | cut -f4 -d ' ' | cut -f2 -d 'x' | cut -f1 -d '+'`
# this started as a special request for abushcrafter for something simple to auto mount
# then grew into writing to the desktop also with multiple screen sizes
# thanks for catching the loop error amigo
temp_file="/tmp/pin-fix"
rm -f /tmp/pin-fix
rm -f /tmp/NTFS_LIST
rm -f /tmp/FAT_LIST
rm -f /tmp/Linux_LIST
echo >/tmp/list_of_drives
#*************************************************************************
fdisk -l | grep NTFS | cut -f 1 -d ' '| sed 's/\/dev\///'>/tmp/NTFS_LIST
if [ "$?" == "0" ]; then
echo "NTFS_LIST written to /tmp/NTFS_LIST"
NTFS_LIST=$(</tmp/NTFS_LIST)
for ntfs_drive in `cat /tmp/NTFS_LIST` ; do
mkdir -p /mnt/$ntfs_drive
mount -t ntfs-3g /dev/$ntfs_drive /mnt/$ntfs_drive
cat /tmp/NTFS_LIST >>/tmp/list_of_drives
done
fi # bypass the mounting if no ntfs drive found
#*************************************************************************
fdisk -l | egrep '(FAT32|FAT16)' | cut -f 1 -d ' '| sed 's/\/dev\///'>/tmp/FAT_LIST
if [ "$?" == "0" ]; then
echo "FAT_LIST written to /tmp/FAT_LIST"
FAT_LIST=$(</tmp/FAT_LIST)
for fat_drive in `cat /tmp/FAT_LIST` ; do
mkdir -p /mnt/$fat_drive
mount -t vfat /dev/$fat_drive /mnt/$fat_drive
cat /tmp/FAT_LIST >>/tmp/list_of_drives
done
fi # bypass the mounting if no fat drives found
#*************************************************************************
fdisk -l | grep Linux | egrep -v "swap" | cut -f 1 -d ' '| sed 's/\/dev\///'>/tmp/Linux_LIST
if [ "$?" == "0" ]; then
echo "Linux_LIST written to /tmp/Linux_LIST"
Linux_LIST=$(</tmp/Linux_LIST)
for Linux_drive in `cat /tmp/Linux_LIST` ; do
mkdir -p /mnt/$Linux_drive
mount /dev/$Linux_drive /mnt/$Linux_drive
cat /tmp/Linux_LIST >>/tmp/list_of_drives
done
fi # bypass the mounting if no Linux drive found
# refresh icons
rox -p /root/Choices/ROX-Filer/PuppyPin
# set up positions of x and y to print the folder icons on the desktop
# they get repositioned depending on what drives you have. getting added to the right
# by the order they got detected
# preset base values here maybe a test to see what screen size you are using goes here
x_val="64"
c_val="64" #this is the constant
#the y_val="" gets auto detected and then adjusted here
SCW=`xwininfo -root | grep '\geometry' | cut -f4 -d ' ' | cut -f1 -d 'x'`
SCH=`xwininfo -root | grep '\geometry' | cut -f4 -d ' ' | cut -f2 -d 'x' | cut -f1 -d '+'`
echo "screen width" $SCW x "height" $SCH
if [[ $SCH = "480" ]]; then
echo " the condition is true ---> $SCH "
#do something here
y_val="340"
elif [[ $SCH = "600" ]]; then
echo " the condition is true ---> $SCH "
#do something here
y_val="472"
elif [[ $SCH = "768" ]]; then
echo " the condition is true ---> $SCH "
#do something here
y_val="628"
elif [[ $SCH = "864" ]]; then
echo " the condition is true ---> $SCH "
#do something here
y_val="726"
elif [[ $SCH = "960" ]]; then
echo " the condition is true ---> $SCH "
#do something here
y_val="822"
elif [[ $SCH = "1024" ]]; then
echo " the condition is true ---> $SCH "
#do something here
y_val="882"
fi
# to remove any chance of double writes to screen
cat /tmp/list_of_drives | sort -u >/tmp/list_of_drives
for drive in `cat /tmp/list_of_drives` ; do
# edit this with much care it was tedious to format it. Save a copy first of your PuppyPin !
echo " <"icon x='"'$x_val'"' y='"'$y_val'"' label='"'$drive'"'">"/mnt/$drive"<"/icon">" >>$temp_file
# keep adding 64 to the x number to allow for spacing of the icons to be uniform
let x_val="$x_val + $c_val"
done
#----------------------------------------------------
#Append content of file year.txt at line 3 of data.txt.
#sed '3 r year.txt' data.txt > newdata.txt
#year.txt=/tmp/pin-fix data.txt=/root/Choices/ROX-Filer/PuppyPin newdata.txt=/root/Choices/ROX-Filer/PuppyPin4
#----------------------------------------------------
#remove out the /mnt/$drive because it keeps getting appended this wipes it clean each time
cat /root/Choices/ROX-Filer/PuppyPin | egrep -v "/mnt" >/root/Choices/ROX-Filer/PuppyPin1
mv /root/Choices/ROX-Filer/PuppyPin1 /root/Choices/ROX-Filer/PuppyPin
sed '10 r /tmp/pin-fix' /root/Choices/ROX-Filer/PuppyPin > /root/Choices/ROX-Filer/PuppyPin4
mv /root/Choices/ROX-Filer/PuppyPin /root/Choices/ROX-Filer/PuppyPin-old
mv /root/Choices/ROX-Filer/PuppyPin4 /root/Choices/ROX-Filer/PuppyPin
rox -p /root/Choices/ROX-Filer/PuppyPin
|
Joe
| Description |
|
| Filesize |
94.74 KB |
| Viewed |
1935 Time(s) |

|
_________________ slackware 14
Last edited by big_bass on Sat 06 Nov 2010, 12:28; edited 13 times in total
|
|
Back to top
|
|
 |
sc0ttman

Joined: 16 Sep 2009 Posts: 2175 Location: UK
|
Posted: Wed 27 Oct 2010, 04:53 Post subject:
|
|
awesome!
_________________ Akita Linux, VLC-GTK, Pup Search, Pup File Search
|
|
Back to top
|
|
 |
aragon
Joined: 15 Oct 2007 Posts: 1690 Location: Germany
|
Posted: Wed 27 Oct 2010, 11:24 Post subject:
|
|
hi big_bass,
i know you know but maybe it saves some seconds:
| Code: | SCW=`xwininfo -root | grep '\geometry' | cut -f4 -d ' ' | cut -f1 -d 'x'`
SCH=`xwininfo -root | grep '\geometry' | cut -f4 -d ' ' | cut -f2 -d 'x' | cut -f1 -d '+'` |
aragon
_________________ PUPPY SEARCH: http://wellminded.com/puppy/pupsearch.html
|
|
Back to top
|
|
 |
big_bass

Joined: 13 Aug 2007 Posts: 1736
|
Posted: Thu 28 Oct 2010, 09:14 Post subject:
|
|
Hey aragon
I like it
a very linux way of doing it and I will use it
thanks
| Code: |
#!/bin/bash
#
# simple test using Xdialog
SCW=`xwininfo -root | grep '\geometry' | cut -f4 -d ' ' | cut -f1 -d 'x'`
SCH=`xwininfo -root | grep '\geometry' | cut -f4 -d ' ' | cut -f2 -d 'x' | cut -f1 -d '+'`
echo "screen width" $SCW x "height" $SCH
Xdialog --title "sceen size check " \
--infobox "\n screen width $SCW x height $SCH\n" 0 0 4000
|
the "puppy way" would be to read this file
/etc/videomode
if you notice that the code above to mount and draw to the desktop is very compact and doesnt use any of these listed below
pmount
gtkdialog
eventmanager
partprobe,
probedisk and a few other small scripts/apps that are used while mounting
*I dont like to use "PuppyPin" but on the standard versions I will fix that
special features will be added
here's a nice little trick if you used my code in the mount_all2
a file got generated called PuppyPin-old
so if you need or want to toggle off the folder icons you could by doing this code snip
| Code: | | rox --pinboard=/root/Choices/ROX-Filer/PuppyPin-old |
thanks aragon
Joe
_________________ slackware 14
Last edited by big_bass on Fri 05 Nov 2010, 12:11; edited 4 times in total
|
|
Back to top
|
|
 |
amigo
Joined: 02 Apr 2007 Posts: 1759
|
Posted: Thu 28 Oct 2010, 11:41 Post subject:
|
|
Another small thing, Joe. I wouldn't mount the drives as 'loop' mounts since they are real partitions. Mounting them with the 'loop' option will disable any DMA access to the drives. 'loop' is only needed for partition images which you are filtering out of the list.
|
|
Back to top
|
|
 |
vovchik

Joined: 23 Oct 2006 Posts: 1231 Location: Ukraine
|
Posted: Thu 28 Oct 2010, 16:02 Post subject:
impressive |
|
Dear Joe and aragon,
This is starting to look very good. Thanks....
With kind regards,
vovchik
|
|
Back to top
|
|
 |
big_bass

Joined: 13 Aug 2007 Posts: 1736
|
Posted: Thu 28 Oct 2010, 22:31 Post subject:
|
|
Hey amigo!
Thanks I'll fix it and remove the "loop" I recycled a snip of code from my dragNdrop SFS mounter a cut and paste
Thanks for catching that and taking the time to post
as always any suggestions are always very welcomed
I am adding the correct file system checking for the mount
thanks
Joe
_________________ slackware 14
|
|
Back to top
|
|
 |
abushcrafter

Joined: 30 Oct 2009 Posts: 1447 Location: England
|
Posted: Sun 31 Oct 2010, 10:45 Post subject:
|
|
The new version is a big improvement with the refreshing of "PuppyPin". So I have commented out the separate drive icon code. There is one big bug though. The puppy home partition drive icon has the wrong icon and when clicked on give me three Rox-Filer windows. Two are at "/mnt/sda1" the other one is at "/initrd/mnt/dev_save".
| big_bass wrote: | | this started as a special request | I know and I am very gratefully.
Perhaps the simplest thing would be some thing like this:
This only works with drive partition icons enabled to my knowledge.
| Code: | #!/bin/bash
# Half the code is from the "mount_all2" script by "big_bass"
#----------------------------------------
# generate /tmp/list_of_drives
#----------------------------------------
#to be safe remove out the loop mounted stuff and the swap partion if there is one from the list
blkid | egrep '(hd|sd)' | egrep -v "/dev/loop*" | egrep -v "swap" | cut -f 1 -d ':' | sed 's/\/dev\///'>/tmp/list_of_drives
for drive in `cat /tmp/list_of_drives` ; do
#Insert code here for extracting "args" parameter of drive partition icons from "/root/Choices/ROX-Filer/PuppyPin" and setting it to the variable "$driveargs".
/root/.pup_event/drive_$drive/AppRun "$driveargs"
done |
_________________ adobe flash is rubbish!
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/
|
|
Back to top
|
|
 |
big_bass

Joined: 13 Aug 2007 Posts: 1736
|
Posted: Tue 02 Nov 2010, 14:03 Post subject:
|
|
ok here is the latest version 3
I will update the first post
I had to go about this differently to get the correct mount command
for each drive
@Hey vovchik good to hear from you
*mount does well guessing a linux partition but not for fat and ntfs correctly
if you find something that needs adjusting let me know this is working correctly for me
Joe
special features will be added
here's a nice little trick if you used my code in the mount_all3
a file got generated called PuppyPin-old
so if you need or want to toggle off the folder icons you could by doing this code snip
| Code: | | rox --pinboard=/root/Choices/ROX-Filer/PuppyPin-old |
and to get the folders back again
| Code: | | rox --pinboard=/root/Choices/ROX-Filer/PuppyPin |
_________________ slackware 14
Last edited by big_bass on Fri 05 Nov 2010, 12:16; edited 3 times in total
|
|
Back to top
|
|
 |
esmourguit
Joined: 17 Nov 2006 Posts: 1154 Location: Sur l'ile aux oiseaux.
|
Posted: Wed 03 Nov 2010, 06:11 Post subject:
|
|
Bonjour à tous,
Very good job. I tested version 3 in Quirky 1.3.0,
It works wonderfully.
But there is still a part of the bug which abushcrafter was talking about in previous post.
| Quote: | | There is one big bug though............ and when clicked on give me three Rox-Filer windows. Two are at "/mnt/sda1" the other one is at "/initrd/mnt/dev_save". | Cordialement
_________________ Toutou Linux - Pets francisés
|
|
Back to top
|
|
 |
big_bass

Joined: 13 Aug 2007 Posts: 1736
|
Posted: Wed 03 Nov 2010, 11:49 Post subject:
|
|
I posted the wrong code its fixed I am testing live cd now as I write
I cant reproduce that error but I am trying to get it
my home directory is correct on my installed version
what does your symlink read when you hover over it with the mouse for home ?
Joe
_________________ slackware 14
|
|
Back to top
|
|
 |
abushcrafter

Joined: 30 Oct 2009 Posts: 1447 Location: England
|
Posted: Wed 03 Nov 2010, 12:03 Post subject:
|
|
Its with the original drive icon not yours created by mount_all2/3.
_________________ adobe flash is rubbish!
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/
|
|
Back to top
|
|
 |
abushcrafter

Joined: 30 Oct 2009 Posts: 1447 Location: England
|
Posted: Wed 03 Nov 2010, 12:10 Post subject:
|
|
There is a screen shot.
| Description |
|
| Filesize |
67.8 KB |
| Viewed |
1578 Time(s) |

|
_________________ adobe flash is rubbish!
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/
|
|
Back to top
|
|
 |
big_bass

Joined: 13 Aug 2007 Posts: 1736
|
Posted: Wed 03 Nov 2010, 12:18 Post subject:
|
|
ok now I get it I'll fix that
thanks for posting
Joe
_________________ slackware 14
|
|
Back to top
|
|
 |
big_bass

Joined: 13 Aug 2007 Posts: 1736
|
Posted: Thu 04 Nov 2010, 12:41 Post subject:
|
|
well the conflict is in the / root/.pup_event/drive_hda1/AppRun
in your case sda1
*I dont know if the AppRun in your version differs than mine so I posted just the code
I added starting with the single plus"+" sign starting on line 186
what happens there is every thing gets mounted thats why the three folders
caused by the AppRun code (non related to the code I wrote)
I have to really dig in that and make a filter for any drives getting mounted in more than one place in the AppRun and have it select only one
I got a simple test working but needs to be improved if even more mounts are present
with the same hard drive number
here's what I got for a temp fix so far (suggestions welcomed)
this does eliminate the problem for me on my box with my drive selection
note :I am running live cd so I dont have a save file
| Code: | --- /root/.pup_event/drive_hda1/AppRun-old 2008-10-20 07:12:48.000000000 +0800
+++ /root/.pup_event/drive_hda1/AppRun 2010-10-04 10:14:55.000000000 +0800
@@ -183,7 +183,13 @@ if [ "$FSTYPE" != "" ];then
[ "`readlink /mnt/home`" = "$MNTPT" ] && MNTPT="/mnt/home"
fi
#exec rox -x /mnt/$ONEDRVNAME -d /mnt/$ONEDRVNAME
+ mount | grep "/initrd/mnt/dev_ro2" && mount | grep "/mnt/$ONEDRVNAME"
+ if [[ "$?" == 0 ]];then
+ echo "mounted on more than one place open only one rox folder"
+ exec rox -d /initrd/mnt/dev_ro2
+ else
exec rox -x $MNTPT -d $MNTPT
+ fi
fi
fi
|
I realize your folders are produced with
/initrd/mnt/dev_save
so your fix would be instead using this
| Code: |
+ mount | grep "/initrd/mnt/dev_save" && mount | grep "/mnt/$ONEDRVNAME"
+ if [[ "$?" == 0 ]];then
+ echo "mounted on more than one place open only one rox folder"
+ exec rox -d /initrd/mnt/dev_save
+ else
exec rox -x $MNTPT -d $MNTPT
+ fi
fi
fi |
_________________ slackware 14
|
|
Back to top
|
|
 |
|