Working with OCC commands > How to add a user directly to an external storage?

#1

Hey forum,

i have some questions concerning occ commands… I have to create many external storages with occ (later with a php script). After trying a long while i figured out that this one works to create a external storage:

sudo -u www-data php /var/www/nextcloud/occ files_external:create NAME_OF_STORAGE smb password::global -c host=192.168.100.19 -c share=SHARE_NAME -c root=ROOT_FOLDER_NAME -c domain=DOMAIN_NAME

This one creates a external storage as expected. BUT… How can i add a user to this storage WITHIN THE SAME COMMAND? I know that i can add users with “files_external:applicable --user XXXX ID_OF_STORAGE” but i have to do this in the same comman when i create it.

Background is that i have to create many external storages with a php script later and i have no idea how to get the storage id after creating to do the next step with php (adding a user).

Sorry for my bad englisch, sorry for the bad explenation… im a total beginner with all that stuff… i hope anyone understands my needs and can help.

Thanks a lot in advance,

Greetings from Germany, Mirko

0 Likes

#2

Basically occ files_external:list could help you to get IDs of external storages, this is a command to output it in a “list” format:

php occ files_external:list | awk -F'|' '{print $8"/files"$3}'| tail -n +4 | head -n -1 | awk '{gsub(/ /, "", $0); print}'

Taken from here:

0 Likes