File: oci-userdb

package info (click to toggle)
openstack-cluster-installer 43.0.18
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,484 kB
  • sloc: php: 19,127; sh: 18,142; ruby: 75; makefile: 31; xml: 8
file content (34 lines) | stat: -rwxr-xr-x 817 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh

set -e

CMD="mysql -D oci -e"

usage (){
	echo $(basename $0)" usages:"
	echo "                      -l -> list users"
	echo "           -d <username> -> remove a user"
	echo "           -r <username> -> add a user with radius authentication"
	echo "-a <username> [password] -> add a user with local db authentication"
}

if [ $# = 0 ] ; then
	usage
fi

if [ "${1}" = "-l" ] ; then
	${CMD} "SELECT * FROM users"
fi

if [ "${1}" = "-a" ] ; then
	HASHED_PASS=$(php -r "echo password_hash('${3}', PASSWORD_BCRYPT);")
	${CMD} "INSERT INTO users (login,hashed_password,use_radius) VALUES ('${2}','${HASHED_PASS}','no')"
fi

if [ "${1}" = "-r" ] ; then
	${CMD} "INSERT INTO users (login,use_radius) VALUES ('${2}','yes')"
fi

if [ "${1}" = "-d" ] ; then
	${CMD} "DELETE FROM users WHERE login='${2}' LIMIT 1"
fi