commit 714bd3bd3b54754254f4d8cbd6ab351eb6013847 Author: João Pedro Agostinho de Sousa Date: Tue Jul 1 09:12:27 2025 +0200 First commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..bfed65e --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Installing CryoSPARC on Merlin 7 + +This repository contains the necessary scripts to install CryoSPARC on the Merlin 7 cluster. + +For the complete installation guide, please refer to the following page: +https://intranet.psi.ch/en/cls/cryosparc-merlin-7-installation diff --git a/scripts/configure_cryosparc_for_slurm.sh b/scripts/configure_cryosparc_for_slurm.sh new file mode 100755 index 0000000..bb584ee --- /dev/null +++ b/scripts/configure_cryosparc_for_slurm.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Check that CRYOSPARC_HOME is set and directory exists +if [ -z "$CRYOSPARC_HOME" ]; then + echo "Error: CRYOSPARC_HOME is not set." + return 1 +fi + +if [ ! -d "$CRYOSPARC_HOME" ]; then + echo "Error: CRYOSPARC_HOME directory '$CRYOSPARC_HOME' does not exist." + return 1 +fi + +cd "$CRYOSPARC_HOME" || { echo "Failed to change directory to $CRYOSPARC_HOME"; return 1; } + +echo "Cloning merlin7 branch of merlin-cryosparc into 'config' directory..." +if git clone -b merlin7 git@gitea.psi.ch:CLS-IT/merlin-cryosparc.git config; then + echo "Clone successful." +else + echo "Git clone failed." + return 1 +fi + +# Define remote host +remote_host="merlin7-cryosparc01.psi.ch" + +echo "Running install_filter on remote host..." +if ssh "$USER@$remote_host" install_filter; then + echo "install_filter command completed successfully." +else + echo "install_filter command failed." + return 1 +fi + +echo "Running connect_all on remote host..." +if ssh "$USER@$remote_host" connect_all; then + echo "connect_all command completed successfully." +else + echo "connect_all command failed." + return 1 +fi diff --git a/scripts/create_cryosparc_user.sh b/scripts/create_cryosparc_user.sh new file mode 100755 index 0000000..f4d59ac --- /dev/null +++ b/scripts/create_cryosparc_user.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# Define remote host +remote_host="merlin7-cryosparc01.psi.ch" + +echo "------------------------------------------------------------" +echo "CryoSPARC User Creation Script" +echo "This script will help you create a new CryoSPARC user on the" +echo "remote master node ($remote_host)." +echo "You will be prompted for the user's email, username, name," +echo "and password, and then asked to confirm before proceeding." +echo "------------------------------------------------------------" +echo + +# Prompt for inputs +read -rp "Enter your first name: " cryo_firstname +read -rp "Enter your last name: " cryo_lastname +read -rp "Enter your PSI email: " cryo_user_email +read -rp "Enter your CryoSPARC login username: " cryo_username +read -rsp "Enter your CryoSPARC password: " cryo_user_password +echo + +# Confirm user input +read -rp "Do you wish to proceed with user creation? (y/n): " confirm + +if [[ "$confirm" != [Yy]* ]]; then + echo "Aborted." + return 1 +fi + +# Execute createuser command on remote host +echo "Creating user on CryoSPARC at $remote_host..." +ssh "$USER@$remote_host" "cryosparcm createuser \ + --email '$cryo_user_email' \ + --password '$cryo_user_password' \ + --username '$cryo_username' \ + --firstname '$cryo_firstname' \ + --lastname '$cryo_lastname'" + +# Check if creation was successful +if [ $? -eq 0 ]; then + echo "✅ User '$cryo_username' created successfully." +else + echo "❌ Failed to create user." + return 1 +fi diff --git a/scripts/install_cryosparc_master.sh b/scripts/install_cryosparc_master.sh new file mode 100755 index 0000000..97f2b82 --- /dev/null +++ b/scripts/install_cryosparc_master.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +# Set CryoSPARC installation directory +CRYOSPARC_HOME="/data/user/$USER/cryosparc" + +# Check if CRYOSPARC_HOME already exists and is not empty +if [ -d "$CRYOSPARC_HOME" ] && [ "$(ls -A "$CRYOSPARC_HOME")" ]; then + echo "Warning: CryoSPARC home directory already exists at: $CRYOSPARC_HOME" + read -rp "Are you sure you want to overwrite it? [y/N]: " confirm + case "$confirm" in + [yY][eE][sS]|[yY]) + echo -e "\nProceeding with installation and overwriting existing directory." + ;; + *) + echo -e "\nInstallation aborted by user." + return 0 + ;; + esac +fi + +# Create CryoSPARC home directory +mkdir -p "$CRYOSPARC_HOME" +cd "$CRYOSPARC_HOME" || { echo "Failed to enter directory $CRYOSPARC_HOME"; return 1; } +echo "CryoSPARC home directory ready at: $CRYOSPARC_HOME" + +# Set and create temporary directory +export TMPDIR="/scratch/$USER" +mkdir -p "$TMPDIR" + +# Prompt for license ID +read -rp "Enter your CryoSPARC License ID: " CRYOSPARC_LICENSE_ID +if [ -z "$CRYOSPARC_LICENSE_ID" ]; then + echo "Error: License ID is required." + return 1 +fi + +# Prompt for base port +read -rp "Enter CryoSPARC base port: " CRYOSPARC_BASE_PORT +if ! [[ "$CRYOSPARC_BASE_PORT" =~ ^[0-9]+$ ]]; then + echo "Error: Port must be a number." + return 1 +fi + +# Download and extract CryoSPARC master package +echo "Downloading CryoSPARC master package..." +curl -L -o cryosparc_master.tar.gz "https://get.cryosparc.com/download/master-latest/$CRYOSPARC_LICENSE_ID" +if [ $? -ne 0 ]; then + echo "Download failed. Please check your license ID and internet connection." + return 1 +fi + +echo "Extracting CryoSPARC master package..." +tar -xf cryosparc_master.tar.gz && rm cryosparc_master.tar.gz +echo "CryoSPARC master package extracted." + +cd cryosparc_master || { echo "Failed to enter cryosparc_master directory"; return 1; } + +# Define remote host +remote_host="merlin7-cryosparc01.psi.ch" + +# Run installer +echo "Running CryoSPARC installer..." +./install.sh --license "$CRYOSPARC_LICENSE_ID" \ + --hostname "$remote_host" \ + --dbpath "$CRYOSPARC_HOME/database" \ + --port "$CRYOSPARC_BASE_PORT" + +# Start CryoSPARC master process +INSTALL_EXIT_CODE=$? +if [ $INSTALL_EXIT_CODE -eq 0 ]; then + echo "CryoSPARC installation completed successfully." + + echo "Attempting to start CryoSPARC master process on $remote_host..." + ssh "$USER@$remote_host" "cryosparcm start" + if [ $? -eq 0 ]; then + echo "CryoSPARC master process started successfully on $remote_host." + else + echo "Failed to start CryoSPARC master process on $remote_host." + fi +else + echo "CryoSPARC installation failed with exit code $INSTALL_EXIT_CODE. Not attempting to start master process." +fi diff --git a/scripts/install_cryosparc_worker.sh b/scripts/install_cryosparc_worker.sh new file mode 100755 index 0000000..29d3b80 --- /dev/null +++ b/scripts/install_cryosparc_worker.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Check CRYOSPARC_HOME +if [ -z "$CRYOSPARC_HOME" ]; then + echo "Error: CRYOSPARC_HOME is not set." + return 1 +fi + +cd "$CRYOSPARC_HOME" || { echo "Failed to enter directory $CRYOSPARC_HOME"; return 1; } + +# Check license ID +if [ -z "$CRYOSPARC_LICENSE_ID" ]; then + read -rp "Enter your CryoSPARC License ID: " CRYOSPARC_LICENSE_ID + if [ -z "$CRYOSPARC_LICENSE_ID" ]; then + echo "Error: License ID is required." + return 1 + fi +fi + +echo "Downloading CryoSPARC worker package..." +curl -L -o cryosparc_worker.tar.gz "https://get.cryosparc.com/download/worker-latest/$CRYOSPARC_LICENSE_ID" +if [ $? -ne 0 ]; then + echo "Download failed. Please check your license ID and internet connection." + return 1 +fi + +echo "Extracting CryoSPARC worker package..." +tar -xf cryosparc_worker.tar.gz || { echo "Failed to extract package."; return 1; } +rm cryosparc_worker.tar.gz +echo "Extraction complete." + +cd cryosparc_worker || { echo "Failed to enter cryosparc_worker directory"; return 1; } + +echo "Running CryoSPARC worker installer..." +./install.sh --license "$CRYOSPARC_LICENSE_ID" diff --git a/scripts/reset_cryosparc_password.sh b/scripts/reset_cryosparc_password.sh new file mode 100755 index 0000000..251526f --- /dev/null +++ b/scripts/reset_cryosparc_password.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Prompt for CryoSPARC email +read -rp "Enter your CryoSPARC email (e.g. your_email@psi.ch): " CRYO_EMAIL + +# Prompt for new password (hidden input) +read -rsp "Enter your new CryoSPARC password: " CRYO_PASSWORD +echo + +# Confirm before executing +echo "Resetting CryoSPARC password for: $CRYO_EMAIL" +read -rp "Are you sure you want to proceed? [y/N]: " confirm +case "$confirm" in + [yY][eE][sS]|[yY]) + ;; + *) + echo "Operation cancelled." + exit 1 + ;; +esac + +# Run the reset command over SSH +ssh "$USER@merlin7-cryosparc01.psi.ch" \ + "cryosparcm resetpassword --email '$CRYO_EMAIL' --password '$CRYO_PASSWORD'" + +# Check result +if [ $? -eq 0 ]; then + echo "✅ Password reset successfully." +else + echo "❌ Failed to reset password. Please check your inputs and try again." +fi