Jump to content

[Plugin] CA User Scripts


Recommended Posts

On 4/17/2024 at 12:13 AM, Amane said:

Hi sasbro

 

Cron jobs do not run with the full user environment, which means some environment variables needed by docker or your script might not be set correctly. This can affect the execution of commands that rely on these variables.

 

Add the line on top of your script:

PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

 

I hope it helps.

If not, test whether you can copy the script into the container and execute it with the scheduled user script - just for test

 

Grüsse ;)

Hey as I told you it worked. At least I thought so. Now after many days I realized again it did not work. I changed the schedule now once to run it in a few minutes also opened the script and closed it again without changes. Now it worked again. I guess unfortunately again just once. What the hell is causing this behavior? I added the PATH line. I feels like some kind of cache or something.

Link to comment
11 hours ago, sasbro97 said:

Hey as I told you it worked. At least I thought so. Now after many days I realized again it did not work. I changed the schedule now once to run it in a few minutes also opened the script and closed it again without changes. Now it worked again. I guess unfortunately again just once. What the hell is causing this behavior? I added the PATH line. I feels like some kind of cache or something.

 

Ok... I would extend the logging so that you create a log file in the "/config" folder, i.e. the one that is mapped in appdata.

 

#!/bin/bash
#description=This script updates all apps in Nextcloud.
#arrayStarted=true
#name=Nextcloud Auto-Update Apps

CONTAINER_LOGFILE="/config/auto_update_script.log"

echo "Script PATH: $(printenv PATH)"

docker exec -u www-data nextcloud echo -e "\nStart: $(date)" >> $CONTAINER_LOGFILE
docker exec -u www-data nextcloud echo -e "\nDocker PATH: $(printenv PATH)" >> $CONTAINER_LOGFILE

docker exec -u www-data nextcloud echo -e "\napp:update output:" >> $CONTAINER_LOGFILE
docker exec -u www-data nextcloud php /var/www/html/occ app:update --all >> $CONTAINER_LOGFILE 2>&1
docker_exit_status=$?

if [ $docker_exit_status -eq 0 ]; then
    curl -fsS -m 10 --retry 5 --data-raw "$m" http://unraid-server:8003/ping/1505e87d-84e2-4806-a2a0-fa214d96cb17
    echo -e "\nScript succeeded"
fi

 

On 4/16/2024 at 10:10 PM, sasbro97 said:
OK
Script succeeded

This issue is particularly interesting, as it is otherwise not logged?!

docker exec -u www-data nextcloud php /var/www/html/occ app:update --all >> $CONTAINER_LOGFILE 2>&1

 

 

Edited by Amane
Link to comment

@sasbro97 Ok i have test the PATH and i see that:

Manual Script PATH:	/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
Cron Script PATH:	.:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin

So test:

PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin"

 

That also works:

On 4/17/2024 at 3:22 PM, JoeUnraidUser said:
#!/bin/bash -l

source /root/.bash_profile

 

But check the docker PATH with the script above

 

Edited by Amane
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...