about summary refs log tree commit diff
path: root/genenetwork-local-container.sh
diff options
context:
space:
mode:
Diffstat (limited to 'genenetwork-local-container.sh')
-rwxr-xr-xgenenetwork-local-container.sh52
1 files changed, 50 insertions, 2 deletions
diff --git a/genenetwork-local-container.sh b/genenetwork-local-container.sh
index ca67d4a..8d5cdf4 100755
--- a/genenetwork-local-container.sh
+++ b/genenetwork-local-container.sh
@@ -33,6 +33,7 @@ SYSTEM_DIRECTORIES=(
     "$BASE_DIR/var/lib/redis"
     "$BASE_DIR/var/lib/virtuoso"
     "$BASE_DIR/var/lib/xapian"
+    "$BASE_DIR/var/genenetwork/genotype-files"
     "$BASE_DIR/var/lib/genenetwork-sqlite"
     "$BASE_DIR/var/lib/genenetwork-gnqa"
     "/tmp/local-container"
@@ -45,6 +46,14 @@ GN_PROJECTS=(
     "gn-docs:https://git.genenetwork.org/gn-docs"
 )
 
+# File mappings: source -> destination
+declare -A FILE_MAPPINGS=(
+    ["etc/auth.db"]="$BASE_DIR/var/genenetwork/auth.db"
+    ["etc/gn2-secrets.py"]="$BASE_DIR/etc/genenetwork/conf/gn2/secrets.py"
+    ["etc/gn3-secrets.py"]="$BASE_DIR/etc/genenetwork/conf/gn3/secrets.py"
+    ["etc/gn-auth-secrets.py"]="$BASE_DIR/etc/genenetwork/conf/secrets.py"
+)
+
 CONTAINER_SCM="genenetwork-local-container.scm"
 CONTAINER_BIN="/usr/local/bin/genenetwork-local-container"
 GC_ROOT="/var/guix/gcroots/genenetwork-local-container"
@@ -56,7 +65,7 @@ log() {
 }
 
 # Check dependencies
-for cmd in git guix sudo; do
+for cmd in git guix sudo diff cp; do
     if ! command -v "$cmd" &>/dev/null; then
         log "ERROR" "Required command '$cmd' not found"
         exit 1
@@ -76,7 +85,8 @@ for dir in "${SYSTEM_DIRECTORIES[@]}"; do
         if [ -w "$dir" ]; then
             log "DEBUG" "Directory exists and is writable: $dir"
         else
-            log "WARNING" "Directory exists but is not writable: $dir"
+            log "WARNING" "Directory exists but is not writable: $dir.  Making this writable"
+	    sudo chown -R "$USER" "$dir"
         fi
         continue
     fi
@@ -102,6 +112,44 @@ for dir in "${SYSTEM_DIRECTORIES[@]}"; do
     fi
 done
 
+# Check and copy configuration files
+log "INFO" "Checking and copying configuration files..."
+for src in "${!FILE_MAPPINGS[@]}"; do
+    dest="${FILE_MAPPINGS[$src]}"
+    log "INFO" "Processing $src -> $dest"
+
+    # Check if source file exists
+    if [ ! -f "$src" ]; then
+        log "ERROR" "Source file does not exist: $src"
+        exit 1
+    fi
+
+    # Check if destination file exists
+    if [ ! -f "$dest" ]; then
+        log "INFO" "Destination file does not exist, copying $src to $dest"
+        mkdir -p "$(dirname "$dest")"
+        if ! cp "$src" "$dest"; then
+            log "ERROR" "Failed to copy $src to $dest"
+            exit 1
+        fi
+        continue
+    fi
+
+    # Compare files using diff
+    log "INFO" "Comparing $src with $dest"
+    if diff_output=$(diff -u "$dest" "$src" 2>&1); then
+        log "INFO" "Files $src and $dest are identical"
+    else
+        log "INFO" "Differences found between $src and $dest:"
+        echo "$diff_output" >&2
+        log "INFO" "Copying $src to $dest"
+        if ! cp "$src" "$dest"; then
+            log "ERROR" "Failed to copy $src to $dest"
+            exit 1
+        fi
+    fi
+done
+
 is_git_repository() {
     local dir="$1"
     # Check for standard repository