Skip to content

Commit

Permalink
Modified scripts for IDEA4RC project
Browse files Browse the repository at this point in the history
  • Loading branch information
frankcorneliusmartin committed Mar 14, 2024
1 parent 0695949 commit f036ab1
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 288 deletions.
2 changes: 1 addition & 1 deletion create-cronjob.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source $SCRIPT_DIR/utils.sh
print_step "Adding cron job"
if ! check_command "crontab"; then
print_warning "Crontab not installed. Installing crontab."
sudo dnf install crontabs -y &>> $LOG_DIR/install-crontab.log
sudo apt install cron -y &>> $LOG_DIR/install-crontab.log
fi
if ! (crontab -l 2>/dev/null | grep -q "$SCRIPT_DIR/start.sh"); then
(crontab -l 2>/dev/null; echo "@reboot $SCRIPT_DIR/start.sh") | crontab -
Expand Down
87 changes: 35 additions & 52 deletions create-node.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/bash
source $SCRIPT_DIR/utils.sh
CONFIG_FILE=$HOME/.config/vantage6/node/blueberry.yaml
CONFIG_FILE=$HOME/.config/vantage6/node/idea4rc.yaml
CONFIG_FILE_TEMPLATE=$SCRIPT_DIR/node.tpl

WRITE_CONFIG_FILE=true
Expand Down Expand Up @@ -55,62 +55,42 @@ if [ "$WRITE_CONFIG_FILE" = true ]; then
export API_KEY=$API_KEY

# OMOP database settings
if is_set "OMOP_HOST" "silent"; then
if is_set "DOCKER_SERVICE_CONTAINER_LABEL" "silent"; then
print_step "Using previous Docker service container label: $DOCKER_SERVICE_CONTAINER_LABEL"
DB_METHOD="Docker-service"
else
print_step "Using previous SSH OMOP_HOST: $OMOP_HOST"
DB_METHOD="SSH-tunnel"
fi
else
# depending on the method selected we need to inject a different block in the
# config file
select_database_method
fi
is_set_or_prompt "OMOP_API_PROTOCOL" "http/https"
export OMOP_API_PROTOCOL=$OMOP_API_PROTOCOL
is_set_or_prompt "OMOP_API_URI" "ip or domain"
export OMOP_API_URI=$OMOP_API_URI
is_set_or_prompt "OMOP_API_PORT" "typically 80 or 443"
export OMOP_API_PORT=$OMOP_API_PORT

select_whitelist_method

is_set_or_prompt "OMOP_PORT"
export OMOP_PORT=$OMOP_PORT
is_set_or_prompt "OMOP_DATABASE"
export OMOP_DATABASE=$OMOP_DATABASE
is_set_or_prompt "OMOP_USER"
export OMOP_USER=$OMOP_USER
is_set_or_prompt "OMOP_PASSWORD"
export OMOP_PASSWORD=$OMOP_PASSWORD
is_set_or_prompt "OMOP_CDM_SCHEMA"
export OMOP_CDM_SCHEMA=$OMOP_CDM_SCHEMA
is_set_or_prompt "OMOP_RESULT_SCHEMA"
export OMOP_RESULT_SCHEMA=$OMOP_RESULT_SCHEMA

case "$DB_METHOD" in
"Docker-service")
case "$WHITELIST_VERSION" in
"Domain")
# Code to execute if DB_METHOD is "docker"
if ! is_set "OMOP_HOST" "silent"; then
user_input "Please enter the OMOP container name"
OMOP_HOST=$REPLY
fi

export OMOP_HOST=$OMOP_HOST
export DOCKER_SERVICE_CONTAINER_LABEL=$OMOP_HOST
include_content=$(<$SCRIPT_DIR/templates/docker-service.tpl)
is_set_or_prompt "WHITELIST_DOMAIN"
export WHITELIST_DOMAIN=$WHITELIST_DOMAIN
include_content=$(<$SCRIPT_DIR/templates/whitelist-domain.tpl)

;;
"SSH-tunnel")
"IP")
# Code to execute if DB_METHOD is "ssh_tunnel"
export OMOP_HOST="omop"
include_content=$(<$SCRIPT_DIR/templates/ssh-tunnel.tpl)
source $SCRIPT_DIR/create-ssh-tunnel.sh
is_set_or_prompt "WHITELIST_IP"
export WHITELIST_IP=$WHITELIST_IP
include_content=$(<$SCRIPT_DIR/templates/whitelist-ip.tpl)
;;
*)
# Code to execute if DB_METHOD is anything else
print_error "Invalid option $DB_METHOD. Exiting..."
print_error "Invalid option $WHITELIST_VERSION. Exiting..."
exit 1
;;
esac
is_set_or_prompt "WHITELIST_PORT"
export WHITELIST_PORT=$WHITELIST_PORT

escaped_content=$(echo "$include_content" | sed -e ':a' -e 'N' -e '$!ba' -e 's/[\/&]/\\&/g' -e 's/\n/NEWLINE/g')
sed "s/{{DATABASE_CONNECTION}}/$escaped_content/g" $SCRIPT_DIR/templates/node-config.tpl | sed 's/NEWLINE/\n/g' > $CONFIG_FILE_TEMPLATE
# sed "s/{{DATABASE_CONNECTION}}/$escaped_content/" $SCRIPT_DIR/templates/node-config.tpl > $CONFIG_FILE_TEMPLATE
sed "s/{{WHITELIST}}/$escaped_content/g" $SCRIPT_DIR/templates/node-config.tpl | sed 's/NEWLINE/\n/g' > $CONFIG_FILE_TEMPLATE
# sed "s/{{WHITELIST}}/$escaped_content/" $SCRIPT_DIR/templates/node-config.tpl > $CONFIG_FILE_TEMPLATE

