Zucca
Group: Members
Posts: 524
Joined: Feb. 2006 |
|
Posted: Sep. 28 2006,23:47 |
|
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
|