/galaxyproject_gxadmin

Handy command line utility for Galaxy administrators :rocket:

Primary LanguageShellGNU General Public License v3.0GPL-3.0

gxadmin: Make Galaxy administration magical 🌈

A command line tool for Galaxy administrators to run common queries against our Postgres databases. It additionally includes some code for managing Galaxy and associated features, and other utilities.

Mostly gxadmin acts as a repository for the common queries we all run regularly but fail to share with each other.

It comes with a wide array of useful queries that you might want to run, but you can also easily add more to your installation with local functions. gxadmin attempts to be a very readable bash script and avoids using fancy new bash features.

Subcommand Functions
query 104
server 22
mutate 22
meta 12
galaxy 12
report 5
filter 3
config 2
cluster 1

This script requires a postgres database and has no plans to support mysql or sqlite3.

If we do support sqlite3 in the future, it will be on a "if you're lucky" type basis, we won't be modifying queries to remove postgres-ism.

Installation

curl -L https://github.com/galaxyproject/gxadmin/releases/latest/download/gxadmin > /usr/bin/gxadmin
chmod +x /usr/bin/gxadmin

Contributing

See CONTRIBUTING.md

Changelog

Changelog

Contributors

License

GPLv3

Configuration

gxadmin does not have much configuration, mostly env vars and functions will complain if you don't have them set properly.

Postgres

Queries support being run in normal postgres table, csv, or tsv output as you need. Just use gxadmin query, gxadmin tsvquery, or gxadmin csvquery as appropriate.

You should have a ~/.pgpass with the database connection information, and set PGDATABASE, PGHOST, and PGUSER in your environment.

Example .pgpass:

<pg_host>:5432:*:<pg_user>:<pg_password>

InfluxDB

In order to use functions like gxadmin meta influx-post, gxadmin requires a few environment variables to be set. Namely

  • INFLUX_URL
  • INFLUX_PASS
  • INFLUX_USER
  • INFLUX_DB

Other Environment Variables

Some subcommands may ask you to set these environment variables, if they aren't already.

Variable Example Value
GALAXY_CONFIG_DIR /srv/galaxy/config/
GALAXY_CONFIG_FILE /srv/galaxy/config/galaxy.yml
GALAXY_LOG_DIR /var/log/galaxy/
GALAXY_MUTABLE_CONFIG_DIR /srv/galaxy/var/
GALAXY_ROOT /srv/galaxy/server/
VIRTUAL_ENV /srv/galaxy/venv/

GDPR

You may want to set GDPR_MODE=1. Please determine your own legal responsibilities, the authors take no responsibility for anything you may have done wrong.

If you want to publish data, first be careful! Second, the GDPR_MODE variable is part of the hash, so you can set it to something like GDPR_MODE=$(openssl rand -hex 24 2>/dev/null) gxadmin query ... for hashing and "throwing away the key"

Local Functions

If you want to add some site-specific functions, you can do this in ~/.config/gxadmin-local.sh (location can be overridden by setting $GXADMIN_SITE_SPECIFIC)

You should write a bash script which looks like. ALL functions must be prefixed with local_

local_cats() { ## : Makes cat noises
	handle_help "$@" <<-EOF
		Here is some documentation on this function
	EOF

	echo "Meow"
}

This can then be called with gxadmin like:

$ gxadmin local cats --help
gxadmin local functions usage:

    cats   Cute kitties

help / -h / --help : this message. Invoke '--help' on any subcommand for help specific to that subcommand
$ gxadmin local cats
Meow
$

If you prefix the function name with query-, e.g. local_query-cats, then it will be run as a database query. CSV/TSV/Influx queries are not currently supported.