Files
merlin-cryosparc-installation/scripts/create_cryosparc_user.sh

47 lines
1.4 KiB
Bash
Executable File

#!/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