Set execution Bit on occ script after updater Script

Nextcloud version: 26.0.3
Operating system and version: Debian 11
Apache or nginx version: Apache 2.4.56
PHP version: 8.1

The issue you are facing:

After updating Nextcloud. The update script removes/ does not set the executable flag (+x) on the occ script. Since it has the shebang line, it can directly be executed.

Is this the first time you’ve seen this error?: No

Steps to replicate it:

  1. Update Nextcloud
  2. Executable Flag is missing on occ script

I did not include any config files. If there is a config flag, i missed it.

I have observed at various instances that the update script updater/updater.phar sets the execution bit, but the webupdater does not.

I’ve never seen a problem with it. If you updates via webupdater, you may probably have less to do with occ anyway. If you are more command line-affin, you will propably do your update with updater.phar anyway and get the execution bit set as a small bonus. If not set and you need it later, you can set it yourself.
In the manuals it is described everywhere to call occ as an argument of php.

I never call occ directly. For direct use on the commandline I have it as pre loaded alias / function loaded by ~/.bashrc (or rather ~/.bash_aliases which is loaded by ~/.bashrc):

NC_DIR="/var/www/nextcloud"
HT_USER="$(ls -l $NC_DIR/config/config.php 2>/dev/null | awk '{print $3}')"
alias suht='sudo -u $HT_USER'
# using the -E (or --preserve-env) option with sudo to preserve the environment variables:
alias suhtphp='suht -E /usr/bin/php'
occ() { suhtphp -f "$NC_DIR/occ" "$@"; }

The reason I put occ in a function and not in an alias is that → autocompletion ← doesn’t work on aliases.

For use in scripts or cronjobs I cal php with occ as argument.

Hey ernolf,

ok, need to test that.

I do the update via web but want to use the occ commandline tool.

But i do understand the reasoning. Even though there is no reason for not having the +x set on the script.

for autocomplete of commandline arguments your function is not working. but can be extended.

It definitely works but it is terribly slow:

Enter occ[space][tab]

and wait
(Sometimes it requires more than one hit on [tab]):

occ
Display all 289 possibilities? (y or n)

Much luck.

So, did try that, and the updater will remove the executable flag on itself :slight_smile:

maybe in the next update it can be set on both the web updater and the cli