Permalink
Browse files

first cut of bootstrap cfpkg

  • Loading branch information...
tjanczuk committed Apr 21, 2012
1 parent 7e20e51 commit d70df3055d370633edd3f0f1f9ad83117998faf7
View
@@ -0,0 +1,2 @@
+*.exe
+*.msi
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<ServiceConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serviceName="git-azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
+ <Role name="bootstrap">
+ <ConfigurationSettings>
+ <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="" />
+ <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="" />
+ <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="" />
+ <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="" />
+ <Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="" />
+ <Setting name="REMOTE_BRANCH" value="##REMOTE_BRANCH##" />
+ <Setting name="REMOTE_URL" value="##REMOTE_URL##" />
+ </ConfigurationSettings>
+ <Instances count="##INSTANCE_COUNT##" />
+ <Certificates>
+ <Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="0000000000000000000000000000000000000000" thumbprintAlgorithm="sha1" />
+ </Certificates>
+ </Role>
+</ServiceConfiguration>
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<ServiceDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="git-azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
+ <WorkerRole name="bootstrap">
+ <ConfigurationSettings>
+ <Setting name="REMOTE_URL" />
+ <Setting name="REMOTE_BRANCH" />
+ </ConfigurationSettings>
+ <Imports>
+ <Import moduleName="RemoteForwarder" />
+ <Import moduleName="RemoteAccess" />
+ </Imports>
+ <Startup>
+ <Task commandLine="setup_worker.cmd" executionContext="elevated">
+ <Environment>
+ <Variable name="REMOTE_URL">
+ <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/ConfigurationSettings/ConfigurationSetting[@name='REMOTE_URL']/@value" />
+ </Variable>
+ <Variable name="REMOTE_BRANCH">
+ <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/ConfigurationSettings/ConfigurationSetting[@name='REMOTE_BRANCH']/@value" />
+ </Variable>
+ </Environment>
+ </Task>
+ </Startup>
+ <Endpoints>
+ <InputEndpoint name="HttpIn" protocol="tcp" port="80" />
+ <InputEndpoint name="HttpsIn" protocol="tcp" port="443" />
+ <InputEndpoint name="ManagementPublic" protocol="tcp" port="31415" />
+ <InternalEndpoint name="ManagementInternal" protocol="tcp" port="31416" />
+ </Endpoints>
+ <Runtime executionContext="elevated">
+ <Environment>
+ <Variable name="HTTP_PORT">
+ <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/Endpoints/Endpoint[@name='HttpIn']/@port" />
+ </Variable>
+ <Variable name="HTTPS_PORT">
+ <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/Endpoints/Endpoint[@name='HttpsIn']/@port" />
+ </Variable>
+ <Variable name="MANAGEMENT_PUBLIC_PORT">
+ <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/Endpoints/Endpoint[@name='ManagementPublic']/@port" />
+ </Variable>
+ <Variable name="MANAGEMENT_INTERNAL_PORT">
+ <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/Endpoints/Endpoint[@name='ManagementInternal']/@port" />
+ </Variable>
+ </Environment>
+ <EntryPoint>
+ <ProgramEntryPoint commandLine="start_worker.cmd" setReadyOnProcessStart="true" />
+ </EntryPoint>
+ </Runtime>
+ </WorkerRole>
+</ServiceDefinition>
View
@@ -0,0 +1,17 @@
+@echo off
+
+SET THIS=%~dp0
+
+csc.exe /out:%THIS%\download.exe %THIS%\download.cs
+if %ERRORLEVEL% NEQ 0 (
+ echo Error building download.exe. Make sure csc.exe from .NET Framework is on the PATH.
+ exit /b -1
+)
+
+cspack.exe %THIS%\bootstrap.csdef /out:%THIS%\bootstrap.cspkg /roleFiles:bootstrap;%THIS%\files.txt
+if %ERRORLEVEL% NEQ 0 (
+ echo Error building bootstrap.cspkg. Make sure cspack.exe from Windows Azure SDK is on the PATH.
+ exit /b -1
+)
+
+exit /b 0
View
@@ -0,0 +1,64 @@
+using System;
+using System.Net;
+using System.ComponentModel;
+using System.Threading;
+
+class Program
+{
+ static void OnError(string url, string file, Exception e)
+ {
+ Console.WriteLine("Error downloading from " + url + " to " + file + ":");
+ Console.WriteLine(e.ToString());
+ Environment.Exit(1);
+ }
+
+ static void Main(string[] args)
+ {
+ int timeout = 0;
+
+ if ((args.Length % 2) != 1 || args.Length == 1 || !int.TryParse(args[0], out timeout))
+ {
+ Console.WriteLine("Usage: download.exe <timeout_in_seconds> [<url> <output_file>]+");
+ Environment.Exit(1);
+ }
+
+ int n = 1;
+ int completed = 0;
+ ManualResetEvent waitHandle = new ManualResetEvent(false);
+
+ try
+ {
+ while (n < args.Length)
+ {
+ WebClient client = new WebClient();
+ int k = n;
+ client.DownloadFileCompleted += new AsyncCompletedEventHandler(delegate (object sender, AsyncCompletedEventArgs e) {
+ if (e.Error != null)
+ {
+ OnError(args[k], args[k + 1], e.Error);
+ }
+
+ Console.WriteLine("Finished download from " + args[k] + " to " + args[k + 1]);
+
+ if (++completed == ((args.Length - 1) / 2))
+ {
+ waitHandle.Set();
+ }
+ });
+ Console.WriteLine("Starting download from " + args[n] + " to " + args[n + 1]);
+ client.DownloadFileAsync(new Uri(args[n]), args[n + 1]);
+ n += 2;
+ }
+ }
+ catch (Exception e)
+ {
+ OnError(args[n], args[n + 1], e);
+ }
+
+ if (!waitHandle.WaitOne(new TimeSpan(0, 0, timeout)))
+ {
+ Console.WriteLine("Download timed out.");
+ Environment.Exit(1);
+ }
+ }
+}
View
@@ -0,0 +1,3 @@
+download.exe;download.exe
+setup_worker.cmd;setup_worker.cmd
+start_worker.cmd;start_worker.cmd
@@ -0,0 +1,7 @@
+REM This script is called by setup_worker.cmd when a new Windows Azure Worker Role instance is created.
+REM It should be used to install additional software or configure the machine.
+REM When this script is called, node.js and GIT are already installed on the system,
+REM and the user repository is cloned in %~dp0\repo
+REM Make sure to return a non-zero exit code on failure.
+
+exit /b 0
@@ -0,0 +1,69 @@
+@echo off
+
+SET NODE_URL=http://nodejs.org/dist/v0.6.15/node-v0.6.15.msi
+SET GIT_URL=http://msysgit.googlecode.com/files/Git-1.7.10-preview20120409.exe
+
+SET THIS=%~dp0
+SET POST_SETUP=%THIS%\repo\.git-azure\src\bootstrap\post_setup.cmd
+SET GIT="%ProgramFiles%\Git\cmd\git.cmd"
+
+echo %TIME% Downloading prerequisities...
+%THIS%\download.exe 300 %NODE_URL% %THIS%\node.msi %GIT_URL% %THIS%\git-setup.exe
+if %ERRORLEVEL% NEQ 0 (
+ echo %TIME% ERROR downloading prerequisities
+ exit /b -1
+)
+echo %TIME% Prerequisities downloaded
+
+echo %TIME% Installing node.js...
+msiexec /i %THIS%\node.msi /q
+if %ERRORLEVEL% NEQ 0 (
+ echo %TIME% ERROR installing node.js
+ exit /b -1
+)
+echo %TIME% Node.js installed
+
+echo %TIME% Installing GIT...
+start /wait %THIS%\git-setup.exe /verysilent
+if %ERRORLEVEL% NEQ 0 (
+ echo %TIME% ERROR installing GIT
+ exit /b -1
+)
+if NOT EXIST %GIT% (
+ echo %TIME% ERROR Unable to find GIT at %GIT%
+ exit /b -1
+)
+echo %TIME% GIT installed
+
+echo %TIME% Cloning branch %REMOTE_BRANCH% from repo %REMOTE_URL%...
+call %GIT% clone -b %REMOTE_BRANCH% %REMOTE_URL% %THIS%\repo
+if %ERRORLEVEL% NEQ 0 (
+ echo %TIME% ERROR Unable to clone branch %REMOTE_BRANCH% from repo %REMOTE_URL%
+ exit /b -1
+)
+echo %TIME% Repo cloned
+
+echo %TIME% Updating submodules...
+pushd %THIS%\repo
+call %GIT% submodule update --init --recursive
+if %ERRORLEVEL% NEQ 0 (
+ popd
+ echo %TIME% ERROR Updating submodules
+ exit /b -1
+)
+popd
+echo %TIME% Submodules updated
+
+if NOT EXIST %POST_SETUP% goto end
+
+echo %TIME% Running post setup from %POST_SETUP%...
+call %POST_SETUP%
+if %ERRORLEVEL% NEQ 0 (
+ echo %TIME% ERROR The post setup failed with %ERRORLEVEL%
+ exit /b -1
+)
+echo %TIME% Post setup finished
+
+:end
+
+exit /b 0
No changes.

0 comments on commit d70df30

Please sign in to comment.