summaryrefslogtreecommitdiff
path: root/bins/release-repo-migration.sh
blob: d54cd36d9977db614de71d859f355f95e5671445 (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
#!/bin/bash

managers_group()
ln -s "/home/git/repos/##PREFIX##/site/releases" "/var/www/htdocs/releases"

function readers_group()
{
  set +e
  (
    set -e
    su -c "ssh localhost group add site-readers \
        'Users with read access to the site project'" - git
    su -c "ssh localhost group addgroup site-admins site-managers" - git
    su -c "ssh localhost group addgroup site-writers site-admins" - git
    su -c "ssh localhost group addgroup site-readers site-writers" - git
    su -c "ssh localhost create '##PREFIX##/site/releases'" - git
  )
  local ret = "$?"
  if [ "$ret" != 0 ]; then
    token=$(su -c "ssh localhost group del site-readers | tail -1 | \
        cut -d' ' -f 2" - git)
    su -c "ssh localhost group del site-readers $token" - git
  fi
}

function writers_group()
{
  set +e
  (
    set -e
    su -c "ssh localhost group add site-writers \
        'Users with write access to the site project'" - git
    readers_group()
  )
  local ret = "$?"
  if [ "$ret" != 0 ]; then
    token=$(su -c "ssh localhost group del site-writers | tail -1 | \
        cut -d' ' -f 2" - git)
    su -c "ssh localhost group del site-writers $token" - git
  fi
}

function admins_group()
{
  set +e
  (
    set -e
    su -c "ssh localhost group add site-admins \
        'Users with admin access to the site project'" - git
    writers_group()
  )
  local ret = "$?"
  if [ "$ret" != 0 ]; then
    token=$(su -c "ssh localhost group del site-admins | tail -1 | \
        cut -d' ' -f 2" - git)
    su -c "ssh localhost group del site-admins $token" - git
  fi
}

function managers_group()
{
  set +e
  (
    set -e
    su -c "ssh localhost group add site-managers \
        'Users with manager access to the site project'" - git
    admins_group()
  )
  local ret = "$?"
  if [ "$ret" != 0 ]; then
    token=$(su -c "ssh localhost group del site-managers | tail -1 | \
        cut -d' ' -f 2" - git)
    su -c "ssh localhost group del site-managers $token" - git
  fi
}