Your cloud data, synced with WebDAV
and encoded with EncFs
.
cloud-davfs-encfs
makes it easy create and manage your cloud connections for
your encoded files.
The command cloud-davfs-encfs, encrypts your data using Encfs
and uses a
WebDAV
connection to your cloud provider for uploading and syncing the
encrypted data to the encoded
directory. Only you have the encfs password.
By using an easy to remember unique identifier, multiple cloud instances and cloud
providers can be used, independently. But the mechanics and operations remain the
same. Cloud-davfs-enfs
will create a new tree structure for each identifier.
You can upload and keep un-encoded data on your cloud anywhere outside of the
encoded
directory.
Since it is probably a good idea to keep a local copy of the cloud data, sync functionality is encouraged (with some setup). Unison is a good bidirectional file synchronizer, recommended. A unison sample template is provided. Of course, you may use another file synchronization tool of your choice.
This is a bash shell-script that coordinates the needed actions to handle your encrypted cloud data.
The prerequisites are provided by most Linux distributions. Nothing fancy here. These are:
- bash shell.
- util-linux for
mountpoint
. sudo
.- davfs2.
- encfs.
- unison, optional. You may use another tool of your choice for file synchronization.
Install the needed libraries using your distribution’s package manager or directly from source.
To configure davfs2
, make sure to:
- add your user to the
davfs2
group. You may have to first create thedavfs2
group. - check your
http
proxy configuration, if needed. The system will work with correct proxy setup. - add the cloud mount-point, cloud-username and password to the
~/.davfs2/secrets
file. See below section on layout for the cloud mount point.
Download and uncompress the archive file or clone the repository. Make sure the
cloud-davfs-encfs.sh
is executable and create a link to it, with a name like
cdectl
. The link should be within the shell path.
chmod +x cloud-davfs-encfs.sh
# cd to your local path, such as ~/.local/bin or ~/bin
cd ~/bin
# create symbolic link, cdectl
ln -s path/to/executable/cloud-davfs-encfs.sh cdectl
The general command follows a systemd
style pattern of:
cdectl action [cloudname]
where:
cdectl
: the command name from the installation.action
: specifies action to be taken.cloudname
: usually the identifier for the cloud instance, with some exceptions:- some actions do not need it
- has a different meaning for the
create
action.
The cloudname
identifier should be easy to memorize, but characteristic enough
to clearly distinguish your cloud instances. Perhaps, as a decent rule-of-thumb,
should be between 3-4 characters long. Avoid, using things like: cloud01
,
cloud02
, nextcloudofficenew
, etc. which have no meaning or are too long.
Prefer (short) cloudnames
that make sense to you. Should also be good for use as
a directory names.
A diagram showing the layout will be provided soon, here. Sorry.
All the cloud instances, are mounted under a common directory root, the
CLOUD_ROOT
by default ~/cloud
. Each cloud instance is set under the
CLOUD_ROOT
using a unique cloudname identifier. For a cloudname of exam
,
using the defaults the directory DIR_CLOUDNAME
would be ~/cloud/exam
.
The remote cloud directory, usually named FILES
or similar, is mounted at the
webdav
mount-point as $DIR_CLOUDNAME/webdav
. Under the webdav
mount-point, a
directory is set for the encoded files as $DIR_CLOUDNAME/webdav/encoded
. The
encoded files are mounted, using EncFs, to $DIR_CLOUDNAME/cloudfiles
.
Defined actions are:
createb
status
start
stop
list
orls
sync
The create
action will create the configuration and directory layout for a new
cloud instance. The format of the create
action is:
cdectl create file.config
where file.config
is the full or relative path to the configuration file. The
path of this file is not important. See configuration file section for details
on file.config
.
The create
action will:
- check the provided
cloudname
is not already used. - place a new configuration file in the proper location.
- add an entry to
/etc/fstab
for mounting thewedbav
instance. This requires root privileges withsudo
.
The start
action mounts the webdav
and encfs
directories for the cloud
instance provided. The format is:
cdectl start cloudname
This action connects the cloud files, decodes them and mounts them to the
$DIR_CLOUDNAME/cloudfiles
directory.
The stop
action un-mounts the webdav
and encfs
directories for the cloud
instance provided. The format is:
cdectl stop cloudname
As the name implies, this action is the opposite of the start
action.
The status
action will check and report on the webdav
and encfs
status.
The format is:
cdectl status cloudname
Note, the davfs2
backend will:
- refuse to close the connection when the
webdav
is active. - wait for cache synchronization when closing the
webdav
connection.
The list
action will report on the known cloudnames
.
The format is:
cdectl list
cdectl ls # short format
It will not do any checks, such as check if the cloud instances are active, have the correct layout, etc.
The config-show
action will print the contents of the configuration file.
The format is:
cdectl config-show cloudname
The sync
action will run the file synchronization command given in the
configuration file. The format is:
cdectl sync cloudname
The file synchronization should take place between the decoded files at
$DIR_CLOUDNAME/cloudfiles
and a local location.
By default, this action is disabled as it requires to be set-up by the user.
The configuration file uses a simple shell-syntax for setting shell variables:
# Use Unix shell syntax.
# Change the value assignd to the variables as needed.
# The webdav remote path depends on your cloud provider.
# Consult the cloud provider documentation.
WEBDAV_REMOTE_PATH=https://server/remote.php/dav/files/[email protected]/
# provide an identifier
CLOUDNAME=exam
# Command for bi-directional syncing with the local files.
# See example using the unison synchronizer, with the synchronization
# details in the .prf file.
# By default this command is disabled, as it requires setup by the user.
# SYNC_CMD='unison example.prf'
SYNC_CMD='echo "Sync disabled"; exit'
The above sample is available in sample.conf.
GPLv3 or later. No warranties made.