sshfs-mapper: Allow long command-line options. Test selected map existance.
git-svn-id: https://websvn.glenux.net/svn/Upoc/sshfs-mapper/trunk@1429 eaee96b3-f302-0410-b096-c6cfd47f7835
This commit is contained in:
parent
bbcb584348
commit
2ead8e6c50
1 changed files with 51 additions and 33 deletions
84
sshfs-mapper
84
sshfs-mapper
|
@ -57,12 +57,12 @@ do_umount() {
|
||||||
do_usage() {
|
do_usage() {
|
||||||
cat >&2 <<EOF
|
cat >&2 <<EOF
|
||||||
Usage: `basename $0` [options]
|
Usage: `basename $0` [options]
|
||||||
-h Show this help and exit.
|
-h, --help Show this help and exit.
|
||||||
-i Initialize user configuration.
|
-i, --init Initialize user configuration.
|
||||||
-l List available maps.
|
-l, --list List available maps.
|
||||||
-a Use all maps.
|
-a, --all Use all maps.
|
||||||
-s Only use specified map.
|
-s, --select <map> Only use specified map.
|
||||||
-u Umount user maps (mount if not specified).
|
-u, --umount Umount user maps (mount if not specified).
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -107,36 +107,48 @@ SSHFS_HOST_PATTERN=" "
|
||||||
SSHFS_HOST_LIMIT=0
|
SSHFS_HOST_LIMIT=0
|
||||||
SSHFS_HOST_LIST=0
|
SSHFS_HOST_LIST=0
|
||||||
SSHFS_HOST_AUTO=0
|
SSHFS_HOST_AUTO=0
|
||||||
#TODO:while getopts h:u o
|
OPTFOUND=0
|
||||||
while getopts ahiuls: o
|
while OPT=${1:-} ; shift
|
||||||
do
|
do
|
||||||
case "$o" in
|
OPTARG=${1:-}
|
||||||
a) # mount all
|
#echo "$OPT?"
|
||||||
SSHFS_HOST_AUTO=1
|
case "$OPT" in
|
||||||
;;
|
--all|-a) # mount all
|
||||||
i) # init (copy config files in user HOME)
|
SSHFS_HOST_AUTO=1
|
||||||
do_initialize
|
OPTFOUND=1
|
||||||
;;
|
;;
|
||||||
u) # umount
|
--init|-i) # init (copy config files in user HOME)
|
||||||
echo "Umounting..."
|
do_initialize
|
||||||
SSHFS_MOUNT=0
|
OPTFOUND=1
|
||||||
;;
|
;;
|
||||||
s) # only selected hosts
|
--umount|-u) # umount
|
||||||
SSHFS_HOST_PATTERN="${SSHFS_HOST_PATTERN}${OPTARG} "
|
echo "Umounting..."
|
||||||
SSHFS_HOST_LIMIT=1
|
SSHFS_MOUNT=0
|
||||||
;;
|
OPTFOUND=1
|
||||||
l)
|
;;
|
||||||
SSHFS_HOST_LIST=1
|
--select|-s) # only selected hosts
|
||||||
;;
|
SSHFS_HOST_PATTERN="${SSHFS_HOST_PATTERN}${OPTARG} "
|
||||||
|
SSHFS_HOST_LIMIT=1
|
||||||
h)
|
shift
|
||||||
do_usage
|
OPTFOUND=1
|
||||||
;;
|
;;
|
||||||
[?])
|
--list|-l)
|
||||||
do_usage
|
SSHFS_HOST_LIST=1
|
||||||
;;
|
OPTFOUND=1
|
||||||
|
;;
|
||||||
|
--help|-h)
|
||||||
|
do_usage
|
||||||
|
OPTFOUND=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
do_usage
|
||||||
|
OPTFOUND=1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
if [ $OPTFOUND -eq 0 ]; then
|
||||||
|
do_usage
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -e $SSHFS_DIR ]; then mkdir $SSHFS_DIR ; fi
|
if [ ! -e $SSHFS_DIR ]; then mkdir $SSHFS_DIR ; fi
|
||||||
if [ ! -e $SSHFS_DIR ]; then
|
if [ ! -e $SSHFS_DIR ]; then
|
||||||
|
@ -152,6 +164,12 @@ if [ ! -e "$SSHFS_CONFIG" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
for map_file in $SSHFS_HOST_PATTERN; do
|
||||||
|
if [ ! -e "$SSHFS_DIR/$map_file.map" ]; then
|
||||||
|
echo -e "\nERROR: Unable to find map file '$map_file.map'." >&2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
mountpoint=$( read_conf "$SSHFS_CONFIG" MOUNTPOINT )
|
mountpoint=$( read_conf "$SSHFS_CONFIG" MOUNTPOINT )
|
||||||
if [ "x$mountpoint" = "x" ]; then
|
if [ "x$mountpoint" = "x" ]; then
|
||||||
echo -e "\nERROR: Mountpoint undefined." >&2
|
echo -e "\nERROR: Mountpoint undefined." >&2
|
||||||
|
|
Loading…
Reference in a new issue