[Assorted-commits] SF.net SVN: assorted:[985] sharing-gateway/trunk/src
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-10-05 18:26:33
|
Revision: 985 http://assorted.svn.sourceforge.net/assorted/?rev=985&view=rev Author: yangzhang Date: 2008-10-05 17:16:10 +0000 (Sun, 05 Oct 2008) Log Message: ----------- added support for sshfs, bind; better err msgs; tweaked documentation Modified Paths: -------------- sharing-gateway/trunk/src/gateway.py sharing-gateway/trunk/src/index.pandoc Modified: sharing-gateway/trunk/src/gateway.py =================================================================== --- sharing-gateway/trunk/src/gateway.py 2008-10-02 22:18:03 UTC (rev 984) +++ sharing-gateway/trunk/src/gateway.py 2008-10-05 17:16:10 UTC (rev 985) @@ -21,13 +21,13 @@ class my_exception( Exception ): pass -def run( cmd ): - p = Popen( cmd ) +def sudo( cmd ): + p = Popen( ['sudo'] + cmd ) if p.wait() != 0: raise my_exception( 'command failed with error code %s: %s' % ( p.returncode, cmd ) ) def runout( cmd, f ): - p = Popen( cmd, stdout = f ) + p = Popen( ['sudo'] + cmd, stdout = f ) if p.wait() != 0: raise my_exception( 'command failed with error code %s: %s' % ( p.returncode, cmd ) ) @@ -45,26 +45,38 @@ if cmd == 'mount': for s in cfg.shares: - if s.type == 'cifs': + try: + mountpt = mountdir / s.name + sudo( [ 'mkdir', '-p', mountpt ] ) d = structs2dicts( s ) - d[ 'ip' ] = gethostbyname( s.host ) - mountpt = mountdir / s.name - try: - run( [ 'sudo', 'mkdir', '-p', mountpt ] ) - run( 'sudo mount -t cifs -o'.split() + + if s.type == 'cifs': + d[ 'ip' ] = gethostbyname( s.host ) + sudo( 'mount -t cifs -o'.split() + [ 'user=%(user)s,pass=%(pass)s,ip=%(ip)s' % d, s.share, mountpt ] ) - except: - print >> stderr, 'error mounting', s.name - else: - raise my_exception( 'unknown share type: %s' % s.type ) + elif s.type == 'sshfs': + sudo( [ 'sshfs', s.share, mountpt, + '-o', 'IdentityFile=%(key)s' % d, '-o', 'allow_other' ] ) + elif s.type == 'bind': + sudo( [ 'mount', '--bind', s.share, mountpt ] ) + else: + raise my_exception( 'unknown share type: %s' % s.type ) + except Exception, ex: + print >> stderr, 'error mounting', s.name + print >> stderr, ex elif cmd == 'umount': for s in cfg.shares: mountpt = mountdir / s.name try: - run( [ 'sudo', 'umount', mountpt ] ) - run( [ 'sudo', 'rmdir', mountpt ] ) - except: + if s.type in 'cifs bind'.split(): + sudo( [ 'umount', mountpt ] ) + elif s.type == 'sshfs': + sudo( [ 'fusermount', '-u', mountpt ] ) + else: + raise my_exception( 'unknown share type: %s' % s.type ) + sudo( [ 'rmdir', mountpt ] ) + except Exception, ex: print >> stderr, 'error unmounting', s.name + print >> stderr, ex elif cmd == 'index': for s in cfg.shares: print 'indexing', s.name Modified: sharing-gateway/trunk/src/index.pandoc =================================================================== --- sharing-gateway/trunk/src/index.pandoc 2008-10-02 22:18:03 UTC (rev 984) +++ sharing-gateway/trunk/src/index.pandoc 2008-10-05 17:16:10 UTC (rev 985) @@ -23,8 +23,8 @@ Each of the top-level directories represents a different share, so their speeds and availability may vary. -About ------ +About Sharing Gateway +--------------------- To find more information about this system or to run your own sharing gateway, take a look at the [project homepage]. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |