Subversion Repositories ALCASAR

Rev

Rev 2488 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2488 Rev 2564
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-profil.sh 2488 2018-02-25 14:53:54Z lucas.echard $
2
# $Id: alcasar-profil.sh 2564 2018-07-07 21:03:32Z lucas.echard $
3
 
3
 
4
# alcasar-profil.sh
4
# alcasar-profil.sh
5
# by Richard REY
5
# by Richard REY
6
# This script is distributed under the Gnu General Public License (GPL)
6
# This script is distributed under the Gnu General Public License (GPL)
7
 
7
 
Line 22... Line 22...
22
	passwdfile="$1"
22
	passwdfile="$1"
23
	username="$2"
23
	username="$2"
24
 
24
 
25
	[ -f "$passwdfile" ] || touch "$passwdfile"
25
	[ -f "$passwdfile" ] || touch "$passwdfile"
26
 
26
 
27
	[ $(grep -c "${username}:${REALM}:" "$passwdfile") ] && existing_user=0 || existing_user=1
27
	grep -q "${username}:${REALM}:" "$passwdfile" && existing_user=1 || existing_user=0
28
 
28
 
29
	if [ $existing_user -eq 1 ]; then
29
	if [ $existing_user -eq 1 ]; then
30
		echo "Changing password for user $username in realm $REALM"
30
		echo "Changing password for user $username in realm $REALM"
31
	else
31
	else
32
		echo "Adding user $username in realm $REALM"
32
		echo "Adding user $username in realm $REALM"
Line 136... Line 136...
136
			fi
136
			fi
137
			read profil
137
			read profil
138
		else
138
		else
139
			profil="$2"
139
			profil="$2"
140
		fi
140
		fi
-
 
141
 
-
 
142
		if ! echo $ALL_PROFILS | grep -qw $profil
-
 
143
		then
-
 
144
			if [ $Lang == "fr" ]
-
 
145
			then
-
 
146
				echo "Le profil indiqué n'existe pas"
-
 
147
			else
-
 
148
				echo "The given profile doesn't exist"
-
 
149
			fi
-
 
150
			exit 1
-
 
151
		fi
-
 
152
 
141
		if [ $Lang == "fr" ]
153
		if [ $Lang == "fr" ]
142
		then
154
		then
143
			echo -n "Entrez le nom du compte à créer (profil '$profil') : "
155
			echo -n "Entrez le nom du compte à créer (profil '$profil') : "
144
		else
156
		else
145
			echo "Enter the name of the account to create (profile '$profil') : "
157
			echo "Enter the name of the account to create (profile '$profil') : "
Line 156... Line 168...
156
						then
168
						then
157
							echo "Ce compte existe déjà"
169
							echo "Ce compte existe déjà"
158
						else
170
						else
159
							echo "This account already exists"
171
							echo "This account already exists"
160
						fi
172
						fi
161
					exit 0
173
					exit 1
162
				fi
174
				fi
163
				done
175
				done
164
		done
176
		done
165
		htdigest $DIR_KEY/key_only_$profil "$account"
177
		htdigest $DIR_KEY/key_only_$profil "$account"
166
		concat
178
		concat