# Ongoing server management

## Server Messages on Login Page

If you wish to display a message linked to a more detailed description of some server or service information you must modify the server-status.json file located in the web directory. By default this file contains an example which is not displayed. The example shows that a message must contain a title (not too long), a startdate (in YYYY/MM/DD format), an enddate and a longer textual description of the message. If the date the user connects to the server and is presented with the login page is between the startdate and enddate then the login page will show the title along with a link to a page with all the recent server messages.

Example contents of the server-status.json file:

    {
    "README.TXT" : "Each message needs to have a title, startdate, enddate and description field. Only the first message can be displayed on the login screen.",
    "messages" : [
    	{
    		"title" : "Provide a short description of the message here",
    		"startdate" : "2012/10/22",
    		"enddate" : "2012/10/23",
    		"description" : "This is the longer description of the message.  You can see that this message will be displayed from October 22nd until the end of October 23rd."
    	},
    	{
    		"title" : "This is an older message",
    		"startdate" : "2012/10/10",
    		"enddate" : "2012/10/12",
    		"description" : "This message will be display on the server messages page but not in the login page."
    	}
    ],
    "example-messages" : [
    	{
    		"title" : "This is an older message never to be displayed",
    		"startdate" : "2012/10/22",
    		"enddate" : "2012/10/23",
    		"description" : "This is the longer description of the message.  You can see that this message will be displayed from October 22nd until the end of October 23rd."
    	}
    ]
    }

## Wiping server data

If you are deploying a demo server of Orion, you may want to periodically wipe out all user data, but preserve account names and passwords. This is done as follows:

- Stop the server
- Rename serverworkspace to serverworkspace.old
- Reinstall or reimage the server if you want to be paranoid
- Create a new clean serverworkspace directory
- Copy the following two directories from the old server workspace to the new one:

     .metadata\.plugins\org.eclipse.core.runtime (contains server configuration file)
     .metadata\.plugins\org.eclipse.orion.server.user.securestore (contains user account information)

- Start the server again

    #!/bin/bash

    BASE_PATH=/home/admin
    ECLIPSE_PATH=eclipse-orion-0.2M6

    cd $BASE_PATH || die "Cannot access home directory"

    kill $(ps aux | grep "[o]rg.eclipse.equinox.http.jetty.http.port=8080" | awk {'print $2'})
    rm -rf $ECLIPSE_PATH/serverworkspace.old
    mv $ECLIPSE_PATH/serverworkspace/ $ECLIPSE_PATH/serverworkspace.old
    mkdir $ECLIPSE_PATH/serverworkspace
    mkdir -p $ECLIPSE_PATH/serverworkspace/.metadata/.plugins/org.eclipse.core.runtime/
    rsync -av $ECLIPSE_PATH/serverworkspace.old/.metadata/.plugins/org.eclipse.core.runtime/ $ECLIPSE_PATH/serverworkspace/.metadata/.plugins/org.eclipse.core.runtime/
    rsync -av $ECLIPSE_PATH/serverworkspace.old/.metadata/.plugins/org.eclipse.orion.server.user.securestorage/ $ECLIPSE_PATH/serverworkspace/.metadata/.plugins/org.eclipse.orion.server.user.securestorage/

    $BASE_PATH/start_orion

## Automating account creation with curl

To automate account creation with curl, you need to issue one curl command to log into the Orion server and capture the returned cookie. Subsequent curl calls must include the authentication cookie, and a POST payload, to create an account.

    #!/bin/bash

    # Create accounts on Orion server
    CURL=/usr/bin/curl
    SERVER=localhost

    # Log in
    $CURL -c curl_cookies.txt \ # Store cookies in this file
          -d 'store=Orion'    \ # POST value: store type
          -d 'login=admin'    \ # POST value: login
          -d 'password=yourpass' http://$SERVER/login

    # Create one account
    # Loop here to create multiple accounts
    $CURL -b curl_cookies.txt    \ # Use this cookies file
          -H "Orion-Version:1"   \ # Specify Orion version as an HTTP header
          -d 'login=someaccount' \ # POST value: create account called someaccount
          -d 'password=abc123'   \ # POST value: password is abc123
          http://$SERVER/users

Server admin guide Server admin guide