Thomas Vachuska | 12bf445 | 2015-06-26 09:15:38 -0700 | [diff] [blame] | 1 | #!/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 | |
| 8 | set -e |
| 9 | |
| 10 | user=$1 |
| 11 | [ -f $2 ] && key=$(cut -d\ -f2 $2) || key=$2 |
| 12 | |
| 13 | cd $(dirname $0)/../apache-karaf-*/etc |
| 14 | KEYS=keys.properties |
| 15 | |
| 16 | # Remove the user key first, in case one was already present |
| 17 | egrep -v "^$user[ ]*=" $KEYS > $KEYS.new && mv $KEYS.new $KEYS |
| 18 | if [ $key != "remove" ]; then |
| 19 | echo "$user=$key,_g_:admingroup" >> $KEYS |
| 20 | fi |