From 6aaf665db5639b26e5dcceb8599bc4ec448c8ac4 Mon Sep 17 00:00:00 2001 From: glenux Date: Fri, 13 Mar 2009 13:32:32 +0000 Subject: [PATCH] sshfs-mapper: create trunk directory and migrate project source code. git-svn-id: https://websvn.glenux.net/svn/Upoc/sshfs-mapper/trunk@1221 eaee96b3-f302-0410-b096-c6cfd47f7835 --- Makefile | 17 ++++ conf/config | 2 + conf/default.map | 32 ++++++++ debian/changelog | 41 ++++++++++ debian/compat | 1 + debian/control | 13 ++++ debian/copyright | 40 ++++++++++ debian/dirs | 2 + debian/docs | 0 debian/rules | 90 +++++++++++++++++++++ sshfs-mapper | 182 +++++++++++++++++++++++++++++++++++++++++++ sshfs-mapper.1 | 86 ++++++++++++++++++++ sshfs-mapper.desktop | 10 +++ 13 files changed, 516 insertions(+) create mode 100644 Makefile create mode 100644 conf/config create mode 100644 conf/default.map create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dirs create mode 100644 debian/docs create mode 100755 debian/rules create mode 100755 sshfs-mapper create mode 100644 sshfs-mapper.1 create mode 100644 sshfs-mapper.desktop diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ed26993 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ + +BINDIR=$(DESTDIR)/usr/bin +MANDIR=$(DESTDIR)/usr/share/man +DOCDIR=$(DESTDIR)/usr/share/doc/sshfs-mapper +all: + +clean: + +install: + mkdir -p $(BINDIR) + mkdir -p $(MANDIR)/man1 + mkdir -p $(DOCDIR)/examples + cp sshfs-mapper $(BINDIR)/ + cat sshfs-mapper.1 | gzip > $(MANDIR)/man1/sshfs-mapper.1.gz + for f in `ls conf`; do \ + cat conf/$$f | gzip -f9 > $(DOCDIR)/examples/$$f.gz ; \ + done diff --git a/conf/config b/conf/config new file mode 100644 index 0000000..6e9bbe3 --- /dev/null +++ b/conf/config @@ -0,0 +1,2 @@ +# +# diff --git a/conf/default.map b/conf/default.map new file mode 100644 index 0000000..9242125 --- /dev/null +++ b/conf/default.map @@ -0,0 +1,32 @@ +# +# Remote host (where you connect) +# +# Example: +# REMOTE_HOST=www.example.com +# + +# +# Remote port (where you connect) +# +# Example: +# REMOTE_PORT=22 +# + +# +# Remote user (who you are on the remote side) +# +# Example: +# REMOTE_USER=$USER +# + +# +# Map local directory to remote share +# +# Syntax: +# MAP=directory_name remote_directory +# +# Examples: +# MAP=Config /home/$USER/Documents +# MAP=Documents /home/common/Config +# + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..2193003 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,41 @@ +sshfs-mapper (0.1-4.2) unstable; urgency=low + + * Changed interpreter to /bin/sh instead of /bin/bash . + + -- Glenn ROLLAND Tue, 30 Dec 2008 08:06:10 +0100 + +sshfs-mapper (0.1-4.1) unstable; urgency=low + + * Required dependencies were too strict on sshfs. + * Required version of sshfs is now 1.7. + + -- Glenn ROLLAND Tue, 30 Dec 2008 07:44:45 +0100 + +sshfs-mapper (0.1-4) unstable; urgency=low + + * Included REMOTE_PORT in default map example. + * Disabled compression for performance reasons. + + -- Glenn ROLLAND Mon, 08 Oct 2008 01:15:00 +0100 + +sshfs-mapper (0.1-3) unstable; urgency=low + + * Port change support. + + -- Glenn ROLLAND Mon, 18 Aug 2008 21:27:00 +0100 + +sshfs-mapper (0.1-2) unstable; urgency=low + + * A lot of fixes in the debian package: + - Updated short description. + * Added a .desktop file for ''XDG_CONFIG_HOME/.config/autostart''. + * Add config files in documentation dir. + + -- Glenn ROLLAND Sat, 17 Mar 2008 12:29:00 +0100 + +sshfs-mapper (0.1-1) unstable; urgency=low + + * Initial release. + + -- Glenn ROLLAND Sat, 15 Mar 2008 17:11:00 +0100 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..1e8b314 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +6 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..04a964e --- /dev/null +++ b/debian/control @@ -0,0 +1,13 @@ +Source: sshfs-mapper +Section: net +Priority: extra +Maintainer: Glenn ROLLAND +Build-Depends: debhelper (>= 5) +Standards-Version: 3.7.2 + +Package: sshfs-mapper +Architecture: all +Depends: ${shlibs:Depends}, ${misc:Depends}, sshfs (>= 1.7) +Description: Easy mount solution for SSH filesystems. + Sshfs-Mapper is a helper script for sshfs, the filesystem client based on fuse + and ssh. It provides automating and global settings control for sshfs mounts. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..92fb2f3 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,40 @@ +This package was debianized by Glenn ROLLAND on +Sat, 15 Mar 2008 17:11:00 +0100. + +It was downloaded from + +Upstream Author(s): + + + + +Copyright: + + + + +License: + + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + +The Debian packaging is (C) 2008, Glenn ROLLAND and +is licensed under the GPL, see above. + + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..ca882bb --- /dev/null +++ b/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/sbin diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..e69de29 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..6f85ad9 --- /dev/null +++ b/debian/rules @@ -0,0 +1,90 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + + + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/sshfs-mapper.sgml > sshfs-mapper.1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/sshfs-mapper. + $(MAKE) DESTDIR=$(CURDIR)/debian/sshfs-mapper install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + dh_strip + dh_compress + dh_fixperms +# dh_perl +# dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/sshfs-mapper b/sshfs-mapper new file mode 100755 index 0000000..3069b83 --- /dev/null +++ b/sshfs-mapper @@ -0,0 +1,182 @@ +#!/bin/sh +# vim: set ts=2 sw=2 et: +set -u + + +################################################################################ +## +## Variables initializations +## + +set |grep -q '^XDG_CONFIG_HOME' || XDG_CONFIG_HOME="$HOME/.config" +SSHFS_DIR="$XDG_CONFIG_HOME/sshfs-mapper" +SSHFS_CONFIG="$SSHFS_DIR/config" +SSHFS_MOUNT=1 +SSHFS_HOSTS_SELECTION=0 + + +################################################################################ +## +## Functions definitions +## + +read_conf() { + local config=$1 + local var=$2 + local value=`eval echo \`cat $config |grep "^$2=" |sed "s/$2=//"\`` + echo $value +} + +do_mount() { + local remotedir=$1 + local localdir=$2 + local remoteport=$3 + + sshfs \ + -o allow_root \ + -o idmap=user \ + -o uid=`id -u` \ + -o gid=`id -g` \ + -o reconnect \ + -o workaround=all \ + -o cache_timeout=240 \ + -o Ciphers=arcfour \ + -o Port=$remoteport \ + $remotedir \ + $localdir + + #-o compression=yes +} + +do_umount() { + local remotedir=$1 + local localdir=$2 + fusermount -u $localdir +} + +do_usage() { + cat >&2 <&2 + echo "To erase your setup, please manually remove directory \"$SSHFS_DIR\" first." >&2 + exit 1 + else + mkdir -p "$SSHFS_DIR" + cat > "$SSHFS_DIR/config" < "$SSHFS_DIR/default.map" <&2 + exit 1 +} + +[ ! -f "$SSHFS_CONFIG" ] && { + echo "MOUNTPOINT=\$HOME/mnt" >> "$SSHFS_CONFIG" +} +[ ! -f "$SSHFS_CONFIG" ] && { + echo -e "\nERROR: Unable to find config file." >&2 + exit 1 +} + +mountpoint=$( read_conf "$SSHFS_CONFIG" MOUNTPOINT ) +[ "x$mountpoint" = "x" ] && { + echo -e "\nERROR: Mountpoint undefined." >&2 + echo "Edit mountpoint definition in \"$SSHFS_CONFIG\"" >&2 + exit 1; +} +echo "MOUNTPOINT=$mountpoint" + +for map_file in `find "$SSHFS_DIR" -type f -name '*.map' `; do + remote_host=$( read_conf $map_file REMOTE_HOST ) + remote_user=$( read_conf $map_file REMOTE_USER ) + remote_port=$( read_conf $map_file REMOTE_PORT ) + map=$( read_conf $map_file MAP ) + echo "Map: $remote_user@$remote_host" + + map_count=0 + map_name="" + remote_dir="" + for map_item in $map; do + [ $map_count = 0 ] && map_name=$map_item + [ $map_count = 1 ] && remote_dir=$map_item + map_count=$(( ( $map_count + 1 ) % 2 )) + [ $map_count = 0 ] && { + echo " $map_name => $remote_dir" + if ! mount | grep -q " $mountpoint/$map_name " ; then + [ $SSHFS_MOUNT = 1 ] && { + mkdir -p $mountpoint/$map_name + do_mount $remote_user@$remote_host:$remote_dir $mountpoint/$map_name $remote_port + rm -f $HOME/$map_name + ln -s $mountpoint/$map_name $HOME/$map_name + } + else + [ $SSHFS_MOUNT = 0 ] && { + do_umount $remote_user@$remote_host:$remote_dir $mountpoint/$map_name + rm -f $HOME/$map_name + } + [ $SSHFS_MOUNT = 1 ] && echo " (Already mounted on $mountpoint/$map_name)" + fi + } + done +done + diff --git a/sshfs-mapper.1 b/sshfs-mapper.1 new file mode 100644 index 0000000..5fd079a --- /dev/null +++ b/sshfs-mapper.1 @@ -0,0 +1,86 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH SSHFS-MAPPER 1 "mars 15, 2008" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) + + +.SH NAME + +sshfs-mapper \- A small utility for automatizing sshfs mounts. + + +.SH SYNOPSIS + +.B sshfs-mapper +.RI [ options ] + + +.SH DESCRIPTION +This manual page documents briefly the +.B sshfs-mapper +command. +.PP +.\" TeX users may be more comfortable with the \fB\fP and +.\" \fI\fP escape sequences to invode bold face and italics, +.\" respectively. +\fBsshfs-mapper\fP is a program that... + + + +.SH OPTIONS + +.TP +.B \-h +Show summary of options. +.TP +.B \-i +Initialize sshfs-mapper configuration. +.TP +.B \-u +Umount +.TP +.B \-v +Show version of program. + + +.SH FILES + +.TP +$XDG_CONFIG_HOME/sshfs-mapper/config +blabla FIXME +.TP +$XDG_CONFIG_HOME/sshfs-mapper/*.map +bliblibli FIXME + + +.SH CONFIGURATION + +Configuration file is stored inside $XDG_CONFIG_HOME/sshfs-mapper/ . +Global settings are storend in the \fBconfig\fP file a FIXME + +.SH SEE ALSO + +.BR sshfs (1), +.BR ssh (1), +.BR ssh-keygen (1). + + +.SH AUTHOR + +sshfs-mapper was written by Glenn.Rolland . +.PP +This manual page was written by Glenn ROLLAND , +for the Debian project (but may be used by others). diff --git a/sshfs-mapper.desktop b/sshfs-mapper.desktop new file mode 100644 index 0000000..50fcba9 --- /dev/null +++ b/sshfs-mapper.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=Application +Encoding=UTF-8 +Version=1.0 +Name=SSHFS Mapper +Name[fr_FR@euro]=SSHFS Mapper +Comment=Access to remote SSH shares +Comment[fr_FR@euro]=Accès aux partages SSH distants +Exec=sshfs-mapper +X-GNOME-Autostart-enabled=true