83 lines
2.7 KiB
Bash
Executable File
83 lines
2.7 KiB
Bash
Executable File
#!/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
|