# Ongoing server management

## 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

<source lang="bash">

1. !/bin/bash

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

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

kill $(ps aux | grep " org.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

</source>

## 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.

<source lang="bash">

1. !/bin/bash

1. Create accounts on Orion server

CURL=/usr/bin/curl SERVER=localhost

1. 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

1. Create one account
2. 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

</source>

Server admin guide Server admin guide