IDA Research Data Service v2 - Command Line Tools
Clone or download
patrick-stickler-csc-fi Added support for scope intersection checking.
Added support for download of folders.
Updated curl parameters to disregard certificate issues.
Added check for excess parameters.
Fixed bug in ignore file parameter handling.
Normalized error messages.
Refinements to pathname parameter handling
Various bug fixes and minor enhancements.
Latest commit d1da3eb Jan 14, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Initial commit Jun 29, 2018
.gitignore Added /tags to .gitignore Jul 19, 2018
LICENSE Initial commit Jun 29, 2018
README.md Added support for scope intersection checking. Jan 14, 2019
ida Added support for scope intersection checking. Jan 14, 2019

README.md

IDA Command Line Tools

This repository provides a bash script ida for interacting with v2 of the IDA service from the command line.

Usage: ida [-h]
       ida upload   [-v] [-c config] [-i ignore] [-t host] [-p project] target_pathname local_pathname
       ida download [-v] [-c config]             [-t host] [-p project] target_pathname local_pathname
       ida move     [-v] [-c config]             [-t host] [-p project] target_pathname new_target_pathname
       ida delete   [-v] [-c config]             [-t host] [-p project] target_pathname
       
       -h : show this guide
       -v : provide verbose output
       -c : configuration file
       -i : ignore file
       -t : target host (default: "https://ida.fairdata.fi")
       -p : project name

Pathnames may correspond to either files or folders. If a folder is specified, then the action is performed for all files within that folder and all subfolders. Folders are downloaded as zip files. Actions can be performed on only one file or folder at a time.

target_pathname and new_target_pathname are relative to the staging area of the specified project.

local_pathname is the pathname of a folder or file on the local system which is to be uploaded, or the pathname on the local system to which a file will be downloaded (either a single data file or the zip file for a data folder). Existing files will not be overwritten.

move can also be used to rename a file or folder without changing its location.

Installation

Download the ida script, ideally placing it in a location somewhere in your $PATH, and ensure that the script is executable:

chmod +x ida

The ida script requires that bash is installed on your system as /bin/bash and that curl is installed on your system somewhere in your $PATH.

Configuration

The ida script requires that certain parameters are defined, either via environment variables or provided as arguments.

Configuration file

The ida script will look for and load a file .ida-config if it exists in your home directory.

You can copy the provided example ida-config file from the examples subdirectory to your home directory as .ida-config and edit it accordingly.

It is also possible to explicitly specify a configuration file using the -c command line option.

Configuration settings will be taken from existing environment variables, followed by $HOME/.ida-config, followed by a configuration file specified with the -c command line option, followed by any other specified command line options; thus, it is possible to partially or completely override configuration settings defined at each subsequent level of specification.

Project

You may define the name of your project using the IDA_PROJECT environment variable.

IDA_PROJECT="myproject"

You may also specify the project using the -p command line option.

If you belong to more than one project, you can define whichever project is most frequently used and use the -p commmand line option to explicitly specify another project when different from the default.

All target pathnames are considered to be relative to the staging or frozen area of the specified project.

IDA Host

The IDA_HOST environment variable may be defined as something other than the main production service, when appropriate. If undefined, the script will default to the main production service.

IDA_HOST="https://ida.fairdata.fi"

Authentication

The ida script will need to be provided your IDA account credentials in order to access the project space.

The username and password credentials are the same as you use to log in to the IDA web UI, and are managed in the SUI CSC Customer Portal.

Account credentials should ideally be defined using netrc.

You can copy the provided example netrc file from the examples subdirectory to your home directory as .ida-config and edit it accordingly. Be sure to set the permissions of your netrc file securely:

chmod go-rwx $HOME/.netrc

If a .netrc file exists in your home directory, the script will retrieve your credentials from there. If no .netrc file exists in your home directory, you will be prompted to enter your credentials on each invocation.

App passwords

If you prefer not to use or store your personal account password, it is possible to create an application specific password which can be used and stored in place of your official account password.

To create an app password, log in to the IDA web UI, and open the settings view by selecting "Personal" from the pull down settings menu at the top right of the view, and then either select the "Security" section in the left hand navigation pane or scroll down to the security section.

In the field provided, enter a name for your new app password and click "Create new app password". The new app password will be displayed, and must be copied and saved immediately. It will not be possible to view the app password again, though it will be listed by the provided name and you will be able to delete it and remove it from use.

Enter or store the app password in your .netrc file, the same as you would your official personal account password.

Ignore file

The ida script will look for and use a file .ida-ignore if it exists in your home directory, to exclude files matching certain patterns from upload.

This is useful when uploading entire folders, to exclude special system files such as .DS_Store on OS-X or various temporary or log files which might exist within the local filesystem but are not part of the data to be stored in IDA.

You can copy the provided example ida-ignore file from the examples subdirectory to your home directory as .ida-ignore and edit it accordingly.

It is also possible to explicitly specify an ignore file using the -i command line option.

The ignore file should contain one pattern per line, and will be applied only to filenames, not to pathnames or portions of pathnames. Patterns should be compatible with those understood by the -name option of the POSIX find command.

Collision Avoidance for File Operations

All users belonging to a given project have the same rights, and may interact with, add, and remove project data concurrently. To help avoid one user unintentionally interfering with another user's activity, the IDA service employs a number of checks and restrictions to ensure that multiple concurrent users' activities do not collide in undesirable ways.

Operations on files in the staging area, including uploading, deleting, renaming, and moving (but not downloading), will not be allowed if they intersect with the scope of an action that is being initiated.

If an action is initiated in the web UI of the service, it takes precidence over any batch operations utilizing the command line tools, such that the batch operations may be blocked by the initiated action. In such cases, the command line tools will exit with an error message.

More details can be found in the online user guide.

Special Notes

Files named .htaccess and files with a suffix of either .part or .filepart may not be uploaded. The filenames will need to be changed in some manner, such as zipping the file or adding some other suffix or name change. These restrictions are due to security and other internal management contraints of the underlying Nextcloud platform employed by the IDA service.

Note that files are not officially stored persistently in the IDA service until they are frozen, which can only be done using the web UI of the service.