Server IP : 195.201.23.43 / Your IP : 3.148.109.137 Web Server : Apache System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64 User : kdecoratie ( 1041) PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/webmin/virtual-server/ |
Upload File : |
#!/usr/bin/perl =head1 list-dropbox-files.pl Lists all files under a Dropbox path. This command lists all files under a path owner by the cloud storage account currently configured for use by Virtualmin, specified by the C<--path> flag. By default output is in a human-readable table format, but you can switch to a more parsable output format with the C<--multiline> flag. Or to just get a list of filenames, use the C<--name-only> flag. =cut package virtual_server; if (!$module_name) { $main::no_acl_check++; $ENV{'WEBMIN_CONFIG'} ||= "/etc/webmin"; $ENV{'WEBMIN_VAR'} ||= "/var/webmin"; if ($0 =~ /^(.*)\/[^\/]+$/) { chdir($pwd = $1); } else { chop($pwd = `pwd`); } $0 = "$pwd/list-gcs-files.pl"; require './virtual-server-lib.pl'; $< == 0 || die "list-gcs-files.pl must be run as root"; } $state = &cloud_dropbox_get_state(); $state->{'ok'} || &usage("Dropbox has not been configured yet"); # Parse command-line args while(@ARGV > 0) { local $a = shift(@ARGV); if ($a eq "--multiline") { $multi = 1; } elsif ($a eq "--name-only") { $nameonly = 1; } elsif ($a eq "--path") { $path = shift(@ARGV); } elsif ($a eq "--help") { &usage(); } else { &usage("Unknown parameter $a"); } } $path ||= "/"; # Login and list the buckets $files = &list_dropbox_files($path); if (!ref($files)) { print "ERROR: $files\n"; exit(1); } if ($multi) { # Full details foreach $f (@$files) { $name = $f->{'path_display'}; $name =~ s/^\Q$path\E\/?//; print $name,"\n"; if ($f->{'client_modified'} ne '') { print " Last modified: ", &make_date(&dropbox_timestamp( $f->{'client_modified'})),"\n"; } if ($f->{'size'} ne '') { print " Size: ",$f->{'size'},"\n"; } print " Type: ",($f->{'.tag'} eq 'folder' ? "Directory" : "File"),"\n"; print " Full path: ",$f->{'path_display'},"\n"; } } elsif ($nameonly) { # Container names only foreach $f (@$files) { $name = $f->{'path_display'}; $name =~ s/^\Q$path\E\/?//; $name .= "/" if ($f->{'.tag'} eq 'folder'); print $name,"\n"; } } else { # Summary $fmt = "%-40.40s %-4.4s %-20.20s %-10.10s\n"; printf $fmt, "File name", "Type", "Modified", "Size"; printf $fmt, ("-" x 40), ("-" x 4), ("-" x 20), ("-" x 10); foreach $f (@$files) { $name = $f->{'path_display'}; $name =~ s/^\Q$path\E\/?//; printf $fmt, $name, $f->{'.tag'} eq 'folder' ? "Dir" : "File", $f->{'client_modified'} eq '' ? '-' : &make_date(&dropbox_timestamp($f->{'client_modified'})), $f->{'size'} eq '' ? '-' : &nice_size($f->{'size'}); } } sub usage { print "$_[0]\n\n" if ($_[0]); print "Lists all files under a Dropbox path.\n"; print "\n"; print "virtualmin list-dropbox-files [--multiline | --name-only]\n"; print " [--path dir]\n"; exit(1); }Private