btidey
Posts: 1615
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Thu Nov 30, 2017 9:27 pm

alberto.tagliavini wrote:
Thu Nov 30, 2017 3:30 pm

Thanks for your reply.
I've seen that putting tl 1 in the Motion Start and tl 0 in the motion stop then a new time lapse will be started every 10 minutes can be a problem if i have subfolders by day and hour to save the images. Because i cannot see in the download page the files created in the second folder. For example if i start the timelapse at 3:50 i can see in the download page only the files up to 4 because at 4 it changes subfolder. I cannot see the following files.
Thumbnail is always in media folder. Its name provides a link to where the actual captures are stored including the subfolder. This will cause a problem if you have a naming structure where the subfolder cna change in th middle of a time lapse sequence as the thumbnail will only point to the first folder.

If you want to use subfolders with time lapse then I suggest using the lapse sequence number %t as the subfolder path.

It might be possible in the future to change this so the lapse subfolder path is locked for a single time lapse sequence but this is a bit complicated because the names of the images are created dynamically using the naming formula.

btidey
Posts: 1615
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Thu Nov 30, 2017 9:50 pm

ruder wrote:
Thu Nov 30, 2017 5:18 pm
btidey wrote:
Wed Nov 29, 2017 10:12 pm
ruder wrote:
Wed Nov 29, 2017 8:17 am
hello everyone, I want to make custom webpage but could not edit index.php file, plz guide me how to edit that webpage, thnx.
-imtiyaz
To physically change the index.php you need to make any changes to the run time one that gets installed e.g. /var/www/html/index.php not the one that is in the installer directory (that one is just copied during the installation process).

It can be edited with a standard text editor like nano on the raspberry. I normally make changes to the file on a PC and then copy it across to my test Pi using winscp and putty.

If you mean how do you change it for some specific functionality or look that you want to achieve then please say what you are trying to do.
Actually i want to remove some buttons like, timelapse ,motion detection, edit motion setting and edit schedual setting. but could not find the exact file where the require the changes.

btidey....thanks for reply :)
index.php defines the user interface for the main page with those buttons. They are defined around line 295 - 315.

However, there is already a facility to hide some of the buttons depending on logged in user name. The details on how to use this is in the wiki and works when you define different users. There are 3 types of level, min ('0') which is just view only, max ('6') which shows all buttons, and medium ('3') which shows just capture buttons which sounds similar to what you want.
medium.jpg
medium.jpg (8.24 KiB) Viewed 4187 times
If you want say medium even without logging in a user then you could change the config.php to return medium as the default. E.g. change around line 279 to be

Code: Select all

			return USERLEVEL_MEDIUM;

Note that this means you won't be able to change the camera settings etc without changing the file again.

CharlyDelta
Posts: 119
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

Re: RPi Cam Web Interface

Fri Dec 01, 2017 9:54 pm

btidey wrote:
Wed Nov 29, 2017 10:01 pm
CharlyDelta wrote:
Wed Nov 29, 2017 3:14 pm
btidey wrote:
Tue Nov 28, 2017 5:00 pm
User buttons

I have added a facility to the main web page to add up to 6 user buttons
The file exist at the right place but I can't get the two extra buttons.

Code: Select all

#User buttons definitions
#maximum of six buttons
#buttonname, macro
button1,button1.sh
button2,button2.sh

Thanks for your help.
Hmm. Looks like the index.php file with userbuttons code didn't get uploaded to git. Not sure how that happened as the other files that were changed went up OK.

Try it now.

Sorry for that.



