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
|
module SshfsMapper
|
||||||
class Map
|
class Map
|
||||||
def initialize
|
def initialize( map_path )
|
||||||
|
@path = map_path
|
||||||
@host = nil
|
@host = nil
|
||||||
@port = 22
|
@port = 22
|
||||||
@user = nil
|
@user = nil
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def parse()
|
||||||
|
puts "Parsing #{@path}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
12
sshfs-mapper
12
sshfs-mapper
|
@ -59,6 +59,8 @@ do_usage() {
|
||||||
Usage: `basename $0` [options]
|
Usage: `basename $0` [options]
|
||||||
-h Show this help and exit.
|
-h Show this help and exit.
|
||||||
-i Initialize user configuration.
|
-i Initialize user configuration.
|
||||||
|
-l List available maps.
|
||||||
|
-s Only use specified map.
|
||||||
-u Umount user maps.
|
-u Umount user maps.
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -115,7 +117,6 @@ do
|
||||||
SSHFS_MOUNT=0
|
SSHFS_MOUNT=0
|
||||||
;;
|
;;
|
||||||
s) # only selected hosts
|
s) # only selected hosts
|
||||||
#SSHFS_HOST_SELECTION=1
|
|
||||||
SSHFS_HOST_PATTERN+="$OPTARG "
|
SSHFS_HOST_PATTERN+="$OPTARG "
|
||||||
SSHFS_HOST_LIMIT=1
|
SSHFS_HOST_LIMIT=1
|
||||||
;;
|
;;
|
||||||
|
@ -153,6 +154,13 @@ mountpoint=$( read_conf "$SSHFS_CONFIG" MOUNTPOINT )
|
||||||
exit 1;
|
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
|
for map_file in `find "$SSHFS_DIR" -type f -name '*.map' `; do
|
||||||
if [ $SSHFS_HOST_LIST -eq 1 ]; then
|
if [ $SSHFS_HOST_LIST -eq 1 ]; then
|
||||||
basename ${map_file/.map/}
|
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=$(( ( $map_count + 1 ) % 2 ))
|
||||||
[ $map_count = 0 ] && {
|
[ $map_count = 0 ] && {
|
||||||
echo " $map_name => $remote_dir"
|
echo " $map_name => $remote_dir"
|
||||||
if ! mount | grep -q " $mountpoint/$map_name " ; then
|
if ! is_mounted $map_name ; then
|
||||||
[ $SSHFS_MOUNT = 1 ] && {
|
[ $SSHFS_MOUNT = 1 ] && {
|
||||||
mkdir -p $mountpoint/$map_name
|
mkdir -p $mountpoint/$map_name
|
||||||
do_mount $remote_user@$remote_host:$remote_dir $mountpoint/$map_name $remote_port
|
do_mount $remote_user@$remote_host:$remote_dir $mountpoint/$map_name $remote_port
|
||||||
|
|
|
@ -21,6 +21,7 @@ module SshfsMapper
|
||||||
end
|
end
|
||||||
@maps.each do |map_path|
|
@maps.each do |map_path|
|
||||||
map = Map.new( map_path )
|
map = Map.new( map_path )
|
||||||
|
map.parse()
|
||||||
end
|
end
|
||||||
puts "--run"
|
puts "--run"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue