| # ----------------------------------------------------------------------------- |
| # Adds or removes the specified user and password to secure ONOS GUI and |
| # ONOS REST API; also removes the default user/password entry. |
| # ----------------------------------------------------------------------------- |
| usage="usage: $(basename $0) user {password|--remove}" |
| [ -z "$user" -o -z "$password" ] && echo "$usage" >&2 && exit 1 |
| cd $(dirname $0)/../apache-karaf-*/etc |
| # Remove the user entry first, in case one was already present. |
| # Also remove the built-in user to implicitly secure access. |
| egrep -v "^($user|onos)[ ]*=" $USERS > $USERS.new && mv $USERS.new $USERS |
| # Add the user and the password to the user properties file. |
| if [ $password != "--remove" ]; then |
| echo "$user = $password,_g_:admingroup" >> $USERS |