HOW-TO: owncloud client

Osiris

Contributor
Joined
Aug 15, 2013
Messages
148
How to install owncloud client in a freenas 10.3 jail
Actually : FreeBSD owncloud_client 10.3-STABLE FreeBSD 10.3-STABLE #0 r295946+0ea9076(9.10-STABLE): Mon Oct 3 06:51:23 UTC 2016

  • Set up a standard jail via the freenas gui (here named owncloud_client)

  • shell into it
    jexec -u root owncloud_client csh

  • install package owncloudclient.
    You could compile it from source, using port /usr/ports/deskutils/owncloudclient/, but this is an enormous process due to tons of dependencies.
    Not kidding - took a full day! - so witched to the pkg.
    pkg install owncloudclient-2.2.4
    You might need to pkg update first.
    Version might change in the meantime, so do pkg search owncloudclient to get the latest package.

  • Then (or done before), setup a user on your owncloud server.
    In my example
    user: share
    password: sharepass
    server: http://cloud-server.local
    local share in the jail: /mnt/share

  • Preparation for a cron script ...
    I've used bash so install bash first, if you want to copy mine
    pkg install bash
    Create a symlink (not necessary if you change it in the script, but I'm staying linux compliant)
    ln -s /usr/local/bin/bash /bin/bash

  • Create a cron entry using crontab -e in the jail. This works since Freenas v9.10 (I think. Before I had to create cronjobs on the host).
    Code:
    * * * * * /mnt/owncloud_share.sh


  • The cron script that runs every minute, as configured above.
    I can't take all the credit, but made proper adaptations for freebsd.
    vi /mnt/owncloud_share.sh
    Code:
    #!/bin/bash
    SCRIPTNAME=`basename $0`
    PIDFILE=/tmp/${SCRIPTNAME}.pid
    
    if [ -f ${PIDFILE} ]; then
    	OLDPID=`cat ${PIDFILE}`
    	if [ "$OLDPID" == "" ]; then
    		OLDPID="no_old_pid"
    	fi
    	RESULT=`ps auxww | grep ${OLDPID} | grep ${SCRIPTNAME}`
    	if [ -n "${RESULT}" ]; then
    		echo "Script already running! Exiting"
    		exit 255
    	fi
    
    fi
    
    #grab pid of this process and update the pid file with it
    PID=`ps auxww | grep ${SCRIPTNAME} | head -n1 |  awk ' {print $2;} '`
    echo ${PID} > ${PIDFILE}
    
    /usr/local/bin/owncloudcmd --trust --silent --non-interactive --user share --password sharepass /mnt/share http://cloud-server.local
    
    if [ -f ${PIDFILE} ]; then
    	rm -f ${PIDFILE}
    fi
 
Last edited:

deltapi

Cadet
Joined
May 26, 2020
Messages
1
This guide was great. It was straightforward and did everything I needed. Thank you very much!

There were a couple things I did differently, it has been a couple years..!
for anyone else following along now, my notes - running 11.3u3.1
  • had to identify the jail by the jail ID number as it would not accept the ascii name of my jail, eg:
    Code:
    jexec -u root 2 csh
  • owncloud was at 2.6 at the time of my install
  • I changed my crontab to start off with */5 so that it would run every 5 minutes instead of every minute as I don't need instant sync
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
had to identify the jail by the jail ID number as it would not accept the ascii name of my jail
A lot has changed in three years, one thing being that the default jail manager is now iocage, which does things a little differently. The better command would be iocage console owncloud_client.
owncloud was at 2.6 at the time of my install
I have no idea why this guide specifies a version number in the pkg install command, as I can't think of any reason to do it. Just pkg install owncloudclient, as long as that's still the package name, will work and will get the latest version.
 
Top