From 164d565283f52be3f7ac66e6b25a9093c1040338 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Tue, 14 Jun 2016 13:50:50 -0300 Subject: [PATCH] Make the data path configurable --- CHANGELOG.md | 2 ++ gosuper/gosuper/main.go | 3 +++ src/application.coffee | 6 +++--- src/config.coffee | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f71878e7..bd15b75e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +* Make the data path configurable [Pablo] + # v1.11.3 * Add listener for container events and reattach on restart [Pablo] diff --git a/gosuper/gosuper/main.go b/gosuper/gosuper/main.go index ab9860a4..f9133e38 100644 --- a/gosuper/gosuper/main.go +++ b/gosuper/gosuper/main.go @@ -67,6 +67,9 @@ func main() { // Start OOMProtectionTimer for protecting Openvpn/Connman dockerSocket := os.Getenv("DOCKER_SOCKET") hostproc := os.Getenv("HOST_PROC") + if dataPathEnv := os.Getenv("RESIN_DATA_PATH"); dataPathEnv != "" { + ResinDataPath = "/mnt/root" + dataPathEnv + } defer startOOMProtectionTimer(hostproc, dockerSocket).Stop() listenAddress := os.Getenv("GOSUPER_SOCKET") diff --git a/src/application.coffee b/src/application.coffee index 889a4ebe..b76a9b0c 100644 --- a/src/application.coffee +++ b/src/application.coffee @@ -174,7 +174,7 @@ application.start = start = (app) -> '/host/var/lib/connman': {} '/host/run/dbus': {} binds = [ - '/resin-data/' + app.appId + ':/data' + config.dataPath + '/' + app.appId + ':/data' '/lib/modules:/lib/modules' '/lib/firmware:/lib/firmware' '/run/dbus:/run/dbus' @@ -305,11 +305,11 @@ getEnvironment = do -> lockPath = (app) -> appId = app.appId ? app - return "/mnt/root/resin-data/#{appId}/resin-updates.lock" + return "/mnt/root#{config.dataPath}/#{appId}/resin-updates.lock" killmePath = (app) -> appId = app.appId ? app - return "/mnt/root/resin-data/#{appId}/resin-kill-me" + return "/mnt/root#{config.dataPath}/#{appId}/resin-kill-me" # At boot, all apps should be unlocked *before* start to prevent a deadlock application.unlockAndStart = unlockAndStart = (app) -> diff --git a/src/config.coffee b/src/config.coffee index 963ec5dc..1d044224 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -48,3 +48,4 @@ module.exports = config = 'RESIN_SUPERVISOR_API_KEY' 'RESIN_API_KEY' ] + dataPath: checkString(process.env.RESIN_DATA_PATH) ? "/resin-data"