blob: db24da170418a1c2c615f303bcd04b78e5d36c7c [file] [log] [blame]
Thomas Vachuska12bf4452015-06-26 09:15:38 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Adds or removes a user key for managing passwordless loging to ONOS console.
4# -----------------------------------------------------------------------------
5
6[ $# -lt 2 ] && echo "usage: $(basename $0) user {key|remove}" && exit 1
7
8set -e
9
10user=$1
11[ -f $2 ] && key=$(cut -d\ -f2 $2) || key=$2
12
13cd $(dirname $0)/../apache-karaf-*/etc
14KEYS=keys.properties
15
16# Remove the user key first, in case one was already present
17egrep -v "^$user[ ]*=" $KEYS > $KEYS.new && mv $KEYS.new $KEYS
18if [ $key != "remove" ]; then
19 echo "$user=$key,_g_:admingroup" >> $KEYS
20fi