summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/tools/package/bin/onos-user-key
blob: db24da170418a1c2c615f303bcd04b78e5d36c7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
# -----------------------------------------------------------------------------
# Adds or removes a user key for managing passwordless loging to ONOS console.
# -----------------------------------------------------------------------------

[ $# -lt 2 ] && echo "usage: $(basename $0) user {key|remove}" && exit 1

set -e

user=$1
[ -f $2 ] && key=$(cut -d\  -f2 $2) || key=$2

cd $(dirname $0)/../apache-karaf-*/etc
KEYS=keys.properties

# Remove the user key first, in case one was already present
egrep -v "^$user[ ]*=" $KEYS > $KEYS.new && mv $KEYS.new $KEYS
if [ $key != "remove" ]; then
    echo "$user=$key,_g_:admingroup" >> $KEYS
fi