blob: e7ac9b9abac65b1a25fa459292ae3e67a676ee3c (
plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
#!/bin/bash
function readers_group()
{
set +e
(
set -e
ssh localhost group add site-readers \
'Users with read access to the site project'
)
local ret="$?"
if [ "$ret" != 0 ]; then
token=$(ssh localhost group del site-readers 2>&1 | tail -1 | \
cut -d' ' -f 2)
ssh localhost group del site-readers $token
fi
}
function writers_group()
{
set +e
(
set -e
ssh localhost group add site-writers \
'Users with write access to the site project'
readers_group
)
local ret="$?"
if [ "$ret" != 0 ]; then
token=$(ssh localhost group del site-writers 2>&1 | tail -1 | \
cut -d' ' -f 2)
ssh localhost group del site-writers $token
fi
}
function admins_group()
{
set +e
(
set -e
ssh localhost group add site-admins \
'Users with admin access to the site project'
writers_group
)
local ret="$?"
if [ "$ret" != 0 ]; then
token=$(ssh localhost group del site-admins 2>&1 | tail -1 | \
cut -d' ' -f 2)
ssh localhost group del site-admins $token
fi
}
function managers_group()
{
set +e
(
set -e
ssh localhost group add site-managers \
'Users with manager access to the site project'
admins_group
)
local ret="$?"
if [ "$ret" != 0 ]; then
token=$(ssh localhost group del site-managers 2>&1 | tail -1 | \
cut -d' ' -f 2)
ssh localhost group del site-managers $token
fi
}
function link_groups()
{
set -e
ssh localhost group addgroup site-admins site-managers
ssh localhost group addgroup site-writers site-admins
ssh localhost group addgroup site-readers site-writers
}
function delete_groups()
{
token=$(ssh localhost group del site-managers 2>&1 | tail -1 | \
cut -d' ' -f 2)
ssh localhost group del site-managers $token
token=$(ssh localhost group del site-admins 2>&1 | tail -1 | \
cut -d' ' -f 2)
ssh localhost group del site-admins $token
token=$(ssh localhost group del site-writers 2>&1 | tail -1 | \
cut -d' ' -f 2)
ssh localhost group del site-writers $token
token=$(ssh localhost group del site-readers 2>&1 | tail -1 | \
cut -d' ' -f 2)
ssh localhost group del site-readers $token
}
function create_groups()
{
# call managers_group which calls admin_group and so on...
managers_group
set +e
(
set -e
link_groups
)
local ret="$?"
if [ "$ret" != 0 ]; then
delete_groups
fi
}
site_groups=$(ssh localhost group list | grep -cE "site-[[:alnum:]]+")
if [ "$site_groups"== 0 ]; then
create_groups
fi
ssh localhost create "##PREFIX##/site/releases"
|