Ok.. I got the two buttons now... named IR and Blanches in userbuttons (Bright PI leds https://www.pi-supply.com/product/brigh ... pberry-pi/)

Code: Select all

#User buttons definitions
#maximum of six buttons
#buttonname, macro
IR,IR.sh
Blanches,Blanches.sh
 
Created two .sh files=Blanches.sh IR.sh in macros directory

For example, here is what looks like the Blanches.sh file:

Code: Select all

#!/bin/bash
sudo i2cset -y 1 0x70 0x00 0x5a
Unfortunately, no light comes on. Did I forget something ??

btidey
Posts: 1615
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Fri Dec 01, 2017 10:26 pm

CharlyDelta wrote:
Fri Dec 01, 2017 9:54 pm
Ok.. I got the two buttons now... named IR and Blanches in userbuttons (Bright PI leds https://www.pi-supply.com/product/brigh ... pberry-pi/)

Code: Select all

#User buttons definitions
#maximum of six buttons
#buttonname, macro
IR,IR.sh
Blanches,Blanches.sh
 
Created two .sh files=Blanches.sh IR.sh in macros directory

For example, here is what looks like the Blanches.sh file:

Code: Select all

#!/bin/bash
sudo i2cset -y 1 0x70 0x00 0x5a
Unfortunately, no light comes on. Did I forget something ??
macro files are executed by a process running as user www-data.

First you need to ensure the .sh files are owned by user www-data e.g

Code: Select all

sudo chown www-data:www-data /var/www/html/macros/IR.sh
Then they need execution rights e.g.

Code: Select all

sudo chmod 744 /var/www/html/macros/IR.sh
Now the macro files should execute but the commands in the macro still operate under the permissions of user www-data. www-data is not a member of sudo group so you can't elevate privileges by using sudo.

You can do various things here to perform the operations you want. For example, if your commands need to perform gpio operations then you can add user www-data to the gpio group

Code: Select all

sudo adduser www-data gpio
or

Code: Select all

sudo adduser www-data i2c
to add to the i2c group

You can also give www-data privileges to execute a specific command by editing the /etc/sudoers.d/RPI_Cam_Web_Interface file. This can allow sudo privileges to a user to perform specific operations.

Note the reason why macros operate this way is to deliberately avoid giving excess privileges to operations initiated via the web and avoid potential exploits. For that reason it is not a good idea to just add www-data to the sudo group.

ruder
Posts: 11
Joined: Sat Nov 18, 2017 3:48 pm

Re: RPi Cam Web Interface

Sat Dec 02, 2017 9:32 am

btidey wrote:
Thu Nov 30, 2017 9:50 pm
ruder wrote:
Thu Nov 30, 2017 5:18 pm
btidey wrote:
Wed Nov 29, 2017 10:12 pm


To physically change the index.php you need to make any changes to the run time one that gets installed e.g. /var/www/html/index.php not the one that is in the installer directory (that one is just copied during the installation process).

It can be edited with a standard text editor like nano on the raspberry. I normally make changes to the file on a PC and then copy it across to my test Pi using winscp and putty.

If you mean how do you change it for some specific functionality or look that you want to achieve then please say what you are trying to do.
Actually i want to remove some buttons like, timelapse ,motion detection, edit motion setting and edit schedual setting. but could not find the exact file where the require the changes.

btidey....thanks for reply :)
index.php defines the user interface for the main page with those buttons. They are defined around line 295 - 315.

However, there is already a facility to hide some of the buttons depending on logged in user name. The details on how to use this is in the wiki and works when you define different users. There are 3 types of level, min ('0') which is just view only, max ('6') which shows all buttons, and medium ('3') which shows just capture buttons which sounds similar to what you want.
medium.jpg

If you want say medium even without logging in a user then you could change the config.php to return medium as the default. E.g. change around line 279 to be

Code: Select all

			return USERLEVEL_MEDIUM;

Note that this means you won't be able to change the camera settings etc without changing the file again.

Done...!! thanks :)

ruder
Posts: 11
Joined: Sat Nov 18, 2017 3:48 pm

Re: RPi Cam Web Interface

Sun Dec 03, 2017 1:02 pm

can we setup hotspot queue? like each new device/user can use my local webpage for 5 minutes then disconnects. and at a time only one device can use webpage. Meanwhile, i want to create device/user queue to use webpage.

btidey
Posts: 1615
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Sun Dec 03, 2017 3:01 pm

ruder wrote:
Sun Dec 03, 2017 1:02 pm
can we setup hotspot queue? like each new device/user can use my local webpage for 5 minutes then disconnects. and at a time only one device can use webpage. Meanwhile, i want to create device/user queue to use webpage.
The underlying processes are not really aware of how many clients are trying to access the system at the moment. This is more under control of the web server configuration.

Apache does have config parameters to limit the number of connections but defaults to a fairly large number.

I can see 3 possible approaches here.

1) Change Apache config to lower numbers.

2) Use iptables to restrict access to one ip at a time (see https://www.cyberciti.biz/faq/iptables- ... its-howto/)

3) Put extra user logic into index.php so that it tracks user ip and returns a waiting time response to further requests from a different ip. This would also have to have some sort of timeout mechanism to deal with client just stopping requests as otherwise it could get stuck. There is a similar mechanism already used to provide the autocamera interval which allows turning the camera off when there are no more clients attached.

CharlyDelta
Posts: 119
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

Re: RPi Cam Web Interface

Mon Dec 04, 2017 2:21 pm

