#!/bin/sh # Copyright (C) 2006 Krzysztof Kozlowski # License: GNU General Public License version 2 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # version 2 as published by the Free Software Foundation. # # This program 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. # # # Homepage: http://www.kozik.net.pl # # Last change: 18.11.2006 # # Mounting usermount shares. Requirements (from Gentoo Portage): # - in kernel CONFIG_FUSE_FS (or module from sys-fs/fuse) # - sys-fs/fuse # - sys-fs/sshfs-fuse (for SSH mounting) # - net-fs/curlftpfs (for FTP mounting) # # See examples below # usage () { echo "Usage: $(basename $0) " exit 127 } if [ $# -ne 1 ]; then usage fi echo -n "Loading fuse module..." sudo modprobe fuse > /dev/null if [ $? -ne 0 ]; then echo " *** ERROR *** Error loading fuse module. Make sure you have it or compile your kernel with fuse built-in." else echo " OK" fi # check_prog prog_name check_prog() { PROG=`which $1 2> /dev/null` if [ $? -ne 0 ]; then echo " *** ERROR *** Could not find needed program '$1'." exit 1 fi } # Where mounted directories will be located: MNT_TREE="/mnt/userfs" # Options for sshfs (sshfs -h), eg.: "-o kernel_cache,idmap=user,allow_root" SSHFS_OPTIONS="-o kernel_cache,idmap=user" # Options for curlftpfs (man curlftpfs), eg.: "-o tcp_nodelay,transform_symlinks,utf8,connect_timeout=15" CURLFTPFS_OPTIONS="-o transform_symlinks,connect_timeout=15" if [ ! -d "${MNT_TREE}/${1}" ]; then echo "Directory ${MNT_TREE}/${1} does not exist!" echo usage fi case "$1" in # # Examples # # SSH example: # Usage: mount_userfs my_ssh_site # will mount ssh_host (from .ssh/config file) in ${MNT_TREE}/my_ssh_site #my_ssh_site) # sshfs ${1}: ${MNT_TREE}/${1} ${SSHFS_OPTIONS} # ;; # # FTP example: # Usage: mount_userfs my_ftp_site # Remember to put username and password in file .netrc. #my_ftp_site) # curlftpfs ${CURLFTPFS_OPTIONS} my.ftp.site.com ${MNT_TREE}/${1} # ;; # # End - examples # *) usage ;; esac