admin: Update fill_teams.sh
This commit is contained in:
parent
70891bf0e9
commit
fbeb2cc42b
@ -5,11 +5,11 @@ GEN_CERTS=0
|
||||
GEN_PASSWD=0
|
||||
EXTRA_TEAMS=0
|
||||
CSV_SPLITER=","
|
||||
CSV_COL_LASTNAME=1
|
||||
CSV_COL_FIRSTNAME=2
|
||||
CSV_COL_NICKNAME=3
|
||||
CSV_COL_COMPANY=7
|
||||
CSV_COL_TEAM=7
|
||||
CSV_COL_LASTNAME=2
|
||||
CSV_COL_FIRSTNAME=3
|
||||
CSV_COL_NICKNAME=5
|
||||
CSV_COL_COMPANY=6
|
||||
CSV_COL_TEAM=1
|
||||
|
||||
usage() {
|
||||
echo "$0 [options] csv_file"
|
||||
@ -62,24 +62,7 @@ new_team() {
|
||||
|
||||
COLOR=$((($R*256 + $G) * 256 + $B))
|
||||
|
||||
[ "${GEN_PASSWD}" -eq 1 ] && {
|
||||
PASSWD=$(pwgen -r '\\' -B -y 12)
|
||||
NP=$(echo $N | cut -d : -f 1 | sed 's/[[:upper:]]/\l&/g;s/[âáàä]/a/g;s/[êéèë]/e/g')
|
||||
cat >> teams.pass <<EOF
|
||||
${N}:${PASSWD}
|
||||
EOF
|
||||
SALT="$(openssl rand -base64 3)"
|
||||
HASHED="{SSHA}$(echo -n $PASSWD$SALT | openssl dgst -binary -sha1 | sed 's#$#'"$SALT"'#' | base64)"
|
||||
cat >> htpasswd.ssha <<EOF
|
||||
${NP}:${HASHED}
|
||||
EOF
|
||||
HASHED="$(echo -n $PASSWD | openssl passwd -apr1 -in -)"
|
||||
cat >> htpasswd.apr1 <<EOF
|
||||
${NP}:${HASHED}
|
||||
EOF
|
||||
}
|
||||
|
||||
curl -s -d "{\"name\": \"$N\",\"color\": $COLOR}" "${BASEURL}/api/teams/"
|
||||
curl -s -d "{\"name\": \"$N\",\"color\": $COLOR}" "${BASEURL}/api/teams"
|
||||
done | grep -Eo '"id":[0-9]+,' | grep -Eo "[0-9]+"
|
||||
}
|
||||
|
||||
@ -96,6 +79,23 @@ do
|
||||
if [ "${GEN_CERTS}" -eq 1 ] && ! curl -s -f "${BASEURL}/api/teams/${TID}/certificate" > /dev/null
|
||||
then
|
||||
curl -s -f "${BASEURL}/api/teams/${TID}/certificate/generate"
|
||||
elif [ "${GEN_PASSWD}" -eq 1 ]
|
||||
then
|
||||
TEAMID=$(curl -s -f "${BASEURL}/api/teams/${TID}/" | jq -r .name)
|
||||
PASSWD=$(curl -X POST -s -f "${BASEURL}/api/teams/${TID}/password" | jq -r .password)
|
||||
NP=$(echo "${TEAMID}" | cut -d : -f 1 | sed 's/[[:upper:]]/\l&/g;s/[âáàä]/a/g;s/[êéèë]/e/g')
|
||||
cat >> teams.pass <<EOF
|
||||
${TEAMID}:${PASSWD}
|
||||
EOF
|
||||
SALT="$(openssl rand -base64 3)"
|
||||
HASHED="{SSHA}$(echo -n $PASSWD$SALT | openssl dgst -binary -sha1 | sed 's#$#'"$SALT"'#' | base64)"
|
||||
cat >> htpasswd.ssha <<EOF
|
||||
${NP}:${HASHED}
|
||||
EOF
|
||||
HASHED="$(echo -n $PASSWD | openssl passwd -apr1 -in -)"
|
||||
cat >> htpasswd.apr1 <<EOF
|
||||
${NP}:${HASHED}
|
||||
EOF
|
||||
fi
|
||||
echo
|
||||
done
|
||||
@ -116,7 +116,7 @@ do
|
||||
if ! (
|
||||
echo -n "["
|
||||
HAS_MEMBER=1
|
||||
grep "${CSV_SPLITER}${TEAMID}\$" "$PART_FILE" | while read MEMBER
|
||||
grep "${TEAMID}${CSV_SPLITER}" "$PART_FILE" | while read MEMBER
|
||||
do
|
||||
LASTNAME=`echo $MEMBER | cut -d "${CSV_SPLITER}" -f $CSV_COL_LASTNAME | tr -d "\r\n"`
|
||||
FIRSTNAME=`echo $MEMBER | cut -d "${CSV_SPLITER}" -f $CSV_COL_FIRSTNAME | tr -d "\r\n"`
|
||||
@ -146,6 +146,22 @@ EOF
|
||||
elif [ "${GEN_CERTS}" -eq 1 ] && ! curl -s -f "${BASEURL}/api/teams/${TID}/certificate" > /dev/null
|
||||
then
|
||||
curl -s -f "${BASEURL}/api/teams/${TID}/certificate/generate"
|
||||
elif [ "${GEN_PASSWD}" -eq 1 ]
|
||||
then
|
||||
PASSWD=$(curl -X POST -s -f "${BASEURL}/api/teams/${TID}/password" | jq -r .password)
|
||||
NP=$(echo "${TEAMID}" | cut -d : -f 1 | sed 's/[[:upper:]]/\l&/g;s/[âáàä]/a/g;s/[êéèë]/e/g')
|
||||
cat >> teams.pass <<EOF
|
||||
${TEAMID}:${PASSWD}
|
||||
EOF
|
||||
SALT="$(openssl rand -base64 3)"
|
||||
HASHED="{SSHA}$(echo -n $PASSWD$SALT | openssl dgst -binary -sha1 | sed 's#$#'"$SALT"'#' | base64)"
|
||||
cat >> htpasswd.ssha <<EOF
|
||||
${NP}:${HASHED}
|
||||
EOF
|
||||
HASHED="$(echo -n $PASSWD | openssl passwd -apr1 -in -)"
|
||||
cat >> htpasswd.apr1 <<EOF
|
||||
${NP}:${HASHED}
|
||||
EOF
|
||||
fi
|
||||
echo
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user