source: spip-zone/_outils_/svn2git/trunk/create_user_gitea.sh @ 111069

Last change on this file since 111069 was 111069, checked in by cam.lafit@…, 13 months ago

Toujours préciser dans la requete le type PUT/GET/DELETE/PATCH/POST

File size: 1013 bytes
Line 
1#!/bin/bash
2
3. create_user_gitea.conf
4
5while read row ; do
6    #Ignorer les lignes vides ou commentées
7    if [ -z "$row" ]; then
8        continue;
9    fi
10    if [ `expr match "$row" '\s*#'` != "0" ]; then
11        continue;
12    fi
13
14    #Un compte de type mail doit être présent
15    if [ `expr index "$row" '@'` = "0" ]; then
16        continue;
17    fi
18
19    if [[ "$row" =~ ([a-zA-Z0-9@\.]*)[[:space:]]*=[[:space:]]*(.*) ]]; then
20            email=${BASH_REMATCH[1]}
21            password=${BASH_REMATCH[2]}
22            username=${email%@*}
23    fi
24
25    if [ -z "$email" -o -z "$password" ]; then
26        continue;
27    fi
28    echo "$row"
29
30    ## IMPORT in gitea
31    curl -H "Authorization: token $GITEA_TOKEN" \
32            -X POST \
33            --data "username=$username&email=$email&password=$password" \
34            $GITEA_HOST/api/v1/admin/users
35
36    curl -H "Authorization: token $GITEA_TOKEN" \
37            -X PUT \
38            $GITEA_HOST/api/v1/teams/$GITEA_ORGA_ID/members/$username
39
40done <$SVN_USERS_FILE
Note: See TracBrowser for help on using the repository browser.