SSHFS example (script inid for Wuala)

SSHFS example (script inid for Wuala)

Posted By: pmietlicki

Published to Linux on Jun 23, 2017

If you use wuala, you will probably like to share your storage on your network via samba. It is possible to do it using sshfs.

To do this, you will have to 2 users:

1. one that mounts the wuala disk (here Pascal)
2. other one that connects to it with sshfs (here sandra)

WIth the user N°2, you'll have to exchange ssh keys to avoid having to retype the password each time :

ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub pascal@ucsdc

And now, it remains only to start from the user 2, the command to share the folder with all users :

sshfs pascal@ucsdc:/mnt/wuala /media/wuala -o allow_other -s

Below the script you can add in init.d to auto mount the disk (add it with update-rc.d defaults /etc/init.d/wuala) :

#!/bin/bash
 
# Based on script found on Pascal's blog
# http://pascal.nextrem.ch/2009/10/20/wuala-init-d-script/comment-page-1/#comment-431
#
# Extended by Frode Haugsgjerd Apr 10 2011
 
### BEGIN INIT INFO
# Provides:          wuala
# Required-Start:    $network $local_fs $remote_fs
# Required-Stop:     $network $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: start Wuala headless (wuala)
### END INIT INFO
 
WUALAUSR=pascal
USER=nomutilisateur
PASS=password
SSHFSUSER=sandra
wuala='cd /tmp;nohup /usr/bin/wualacmd'
 
uptest(){
        if ps aux|grep -v grep|grep loader3.jar >/dev/null;then
                echo "Wuala is running"
                return 0
        else
                echo "Wuala is not running"
                return 1
        fi
}
 
 
case "${1:-''}" in
  'sshfs')
        su $SSHFSUSER -c "sshfs pascal@ucsdc:/mnt/wuala /media/wuala -o allow_other -s"
    ;;
 
  'start')
 
        # start commands here
        echo "Starting Wuala..."
        uptest || su $WUALAUSR -c "$wuala login $USER $PASS -mount /mnt/wuala" &
        su $SSHFSUSER -c "sshfs pascal@ucsdc:/mnt/wuala /media/wuala -o allow_other -s"
        su $WUALAUSR -c "chmod -R 775 /mnt/wuala/$WUALAUSR"
        su $WUALAUSR -c "chmod -R 775 /media/wuala/$WUALAUSR"
        uptest
    ;;
 
  'stop')
        # stop commands here
        su $SSHFSUSER -c "fusermount -u /media/wuala" &
        echo "Stopping Wuala..."
        uptest && su $WUALAUSR -c "wualacmd exit"
 
    ;;
 
  'restart')
        # restart commands here
        su $WUALAUSR -c "wualacmd restart" &
    ;;
 
  'status')
        # status commands here
        cd $WUALADIR
        uptest && su $WUALAUSR -c "wualacmd showStatus"
        uptest && su $WUALAUSR -c "wualacmd connectionInfo"
        uptest && su $WUALAUSR -c "wualacmd showSettings"
    ;;
 
  *)
        # no parameter specified
        echo "Usage: $SELF start|stop|restart|status"
        exit 1
    ;;
esac

Tags: SSHFS

Archive