kerberos-io / machinery

(DEPRECATED) An open source image processing framework, which uses your USB-, IP- or RPi-camera to recognize events (e.g. motion).
https://www.kerberos.io
490 stars 104 forks source link

Automatically mount CIFS in KiOS on startup after network is available #142

Open germama opened 6 years ago

germama commented 6 years ago

Hello there, First of all, really great project!

I would like to issue a "mount -a" on startup in KiOS after bootup right after the WIFI is connected in order to mount a CIFS. It sounds funny but I found no way to do that in KiOS. Do you have any hint or advice for me? Thank you very much.

constant1010 commented 6 years ago

Hello, I had this question and I have make bash script as:

if grep -qs '//192.168.0.3' /proc/mounts; then echo "It's mounted." else mount -a fi

and you can run script on detection in Kios configuration

cedricve commented 6 years ago

Hey @constant1010,

Can you give more detailed steps how you resolved it. This can be helpful for other users. Thanks @constant1010

constant1010 commented 6 years ago

Hello, sorry maybe it's not clear. add this line for cifs parameters in /etc/fstab (server ip is 192.168.1.1) //192.168.1.1/capture/ /data/machinery/capture cifs guest,username=constant,password=10101988,iocharset=utf8,file_mode=0640,dir_mode=0757,noperm 0 0

execute mount -a for check if you want.

create a bash file named check.sh with execute privilege with line if grep -qs '//192.168.1.1' /proc/mounts; then echo "It's mounted." else mount -a fi

you can run this script for check with command ./check.sh

and finally you can get on administration kios webpage, in configuration, add in io, script, with path /root/check.sh

cedricve commented 6 years ago

hey @germama,

were you able to resolve your issue with the help of @constant1010's comment?

docweird commented 4 years ago

Above never worked for me in 2.7.0. or 2.8.0.

Problem is that network shares are mounted way before any network is available, so they will always fail since _netdev option doesn't work and mount them when needed.

In 2.8.0 I resoved this by:

#!/bin/bash
 test -n "${OS_VERSION}" || source /etc/init.d/base``
  mount_fs() {
      msg_begin "Mounting network filesystems"
      /bin/mount -T /etc/fstab.network -a
      test $? == 0 && msg_done || msg_fail
  }
 case "$1" in
    start)
        mount_fs
        ;;
    stop)
       true
        ;;
    *)
        echo "Usage: $0 {start}"
        exit 1
 esac

 exit $?

After next boot you should have a network share where you can save your images of videos.

Having a camera server without a possibility to save to network share is a really, really bad thing...