Initialise config file on selfupdate.

This commit is contained in:
Marco Vermeulen
2012-12-07 13:45:00 +00:00
parent b60b935ec7
commit 70463aa7a2
4 changed files with 45 additions and 4 deletions

View File

@@ -20,14 +20,20 @@ echo "Updating gvm scripts..."
TMP_ZIP="/tmp/res.zip"
PLATFORM=$(uname)
GVM_DIR="$HOME/.gvm"
mkdir -p "${GVM_DIR}/ext"
mkdir -p "${GVM_DIR}/etc"
mkdir -p "${GVM_DIR}/groovy"
mkdir -p "${GVM_DIR}/groovy"
mkdir -p "${GVM_DIR}/grails"
mkdir -p "${GVM_DIR}/griffon"
mkdir -p "${GVM_DIR}/vert.x"
CONFIG_FILE="${GVM_DIR}/etc/config"
if [[ ! -f "${CONFIG_FILE}" ]]; then
echo "isolated_mode=0" > "${CONFIG_FILE}"
fi
BIN_FOLDER="${GVM_DIR}/bin"
mkdir -p "${BIN_FOLDER}"
curl -s "${GVM_SERVICE}/res?platform=${PLATFORM}" > "${TMP_ZIP}"

View File

@@ -1,6 +1,5 @@
Feature: Upgrade
@manual
Scenario: Upgrade an outdated installation
Given an initialised system
When I enter "gvm selfupdate"
@@ -8,3 +7,16 @@ Feature: Upgrade
Then I see "Successfully upgraded GVM."
Then the gvm scripts are up to date
Scenario: Upgrade an installation without configuration
Given an initialised system
And the configuration file has not been primed
When I enter "gvm selfupdate"
Then the configuration file is present
And the configuration file contains "isolated_mode=0"
Scenario: Upgrade an installation with configuration
Given an initialised system
And the configuration file has been primed
When I enter "gvm selfupdate"
Then the configuration file is present
And the configuration file contains "isolated_mode=1"

View File

@@ -2,7 +2,6 @@ package gvm
import static cucumber.runtime.groovy.Hooks.*
import static gvm.VertxUtils.*
import gvm.BashEnv
baseDir = new File("build/scripts")
@@ -12,6 +11,7 @@ serviceUrlEnv = "http://localhost:8080"
gvmDir = new File("${gvmDirEnv}")
binDir = new File("${gvmDirEnv}/bin")
varDir = new File("${gvmDirEnv}/var")
envDir = new File("${gvmDirEnv}/etc")
broadcastFile = new File("${gvmDirEnv}/var/broadcast")
server = null
@@ -22,6 +22,7 @@ Before(){
server = startServer()
binDir.mkdirs()
varDir.mkdirs()
envDir.mkdirs()
// Copy the scripts into the gvm bin directory.
for (f in baseDir.listFiles()) {

View File

@@ -1,6 +1,6 @@
package gvm
import static cucumber.runtime.groovy.EN.Then
import static cucumber.runtime.groovy.EN.*
Then(~'^the gvm scripts are up to date$') { ->
def gvm = new File("$gvmDir/bin/gvm")
@@ -9,3 +9,25 @@ Then(~'^the gvm scripts are up to date$') { ->
def gvmInit = new File("$gvmDir/bin/gvm-init.sh")
assert gvmInit.exists()
}
And(~'^the configuration file has been primed$') { ->
def configFile = "$gvmDir/etc/config" as File
configFile << "isolated_mode=1"
}
And(~'^the configuration file has not been primed$') { ->
def configFile = "$gvmDir/etc/config" as File
if (configFile.exists()) {
configFile.delete()
}
}
Then(~'^the configuration file is present$') { ->
def configFile = "$gvmDir/etc/config" as File
assert configFile.exists()
}
And(~'^the configuration file contains "([^"]*)"$') { String content ->
def configFile = "$gvmDir/etc/config" as File
assert configFile.text.contains(content)
}