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
This commit is contained in:
Glenn Y. Rolland 2009-03-13 13:32:32 +00:00
commit ea55931bef
13 changed files with 516 additions and 0 deletions

17
Makefile Normal file
View file

@ -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

2
conf/config Normal file
View file

@ -0,0 +1,2 @@
#
#

32
conf/default.map Normal file
View file

@ -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
#

41
debian/changelog vendored Normal file
View file

@ -0,0 +1,41 @@
sshfs-mapper (0.1-4.2) unstable; urgency=low
* Changed interpreter to /bin/sh instead of /bin/bash .
-- Glenn ROLLAND <glenux@glenux.net> 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 <glenux@glenux.net> 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 <glenux@glenux.net> Mon, 08 Oct 2008 01:15:00 +0100
sshfs-mapper (0.1-3) unstable; urgency=low
* Port change support.
-- Glenn ROLLAND <glenux@glenux.net> 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 <glenux@glenux.net> Sat, 17 Mar 2008 12:29:00 +0100
sshfs-mapper (0.1-1) unstable; urgency=low
* Initial release.
-- Glenn ROLLAND <glenux@glenux.net> Sat, 15 Mar 2008 17:11:00 +0100

1
debian/compat vendored Normal file
View file

@ -0,0 +1 @@
6

13
debian/control vendored Normal file
View file

@ -0,0 +1,13 @@
Source: sshfs-mapper
Section: net
Priority: extra
Maintainer: Glenn ROLLAND <glenux@glenux.net>
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.

40
debian/copyright vendored Normal file
View file

@ -0,0 +1,40 @@
This package was debianized by Glenn ROLLAND <glenux@glenux.net> on
Sat, 15 Mar 2008 17:11:00 +0100.
It was downloaded from <url://example.com>
Upstream Author(s):
<put author's name and email here>
<likewise for another author>
Copyright:
<Copyright (C) YYYY Name OfAuthor>
<likewise for another author>
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 <glenux@glenux.net> 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.

2
debian/dirs vendored Normal file
View file

@ -0,0 +1,2 @@
usr/bin
usr/sbin

0
debian/docs vendored Normal file
View file

90
debian/rules vendored Executable file
View file

@ -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

182
sshfs-mapper Executable file
View file

@ -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 <<EOF
Usage: `basename $0` [options]
-h Show this help and exit.
-i Initialize user configuration.
-u Umount user maps.
EOF
exit 1
}
do_initialize()
{
echo "Initializing user maps..."
if [ -d "$SSHFS_DIR" ]; then
echo -e "\nERROR: Configuration directory already exists!" >&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" <<EOF
MOUNTPOINT=\$HOME/mnt
LINKTO=\$HOME
EOF
cat > "$SSHFS_DIR/default.map" <<EOF
REMOTE_USER=\$USER
REMOTE_HOST=example.com
REMOTE_PORT=22
MAP=RemoteDocs /home/\$USER/Documents
MAP=RemoteMusic /home/\$USER/Music
EOF
echo -e "\nManually edit configuration files in \"$SSHFS_DIR\""
echo "to adjust sshfs-mapper configuration to your settings."
echo -e "\nType \"man sshfs-mapper\" to get more help."
exit 0
fi
}
################################################################################
##
## Parse options and mount/umount
##
#TODO:while getopts h:u o
while getopts hiu o
do
case "$o" in
i) # init (copy config files in user HOME)
do_initialize
;;
u) # umount
echo "Umounting..."
SSHFS_MOUNT=0
;;
# s) # only selected hosts
# #SSHFS_HOST_SELECTION=1
# SSHFS_HOST_PATTERN="$OPTARG"
# ;;
h)
do_usage
;;
[?])
do_usage
;;
esac
done
[ ! -d $SSHFS_DIR ] && mkdir $SSHFS_DIR
[ ! -d $SSHFS_DIR ] && {
echo -e "\nERROR: Unable to create $SSHFS_DIR" >&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

86
sshfs-mapper.1 Normal file
View file

@ -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 <n> 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<whatever>\fP and
.\" \fI<whatever>\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 <glenux@glenux.net>.
.PP
This manual page was written by Glenn ROLLAND <glenux@glenux.net>,
for the Debian project (but may be used by others).

10
sshfs-mapper.desktop Normal file
View file

@ -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