Octopus.Script exported 2015-11-15 by timhunt303 belongs to ‘RavenDB’ category.
Used to create a new database on a server
Parameters
When steps based on the template are included in a project’s deployment process, the parameters below can be set.
URL of the RavenDB
ravenDatabaseURL = http://localhost:8080/
URL of the RavenDB, where you would like the database to be created.
For example http://localhost:8080/
Name of the Database
ravenDatabaseName
The name the database will be called. Make sure that name is not already being used.
Active Bundles
ravenActiveBundles
A settings option, Active Bundles refers bundles that RavenDB has (Replication;Versioning; etc)
Name of the Storage Type
ravenStorageTypeName = Esent
What storage type to use
Path for the database directory
ravenDataDir
The path for the database directory on the server
Allow Incremental Backups
allowIncrementalBackups = False
Allow Incremental Backups to be perform on this Database
Path to Temporary Files
voronTempPath
A different path where the temporary files will be stored
Path for the Esent Logs
esentLogsPath
The path for the Esent logs
Path for the Indexes
indexStoragePath
The path for the indexes on a disk, if you want to store the indexes on another HDD for performance reasons
Script body
Steps based on this template will execute the following PowerShell script.
#--------------------------------------------------------------------
#Octopus Variables
#URL where the database will be create
$ravenDatabaseURL = $OctopusParameters["ravenDatabaseURL"]
#Name of the new database
$ravenDatabaseName = $OctopusParameters["ravenDatabaseName"]
#Name of Active Bundles (Replication; Versioning; etc) (Default is null)
$ravenActiveBundles = $OctopusParameters["ravenActiveBundles"]
#storage Type Name (esent or voron)
$ravenStorageTypeName = $OctopusParameters["ravenStorageTypeName"]
#directory the database will be located on the server
$ravenDataDir = $OctopusParameters["ravenDataDir"]
#allow incremental back ups: boolean
$allowIncrementalBackups = $OctopusParameters["allowIncrementalBackups"]
#temporary files will be created at this location
$voronTempPath = $OctopusParameters["voronTempPath"]
#The path for the esent logs
$esentLogsPath = $OctopusParameters["esentLogsPath"]
#The path for the indexes on a disk
$indexStoragePath = $OctopusParameters["indexStoragePath"]
#--------------------------------------------------------------------
#checks to see if the entered database exists, return a boolean value depending on the outcome
function doesRavenDBExist([string] $databaseChecking, [string]$URL)
{
#retrieves the list of databases at the specified URL
$database_list = Invoke-RestMethod -Uri "$URL/databases" -Method Get
#checks if the database is at the specified URL
if ($database_list -contains $databaseChecking.ToString())
{
return $TRUE
}
else
{
return $FALSE
}
}#ends does ravenDB exist function
Write-Output "`n-------------------------`n"
#--------------------------------------------------------------------
#check to see if database exists
Write-Output "Checking to see if $ravenDatabaseName exists"
$database_exists = doesRavenDBExist -databaseChecking $ravenDatabaseName -URL $ravenDatabaseURL
if($database_exists -eq $TRUE)
{
Write-Error "$ravenDatabaseName already exists" -ErrorId E4
Exit 1
}
Write-Output "`n-------------------------`n"
#--------------------------------------------------------------------
#check setting variables
if($ravenActiveBundles -eq $null)
{
$ravenActiveBundles = ""
}
if($ravenDataDir -eq "")
{
Write-Warning "A directory for the database has NOT been entered. The default directory ~\Databases\System is being used."
$ravenDataDir = "~\Databases\System"
}
if($esentLogsPath -eq "")
{
Write-Warning "The path for the esent logs has NOT been entered. The default path of ~/Data/Logs will be used"
$esentLogsPath = "~/Data/Logs"
}
if($indexStoragePath -eq "")
{
Write-Warning "The path for the indexes has NOT been entered. The default path of ~/Data/Indexes will be used"
$indexStoragePath = "~/Data/Indexes"
}
$ravenDataDir = $ravenDataDir.Replace("\", "\\")
$voronTempPath = $voronTempPath.Replace("\", "\\")
$esentLogsPath = $esentLogsPath.Replace("\", "\\")
$indexStoragePath = $indexStoragePath.Replace("\", "\\")
Write-Output "`n-------------------------`n"
#--------------------------------------------------------------------
#database Settings
$db_settings = @"
{
"Settings":
{
"Raven/ActiveBundles": "$ravenActiveBundles",
"Raven/StorageTypeName": "$ravenStorageTypeName",
"Raven/DataDir": "$ravenDataDir",
"Raven/Voron/AllowIncrementalBackups": "$allowIncrementalBackups",
"Raven/Voron/TempPath": "$voronTempPath",
"Raven/Esent/LogsPath": "$esentLogsPath",
"Raven/IndexStoragePath": "$indexStoragePath"
}
}
"@
#--------------------------------------------------------------------
#create Database
Write-Output "Create database: $ravenDatabaseName"
$createURI = "$ravenDatabaseURL/admin/databases/$ravenDatabaseName"
Invoke-RestMethod -Uri $createURI -Body $db_settings -Method Put
Provided under the Apache License version 2.0.
To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.
{
"Id": "ffa7c244-f835-42d1-ad38-15f96037f114",
"Name": "RavenDB - Create Database",
"Description": "Used to create a new database on a server",
"Version": 6,
"ExportedAt": "2015-11-15T22:07:42.439+00:00",
"ActionType": "Octopus.Script",
"Author": "timhunt303",
"Parameters": [
{
"Name": "ravenDatabaseURL",
"Label": "URL of the RavenDB",
"HelpText": "URL of the RavenDB, where you would like the database to be created. \n\nFor example **http://localhost:8080/**",
"DefaultValue": "http://localhost:8080/",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "ravenDatabaseName",
"Label": "Name of the Database",
"HelpText": "The name the database will be called. Make sure that name is not already being used.",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "ravenActiveBundles",
"Label": "Active Bundles",
"HelpText": "A settings option, Active Bundles refers bundles that RavenDB has (Replication;Versioning; etc)",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "ravenStorageTypeName",
"Label": "Name of the Storage Type",
"HelpText": "What storage type to use",
"DefaultValue": "Esent",
"DisplaySettings": {
"Octopus.ControlType": "Select",
"Octopus.SelectOptions": "Esent| Esent\nVoron| Voron"
}
},
{
"Name": "ravenDataDir",
"Label": "Path for the database directory",
"HelpText": "The path for the database directory on the server",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "allowIncrementalBackups",
"Label": "Allow Incremental Backups",
"HelpText": "Allow Incremental Backups to be perform on this Database",
"DefaultValue": "False",
"DisplaySettings": {
"Octopus.ControlType": "Checkbox"
}
},
{
"Name": "voronTempPath",
"Label": "Path to Temporary Files",
"HelpText": "A different path where the temporary files will be stored",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "esentLogsPath",
"Label": "Path for the Esent Logs",
"HelpText": "The path for the Esent logs",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "indexStoragePath",
"Label": "Path for the Indexes",
"HelpText": "The path for the indexes on a disk, if you want to store the indexes on another HDD for performance reasons",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
}
],
"Properties": {
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptBody": "#--------------------------------------------------------------------\n#Octopus Variables\n\n#URL where the database will be create\n$ravenDatabaseURL = $OctopusParameters[\"ravenDatabaseURL\"]\n\n#Name of the new database\n$ravenDatabaseName = $OctopusParameters[\"ravenDatabaseName\"]\n\n#Name of Active Bundles (Replication; Versioning; etc) (Default is null)\n$ravenActiveBundles = $OctopusParameters[\"ravenActiveBundles\"]\n\n#storage Type Name (esent or voron)\n$ravenStorageTypeName = $OctopusParameters[\"ravenStorageTypeName\"]\n\n#directory the database will be located on the server\n$ravenDataDir = $OctopusParameters[\"ravenDataDir\"]\n\n#allow incremental back ups: boolean\n$allowIncrementalBackups = $OctopusParameters[\"allowIncrementalBackups\"]\n\n#temporary files will be created at this location\n$voronTempPath = $OctopusParameters[\"voronTempPath\"]\n\n#The path for the esent logs\n$esentLogsPath = $OctopusParameters[\"esentLogsPath\"]\n\n#The path for the indexes on a disk\n$indexStoragePath = $OctopusParameters[\"indexStoragePath\"]\n\n\n#--------------------------------------------------------------------\n\n#checks to see if the entered database exists, return a boolean value depending on the outcome\nfunction doesRavenDBExist([string] $databaseChecking, [string]$URL)\n{\n #retrieves the list of databases at the specified URL\n $database_list = Invoke-RestMethod -Uri \"$URL/databases\" -Method Get\n #checks if the database is at the specified URL\n if ($database_list -contains $databaseChecking.ToString()) \n {\n return $TRUE\n }\n else \n {\n return $FALSE\n }\n\n \n}#ends does ravenDB exist function\n\nWrite-Output \"`n-------------------------`n\"\n\n\n#--------------------------------------------------------------------\n\n#check to see if database exists\nWrite-Output \"Checking to see if $ravenDatabaseName exists\"\n\n$database_exists = doesRavenDBExist -databaseChecking $ravenDatabaseName -URL $ravenDatabaseURL\n\nif($database_exists -eq $TRUE)\n{\n Write-Error \"$ravenDatabaseName already exists\" -ErrorId E4\n Exit 1\n}\n\n\n\nWrite-Output \"`n-------------------------`n\"\n#--------------------------------------------------------------------\n#check setting variables \n\nif($ravenActiveBundles -eq $null)\n{\n $ravenActiveBundles = \"\" \n}\n\nif($ravenDataDir -eq \"\")\n{\n Write-Warning \"A directory for the database has NOT been entered. The default directory ~\\Databases\\System is being used.\"\n $ravenDataDir = \"~\\Databases\\System\"\n}\n\nif($esentLogsPath -eq \"\")\n{\n Write-Warning \"The path for the esent logs has NOT been entered. The default path of ~/Data/Logs will be used\"\n $esentLogsPath = \"~/Data/Logs\"\n}\n\nif($indexStoragePath -eq \"\")\n{\n Write-Warning \"The path for the indexes has NOT been entered. The default path of ~/Data/Indexes will be used\"\n $indexStoragePath = \"~/Data/Indexes\"\n}\n\n\n$ravenDataDir = $ravenDataDir.Replace(\"\\\", \"\\\\\")\n\n$voronTempPath = $voronTempPath.Replace(\"\\\", \"\\\\\")\n\n$esentLogsPath = $esentLogsPath.Replace(\"\\\", \"\\\\\")\n\n$indexStoragePath = $indexStoragePath.Replace(\"\\\", \"\\\\\")\n\nWrite-Output \"`n-------------------------`n\"\n\n#--------------------------------------------------------------------\n#database Settings \n\n$db_settings = @\"\n{\n \"Settings\":\n {\n \"Raven/ActiveBundles\": \"$ravenActiveBundles\",\n \"Raven/StorageTypeName\": \"$ravenStorageTypeName\",\n \"Raven/DataDir\": \"$ravenDataDir\",\n \"Raven/Voron/AllowIncrementalBackups\": \"$allowIncrementalBackups\",\n \"Raven/Voron/TempPath\": \"$voronTempPath\",\n \"Raven/Esent/LogsPath\": \"$esentLogsPath\",\n \"Raven/IndexStoragePath\": \"$indexStoragePath\"\n }\n}\n\"@\n\n#--------------------------------------------------------------------\n#create Database\n\nWrite-Output \"Create database: $ravenDatabaseName\"\n\n$createURI = \"$ravenDatabaseURL/admin/databases/$ravenDatabaseName\"\n\nInvoke-RestMethod -Uri $createURI -Body $db_settings -Method Put\n"
},
"Category": "RavenDB",
"HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/ravendb-create-database.json",
"Website": "/step-templates/ffa7c244-f835-42d1-ad38-15f96037f114",
"Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADBQTFRF0Y6OjR8iHx8fW1la0szNmVZZZB8k5crLkIyMwl1evI6QwrCw6uPjsiAh////8/HxjiSEkQAABNlJREFUeNrs24uWmyAUBVBQkKfh//+2gKiYGKMRsWkPnbUmdZLUPfeBEUoe/8gggAACCCCAAAIIIIAAAggggAACCCCAAAIIIIAAAggggAACCCCAAAIIIIAAAggggAACCCCAAAIIIIAAAggggADy/0GceDpgpDSM/SCE9L1SxMweK5swWu/5rdQKlDAUmTCmbZqkYb9UIzZR+p4INxxishlHa1xViBNC7H0Lo5RZvrafBrHDIdY2maUixJ+L2v0W/nxfD41D2cRtsiHtXwAhzz9aQlSMj1CvlDantLYSxPeevRArRHZW/cBymWR0LoJSOirHi51sZ9103lml9GooONssKdUhhszN9CEI2apWn1pJmqdXP7zELtKraVlliHot563ZfQyZJYQo6hV0CtOTpDG1IfRACoqeqrxrJMpwzC0hTVsT4vTTTJFlmf0YHyF8VMIflSZHuWxf7q5iz19Me5F6nNJb7WGQ6LXmVaoRn4P0dIBQStWml8avGFYnL8muUxCjeIIMZeG7G5neMOiG2iKUJsrQ++LZLyXWZBnX+mtlVxWSnzMPTcF/p/NBf+YJEh4FDY/nZw1zbBGT5nW0ByfMryB+Ls8n89hnQ9rwESKIJlE1RSRZxn+ONTuGNJdAyPzbJtkpLdr0CCF0HNPT0t9Xp/i340Aj2A/RMyQ8XOtSU0T0BNFPEP56/bg5zOWQ6YVaE50uYL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