-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a lot of robustness features to the scripts
- Loading branch information
1 parent
3a736c8
commit 05269fc
Showing
10 changed files
with
560 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#! /bin/bash | ||
|
||
source ./utils.sh | ||
|
||
# Create config dir | ||
print_step "Creating config dir" | ||
mkdir -p ~/.config | ||
|
||
# Create config file | ||
print_step "Creating config file" | ||
echo " - Please enter the API key:" | ||
read API_KEY | ||
|
||
# vantage6 node settings | ||
export API_KEY=$API_KEY | ||
export TASK_DIR=$HOME/tasks | ||
|
||
mkdir -p $TASK_DIR | ||
|
||
# OMOP settings | ||
export OMOP_HOST="omop" | ||
export OMOP_PORT=5432 | ||
|
||
# TODO @biomeris which settings? | ||
export OMOP_DATABASE="postgres" | ||
export OMOP_USER="postgres" | ||
export OMOP_PASSWORD="postgres" | ||
export OMOP_CDM_SCHEMA="cmd" | ||
export OMOP_RESULT_SCHEMA="result" | ||
|
||
# Check if the vantage6-node user already exists | ||
print_step "Checking if the vantage6-node user already exists" | ||
NEW_USER="vantage6-node" | ||
if id -u "vantage6-node" >/dev/null 2>&1; then | ||
print_step "The vantage6-node user already exists" | ||
else | ||
print_step "Creating new user" | ||
sudo useradd $NEW_USER | ||
|
||
# Set password for the new user | ||
PASSWORD=$(openssl rand -base64 16) | ||
echo $PASSWORD | sudo passwd --stdin $NEW_USER | ||
fi | ||
|
||
|
||
print_step "Executing some steps as the $NEW_USER user" | ||
# Run the create_ssh_key.sh script as the new user | ||
# sudo -u $NEW_USER bash -c "./create_ssh_user.sh" | tee /dev/stdout | ||
print_step "Changing back to the original user" | ||
|
||
# Tunnel settings | ||
print_step "Setting tunnel settings" | ||
# export TUNNEL_HOSTNAME=$OMOP_HOST | ||
# export SSH_HOST=$(hostname -I | awk '{print $1}') | ||
# print_step "SSH_HOST: $SSH_HOST" | ||
# export SHH_PORT=22 | ||
# export SSH_HOST_FINGERPRINT=$(cat /etc/ssh/ssh_host_rsa_key.pub) | ||
|
||
# export SSH_USERNAME=$NEW_USER | ||
# export SSH_KEY=$PRIVATE_KEY_FILE | ||
|
||
# export TUNNEL_BIND_IP="0.0.0.0" | ||
# export TUNNEL_BIND_PORT=$OMOP_PORT | ||
|
||
# export TUNNEL_REMOTE_IP="127.0.0.1" | ||
# export TUNNEL_REMOTE_PORT=5432 | ||
|
||
# # Create the config file | ||
print_step "Creating the config file" | ||
# print_step $USER | ||
# mkdir -p ~/.config/vantage6/node | ||
# envsubst < ./v6-blueberry-installation-scripts/node.tpl > $HOME/.config/vantage6/node/blueberry.yml | ||
# cat << EOF > ~/.config/vantage6/node/config.yml | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# Switch to the new user's home directory | ||
cd ~ | ||
|
||
# Generate a new SSH key pair | ||
echo "Generating a new SSH key pair" | ||
mkdir -p ~/.ssh | ||
PRIVATE_KEY_FILE="~/.ssh/id_rsa" | ||
ssh-keygen -t rsa -b 4096 -f $PRIVATE_KEY_FILE -N "" | ||
|
||
# Add the public key to the authorized_keys file | ||
echo "Adding the public key to the authorized_keys file" | ||
PUBLIC_KEY=$(cat $PRIVATE_KEY_FILE.pub) | ||
touch ~/.ssh/authorized_keys | ||
echo $PUBLIC_KEY >> ~/.ssh/authorized_keys | ||
|
||
# Set the correct permissions | ||
echo "Setting the correct permissions" | ||
chmod 700 ~/.ssh | ||
chmod 600 ~/.ssh/authorized_keys | ||
chmod 600 ~/.ssh/id_rsa | ||
chmod 644 ~/.ssh/id_rsa.pub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,27 @@ | ||
#!/bin/bash | ||
|
||
source ./utils.sh | ||
print_intro | ||
confirm_or_exit | ||
|
||
# Update the current system | ||
print_header "Updating the current system" | ||
sudo dnf update -y &>> update-system.log | ||
|
||
# Run the install-docker.sh script | ||
bash install-docker.sh | ||
print_header "Installing Docker" | ||
source ./install-docker.sh | ||
|
||
# Run the install-miniconda.sh script | ||
bash install-miniconda.sh | ||
print_header "Installing Miniconda" | ||
source ./install-miniconda.sh | ||
|
||
# Run the install-vantage6.sh script | ||
bash install-vantage6.sh | ||
print_header "Installing vantage6" | ||
source ./install-vantage6.sh | ||
|
||
# Configure the vantage6-node | ||
print_header "Creating vantage6-node" | ||
source ./create-node.sh | ||
|
||
print_outro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,51 @@ | ||
#!/bin/bash | ||
|
||
# Print the current time and user | ||
echo "Current time: $(date)" &>> docker-install.log | ||
echo "Current user: $(whoami)" &>> docker-install.log | ||
|
||
# Update the apt package index | ||
sudo yum update -y &>> docker-install.log | ||
|
||
# Install necessary packages | ||
sudo yum install -y yum-utils &>> docker-install.log | ||
|
||
# Set up the stable repository | ||
sudo yum-config-manager --add-repo https://download.docker.com/linux/oracle/docker-ce.repo &>> docker-install.log | ||
|
||
# Install the latest version of Docker Engine and containerd | ||
sudo yum install -y docker-ce docker-ce-cli containerd.io &>> docker-install.log | ||
|
||
# Start Docker | ||
sudo systemctl start docker &>> docker-install.log | ||
|
||
# Enable Docker to start on boot | ||
sudo systemctl enable docker &>> docker-install.log | ||
|
||
# Add the current user to the docker group | ||
sudo usermod -aG docker $USER &>> docker-install.log | ||
|
||
# Apply the new group membership to the current session | ||
newgrp docker &>> docker-install.log | ||
source ./utils.sh | ||
print_info &>> docker-install.log | ||
|
||
print_step "Checking if Docker is already installed" | ||
if command -v docker &> /dev/null | ||
then | ||
print_step "Docker is already installed" | tee -a docker-install.log | ||
else | ||
|
||
# Update the apt package index | ||
print_step "Updating the current system" | ||
sudo dnf update -y &>> docker-install.log | ||
|
||
# Install necessary packages | ||
print_step "Installing necessary packages" | ||
sudo dnf install -y dnf-utils &>> docker-install.log | ||
|
||
# Set up the stable repository | ||
print_step "Setting up the stable repository" | ||
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo &>> docker-install.log | ||
|
||
# Install the latest version of Docker Engine and containerd | ||
print_step "Installing Docker" | ||
sudo dnf install docker-ce --nobest -y &>> docker-install.log | ||
|
||
# Start Docker | ||
print_step "Starting Docker" | ||
|
||
# Enable Docker to start on boot | ||
print_step "Enabling Docker to start on boot & start Docker" | ||
if command -v systemctl &> /dev/null | ||
then | ||
sudo systemctl enable docker &>> docker-install.log | ||
sudo systemctl start docker | ||
else | ||
print_warning "Systemctl not found, are you testing?" | ||
print_warning "If not, docker will not start automatically on boot" | ||
sudo service docker start | ||
fi | ||
|
||
# Add the current user to the docker group | ||
print_step "Adding the current user '$USER' to the docker group" | ||
sudo usermod -aG docker $USER &>> docker-install.log | ||
|
||
# Apply the new group membership to the current session | ||
print_step "Applying the new group membership to the current session" | ||
newgrp docker &>> docker-install.log | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# Print the current time and user | ||
echo "Current time: $(date)" &>> miniconda-install.log | ||
echo "Current user: $(whoami)" &>> miniconda-install.log | ||
source ./utils.sh | ||
print_info &>> miniconda-install.log | ||
|
||
# Download the Miniconda installer script | ||
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh &>> miniconda-install.log | ||
# Check if Miniconda is already installed | ||
print_step "Checking if Miniconda is already installed" | ||
if command -v conda &> /dev/null; then | ||
print_step "Miniconda is already installed." | tee -a miniconda-install.log | ||
else | ||
# 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 &>> miniconda-install.log | ||
|
||
# Run the installer script | ||
bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda &>> miniconda-install.log | ||
# Run the installer script | ||
print_step "Running the Miniconda installer script" | ||
bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda &>> miniconda-install.log | ||
|
||
# Initialize Miniconda to automatically update the PATH | ||
$HOME/miniconda/bin/conda init &>> miniconda-install.log | ||
# Initialize Miniconda to automatically update the PATH | ||
print_step "Initializing Miniconda to automatically update the PATH" | ||
$HOME/miniconda/bin/conda init &>> miniconda-install.log | ||
|
||
# Activate the base environment | ||
print_step "Activating the base environment" | ||
source ~/.bashrc | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,44 @@ | ||
# Create a new conda environment with Python 3.10 | ||
$HOME/miniconda/bin/conda create -n vantage6 python=3.10 -y &>> vantage6-install.log | ||
#!/bin/bash | ||
|
||
# Print the current time and user | ||
source ./utils.sh | ||
print_info &>> vantage6-install.log | ||
|
||
# Check if the vantage6 environment already exists | ||
print_step "Checking if the vantage6 environment already exists" | ||
if conda env list | grep -q 'vantage6' | ||
then | ||
print_step "The vantage6 environment already exists" | tee -a vantage6-install.log | ||
else | ||
# Create a new conda environment with Python 3.10 | ||
print_step "Creating a new conda environment with Python 3.10" | ||
conda create -n vantage6 python=3.10 -y &>> vantage6-install.log | ||
fi | ||
|
||
# Activate the new environment | ||
$HOME/miniconda/bin/activate vantage6 &>> vantage6-install.log | ||
print_step "Activating the (new) environment" | ||
conda activate vantage6 &>> vantage6-install.log | ||
|
||
# Install the vantage6 package | ||
pip install vantage6 &>> vantage6-install.log | ||
print_step "Checking if the vantage6 package is already installed" | ||
if pip freeze | grep -q 'vantage6==' | ||
then | ||
# Print the version of the vantage6 package | ||
print_step "The vantage6 package is already installed" | tee -a vantage6-install.log | ||
vantage6_version=$(pip show vantage6 | grep Version | cut -d ' ' -f 2) | ||
print_step "vantage6 version: $vantage6_version" | tee -a vantage6-install.log | ||
|
||
# Ask for confirmation to upgrade the vantage6 package | ||
if confirm "Do you want to try to upgrade the vantage6 package?" | ||
then | ||
print_step "Upgrading the vantage6 package" | ||
pip install --upgrade vantage6 &>> vantage6-install.log | ||
fi | ||
else | ||
# Install the vantage6 package | ||
print_step "Installing the vantage6 package" | ||
pip install vantage6 &>> vantage6-install.log | ||
fi | ||
|
||
vantage6_version=$(pip show vantage6 | grep Version | cut -d ' ' -f 2) | ||
print_step "vantage6 version: $vantage6_version" | tee -a vantage6-install.log |
Oops, something went wrong.