sshfs-mapper: improved ruby version a bit.
git-svn-id: https://websvn.glenux.net/svn/Upoc/sshfs-mapper/trunk@1389 eaee96b3-f302-0410-b096-c6cfd47f7835
This commit is contained in:
parent
699cc7d337
commit
69a4bcb292
3 changed files with 16 additions and 5 deletions
8
map.rb
8
map.rb
|
@ -1,12 +1,14 @@
|
|||
module SshfsMapper
|
||||
class Map
|
||||
def initialize
|
||||
def initialize( map_path )
|
||||
@path = map_path
|
||||
@host = nil
|
||||
@port = 22
|
||||
@user = nil
|
||||
|
||||
|
||||
end
|
||||
|
||||
def parse()
|
||||
puts "Parsing #{@path}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
12
sshfs-mapper
12
sshfs-mapper
|
@ -59,6 +59,8 @@ do_usage() {
|
|||
Usage: `basename $0` [options]
|
||||
-h Show this help and exit.
|
||||
-i Initialize user configuration.
|
||||
-l List available maps.
|
||||
-s Only use specified map.
|
||||
-u Umount user maps.
|
||||
EOF
|
||||
exit 1
|
||||
|
@ -115,7 +117,6 @@ do
|
|||
SSHFS_MOUNT=0
|
||||
;;
|
||||
s) # only selected hosts
|
||||
#SSHFS_HOST_SELECTION=1
|
||||
SSHFS_HOST_PATTERN+="$OPTARG "
|
||||
SSHFS_HOST_LIMIT=1
|
||||
;;
|
||||
|
@ -153,6 +154,13 @@ mountpoint=$( read_conf "$SSHFS_CONFIG" MOUNTPOINT )
|
|||
exit 1;
|
||||
}
|
||||
|
||||
is_mounted() {
|
||||
local map_name=$1
|
||||
|
||||
mount | grep -q " $mountpoint/$map_name "
|
||||
return $?
|
||||
}
|
||||
|
||||
for map_file in `find "$SSHFS_DIR" -type f -name '*.map' `; do
|
||||
if [ $SSHFS_HOST_LIST -eq 1 ]; then
|
||||
basename ${map_file/.map/}
|
||||
|
@ -184,7 +192,7 @@ for map_file in `find "$SSHFS_DIR" -type f -name '*.map' `; do
|
|||
map_count=$(( ( $map_count + 1 ) % 2 ))
|
||||
[ $map_count = 0 ] && {
|
||||
echo " $map_name => $remote_dir"
|
||||
if ! mount | grep -q " $mountpoint/$map_name " ; then
|
||||
if ! is_mounted $map_name ; then
|
||||
[ $SSHFS_MOUNT = 1 ] && {
|
||||
mkdir -p $mountpoint/$map_name
|
||||
do_mount $remote_user@$remote_host:$remote_dir $mountpoint/$map_name $remote_port
|
||||
|
|
|
@ -21,6 +21,7 @@ module SshfsMapper
|
|||
end
|
||||
@maps.each do |map_path|
|
||||
map = Map.new( map_path )
|
||||
map.parse()
|
||||
end
|
||||
puts "--run"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue