[announce] cloud-cli 1.20 - command line script to perform file, share and user operations

A linux/unix/WSL2 bash script to perform basic file, share and user operations.

Usage: cloud-cli [options]
       --config-file file    config file (default: ~/.cloud-cli)

       --host|-H url         cloud host url https://[fqdn|ip][:port]
       --user|-U user        cloud username (for file operations)
       --pass|-P pass        cloud password (for file operations)
       --admin-user user     admin username (for user operations)
       --admin-pass pass     admin password (for user operations)
       --insecure|-I         ignore self signed SSL certs

       file operations:
       --list|-l path        list date time size name for path elements
       --search|-s text      search files for text
       --upload|-u file      upload file
       --download|-d file    download file
       --delete|-D file      delete file
       --pipe|-p file        pipe file
       --move|-m file        move file
       --copy|-c file        copy file 
       --to|-t file          move/copy destination file
       --exists|-C path      check if file or directory exists
       --create-dir dir      create directory
       --delete-dir dir      delete directory

       --local-dir|-d dir    local directory (default: /tmp)
       --local-file|-f file  local file

       share operations:
       --list-shares         list all shares
       --create-share path   create share for specified path
       --update-share id     update share for specified id
       --delete-share id     delete share for specified id
       --share-type type     share type (default: 3)
                             [0=user|1=group|3=public|6=federated]
       --share-perms type    share permissions to use on the share (default: 17)
                             [1=read|2=update|4=create|8=delete|15=r/w|16=share|31=all]
       --share-pass text     share password to protect the public share
       --share-expire text   share expire per date or in days [NNN|YYYY-MM-DD]
       --share-upload bool   share allow public upload to a public shared [0|false|1|true]
       --share-note text     share a note text
       --share-with type     share with user or group id

       user operations:
       --list-users|-L       list all users (main fields)
       --list-user user      list a user (all fields)
       --search-user user    search for a user(s)
       --create-user user    create a user
       --update-user user    update a user
       --delete-user user    delete a user
       --user-pass text      user password
       --user-name text      user display name
       --user-email text     user email
       --user-group text     user group(s)
       --user-subadmin text  user groups which user is subadmin
       --user-lang text      user language [format: iso 2 character code]
       --user-locale text    user locale [format: ab_YZ]
       --user-quota text     user quota [none|default|numGB|numMB|numKB|num]
       --user-status text    enable/disable user profile [enable|1|disable|0]

       misc helpers:
       --sort-on|-S text     sort --list|--search on a specific output field
                             [date|size|file][:[asc|desc]] (default: file:ascending)
       --yes|-y              confirm required operation
                             [--delete|--delete-dir|--delete-user]
                             [--copy-file|--move-file] if destination exists
       --csv                 output csv instead of fancy format
                             [--list|--list-shares|--list-users|--list-user]

       --quiet|-q            quiet mode
       --verbose|-v          verbose
       --help|-h             help

Config file ~/.cloud-cli and remember chmod 600 ~/.cloud-cli

 Host="https://yoursite.com:443"
 AdminUser="your-admin-username"
 AdminPass="your-admin-password"
 User="your-username"
 Pass="your-password"
 #Insecure="--insecure"

Examples (file operations):

$ cloud-cli --list path
$ cloud-cli --upload local-file
$ cloud-cli --download cloud-file --local-dir /tmp
$ cloud-cli --pipe cloud-file | grep text-string
$ cloud-cli --delete cloud-file
$ cloud-cli --copy cloud-file --to copy-of-file
$ cloud-cli --move cloud-file --to move-to-file
$ cloud-cli --exists cloud-file
$ cloud-cli --create-dir cloud-dir
$ cloud-cli --delete-dir cloud-dir

Examples (share operations):

$ cloud-cli --list-shares
$ cloud-cli --create-share path --share-type 3 --share-perms 17 
$ cloud-cli --update-share 19 --share-expire 2022-12-31 --share-pass "secret"
$ cloud-cli --delete-share 19

