summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2014-03-27 17:30:47 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2014-03-27 17:30:47 +0000
commit732323565af152528f0970c054aa67d4fbf8e52d (patch)
tree62b024d085c8e7716aef1119de50e723db8c7b35
parent5b689301a2a13dd549ed86d236ff26db6e1fae82 (diff)
parent8e3cb3379552418adba1a261b933d6927cda8b1c (diff)
downloadtrove-setup-732323565af152528f0970c054aa67d4fbf8e52d.tar.gz
Merge branch 'baserock/adamcoldrick/binary-delivery-v4-rebase'
Reviewed by: Sam Thursfield <sam.thursfield@codethink.co.uk> Richard Maw <richard.maw@codethink.co.uk>
-rw-r--r--etc/lighttpd/git-httpd.conf4
-rw-r--r--share/releases-repo-README11
-rwxr-xr-xshare/releases-repo-migration.sh132
-rw-r--r--units/releases-repo-migration.service14
4 files changed, 161 insertions, 0 deletions
diff --git a/etc/lighttpd/git-httpd.conf b/etc/lighttpd/git-httpd.conf
index 94e9c26..dea86de 100644
--- a/etc/lighttpd/git-httpd.conf
+++ b/etc/lighttpd/git-httpd.conf
@@ -35,6 +35,10 @@ mimetype.assign = (
".css" => "text/css"
)
+$HTTP["url"] =~ "^/releases(/|$)" {
+ server.dir-listing = "enable"
+}
+
$HTTP["url"] =~ ".*/gitano-command.cgi$" {
setenv.add-environment = (
"HOME" => "/home/git",
diff --git a/share/releases-repo-README b/share/releases-repo-README
new file mode 100644
index 0000000..d3f872b
--- /dev/null
+++ b/share/releases-repo-README
@@ -0,0 +1,11 @@
+site/releases repository
+------------------------
+
+This is a special repository for distributing release binaries over HTTP.
+Visit http://##PREFIX##/releases/ to browse content.
+
+To add a release to this repository, you need to be a member of the
+Gitano group site-writers. With the correct permissions, you can push
+releases to the repository by doing:
+
+ rsync $RELEASE git@##PREFIX##:##PREFIX##/site/releases
diff --git a/share/releases-repo-migration.sh b/share/releases-repo-migration.sh
new file mode 100755
index 0000000..654da0c
--- /dev/null
+++ b/share/releases-repo-migration.sh
@@ -0,0 +1,132 @@
+#!/bin/bash
+
+function create_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
+ return $ret
+}
+
+function create_writers_group()
+{
+ set +e
+ (
+ set -e
+ ssh localhost group add site-writers \
+ 'Users with write access to the site project'
+ create_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
+ return $ret
+}
+
+function create_admins_group()
+{
+ set +e
+ (
+ set -e
+ ssh localhost group add site-admins \
+ 'Users with admin access to the site project'
+ create_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
+ return $ret
+}
+
+function create_managers_group()
+{
+ set +e
+ (
+ set -e
+ ssh localhost group add site-managers \
+ 'Users with manager access to the site project'
+ create_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
+ return $ret
+}
+
+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...
+ create_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"
+description="This is a special repository for distributing release binaries
+over HTTP. Visit http://##PREFIX##/releases/ to browse content."
+ssh localhost config "##PREFIX##/site/releases" \
+ set project.description "$description"
+
+# add a readme to the repository
+repo=$(mktemp -d)
+git clone ssh://localhost/##PREFIX##/site/releases $repo
+cp /usr/share/trove-setup/releases-repo-README $repo/README
+cd $repo
+git add $repo/README
+git commit -m 'Add README'
+git push origin master
+cd -
+rm -Rf $repo
diff --git a/units/releases-repo-migration.service b/units/releases-repo-migration.service
new file mode 100644
index 0000000..1e161fb
--- /dev/null
+++ b/units/releases-repo-migration.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Create the ##PREFIX##/site/releases repository
+ConditionPathExists=!/home/git/repos/##PREFIX##/site/releases.git
+Requires=network.target
+After=network.target
+Requires=opensshd.service
+After=opensshd.service
+Requires=trove-early-setup.service
+After=trove-early-setup.service
+
+[Service]
+User=git
+ExecStart=/usr/share/trove-setup/releases-repo-migration.sh
+Restart=no