Mail Archives: cygwin/2001/01/11/15:31:54
I'm sorry, but there was an error in the script I just posted.
(a leftover line that add extra u to the mount flags).
Seeing an email by cgf I enhanced my script to quote the Paths.
The script takes some times, so I added echos to stderr.
So here is the new script:
------------------------- mount-export.sh -------------------------
#! /bin/sh -e
# Export the current mount into a script to rebuild it
# the script is written into $1 (stdout if none/empty)
# ----------------------------------------------------
quote () # quote stdin to stdout
{ # change \ to \\, " to \"
sed -e "s/\\\\/\\\\\\\\/g" \
-e "s/\\\"/\\\\\\\"/g" \
-e "s/\`/\\\\\\\`/g" # re-escape \, ", ' and `
}
# ----------------------------------------------------------------------
dcd_ln () # decode 1 mount line
{ # given as argument
WINP=`echo $1 | cut "-d " -f1 | quote` # Windows Path (unquoted)
MNTP=`echo $1 | cut "-d " -f2 | quote` # Cygwin mount point
U_S=`echo $1 | cut "-d " -f3` # user / system
BTX=`echo $1 | cut "-d " -f4` # binmode / textmode , exec
FLAGS="-f"
case "$U_S" in
"user" ) U_S=u ;; # user mount
"system" ) U_S=s ;; # user mount
* ) echo "Error, type is $U_S, should be user/system !"
exit 1 ;; # grave error
esac
case "$BTX" in
*"exec" ) FLAGS="${FLAGS}x" ;; # mounted with exec[ute]
esac
case "$BTX" in
"bin"* ) BTX=b ;; # mounted in binary mode
"text"* ) BTX=t ;; # mounted in text mode
* ) echo "Error, flags are $BTX, should be binmode/textmode !"
exit 1 ;; # grave error
esac
FLAGS="$FLAGS$U_S$BTX" # flags for mount
}
# ----------------------------------------------------------------------
add_mounts () # work on current mounts
{ # (output of mount command)
read MLN # ignore 1st line
read MLN # next line
while [ "$MLN" != "" ] # stop on extra empty line
do
dcd_ln "$MLN" # break into components
echo "mount $FLAGS \"$WINP\" \"$MNTP\""
# write mount quoted command
echo "Mount \"$WINP\" on \"$MNTP\" processed" >&2
read MLN # next line
done
}
# ----------------------------------------------------------------------
if [ "$1" != "" ] ; then
exec 1>"$1"
fi
echo "#! /bin/sh -ex
# Rebuild the mount table, Original configuration from:"
HST=`hostname`
date -u "+# $HST at %Y-%m-%d %H:%M"
echo "# ----------------------------------------------------
# 1st remove all currently mount points & prefixes
umount --remove-all-mounts
umount --remove-cygdrive-prefix
# 2nd set Cygwin drive prefix"
PRFXLN=`mount --show-cygdrive-prefixes | tail -1`
dcd_ln "dummy $PRFXLN" # decode prefix
case "$BTX$U_S" in # special flags for prefix
"bs" ) FLAGS="-bs" ;; # -bs
"bu" ) FLAGS="-b" ;; # -b
"ts" ) FLAGS="-s" ;; # -s
* ) FLAGS="" ;; # none (tu)
esac
echo "mount $FLAGS --change-cygdrive-prefix \"$MNTP\""
echo "Prefix is \"$MNTP\" defined" >&2
echo -e "\n# restore mounts, one by one\n"
( mount ; echo ) | add_mounts # write all mounts
echo "
############################## end of re-mount #############################"
############################## mount-export.sh ##############################
--
@@@@@@ @@@ @@@@@@ @ @ Ehud Karni Simon & Wiesel Insurance agency
@ @ @ @@ @ Tel: +972-3-6212-757 Fax: +972-3-6292-544
@ @ @ @ @ @@ (USA) Fax and voice mail: 1-815-5509341
@ @ @ @ @ @ Better Safe Than Sorry
http://www.simonwiesel.co.il mailto:ehud AT unix DOT simonwiesel DOT co DOT il
--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -