blob: a7c638ce4fdd6f78c2300cad57090cf6edd123c6 [file] [log] [blame]
Thomas Vachuska5af2e4f2016-12-16 12:07:33 -08001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Adds or removes the specified user and password to secure ONOS GUI and
4# ONOS REST API; also removes the default user/password entry.
5# -----------------------------------------------------------------------------
6
7usage="usage: $(basename $0) user {password|--remove}"
8
9user=$1
10password=$2
11
12[ -z "$user" -o -z "$password" ] && echo "$usage" >&2 && exit 1
13
14cd $(dirname $0)/../apache-karaf-*/etc
15USERS=users.properties
16
17# Remove the user entry first, in case one was already present.
18# Also remove the built-in user to implicitly secure access.
19egrep -v "^($user|onos)[ ]*=" $USERS > $USERS.new && mv $USERS.new $USERS
20
21# Add the user and the password to the user properties file.
22if [ $password != "--remove" ]; then
23 echo "$user = $password,_g_:admingroup" >> $USERS
24fi