# # Create the config file
print_step "Creating the config file"
Expand All @@ -122,17 +102,20 @@ if [ "$WRITE_CONFIG_FILE" = true ]; then
if [ "$KEEP_PREVIOUS_SETTINGS" = false ]; then
print_step "Creating environment file"
echo "export API_KEY=$API_KEY" > $SCRIPT_DIR/settings.env
echo "export OMOP_PORT=$OMOP_PORT" >> $SCRIPT_DIR/settings.env
echo "export OMOP_DATABASE=$OMOP_DATABASE" >> $SCRIPT_DIR/settings.env
echo "export OMOP_USER=$OMOP_USER" >> $SCRIPT_DIR/settings.env
echo "export OMOP_PASSWORD=$OMOP_PASSWORD" >> $SCRIPT_DIR/settings.env
echo "export OMOP_CDM_SCHEMA=$OMOP_CDM_SCHEMA" >> $SCRIPT_DIR/settings.env
echo "export OMOP_RESULT_SCHEMA=$OMOP_RESULT_SCHEMA" >> $SCRIPT_DIR/settings.env
echo "export OMOP_HOST=$OMOP_HOST" >> $SCRIPT_DIR/settings.env
if is_set "DOCKER_SERVICE_CONTAINER_LABEL" "silent"; then
echo "export DOCKER_SERVICE_CONTAINER_LABEL=$DOCKER_SERVICE_CONTAINER_LABEL" >> $SCRIPT_DIR/settings.env

echo "export OMOP_API_PROTOCOL=$OMOP_API_PROTOCOL" >> $SCRIPT_DIR/settings.env
echo "export OMOP_API_URI=$OMOP_API_URI" >> $SCRIPT_DIR/settings.env
echo "export OMOP_API_PORT=$OMOP_API_PORT" >> $SCRIPT_DIR/settings.env

if is_set "WHITELIST_DOMAIN" "silent"; then
echo "export WHITELIST_DOMAIN=$WHITELIST_DOMAIN" >> $SCRIPT_DIR/settings.env
fi
if is_set "WHITELIST_IP" "silent"; then
echo "export WHITELIST_IP=$WHITELIST_IP" >> $SCRIPT_DIR/settings.env
fi
echo "export WHITELIST_PORT=$WHITELIST_PORT" >> $SCRIPT_DIR/settings.env
fi

fi


41 changes: 0 additions & 41 deletions create-ssh-keys.sh

This file was deleted.

52 changes: 0 additions & 52 deletions create-ssh-tunnel.sh

This file was deleted.

7 changes: 2 additions & 5 deletions install-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ mkdir -p $LOG_DIR

# Update the current system
print_header "Updating the current system (this may take a while)"
sudo dnf update -y &>> $LOG_DIR/update-system.log
sudo apt update &>> $LOG_DIR/update-system.log
sudo apt upgrade -y &>> $LOG_DIR/update-system.log
print_step "System updated"

# Run the install-docker.sh script
print_header "Installing Docker"
source $SCRIPT_DIR/install-docker.sh

# Run the install-miniconda.sh script
print_header "Installing Miniconda"
source $SCRIPT_DIR/install-miniconda.sh
Expand Down
58 changes: 0 additions & 58 deletions install-docker.sh

This file was deleted.

7 changes: 7 additions & 0 deletions install-miniconda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ print_step "Checking if Miniconda is already installed"
if command -v conda &> /dev/null; then
print_warning "Miniconda is already installed." | tee -a $LOG_DIR/miniconda-install.log
else

print_step "Check that curl is installed"
if ! check_command "curl"; then
print_warning "Curl not installed. Installing Curl"
sudo apt install curl -y &>> $LOG_DIR/miniconda-install.log
fi

# Download the Miniconda installer script
print_step "Downloading the Miniconda installer script"
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh &>> $LOG_DIR/miniconda-install.log
Expand Down
2 changes: 0 additions & 2 deletions templates/docker-service.tpl

This file was deleted.

23 changes: 12 additions & 11 deletions templates/node-config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,24 @@ databases:
# uri: C:\data\datafile.csv
# type: csv

- label: omop
uri: jdbc:postgresql://${OMOP_HOST}:${OMOP_PORT}/${OMOP_DATABASE}
type: omop
- label: omop_api
uri: ${OMOP_API_PROTOCOL}://${OMOP_API_URI}:${OMOP_API_PORT}
type: other
# additional environment variables that are passed to the algorithm
# containers (or their wrapper). This can be used to for usernames
# and passwords for example. Note that these environment variables are
# only passed to the algorithm container when the user requests that
# database. In case you want to pass some environment variable to all
# algorithms regard less of the data source the user specifies you can
# use the `algorithm_env` setting.
env:
user: ${OMOP_USER}
password: ${OMOP_PASSWORD}
dbms: postgresql
cdm_database: ${OMOP_DATABASE}
cdm_schema: ${OMOP_CDM_SCHEMA}
results_schema: ${OMOP_RESULT_SCHEMA}
# env:
# user: ${OMOP_USER}
# password: ${OMOP_PASSWORD}
# dbms: postgresql
# cdm_database: ${OMOP_DATABASE}
# cdm_schema: ${OMOP_CDM_SCHEMA}
# results_schema: ${OMOP_RESULT_SCHEMA}



# end-to-end encryption settings
Expand Down Expand Up @@ -108,7 +109,7 @@ policies:
# username: docker-registry-user
# password: docker-registry-password

{{DATABASE_CONNECTION}}
{{WHITELIST}}

# # Whitelist URLs and/or IP addresses that the algorithm containers are
# # allowed to reach using the http protocol.
Expand Down
Loading

0 comments on commit f036ab1

Please sign in to comment.