Automating manual user actions

Hello there,

While working on upgrading Cheky to the lastest version., it appeared that the way to manage the upgrade does not work anymore (See https://github.com/YunoHost-Apps/cheky_ynh/blob/4.4.1/scripts/upgrade#L127) as there is a change in the database model.

When an upgrade is available, there is a button in the webinterface admin panel to click to run the upgrade. I tried to use wget to run the exchanges between my web browser and Cheky but it fails.

I made a post on the project forum and got a reply by the author with a hint to do it in php (here for post and wget commands (in french))

Somebody has experience or tips on this?

Hello there,

I have been able to integrate the php file provided by the author of Cheky inside Yunohost but it does not work as expected :neutral_face:

If Yunohost does the upgrade, it doesn’t work because it cannot find the command

root@yunohost:~# sudo yunohost app upgrade cheky__2 -f /var/tmp/foo/cheky_ynh/ --debug
[...]
15306 INFO Running post upgrade recipe...
15307 DEBUG + local legacy_args=m
15309 DEBUG + args_array=([m]=message=)
15311 DEBUG + declare -Ar args_array
15313 DEBUG + local message
15317 DEBUG + ynh_handle_getopts_args 'Running post upgrade recipe...'
15318 DEBUG + set +x
15320 DEBUG + echo '! Helper used in legacy mode !'
15322 DEBUG + set +x
15323 DEBUG + echo 'Running post upgrade recipe...'
15326 DEBUG + chown -R cheky__2: /var/www/cheky__2
15327 DEBUG + sudo -u cheky__2 '/usr/bin/php /var/cache/yunohost/from_file/scripts/upgrade_cheky.php /var/www/cheky__2'
15429 DEBUG + chown -R root: /var/www/cheky__2
15431 WARNING sudo: /usr/bin/php /var/cache/yunohost/from_file/scripts/upgrade_cheky.php /var/www/cheky__2 : commande introuvable
15432 INFO Upgrading SSOwat configuration...
[...]

If i launch the command manually by SSH, it works

root@yunohost:~# chown -R cheky__2: /var/www/cheky__2/
root@yunohost:~# sudo -u cheky__2 /usr/bin/php /var/tmp/pipo/upgrade_cheky.php /var/www/cheky__2
root@yunohost:~#

My guess is that there is some $PATH or other weird issue. Someone had to figure out a similar issue ?

Code

So…
First I think you should copy your script into $finalpath, so it would be at the right place to work.
Also, try without the double quotes, it probably make the entire command looks like a entire path.

Make sense and it runs now. Thanks :cowboy_hat_face: