summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2014-03-24 10:23:46 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2014-03-25 13:17:45 +0000
commit82b292cc6671314f13de7b2abc5eb95cbc427a2a (patch)
tree52eea0cd1c20b5f8cb090c814bf958d63dd89c96
parentec9c39c67ec46ae3a32e170decde3185817109a3 (diff)
downloadtrove-setup-82b292cc6671314f13de7b2abc5eb95cbc427a2a.tar.gz
Add a script to create the releases repository
Add a script that will create a `site` project containing the releases repository when run. It will be run on boot by a systemd unit.
-rwxr-xr-xbins/releases-repo-migration.sh75
1 files changed, 75 insertions, 0 deletions
diff --git a/bins/releases-repo-migration.sh b/bins/releases-repo-migration.sh
new file mode 100755
index 0000000..ca5f58f
--- /dev/null
+++ b/bins/releases-repo-migration.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+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 2>&1 | 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 2>&1 | 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 2>&1 | 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 2>&1 | tail -1 | \
+ cut -d' ' -f 2" - git)
+ su -c "ssh localhost group del site-managers $token" - git
+ fi
+}
+
+managers_group
+ln -s "/home/git/repos/##PREFIX##/site/releases" "/var/www/htdocs/releases"