From d31c7df7ff65bccfeb1fd3003e0b075f88a91fec Mon Sep 17 00:00:00 2001
From: Laurent Modolo <laurent@modolo.fr>
Date: Mon, 18 Nov 2019 14:02:50 +0100
Subject: [PATCH] add update_config.sh file to update to the last config
 version

---
 README.md             |  1 +
 src/.update_config.sh | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 src/.update_config.sh

diff --git a/README.md b/README.md
index 795d3391..9fbd72fd 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,7 @@ To get the last commits from this repository into your fork use the following co
 git remote add upstream gitlab_lbmc:pipelines/nextflow.git
 git pull upstream master
 ```
+If you created your `.config` file before version `0.4.0` you need to run the script `src/.update_config.sh` to use the latest docker, singularity and conda configuration (don't forget to check your config files afterward for typos).
 
 ## Getting Started
 
diff --git a/src/.update_config.sh b/src/.update_config.sh
new file mode 100644
index 00000000..8d66be12
--- /dev/null
+++ b/src/.update_config.sh
@@ -0,0 +1,18 @@
+# update docker url
+fd ".*config" -E "nf_modules" src/ -x perl -0777pe 's|container = "|container = "lbmc/|g' -i {}
+
+# update singularity url
+fd ".*config" -E "nf_modules" src/ -x perl -pe 's|container = "lbmc/file://bin/(.*).img"|container = "lbmc/\1"|g' -i {}
+
+# update singularity config
+fd ".*config" -E "nf_modules" src/ -x perl -0777pe 's|\n\s*singularity {\n\s*singularity.enabled = true|\n  singularity {\n    singularity.enabled = true\n    singularity.cacheDir = "./bin/"|mg' -i {}
+
+# update in2p3 config
+fd ".*config" -E "nf_modules" src/ -x perl -0777pe 's|\n\s*ccin2p3 {\n\s*singularity.enabled = true|\n  ccin2p3 {\n    singularity.enabled = true\n    singularity.cacheDir = "/sps/lbmc/common/singularity/"|mg' -i {}
+fd ".*config" src/ -x perl -pe 's|container = "lbmc//sps/lbmc/common/singularity/(.*).img"|container = "lbmc/\1"|g' -i {}
+
+# we remove the ccin2p3_conda section
+fd ".*config" -E "nf_modules" src/ -x perl -0777pe "s|\s*ccin2p3_conda {.*ccin2p3 {\n|\n  ccin2p3 {\n|msg" -i {}
+
+# we update the psmn module to conda
+fd ".*config" -E "nf_modules" src/ -x perl -0777pe 's|beforeScript = "source /usr/share/lmod/lmod/init/bash; module use ~/privatemodules"\n\s*module = "(.*)/(.*)"|beforeScript = "source \$baseDir/.conda_psmn.sh"\n        conda = "\$baseDir/.conda_envs/\L\1_\2"|mg' -i {}
-- 
GitLab