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-24 11:32:25 +0000
commitccc041cd88cd0153418936abc332ef8951ca6fee (patch)
tree72a3bb6bbeaa3a637e45aa1c327f4cbfeb1e4811
parentec9c39c67ec46ae3a32e170decde3185817109a3 (diff)
downloadtrove-setup-ccc041cd88cd0153418936abc332ef8951ca6fee.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/release-repo-migration.sh75
1 files changed, 75 insertions, 0 deletions
diff --git a/bins/release-repo-migration.sh b/bins/release-repo-migration.sh
new file mode 100755
index 0000000..d54cd36
--- /dev/null
+++ b/bins/release-repo-migration.sh
@@ -0,0 +1,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
+}