Examples (user operations):

$ cloud-cli --list-users
$ cloud-cli --create-user username --user-pass password [--user-KEY VALUE]
$ cloud-cli --update-user username --user-lang de --user-quota 5GB
$ cloud-cli --update-user username --user-status disable
$ cloud-cli --delete-user username --yes

URL: https://lightaffaire.com/code

Constructive feedback always appreciated.

Iain

3 Likes

Glad to see you are still working on this. :sunglasses:

Thank you. It now does enough that i use it for sharing certain image folders from my internal NAS to customers.

My plan now is too add some picdrop like functionality to the shared folders (favourites and comments (note) per image). If anyone is interested in discussing picdrop features that would be nice to have in nextcloud please contact me.

Are you using particular commands within your Linux desktop as keybindings or as custom actions (Xfce, Gnome, KDE), etc? Would be interested to learn more about how you use this vs. the standard desktop app.

All command line so I can script as needed.

I have my own photography workflow which I have spent 5 years perfecting to the way I like to work.

The storage is on a dual site synology NAS and admin is via linux or WSL2 on windows.

Here is the basic workflow for importing, sorting, renaming, backup to 1-N local disks (when on location), backup to the main local/remote NAS (DR to secondary done via DR scripts) and automatic share to customer via nextcloud.

Here is the rough off the top of my head list of commands I usually use:

# 1. imports, generates checksums for all images and splits them into jpg/ raw/ resized/ folders
# 2. backup work folder to a usb mounted disk in WSL2 (E: = /mnt/e) and to windows dir /images
$ piximport --cust "iain" --type "pay" --job-name "sardinia" --job-date "20221009" --copy-work-to-disk "e: /images"

# after sorting and deleting unwanted images in the resized/ folder simply sync and rename to YYYYMMDD_NNN.extension
$ cd /imgs/pay/2022/10/09_la_sardinia
$ piximport --resync --rename --yes

# sync the folder to a 1-N remote hosts using 8 parallel uploads and ~32Mbps (4x8) bandwidth
$ piximport --sync-work-to-host "lightaffaire.com" --filter-subdirs "resized jpg raw" --transfer 8 --bw-limit 4M

# sync the resized folder to my nextcloud and send share info to customer in an Email
$ piximport --share-resized --share-expire "2022-10-30" --share-pass "secret123!" --share-email "customer@domain.com"

I usually spend 2-3 weeks on Location so needed a tool that could quickly import+sort+verify images (~150 images/minute) and easily generate multiple local and remote copies of my images. I spent a long time looking and then developed piximport which uses cloud-cli to automatically create shares.

If you have questions let me know,

Iain

1 Like

I got a “failed to load external entity” error when try o list my files in a free hosting nextcloudd

./cloud-cli --host https://efss.qloud.my:443 --user user_id --pass password --list /
  OK
failed to load external entity "/tmp/cloud-cli.list-xml.1233340"

Are you using the latest version 1.30?

cloud-cli --help and the first line will state the version.

Are the helper programs curl and xmlstarlet installed on the same system?

Are you using the latest version 1.30?

yes ,

./cloud-cli 
cloud-cli  ver: 1.30

Copyright (c) 2022-2023  Iain Lea (code@lightaffaire.com)

Are the helper programs curl and xmlstarlet installed on the same system?
yes

sudo apt list --installed |grep -E 'curl|xmlstarlet'

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

curl/jammy-updates,jammy-security,now 7.81.0-1ubuntu1.13 amd64 [installed]
libcurl3-gnutls/jammy-updates,jammy-security,now 7.81.0-1ubuntu1.13 amd64 [installed]
libcurl4/jammy-updates,jammy-security,now 7.81.0-1ubuntu1.13 amd64 [installed]
xmlstarlet/jammy,now 1.6.1-2.1 amd64 [installed]

Please try using --verbose or --debug and check the parameters listed.

So did you get it working? what did running it with --verbose or --debug say? If you want free support then provide feedback…