{"action":"created","comment":{"url":"https://api.github.com/repos/mirage/mirage-www-deployment/pulls/comments/33179773","id":33179773,"diff_hunk":"@@ -14,20 +14,60 @@\n # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n # PERFORMANCE OF THIS SOFTWARE.\n \n-VM=mir-www\n-XM=xl\n+# Assumption: the FAT image containing the certificate is at the root\n+# of the Git repository\n \n-ROOT=$(git rev-parse --show-toplevel)\n-cd $ROOT\n+set -e\n \n+XL=xl\n+ROOT=$(git rev-parse --show-toplevel)\n KERNEL=$ROOT/xen/`cat xen/latest`\n-sed -e \"s,@VM@,$VM,g; s,@KERNEL@,$KERNEL/$VM.xen,g\" \\\n-    < $XM.conf.in \\\n-    >| $KERNEL/$XM.conf\n+KEYS=$ROOT/keys.img\n+\n+function destroy_vm {\n+    VM=$1\n+    cd $KERNEL\n+    rm -f $VM.xen\n+    bunzip2 -k $VM.xen.bz2\n+    sudo $XL destroy ${VM#mir-} || true\n+}\n+\n+function create_vm {\n+    VM=$1\n+    cd $KERNEL\n+    sudo $XL create $VM.$XL\n+}\n+\n+function prepare_config {\n+    DISK=$1\n+    cd $ROOT\n+    sed -e \"s,@VM@,$VM,g; s,@KERNEL@,$KERNEL/$VM.xen,g; s:@DISK@:$DISK:g\" \\\n+\t< $XL.conf.in \\\n+\t>| $KERNEL/$NAME.$XL\n+}\n+\n+function deploy {\n+    NAME=$1\n+    VM=mir-${NAME}\n+    prepare_config \"\"\n+    destroy_vm $VM\n+    create_vm $VM\n+}\n \n-cd $KERNEL\n-rm -f $VM.xen\n-bunzip2 -k $VM.xen.bz2\n+function deploy_tls {\n+    NAME=$1\n+    VM=mir-${NAME}\n+    XL=xl\n+    OLD_LOSETUP=`sudo losetup -j ${KEYS} -v | cut -f 1 -d ':'`\n+    # there is a race here\n+    NEW_LOSETUP=`sudo losetup -f`\n+    DISK=\"disk = [ '${NEW_LOSETUP},,xvda' ]\"\n+    prepare_config \"$DISK\"","path":"scripts/deploy.sh","position":68,"original_position":68,"commit_id":"7ec718ec597e122cce3db52feec14244f1d2260a","original_commit_id":"7ec718ec597e122cce3db52feec14244f1d2260a","user":{"login":"mor1","id":167904,"avatar_url":"https://avatars.githubusercontent.com/u/167904?v=3","gravatar_id":"","url":"https://api.github.com/users/mor1","html_url":"https://github.com/mor1","followers_url":"https://api.github.com/users/mor1/followers","following_url":"https://api.github.com/users/mor1/following{/other_user}","gists_url":"https://api.github.com/users/mor1/gists{/gist_id}","starred_url":"https://api.github.com/users/mor1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mor1/subscriptions","organizations_url":"https://api.github.com/users/mor1/orgs","repos_url":"https://api.github.com/users/mor1/repos","events_url":"https://api.github.com/users/mor1/events{/privacy}","received_events_url":"https://api.github.com/users/mor1/received_events","type":"User","site_admin":false},"body":"`${DISK}` for consistency?","created_at":"2015-06-24T18:29:14Z","updated_at":"2015-06-24T18:29:14Z","html_url":"https://github.com/mirage/mirage-www-deployment/pull/2#discussion_r33179773","pull_request_url":"https://api.github.com/repos/mirage/mirage-www-deployment/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/mirage/mirage-www-deployment/pulls/comments/33179773"},"html":{"href":"https://github.com/mirage/mirage-www-deployment/pull/2#discussion_r33179773"},"pull_request":{"href":"https://api.github.com/repos/mirage/mirage-www-deployment/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/mirage/mirage-www-deployment/pulls/2","id":38469197,"html_url":"https://github.com/mirage/mirage-www-deployment/pull/2","diff_url":"https://github.com/mirage/mirage-www-deployment/pull/2.diff","patch_url":"https://github.com/mirage/mirage-www-deployment/pull/2.patch","issue_url":"https://api.github.com/repos/mirage/mirage-www-deployment/issues/2","number":2,"state":"open","locked":false,"title":"Update the deployment to handle the automatic deployment of both mirage.io and om.org","user":{"login":"samoht","id":103693,"avatar_url":"https://avatars.githubusercontent.com/u/103693?v=3","gravatar_id":"","url":"https://api.github.com/users/samoht","html_url":"https://github.com/samoht","followers_url":"https://api.github.com/users/samoht/followers","following_url":"https://api.github.com/users/samoht/following{/other_user}","gists_url":"https://api.github.com/users/samoht/gists{/gist_id}","starred_url":"https://api.github.com/users/samoht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samoht/subscriptions","organizations_url":"https://api.github.com/users/samoht/orgs","repos_url":"https://api.github.com/users/samoht/repos","events_url":"https://api.github.com/users/samoht/events{/privacy}","received_events_url":"https://api.github.com/users/samoht/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-24T17:57:26Z","updated_at":"2015-06-24T18:29:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0785654736854f4b8ef0cb39cca6439c795d7983","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mirage/mirage-www-deployment/pulls/2/commits","review_comments_url":"https://api.github.com/repos/mirage/mirage-www-deployment/pulls/2/comments","review_comment_url":"https://api.github.com/repos/mirage/mirage-www-deployment/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mirage/mirage-www-deployment/issues/2/comments","statuses_url":"https://api.github.com/repos/mirage/mirage-www-deployment/statuses/7ec718ec597e122cce3db52feec14244f1d2260a","head":{"label":"samoht:master","ref":"master","sha":"7ec718ec597e122cce3db52feec14244f1d2260a","user":{"login":"samoht","id":103693,"avatar_url":"https://avatars.githubusercontent.com/u/103693?v=3","gravatar_id":"","url":"https://api.github.com/users/samoht","html_url":"https://github.com/samoht","followers_url":"https://api.github.com/users/samoht/followers","following_url":"https://api.github.com/users/samoht/following{/other_user}","gists_url":"https://api.github.com/users/samoht/gists{/gist_id}","starred_url":"https://api.github.com/users/samoht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samoht/subscriptions","organizations_url":"https://api.github.com/users/samoht/orgs","repos_url":"https://api.github.com/users/samoht/repos","events_url":"https://api.github.com/users/samoht/events{/privacy}","received_events_url":"https://api.github.com/users/samoht/received_events","type":"User","site_admin":false},"repo":{"id":37998902,"name":"mirage-www-deployment","full_name":"samoht/mirage-www-deployment","owner":{"login":"samoht","id":103693,"avatar_url":"https://avatars.githubusercontent.com/u/103693?v=3","gravatar_id":"","url":"https://api.github.com/users/samoht","html_url":"https://github.com/samoht","followers_url":"https://api.github.com/users/samoht/followers","following_url":"https://api.github.com/users/samoht/following{/other_user}","gists_url":"https://api.github.com/users/samoht/gists{/gist_id}","starred_url":"https://api.github.com/users/samoht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samoht/subscriptions","organizations_url":"https://api.github.com/users/samoht/orgs","repos_url":"https://api.github.com/users/samoht/repos","events_url":"https://api.github.com/users/samoht/events{/privacy}","received_events_url":"https://api.github.com/users/samoht/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/samoht/mirage-www-deployment","description":"Deployed binaries of mirage-www (a binary repository)","fork":true,"url":"https://api.github.com/repos/samoht/mirage-www-deployment","forks_url":"https://api.github.com/repos/samoht/mirage-www-deployment/forks","keys_url":"https://api.github.com/repos/samoht/mirage-www-deployment/keys{/key_id}","collaborators_url":"https://api.github.com/repos/samoht/mirage-www-deployment/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/samoht/mirage-www-deployment/teams","hooks_url":"https://api.github.com/repos/samoht/mirage-www-deployment/hooks","issue_events_url":"https://api.github.com/repos/samoht/mirage-www-deployment/issues/events{/number}","events_url":"https://api.github.com/repos/samoht/mirage-www-deployment/events","assignees_url":"https://api.github.com/repos/samoht/mirage-www-deployment/assignees{/user}","branches_url":"https://api.github.com/repos/samoht/mirage-www-deployment/branches{/branch}","tags_url":"https://api.github.com/repos/samoht/mirage-www-deployment/tags","blobs_url":"https://api.github.com/repos/samoht/mirage-www-deployment/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/samoht/mirage-www-deployment/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/samoht/mirage-www-deployment/git/refs{/sha}","trees_url":"https://api.github.com/repos/samoht/mirage-www-deployment/git/trees{/sha}","statuses_url":"https://api.github.com/repos/samoht/mirage-www-deployment/statuses/{sha}","languages_url":"https://api.github.com/repos/samoht/mirage-www-deployment/languages","stargazers_url":"https://api.github.com/repos/samoht/mirage-www-deployment/stargazers","contributors_url":"https://api.github.com/repos/samoht/mirage-www-deployment/contributors","subscribers_url":"https://api.github.com/repos/samoht/mirage-www-deployment/subscribers","subscription_url":"https://api.github.com/repos/samoht/mirage-www-deployment/subscription","commits_url":"https://api.github.com/repos/samoht/mirage-www-deployment/commits{/sha}","git_commits_url":"https://api.github.com/repos/samoht/mirage-www-deployment/git/commits{/sha}","comments_url":"https://api.github.com/repos/samoht/mirage-www-deployment/comments{/number}","issue_comment_url":"https://api.github.com/repos/samoht/mirage-www-deployment/issues/comments{/number}","contents_url":"https://api.github.com/repos/samoht/mirage-www-deployment/contents/{+path}","compare_url":"https://api.github.com/repos/samoht/mirage-www-deployment/compare/{base}...{head}","merges_url":"https://api.github.com/repos/samoht/mirage-www-deployment/merges","archive_url":"https://api.github.com/repos/samoht/mirage-www-deployment/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/samoht/mirage-www-deployment/downloads","issues_url":"https://api.github.com/repos/samoht/mirage-www-deployment/issues{/number}","pulls_url":"https://api.github.com/repos/samoht/mirage-www-deployment/pulls{/number}","milestones_url":"https://api.github.com/repos/samoht/mirage-www-deployment/milestones{/number}","notifications_url":"https://api.github.com/repos/samoht/mirage-www-deployment/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/samoht/mirage-www-deployment/labels{/name}","releases_url":"https://api.github.com/repos/samoht/mirage-www-deployment/releases{/id}","created_at":"2015-06-24T17:12:38Z","updated_at":"2015-06-24T17:12:44Z","pushed_at":"2015-06-24T17:56:08Z","git_url":"git://github.com/samoht/mirage-www-deployment.git","ssh_url":"git@github.com:samoht/mirage-www-deployment.git","clone_url":"https://github.com/samoht/mirage-www-deployment.git","svn_url":"https://github.com/samoht/mirage-www-deployment","homepage":null,"size":731550,"stargazers_count":0,"watchers_count":0,"language":"OCaml","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mirage:master","ref":"master","sha":"eab5d4c636757dc90ff8b4851f7ecf265684a474","user":{"login":"mirage","id":131943,"avatar_url":"https://avatars.githubusercontent.com/u/131943?v=3","gravatar_id":"","url":"https://api.github.com/users/mirage","html_url":"https://github.com/mirage","followers_url":"https://api.github.com/users/mirage/followers","following_url":"https://api.github.com/users/mirage/following{/other_user}","gists_url":"https://api.github.com/users/mirage/gists{/gist_id}","starred_url":"https://api.github.com/users/mirage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mirage/subscriptions","organizations_url":"https://api.github.com/users/mirage/orgs","repos_url":"https://api.github.com/users/mirage/repos","events_url":"https://api.github.com/users/mirage/events{/privacy}","received_events_url":"https://api.github.com/users/mirage/received_events","type":"Organization","site_admin":false},"repo":{"id":13360211,"name":"mirage-www-deployment","full_name":"mirage/mirage-www-deployment","owner":{"login":"mirage","id":131943,"avatar_url":"https://avatars.githubusercontent.com/u/131943?v=3","gravatar_id":"","url":"https://api.github.com/users/mirage","html_url":"https://github.com/mirage","followers_url":"https://api.github.com/users/mirage/followers","following_url":"https://api.github.com/users/mirage/following{/other_user}","gists_url":"https://api.github.com/users/mirage/gists{/gist_id}","starred_url":"https://api.github.com/users/mirage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mirage/subscriptions","organizations_url":"https://api.github.com/users/mirage/orgs","repos_url":"https://api.github.com/users/mirage/repos","events_url":"https://api.github.com/users/mirage/events{/privacy}","received_events_url":"https://api.github.com/users/mirage/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mirage/mirage-www-deployment","description":"Deployed binaries of mirage-www (a binary repository)","fork":false,"url":"https://api.github.com/repos/mirage/mirage-www-deployment","forks_url":"https://api.github.com/repos/mirage/mirage-www-deployment/forks","keys_url":"https://api.github.com/repos/mirage/mirage-www-deployment/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mirage/mirage-www-deployment/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mirage/mirage-www-deployment/teams","hooks_url":"https://api.github.com/repos/mirage/mirage-www-deployment/hooks","issue_events_url":"https://api.github.com/repos/mirage/mirage-www-deployment/issues/events{/number}","events_url":"https://api.github.com/repos/mirage/mirage-www-deployment/events","assignees_url":"https://api.github.com/repos/mirage/mirage-www-deployment/assignees{/user}","branches_url":"https://api.github.com/repos/mirage/mirage-www-deployment/branches{/branch}","tags_url":"https://api.github.com/repos/mirage/mirage-www-deployment/tags","blobs_url":"https://api.github.com/repos/mirage/mirage-www-deployment/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mirage/mirage-www-deployment/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mirage/mirage-www-deployment/git/refs{/sha}","trees_url":"https://api.github.com/repos/mirage/mirage-www-deployment/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mirage/mirage-www-deployment/statuses/{sha}","languages_url":"https://api.github.com/repos/mirage/mirage-www-deployment/languages","stargazers_url":"https://api.github.com/repos/mirage/mirage-www-deployment/stargazers","contributors_url":"https://api.github.com/repos/mirage/mirage-www-deployment/contributors","subscribers_url":"https://api.github.com/repos/mirage/mirage-www-deployment/subscribers","subscription_url":"https://api.github.com/repos/mirage/mirage-www-deployment/subscription","commits_url":"https://api.github.com/repos/mirage/mirage-www-deployment/commits{/sha}","git_commits_url":"https://api.github.com/repos/mirage/mirage-www-deployment/git/commits{/sha}","comments_url":"https://api.github.com/repos/mirage/mirage-www-deployment/comments{/number}","issue_comment_url":"https://api.github.com/repos/mirage/mirage-www-deployment/issues/comments{/number}","contents_url":"https://api.github.com/repos/mirage/mirage-www-deployment/contents/{+path}","compare_url":"https://api.github.com/repos/mirage/mirage-www-deployment/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mirage/mirage-www-deployment/merges","archive_url":"https://api.github.com/repos/mirage/mirage-www-deployment/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mirage/mirage-www-deployment/downloads","issues_url":"https://api.github.com/repos/mirage/mirage-www-deployment/issues{/number}","pulls_url":"https://api.github.com/repos/mirage/mirage-www-deployment/pulls{/number}","milestones_url":"https://api.github.com/repos/mirage/mirage-www-deployment/milestones{/number}","notifications_url":"https://api.github.com/repos/mirage/mirage-www-deployment/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mirage/mirage-www-deployment/labels{/name}","releases_url":"https://api.github.com/repos/mirage/mirage-www-deployment/releases{/id}","created_at":"2013-10-06T10:00:49Z","updated_at":"2015-05-03T10:08:56Z","pushed_at":"2015-06-24T17:57:27Z","git_url":"git://github.com/mirage/mirage-www-deployment.git","ssh_url":"git@github.com:mirage/mirage-www-deployment.git","clone_url":"https://github.com/mirage/mirage-www-deployment.git","svn_url":"https://github.com/mirage/mirage-www-deployment","homepage":null,"size":731550,"stargazers_count":1,"watchers_count":1,"language":"OCaml","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mirage/mirage-www-deployment/pulls/2"},"html":{"href":"https://github.com/mirage/mirage-www-deployment/pull/2"},"issue":{"href":"https://api.github.com/repos/mirage/mirage-www-deployment/issues/2"},"comments":{"href":"https://api.github.com/repos/mirage/mirage-www-deployment/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/mirage/mirage-www-deployment/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/mirage/mirage-www-deployment/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mirage/mirage-www-deployment/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/mirage/mirage-www-deployment/statuses/7ec718ec597e122cce3db52feec14244f1d2260a"}}}}