btidey wrote:
Fri Dec 01, 2017 10:26 pm
CharlyDelta wrote:
Fri Dec 01, 2017 9:54 pm
Ok.. I got the two buttons now... named IR and Blanches in userbuttons (Bright PI leds https://www.pi-supply.com/product/brigh ... pberry-pi/)

Code: Select all

#User buttons definitions
#maximum of six buttons
#buttonname, macro
IR,IR.sh
Blanches,Blanches.sh
 
Created two .sh files=Blanches.sh IR.sh in macros directory

For example, here is what looks like the Blanches.sh file:

Code: Select all

#!/bin/bash
sudo i2cset -y 1 0x70 0x00 0x5a
Unfortunately, no light comes on. Did I forget something ??
macro files are executed by a process running as user www-data.

First you need to ensure the .sh files are owned by user www-data e.g

Code: Select all

sudo chown www-data:www-data /var/www/html/macros/IR.sh
Then they need execution rights e.g.

Code: Select all

sudo chmod 744 /var/www/html/macros/IR.sh
Now the macro files should execute but the commands in the macro still operate under the permissions of user www-data. www-data is not a member of sudo group so you can't elevate privileges by using sudo.

You can do various things here to perform the operations you want. For example, if your commands need to perform gpio operations then you can add user www-data to the gpio group

Code: Select all

sudo adduser www-data gpio
or

Code: Select all

sudo adduser www-data i2c
to add to the i2c group

You can also give www-data privileges to execute a specific command by editing the /etc/sudoers.d/RPI_Cam_Web_Interface file. This can allow sudo privileges to a user to perform specific operations.

Note the reason why macros operate this way is to deliberately avoid giving excess privileges to operations initiated via the web and avoid potential exploits. For that reason it is not a good idea to just add www-data to the sudo group.


No success at all

Here is the RPI_Cam_Web_Interface file in sudoers.d :

Code: Select all

# allow 'shutdown' command via web server
www-data ALL=/sbin/shutdown
www-data ALL=NOPASSWD: /sbin/shutdown
www-date ALL=/var/www/html/macros/Blanches.sh  
All rights and ownership are given as you advised.

Thanks for your help

btidey
Posts: 1615
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Mon Dec 04, 2017 6:28 pm

CharlyDelta wrote:
Mon Dec 04, 2017 2:21 pm

No success at all

Here is the RPI_Cam_Web_Interface file in sudoers.d :

Code: Select all

# allow 'shutdown' command via web server
www-data ALL=/sbin/shutdown
www-data ALL=NOPASSWD: /sbin/shutdown
www-date ALL=/var/www/html/macros/Blanches.sh  
All rights and ownership are given as you advised.

Thanks for your help
I'm not sure adding Blanches.sh to sudoers like that will help. Blanches.sh is a script that gets executed by bash so the checking of permissions is probably being done at the bash level.

One thing is it is important to use the NOPASSWD tag. sudo by default asks for a password and this won't work in the context of executing a script.

FIrst you need to remove the sudo command from the scripts. That is always going to fail as the sudo command will fail to execute under www-data if www-data is not in the sudo group.(see later)

Did you add www-data to the i2c group and take the sudo out of Blanches.sh ?

Another thing to try would be to put i2cset command in the sudoers. Again sudo out of the Blanches.sh file

As a temporary test you could add www-data to the sudo group to make sure everything else is OK. I don't recommend leaving it that way but at least it helps show where the problem is.

spiderdab
Posts: 1
Joined: Tue Dec 12, 2017 2:58 pm

Re: RPi Cam Web Interface

Tue Dec 12, 2017 3:07 pm

btidey wrote:
Sat Nov 11, 2017 11:15 pm
tk1 wrote:
Sat Nov 11, 2017 9:48 pm

I've also been trying to get the multiview to work, but haven't had success yet. One difference is that I do NOT have usernames and passwords yet. I just get the broken icon on the multiview page for each picam. My json file looks similar to the one above. Except for the usernames and passwords, I have the same results as conoral11.

Could it be something else?

Thanks,
tk1
I would build it up bit by bit so one can see where it is going wrong.

First use a multiview.json file like

Code: Select all

{"hosts":["http://192.168.0.02/"],"delays":[40000]}
where the host is just the local ip path through to the first local camera where the multiview.json is defined.

The path should include any subfolder if that has been used (e.g. http://192.168.0.02/html/

The multiview.json file should be owned by www-data and have rw permissions. (Use chown and chmod if required).

Browsing to the multiview.html file should now show one plain live preview screen.

If OK then add further hosts to the multiview.json file
Hi, I have 2 working raspberries, with their cameras working. i.e. if I go to 192.168.1.104/html/min.php I see the stream. the other is on 105 final.
I'm trying to setup the multiview, so from an external pc I navigate to 192.168.1.105/html/multiview.html and I see a blank page. I know the page is correct, because I see the correct title modified by me inside multiview.html.
modifying multiview.json as you suggest i've no result, also tryied first with one then with 2 or 4 ip but nothing changes.
I've tryied with:
{"hosts":["http://192.168.1.105/"],"delays":[40000]}
{"hosts":["http://192.168.1.105/html"],"delays":[40000]}
{"hosts":["http://192.168.1.105/html/min.php"],"delays":[40000]}
none of them works. still a blank page.
Can you help me please?

btidey
Posts: 1615
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Tue Dec 12, 2017 9:49 pm

spiderdab wrote:
Tue Dec 12, 2017 3:07 pm

Hi, I have 2 working raspberries, with their cameras working. i.e. if I go to 192.168.1.104/html/min.php I see the stream. the other is on 105 final.
I'm trying to setup the multiview, so from an external pc I navigate to 192.168.1.105/html/multiview.html and I see a blank page. I know the page is correct, because I see the correct title modified by me inside multiview.html.
modifying multiview.json as you suggest i've no result, also tryied first with one then with 2 or 4 ip but nothing changes.
I've tryied with:
{"hosts":["http://192.168.1.105/"],"delays":[40000]}
{"hosts":["http://192.168.1.105/html"],"delays":[40000]}
{"hosts":["http://192.168.1.105/html/min.php"],"delays":[40000]}
none of them works. still a blank page.
Can you help me please?
You need the trailing / in the definitions in multiview.json so try
{"hosts":["http://192.168.1.105/html/"],"delays":[40000]}

ohiojoe
Posts: 13
Joined: Wed Aug 20, 2014 6:48 am
Location: Benicia, CA

Re: RPi Cam Web Interface

Wed Dec 20, 2017 1:45 am

Question 1: Can end_box.sh be used to sent more than one command? I'm trying to upload mp4 files and then send email notice to myself.

Script:
#!/bin/bash
sudo python /home/pi/email_webcam.py
sudo /home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /var/www/media/$1 RPi-MS-Camera-PIR/$1

#end script.

Running the script from the command line works, both are sent. Running only one of the two works from end_box.sh
Permissions: -rwxr-xr-x 1 www-data www-data 3350 Dec 19 20:11 email_webcam.py
-rwxr-xr-x 1 www-data www-data 230 Dec 20 11:17 end_box.sh
Do I have to use sudo to run the scripts? Is that redundant?

Question 2:
If it is possible to run both, can I also add a third to delete the mp4 after it is uploaded?

Thanks for reading

btidey
Posts: 1615
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Wed Dec 20, 2017 8:51 am

ohiojoe wrote:
Wed Dec 20, 2017 1:45 am
Question 1: Can end_box.sh be used to sent more than one command? I'm trying to upload mp4 files and then send email notice to myself.

Script:
#!/bin/bash
sudo python /home/pi/email_webcam.py
sudo /home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /var/www/media/$1 RPi-MS-Camera-PIR/$1

#end script.

Running the script from the command line works, both are sent. Running only one of the two works from end_box.sh
Permissions: -rwxr-xr-x 1 www-data www-data 3350 Dec 19 20:11 email_webcam.py
-rwxr-xr-x 1 www-data www-data 230 Dec 20 11:17 end_box.sh
Do I have to use sudo to run the scripts? Is that redundant?

Question 2:
If it is possible to run both, can I also add a third to delete the mp4 after it is uploaded?

Thanks for reading
There is no limit to the number of things that can be done within the one script.

However, end_box.sh is run under the user www-data and therefore inherits the permissions applicable to that owner. This is deliberate to ensure that the security of such operations is under your control.

In particular the www-data user does not have sudo permissions so operations inside the script that try to use this will fail as will any other commands that user www-data can't do natively.

There are two basic methods for allowing user www-data to have controlled extra permissions to perform any operations that need them.

1. Add www-data user to a group that naturally has those permissions (e.g. adding to group gpio if access to gpio operations are needed).

2. Give permission to www-data for a specific command or set of commands via the sudoers facility. There is already a file /etc/sudoers.d/RPI_Cam_Web_Interface which does this to allow user www-data to perform a shutdown which requires extra permissions. One needs to make changes carefully (or have a back up SD image) as it is possible tostop the system from booting if not correct.

An alternative is to add user www-data to the sudo group to get all permissions but I wouldn't advise doing this unless you are sure certain that it couldn't be misused.

Albertowue
Posts: 6
Joined: Wed Sep 13, 2017 3:46 pm

Re: RPi Cam Web Interface

Wed Dec 20, 2017 10:49 am

I would like to use avconv to convert timelapse to video. On the webinterface In the string "Convert using:" which command should I write? :roll:

On the ssh pront i use "avconv -r 20 -i inputfile%04d.jpg -r 20 -vcodec libx264 outputfile.mp4" and it works but in the webinterface I do not know how to write the -i parameter :(

PS:
I know that using the gst-launch method is faster but I use stretch lite and I would like to avoid installing the big package gstreamer1.0 ;)

btidey
Posts: 1615
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Wed Dec 20, 2017 10:53 pm

Albertowue wrote:
Wed Dec 20, 2017 10:49 am
I would like to use avconv to convert timelapse to video. On the webinterface In the string "Convert using:" which command should I write? :roll:

On the ssh pront i use "avconv -r 20 -i inputfile%04d.jpg -r 20 -vcodec libx264 outputfile.mp4" and it works but in the webinterface I do not know how to write the -i parameter :(

PS:
I know that using the gst-launch method is faster but I use stretch lite and I would like to avoid installing the big package gstreamer1.0 ;)
We did use avconv back in early 2016 but it was not good particularly on larger collections of images to convert. gst uses the GPU and so exploits the parallel high speed processing and so is not just a bit faster but by a huge margin.

I believe the command used was

avconv -r 5 -i i_%05d.jpg -r 5 -vcodec libx264 -crf 20 -g 5

The routine that actually runs the conversion script gathers all the files into a temp folder and it replaces the i_%05d in the command with the path to where to process the files.

btidey
Posts: 1615
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Wed Dec 20, 2017 10:55 pm

btidey wrote:
Wed Dec 20, 2017 10:53 pm
Albertowue wrote:
Wed Dec 20, 2017 10:49 am
I would like to use avconv to convert timelapse to video. On the webinterface In the string "Convert using:" which command should I write? :roll:

On the ssh pront i use "avconv -r 20 -i inputfile%04d.jpg -r 20 -vcodec libx264 outputfile.mp4" and it works but in the webinterface I do not know how to write the -i parameter :(

PS:
I know that using the gst-launch method is faster but I use stretch lite and I would like to avoid installing the big package gstreamer1.0 ;)
We did use avconv back in early 2016 but it was not good particularly on larger collections of images to convert. gst uses the GPU and so exploits the parallel high speed processing and so is not just a bit faster but by a huge margin.

I believe the command used was

avconv -r 5 -i i_%05d.jpg -r 5 -vcodec libx264 -crf 20 -g 5

The routine that actually runs the conversion script gathers all the files into a temp folder and it replaces the i_%05d in the command with the path to where to process the files and adds on the appropriate output name.

ohiojoe
Posts: 13
Joined: Wed Aug 20, 2014 6:48 am
Location: Benicia, CA

Re: RPi Cam Web Interface

Thu Dec 21, 2017 6:39 am

btidey wrote:
Wed Dec 20, 2017 8:51 am
ohiojoe wrote:
Wed Dec 20, 2017 1:45 am
Question 1: Can end_box.sh be used to sent more than one command? I'm trying to upload mp4 files and then send email notice to myself.

Script:
#!/bin/bash
sudo python /home/pi/email_webcam.py
sudo /home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /var/www/media/$1 RPi-MS-Camera-PIR/$1

#end script.

Running the script from the command line works, both are sent. Running only one of the two works from end_box.sh
Permissions: -rwxr-xr-x 1 www-data www-data 3350 Dec 19 20:11 email_webcam.py
-rwxr-xr-x 1 www-data www-data 230 Dec 20 11:17 end_box.sh
Do I have to use sudo to run the scripts? Is that redundant?

Question 2:
If it is possible to run both, can I also add a third to delete the mp4 after it is uploaded?

Thanks for reading
There is no limit to the number of things that can be done within the one script.

However, end_box.sh is run under the user www-data and therefore inherits the permissions applicable to that owner. This is deliberate to ensure that the security of such operations is under your control.

In particular the www-data user does not have sudo permissions so operations inside the script that try to use this will fail as will any other commands that user www-data can't do natively.

There are two basic methods for allowing user www-data to have controlled extra permissions to perform any operations that need them.

1. Add www-data user to a group that naturally has those permissions (e.g. adding to group gpio if access to gpio operations are needed).

2. Give permission to www-data for a specific command or set of commands via the sudoers facility. There is already a file /etc/sudoers.d/RPI_Cam_Web_Interface which does this to allow user www-data to perform a shutdown which requires extra permissions. One needs to make changes carefully (or have a back up SD image) as it is possible tostop the system from booting if not correct.

An alternative is to add user www-data to the sudo group to get all permissions but I wouldn't advise doing this unless you are sure certain that it couldn't be misused.
Thanks for your assistance. I think I have permissions set correctly. What would cause the end_box.sh to work when ran from the command line /var/www/marcos : ./end_box.sh
But it is not executed from within the RPi-cam-web-internet?

The email_webcam.py works fine, but no output from /home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /var/www/media/$1 RPi-MS-Camera-PIR/$1
I generate motion, files are recorded, email is sent, but no upload to dropbox.

dropbox_uploader.sh works from the command line.

I did remove the SUDO from the end_box.sh

What am I missing?

btidey
Posts: 1615
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Thu Dec 21, 2017 10:14 am

ohiojoe wrote:
Thu Dec 21, 2017 6:39 am


Thanks for your assistance. I think I have permissions set correctly. What would cause the end_box.sh to work when ran from the command line /var/www/marcos : ./end_box.sh
But it is not executed from within the RPi-cam-web-internet?

The email_webcam.py works fine, but no output from /home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /var/www/media/$1 RPi-MS-Camera-PIR/$1
I generate motion, files are recorded, email is sent, but no upload to dropbox.

dropbox_uploader.sh works from the command line.

I did remove the SUDO from the end_box.sh

What am I missing?
1. When you run end_box.sh from command line does it do both email and dropbox?

2. Are you saying the end_box.sh doesn't run at all from the RPi environment, or it only does the email? The easiest way to prove the macro is triggered and runs ok is to comment out your stuff and put a simple echo to file statement in as in the test.sh example.

This does still sound like a permissions issue to me. The dropbox script for example uses curl and I suspect user www-data does not have permission to execute that unless given the extra permission.

ohiojoe
Posts: 13
Joined: Wed Aug 20, 2014 6:48 am
Location: Benicia, CA

Re: RPi Cam Web Interface

Thu Dec 21, 2017 11:28 am

btidey wrote:
Thu Dec 21, 2017 10:14 am
ohiojoe wrote:
Thu Dec 21, 2017 6:39 am


Thanks for your assistance. I think I have permissions set correctly. What would cause the end_box.sh to work when ran from the command line /var/www/marcos : ./end_box.sh
But it is not executed from within the RPi-cam-web-internet?

The email_webcam.py works fine, but no output from /home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /var/www/media/$1 RPi-MS-Camera-PIR/$1
I generate motion, files are recorded, email is sent, but no upload to dropbox.

dropbox_uploader.sh works from the command line.

I did remove the SUDO from the end_box.sh

What am I missing?
1. When you run end_box.sh from command line does it do both email and dropbox?

2. Are you saying the end_box.sh doesn't run at all from the RPi environment, or it only does the email? The easiest way to prove the macro is triggered and runs ok is to comment out your stuff and put a simple echo to file statement in as in the test.sh example.

This does still sound like a permissions issue to me. The dropbox script for example uses curl and I suspect user www-data does not have permission to execute that unless given the extra permission.
1.
When I generate motion, files are recorded, email is sent, but no upload to dropbox.
If I execute ./end_box.sh from the command line, the email fails with this error: File "/home/pi/./email_webcam.py", line 26, in <module>
subject = sys.argv[1]
IndexError: list index out of range
Is this because the email_webcam.py was previously successful? The $1 sys.argv[1] is not available?

The dropbox_uploader.sh then works as expected.
Uploading "/var/www/media/vi_0029_20171221_183912.mp4" to "/media/vi_0029_20171221_183912.mp4"...
Done.

2.
From the RPi environment, the email part works as expected. But no upload.
My end_box.sh code:

Code: Select all

#!/bin/bash
python /home/pi/./email_webcam.py $1
/home/pi/Dropbox-Uploader/dropbox_uploader.sh -h -p upload /var/www/media/$1  /$1 
 

Code: Select all

#!/bin/bash
python /home/pi/./email_webcam.py $1
#/home/pi/Dropbox-Uploader/dropbox_uploader.sh -h -p upload /var/www/media/$1  /$1
date >/var/www/uploadtest.txt 
output from end_box.sh
/var/www $ cat uploadtest.txt
Thu Dec 21 19:16:34 +08 2017

So it looks like the end_box.sh macro is working...just not the dropbox_uploader.sh code. Does that (dropbox_uploader.sh) have to have owner in the www-data group also?

Albertowue
Posts: 6
Joined: Wed Sep 13, 2017 3:46 pm

Re: RPi Cam Web Interface

Thu Dec 21, 2017 1:23 pm

The old avconv method does not work, so I installed the gstreamer1.0 package, but even so it does not work :(

Code: Select all

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gstreamer1.0
wait wait wait reboot
In webinterface "Convert Using:"

Code: Select all

gst-launch-1.0 -v multifilesrc location=i_%05d.jpg caps=\"image/jpeg,framerate=\(fraction\)30/1\" ! jpegdec ! queue ! videoscale ! video/x-raw ! queue ! omxh264enc target-bitrate=15000000 control-rate=variable ! video/x-h264, profile=high ! h264parse ! mp4mux ! filesink location=

Code: Select all

Image res: 1296*972 (or 1920*1080 or 1280*720)
After the convertion I have the file mp4, but don't work

In the log:

Code: Select all

[2017/12/21 14:09:20] start lapse convert:(gst-launch-1.0 -v multifilesrc location=/var/www/html/media/t0005/i_%05d.jpg caps=\"image/jpeg,framerate=\(fraction\)30/1\" ! jpegdec ! queue ! videoscale ! video/x-raw ! queue ! omxh264enc target-bitrate=15000000 control-rate=variable ! video/x-h264, profile=high ! h264parse ! mp4mux ! filesink location=/var/www/html/media/tl_0005_0001_20171221_140819.mp4 ; rm -rf /var/www/html/media/t0005;) >/dev/null 2>&1 &
[2017/12/21 14:09:20] Convert finished

btidey
Posts: 1615
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Thu Dec 21, 2017 4:58 pm

Albertowue wrote:
Thu Dec 21, 2017 1:23 pm
The old avconv method does not work, so I installed the gstreamer1.0 package, but even so it does not work :(

Code: Select all

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gstreamer1.0
wait wait wait reboot
In webinterface "Convert Using:"

Code: Select all

gst-launch-1.0 -v multifilesrc location=i_%05d.jpg caps=\"image/jpeg,framerate=\(fraction\)30/1\" ! jpegdec ! queue ! videoscale ! video/x-raw ! queue ! omxh264enc target-bitrate=15000000 control-rate=variable ! video/x-h264, profile=high ! h264parse ! mp4mux ! filesink location=

Code: Select all

Image res: 1296*972 (or 1920*1080 or 1280*720)
After the convertion I have the file mp4, but don't work

In the log:

Code: Select all

[2017/12/21 14:09:20] start lapse convert:(gst-launch-1.0 -v multifilesrc location=/var/www/html/media/t0005/i_%05d.jpg caps=\"image/jpeg,framerate=\(fraction\)30/1\" ! jpegdec ! queue ! videoscale ! video/x-raw ! queue ! omxh264enc target-bitrate=15000000 control-rate=variable ! video/x-h264, profile=high ! h264parse ! mp4mux ! filesink location=/var/www/html/media/tl_0005_0001_20171221_140819.mp4 ; rm -rf /var/www/html/media/t0005;) >/dev/null 2>&1 &
[2017/12/21 14:09:20] Convert finished
gstreamer conversion does work with full installs.

It can be tricky to install gstreamer onto Lite as there are so many dependencies. I did make it work at one time with an older Jessie but haven't tried putting it onto Lite recently.

This is why I recommend doing the full install and then removing all the packages ( as mentioned in Wiki). This gets back a lot of disk space closer to a Lite installation.

btidey
Posts: 1615
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Thu Dec 21, 2017 5:10 pm

ohiojoe wrote:
Thu Dec 21, 2017 11:28 am


1.
When I generate motion, files are recorded, email is sent, but no upload to dropbox.
If I execute ./end_box.sh from the command line, the email fails with this error: File "/home/pi/./email_webcam.py", line 26, in <module>
subject = sys.argv[1]
IndexError: list index out of range
Is this because the email_webcam.py was previously successful? The $1 sys.argv[1] is not available?

The dropbox_uploader.sh then works as expected.
Uploading "/var/www/media/vi_0029_20171221_183912.mp4" to "/media/vi_0029_20171221_183912.mp4"...
Done.

2.
From the RPi environment, the email part works as expected. But no upload.
My end_box.sh code:

Code: Select all

#!/bin/bash
python /home/pi/./email_webcam.py $1
/home/pi/Dropbox-Uploader/dropbox_uploader.sh -h -p upload /var/www/media/$1  /$1 
 

Code: Select all

#!/bin/bash
python /home/pi/./email_webcam.py $1
#/home/pi/Dropbox-Uploader/dropbox_uploader.sh -h -p upload /var/www/media/$1  /$1
date >/var/www/uploadtest.txt 
output from end_box.sh
/var/www $ cat uploadtest.txt
Thu Dec 21 19:16:34 +08 2017

So it looks like the end_box.sh macro is working...just not the dropbox_uploader.sh code. Does that (dropbox_uploader.sh) have to have owner in the www-data group also?
Yes. www-data probably doesn't have permission to either execute the dropbox script or something within it (maybe curl). First check the execution permissions of the dropbox_uploader.sh and set it to execute by everybody.

One can also run a command as a different user from the command line using sudo

sudo -u www-data command

Albertowue
Posts: 6
Joined: Wed Sep 13, 2017 3:46 pm

Re: RPi Cam Web Interface

Thu Dec 21, 2017 7:25 pm

btidey wrote:
Thu Dec 21, 2017 4:58 pm
gstreamer conversion does work with full installs.

It can be tricky to install gstreamer onto Lite as there are so many dependencies. I did make it work at one time with an older Jessie but haven't tried putting it onto Lite recently.

This is why I recommend doing the full install and then removing all the packages ( as mentioned in Wiki). This gets back a lot of disk space closer to a Lite installation.
Ok, let's start again :)

Full install of Stratch, then removing all the packages (following the wiki)
Install RPi Cam Control and set a compatible resolution for the Image (1920*1080)

I recorded a short timelapse but it does not work :(

In the log it is all ok :

Code: Select all

[2017/12/21 20:12:09] start lapse convert:(gst-launch-1.0 -v multifilesrc location=/var/www/html/media/t0003/i_%05d.jpg caps=\"image/jpeg,framerate=\(fraction\)30/1\" ! jpegdec ! queue ! videoscale ! video/x-raw ! queue ! omxh264enc target-bitrate=15000000 control-rate=variable ! video/x-h264, profile=high ! h264parse ! mp4mux ! filesink location=/var/www/html/media/tl_0003_0001_20171221_201122.mp4 ; rm -rf /var/www/html/media/t0003;) >/dev/null 2>&1 &
[2017/12/21 20:12:09] Convert finished
but you can not see the video in the "Download videos and image" section, i see only a single frame.

btidey
Posts: 1615
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Thu Dec 21, 2017 8:18 pm

Albertowue wrote:
Thu Dec 21, 2017 7:25 pm

Ok, let's start again :)

Full install of Stratch, then removing all the packages (following the wiki)
Install RPi Cam Control and set a compatible resolution for the Image (1920*1080)

I recorded a short timelapse but it does not work :(

In the log it is all ok :

Code: Select all

[2017/12/21 20:12:09] start lapse convert:(gst-launch-1.0 -v multifilesrc location=/var/www/html/media/t0003/i_%05d.jpg caps=\"image/jpeg,framerate=\(fraction\)30/1\" ! jpegdec ! queue ! videoscale ! video/x-raw ! queue ! omxh264enc target-bitrate=15000000 control-rate=variable ! video/x-h264, profile=high ! h264parse ! mp4mux ! filesink location=/var/www/html/media/tl_0003_0001_20171221_201122.mp4 ; rm -rf /var/www/html/media/t0003;) >/dev/null 2>&1 &
[2017/12/21 20:12:09] Convert finished
but you can not see the video in the "Download videos and image" section, i see only a single frame.
Looks like there may be an issue with gstreamer and stretch. It certainly works with jessie. A quick test with stretch here did not work, and there are some reports of gstreamer problems with stretch.

Under investigation.

ohiojoe
Posts: 13
Joined: Wed Aug 20, 2014 6:48 am
Location: Benicia, CA

Re: RPi Cam Web Interface

Thu Dec 21, 2017 9:09 pm

btidey wrote:
Thu Dec 21, 2017 5:10 pm
ohiojoe wrote:
Thu Dec 21, 2017 11:28 am


1.
When I generate motion, files are recorded, email is sent, but no upload to dropbox.
If I execute ./end_box.sh from the command line, the email fails with this error: File "/home/pi/./email_webcam.py", line 26, in <module>
subject = sys.argv[1]
IndexError: list index out of range
Is this because the email_webcam.py was previously successful? The $1 sys.argv[1] is not available?

The dropbox_uploader.sh then works as expected.
Uploading "/var/www/media/vi_0029_20171221_183912.mp4" to "/media/vi_0029_20171221_183912.mp4"...
Done.

2.
From the RPi environment, the email part works as expected. But no upload.
My end_box.sh code:

Code: Select all

#!/bin/bash
python /home/pi/./email_webcam.py $1
/home/pi/Dropbox-Uploader/dropbox_uploader.sh -h -p upload /var/www/media/$1  /$1 
 

Code: Select all

#!/bin/bash
python /home/pi/./email_webcam.py $1
#/home/pi/Dropbox-Uploader/dropbox_uploader.sh -h -p upload /var/www/media/$1  /$1
date >/var/www/uploadtest.txt 
output from end_box.sh
/var/www $ cat uploadtest.txt
Thu Dec 21 19:16:34 +08 2017
So it looks like the end_box.sh macro is working...just not the dropbox_uploader.sh code. Does that (dropbox_uploader.sh) have to have owner in the www-data group also?
Yes. www-data probably doesn't have permission to either execute the dropbox script or something within it (maybe curl). First check the execution permissions of the dropbox_uploader.sh and set it to execute by everybody.
  • [email protected]_Cam:~/Dropbox-Uploader $ ls -la
    total 140
    drwxr-xr-x 3 pi pi 4096 Dec 21 09:18 .
    drwxr-xr-x 8 pi pi 4096 Dec 21 15:31 ..
    -rw-r--r-- 1 pi pi 8348 Nov 28 14:02 CHANGELOG.md
    -rw-r--r-- 1 pi pi 286 Nov 28 14:02 Dockerfile
    -rwxr-xr-x 1 www-data www-data 47825 Nov 28 14:02 dropbox_uploader.sh
One can also run a command as a different user from the command line using sudo

sudo -u www-data command

Code: Select all

[email protected]_Cam:/var/www/macros $ sudo -u www-data ./end_box.sh
Traceback (most recent call last):
  File "/home/pi/./email_webcam.py", line 26, in <module>
    subject =  sys.argv[1]
IndexError: list index out of range
 > Creating Directory "/media"... FAILED
 > Uploading "/var/www/media/vi_0004_20171221_220726.mp4" to "/media/vi_0004_20171221_220726.mp4"... 
######################################################################## 100.0%
DONE
So it does execute with the sudo -u www-data command, but not in the RPi environment. I did change permissions to dropbox_uploader.sh to -rwxr-xr-x 1 www-data www-data 47825 Nov 28 14:02 dropbox_uploader.sh
But still doesn't execute. ;(

I also added www-data to the 'sudo' group, but no change. ( I removed 'sudo' from www-data before running sudo -u www-data ./end_box.sh)

sudo deluser www-data sudo
Removing user `www-data' from group `sudo' ...
Done.
[email protected]_Cam:~/Dropbox-Uploader $ groups www-data
www-data : www-data video pi
Yes. www-data probably doesn't have permission to either execute the dropbox script or something within it (maybe curl).
I don't know anything about curl to change any permissions with it.

Thanks for your generous time and support!

Return to “Camera board”