CRaSH Integration

Version 10.3 by Admin on 2016/03/09 00:05

application_xp_terminalIntegrates CRaSH in XWiki
TypeXAR
Category
Developed by

Vincent Massol, xwiki:XWiki.bouquetf

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Installable with the Extension Manager

Description

Integrates CRaSH into XWiki by allowing the following features:

  • Run CRaSH inside XWiki to provide a shell for it
  • Ability to start/stop CRaSH from the XWiki Admin UI
  • Ability to add commands as wiki pages and to access XWiki script bindings

There's another CRaSH integration. The differences are:

  • It's older
  • Doesn't allow connecting through SSH out of the box
  • Doesn't allow adding commands as wiki pages
  • OTOH it allows to trigger the CRaSH console from a wiki page

Start/Stop CRaSH

crash-start.png

Connect using SSH

Before you can connect using SSH you'll need to edit XWiki's xwiki.properties and add 2 configuration variables (modify the username and password as you see fit!):

crash.auth.simple.username=admin
crash.auth.simple.password=admin

Then here's what you'll get connecting to XWiki's CRaSH instance:

crash-ssh.png

Default XWiki Command

By default we provide an xwiki command (located in page Crash.XWikiCommand and you can use to run any XWQL query.

Examples:

  • Return the list of all users in the wiki: xwiki xwql "from doc.object(XWiki.XWikiUsers) as user"
  • Return the list of all pages containing CRaSH commands in the wiki: xwiki xwql "from doc.object(Crash.CrashCommandClass) as user"

For reference, here's the definition of this command:

@Usage("XWiki commands")
class xwiki
{
 @Usage("execute an XWQL query")
 @Command
 public String xwql(
     @Usage("The XWQL query")
     @Argument
      String query)
 {
    context.attributes.services.query.xwql(query).setLimit(100).execute().each() {
      out.println("- ${it}")
   }
    out.println("")
 }
}

Adding a new Command

Create a page and add an Object of type Crash.CrashCommandClass. For example:

crash-newcommand.png

And here's what you get when you execute it from SSH:

crash-newcommand-ssh.png

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. You'll also need to install all dependent Extensions that are not already installed in your wiki

Dependencies

Dependencies for this extension (org.xwiki.contrib:application-crash-ui 1.0):

Tags:
    

Get Connected