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-26 13:23:05 +0000
commit11c763919f07665280907f5deecf3d0c242823bd (patch)
tree5294c47fd84d27495f3f87ac975f73456ee85113
parentec9c39c67ec46ae3a32e170decde3185817109a3 (diff)
downloadtrove-setup-11c763919f07665280907f5deecf3d0c242823bd.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-xscripts/releases-repo-migration.sh113
1 files changed, 113 insertions, 0 deletions
diff --git a/scripts/releases-repo-migration.sh b/scripts/releases-repo-migration.sh
new file mode 100755
index 0000000..e7ac9b9
--- /dev/null
+++ b/scripts/releases-repo-migration.sh
@@ -0,0 +1,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"