Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (3) </ [1] 2 3 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Auto mounter script., Mounts partitions for specified users.< Next Oldest | Next Newest >
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: July 28 2006,05:27 QUOTE

This script will be included to my server.

Any suggestios? Bug fixes?
Code Sample
#!/bin/bash

# amusrpart.sh By: Zucca@dive.to (ICQ: 66768853 - MSN: ki77bi77@hotmail.com - IRC: Zucca@IRCnet)
# Full copyright owned by Zucca. First non-copyrighted relase will be version 0.1.xxx.;)
# Why? Because I'd like to finish this to... 'stable' version before anyone tries to use this. Any help is still very welcome.;)
# NOTE: This script is mainly designed for DSL LiveCD. I don't know how this would act if used with other distributions/installs.
# v 0.0.2b

# This simple script will mount all the partitions in all devices available on current computer for users if .mount.config is found from the root of partition.

for PARTITION in `ls /mnt/ | grep "[hs]d.[1-9]*"`
# Let's list all the hd* and sd* devices...
do

 mount /mnt/$PARTITION 2> /dev/null

 if [ -e /mnt/$PARTITION/.mount.conf ]
 # Check if .mount.conf exists.

 then
   OWNER=`awk 'NR == 1' /mnt/$PARTITION/.mount.conf`
   echo "$PARTITION owner: $OWNER"
   MOUNTPOINT=`awk 'NR == 2' /mnt/$PARTITION/.mount.conf`
   echo "Mount point: $MOUNTPOINT"
   if [ -e $MOUNTPOINT ]
   # If mount point specified in .mount.conf already exist then abort.
   then
     echo "Aborting mount: $MOUNTPOINT already exists."
     umount /mnt/$PARTITION
   else
     umount /mnt/$PARTITION
     # Next lines are commented because... Think what would happen if filetool.sh is executed.;)
     # mkdir $MOUNTPOINT
     # chmod 750 $MOUNTPOINT
     # chown $OWNER $MOUNTPOINT
     # chgrp staff $MOUNTPOINT

     mount -o owner=$OWNER,mode=0750 /mnt/$PARTITION
     # So instead mounting partition straight to $MOUNTPOINT we do regular mount and create a sym link.
     ln -s /mnt/$PARTITION $MOUNTPOINT
   fi
 else
   # Just simply unmount partition if .mount.conf cannot be found.
   umount /mnt/$PARTITION
 fi
 echo ""
done

echo "User dedicated partitions mounted."


Thanks for all the tips I've received alredy from you guys.  :)


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: July 31 2006,10:54 QUOTE

I've noticed few security hazard bugs.
I'll try to solve those until next friday...


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: Aug. 21 2006,13:04 QUOTE

Project halted.

All my work from past three months are propably gone because of some nasty bug... :(


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: Sep. 28 2006,23:47 QUOTE

Well now I'm back wiith this project. I have improves my script a bit but now I don't get what's wrong...

Here's the source:
Code Sample
#!/bin/bash

# amusrpart.sh By: [EMAIL=Zucca@dive.to]Zucca@dive.to[/EMAIL] (ICQ: 66768853 - MSN: [EMAIL=ki77bi77@hotmail.com]ki77bi77@hotmail.com[/EMAIL] - IRC: Zucca@IRCnet)
# Full copyright owned by Zucca. First non-copyrighted relase will be version 0.1.xxx.;)
# Why? Because I'd like to finish this to... 'stable' version before anyone tries to use this. Any help is still very welcome.;)
# NOTE: This script is mainly designed for DSL LiveCD. I don't know how this would act if used with other distributions/installs.
# v 0.0.5b

# This simple script will mount all the partitions in all devices available on current computer for users if .mount.config is found from the root of partition.

if [ ! -e /var/mount_confs ]
then
 mkdir /var/mount_confs
fi

if [ -z $1 ]
then
 echo 'USAGE: amusrpart.sh <mount|umount>'
 exit
fi

TELLUSAGE="no"

for PARTITION in `ls /mnt/ | grep "[hs]d.[1-9]*"`
# Let's list all the hd* and sd* devices...
do

 if [ $1 = "mount" ]
 then
   
   if [ -e /tmp/.amusrpart.mark ]
   then
     echo "Partitions already mounted."
     echo "Or if you are sure that it is otherwise then delete /tmp/.amusrpart.mark"
     exit
   fi

   mount /mnt/$PARTITION

   if [ -f /mnt/$PARTITION/.mount.conf ]
   # Check if .mount.conf exists.
   then
     OWNER=`awk 'NR == 1' /mnt/$PARTITION/.mount.conf`
     echo "$PARTITION owner: $OWNER"
     MOUNTPOINT=`awk 'NR == 2' /mnt/$PARTITION/.mount.conf`
     echo "Mount point: $MOUNTPOINT"
     if [ -e $MOUNTPOINT ]
     # If mount point specified in .mount.conf already exist then abort.
     then
       echo "Aborting mount: $MOUNTPOINT already exists."
       umount /mnt/$PARTITION
     else
       mv /mnt/$PARTITION/.mount.conf /var/mount_confs/mount.$PARTITION

       # Next lines are commented because... Think what would happen if filetool.sh is executed.;)
       # mkdir $MOUNTPOINT
       # chmod 750 $MOUNTPOINT
       # chown $OWNER $MOUNTPOINT
       # chgrp staff $MOUNTPOINT

       mount -o remount,owner=$OWNER,mode=0750 /mnt/$PARTITION

       # So instead mounting partition straight to $MOUNTPOINT we do regular mount and create a sym link.
       ln -s /mnt/$PARTITION $MOUNTPOINT
     fi
     echo ""
   else
     # Just simply unmount partition if .mount.conf cannot be found.
     umount /mnt/$PARTITION
   fi
 elif [ $1 = "umount" ]
 # move mount.conf back to partition and unmount.
   if [ -f /var/mount_confs/mount.$PARTITION ]
   then
     mv /var/mount_confs/mount.$PARTITION /mnt/$PARTITION/.mount.conf
     if [ -L $MOUNTPOINT ]
     then
       rm -fr $MOUNTPOINT
     fi
     umount /mnt/$PARTITION
   fi
 elif [ -n $1 ]
   TELLUSAGE="yes"
 fi
 
done


When I try to run it with mount option I get an error message:
Quote
./amusrpart.sh: line 83: syntax error near unexpected token `elif'
./amusrpart.sh: line 83: `  elif [ -n $1 ]'

There are the lines from 82 to 84:
Code Sample
   fi
 elif [ -n $1 ]
   TELLUSAGE="yes"


Can you figure out what's wrong?


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
^thehatsrule^ Offline





Group: Members
Posts: 3275
Joined: July 2006
Posted: Sep. 29 2006,02:25 QUOTE

I think you could place some "then"s after your elifs.
Back to top
Profile PM 
14 replies since July 28 2006,05:27 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (3) </ [1] 2 3 >/
reply to topic new topic new poll
Quick Reply: Auto mounter script.

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code