Commit ab141d22 authored by Johannes Kiesel's avatar Johannes Kiesel

Added cheatsheet and functionality for creating it

parent 5c3f10a6
| command | subcommand | description |
| -------------------- | -------------------- | ---------------------------------------- |
| *test* | | *A few unimportant test scripts for developing purpose.* |
| | t | |
| | a | short description |
| | b | |
| *webis20* | | *Storage Management Scripts, need direct access to RAID Controller and MegaCLI installed* |
| | lsi | |
| *util* | | *General helper tools and utilities* |
| | sshproxy | Set up an SSH proxy tunnel for accessing digital library content or university-restricted URLs |
| | read-from-clipboard | read clipboard and print to stddout |
| | write-to-clipboard | write from stdin to the clipboard |
| | login | get fullname based on login name |
| | tasks | Process tasks in parallel |
| | patch-jar | add files from one jar (or other zip) to another one |
| | backup-btrfs-vol | Take a snapshot of a btrfs subvolume and back up its contents to another location |
| *betamng* | | *Low level scripts for managing Betaweb.* |
| | activate_vnc_all | activate vnc on all nodes of the hostlist |
| | set_critical_temp_shutdown | set settings for shutdown on critical temperature |
| | status_all | get power status of every node of betamng |
| | get_bios_boot_settings_all | get boot settings from all nodes |
| | pssh | run a command parallel on all betamng nodes |
| | enable_pxe_bios_boot_all | enable pxe bios boot on all hosts: experimental! hope and prey |
| | start_all | start every node of betamng (parallel) |
| | change_lcd_msg_all | change lcd message of every node of betaweb to betaweb??? |
| | bios_cpu_test_all | starts bios cpu test on all nodes of the hostlist |
| | virtualscreen | open java vnc session to one of the betamng nodes, via idrac |
| | do_all | run a command sequential on all betamng nodes |
| | stop_all | shutdown every node of betamng |
| | vnc | open vnc session to one of the betamng nodes |
| | read_all_macs | printout system dump of all hosts for extracting mac addresses |
| | ssh | open ssh session to one of the betamng nodes (racadm can be used) |
| *git* | | *Helper scripts for working with the Webis Git server and GitLab instance.* |
| | cvstree2git | Try to clone all projects in the current CVS tree from Git. |
| | onboard | Set up the correct Gitlab group permissions for a new student or Hiwi |
| | cvs2git | Import all CVS modules into new Git repositories and push |
| | web-admin | Display a web-admin view for Gitlab (need to have a token with admin access) |
| | clone-groups | Check out groups of webis gitlab projects at once |
| | init | Initialize GitLab API client |
| | clone-deps | Clone dependencies for current project from GitLab |
| | gitlab | Gitlab commandline interface that comes with python-gitlab |
| | update-project | Clone or update the given Git project from GitLab. |
| *core* | | *Core functions of the Webis command.* |
| | install | install webis to PATH |
| | fun | easter egg |
| | update-cheatsheet | update local copy of code-webis-cmd/cheatsheet.md |
| | checker | check codestyle of project |
| | version | get webis version |
| | remove | remove webis from PATH |
| | update | update the webis command from Git |
| *betaweb* | | *High level scripts for betaweb, e.g. hadoop management.* |
| | rolling_restart | Restart betaweb nodes one after another |
| | restart_hadoop_ressourcemanager | restart hadoop ressource manager on betaweb020 and restarts nodemanager |
| | rolling_state | Apply Salt state on nodes one after another |
| | check_ram | |
| | status | get status of betaweb via salt |
| *elasticsearch* | | *Helper scripts for managing Elasticsearch on the Betaweb cluster.* |
| | start_nodes | Restart Elasticsearch cluster |
| | restart_nodes | Restart Elasticsearch cluster |
| | stop_nodes | Restart Elasticsearch cluster |
#!/bin/bash
# update local copy of code-webis-cmd/cheatsheet.md
#
# Update Webis command
#
# Copyright 2017-today
#
# Project WEBIS
# Author: Johannes Kiesel
#
# Constants
#
cheatsheetname=cheatsheet.md
#
# Load libaries and toolkits.
#
scriptPath=${0%/*}
. ${scriptPath}/../../libs/bashhelper.sh
. ${scriptPath}/../../libs/shflags
check_tools "git"
#
# Define usage screen.
#
usage() {
echo "
Usage:
$(basename "$0")
Description:
Update local copy of code-webis-cmd/${cheatsheetname}
Examples:
$(basename "$0")
"
exit 1
}
#
# Define command line arguments and parse them.
#
FLAGS_HELP=$(usage)
export FLAGS_HELP
FLAGS "$@" || exit 1 # Parse command line arguments.
eval set -- "${FLAGS_ARGV}"
#
#
#
main() {
webiscmdrootpath="$(${scriptPath}/../../libs/readlink-f.py $scriptPath/../../)/"
logInfo "${scriptPath}"
cd "$webiscmdrootpath"
logInfo "Writing to ${webiscmdrootpath}/${cheatsheetname}"
./webis.py --helptable > ${cheatsheetname}
}
#
# Start programm with parameters.
#
main "$@"
......@@ -104,6 +104,20 @@ def get_subcommand_help(subcommandpath):
return lines[1][1:].replace("\n", "").strip()
def print_help_table(config):
"""Prints a table with all commands, subcommands, and their descriptions."""
print("| command | subcommand | description |")
print("| -------------------- | -------------------- | ---------------------------------------- |")
commands = get_commands(config)
for command in commands:
command_help = str(config["commands_help"].get(command))
print("| {:20s} | {:20s} | {:40s} | ".format("*"+command+"*", "", "*"+command_help+"*"))
subcommands = get_subcommands(config, commands[command])
for subcommand in subcommands:
subcommand_help = str(get_subcommand_help(subcommands[subcommand]))
print("| {:20s} | {:20s} | {:40s} | ".format("", subcommand, subcommand_help))
def check_subcommand_shebang(subcommandpath, allowed_scripts):
"""Checks if the shebang of a given script is among the allowed shebangs."""
shebang = get_shebang(subcommandpath)
......@@ -144,6 +158,9 @@ def main(args):
commands = get_commands(config)
parser = argparse.ArgumentParser()
parser.register('action', 'parsers', AliasedSubParsersAction)
parser.add_argument('-H', '--helptable',
help='Print help of commands and subcommands',
action='store_true')
parser.add_argument('-v', '--verbose', help='Print debug messages.',
action='store_true')
......@@ -184,6 +201,10 @@ def main(args):
set_verbose_logging(argsdict['verbose'])
parameter = parseresults[1]
if argsdict['helptable']:
print_help_table(config)
return 0
if argsdict['<command>'] not in subparsers:
argsdict['<command>'] = translate_alias_to_command(
config, argsdict['<command>'])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment