From ec9c39c67ec46ae3a32e170decde3185817109a3 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Fri, 21 Mar 2014 10:54:15 +0000 Subject: Enable directory listing in /releases Enable lighttpd's directory listing for /releases. This is a link to the /site/releases repository's rsync store. --- etc/lighttpd/git-httpd.conf | 4 ++++ 1 file changed, 4 insertions(+) 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", -- cgit v1.2.1 From 4c256db0541006e59a084dba99c0384a0b773ad3 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Mon, 24 Mar 2014 10:23:46 +0000 Subject: 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. --- share/releases-repo-migration.sh | 132 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100755 share/releases-repo-migration.sh 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 -- cgit v1.2.1 From 0b47849498646499b3f279d2789da954c1f3d5af Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Mon, 24 Mar 2014 10:25:24 +0000 Subject: Add a systemd unit to run the repo creation script Add a systemd unit to check for the existence of the releases repository, and to run the script to create it if it doesn't exist. --- units/releases-repo-migration.service | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 units/releases-repo-migration.service 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 -- cgit v1.2.1 From 8e3cb3379552418adba1a261b933d6927cda8b1c Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Thu, 27 Mar 2014 14:06:40 +0000 Subject: Add a README for the releases repo --- share/releases-repo-README | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 share/releases-repo-README 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 -- cgit v1.2.1