From abffede3ed693e664f32968eefa1154f279f017a Mon Sep 17 00:00:00 2001 From: Wilfred Tyler Gee Date: Tue, 19 Nov 2024 10:06:38 -1000 Subject: [PATCH] More consistency with the PANUSER and PANDIR. --- resources/scripts/install-conda.sh | 4 ++-- resources/scripts/install-pocs.sh | 8 ++++++-- resources/scripts/install-services.sh | 9 ++++----- resources/scripts/install-system-deps.sh | 12 ++++++------ resources/scripts/install-zsh.sh | 4 ++-- resources/scripts/install.sh | 2 +- resources/scripts/setup-user.sh | 2 -- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/resources/scripts/install-conda.sh b/resources/scripts/install-conda.sh index 77a536121..a0421976b 100644 --- a/resources/scripts/install-conda.sh +++ b/resources/scripts/install-conda.sh @@ -2,6 +2,7 @@ CONDA_URL="https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-$(uname -m).sh" CONDA_ENV_NAME=conda-pocs +PANDIR="${PANDIR:-${HOME}/POCS}" function install_conda() { echo "Installing miniforge conda" @@ -11,7 +12,6 @@ function install_conda() { rm install-miniforge.sh source "${HOME}/conda/etc/profile.d/conda.sh" - source "${HOME}/conda/etc/profile.d/mamba.sh" # Initialize conda for the shells. "${HOME}/conda/bin/conda" init bash zsh @@ -22,7 +22,7 @@ function install_conda() { # Activate by default echo "conda activate ${CONDA_ENV_NAME}" >>"${HOME}/.zshrc" - "${HOME}/conda/bin/mamba" env update -p "${HOME}/conda/envs/${CONDA_ENV_NAME}" -f environment.yaml + "${HOME}/conda/bin/conda" env update -p "${HOME}/conda/envs/${CONDA_ENV_NAME}" -f "${PANDIR}/environment.yaml" } install_conda diff --git a/resources/scripts/install-pocs.sh b/resources/scripts/install-pocs.sh index 1af6202eb..04fb46509 100644 --- a/resources/scripts/install-pocs.sh +++ b/resources/scripts/install-pocs.sh @@ -1,12 +1,16 @@ #!/usr/bin/env bash CODE_BRANCH=${CODE_BRANCH:-"develop"} -PANUSER="${PANUSER:-$USER}" PANDIR="${PANDIR:-${HOME}/POCS}" function get_pocs_repo() { - echo "Cloning POCS repo." + # Check if PANDIR exists and if not, clone. + if [ -d "${PANDIR}" ]; then + echo "POCS repo already exists." + return + fi + echo "Cloning POCS repo." git clone https://github.com/panoptes/POCS "${PANDIR}" cd "${PANDIR}" git checkout "${CODE_BRANCH}" diff --git a/resources/scripts/install-services.sh b/resources/scripts/install-services.sh index 06e30dd6f..62cdaf59e 100644 --- a/resources/scripts/install-services.sh +++ b/resources/scripts/install-services.sh @@ -1,13 +1,12 @@ #!/usr/bin/env bash -PANUSER="${PANUSER:-$USER}" -PANDIR="${PANDIR:-${HOME}/pocs}" +PANUSER="${PANUSER:-panoptes}" function install_services() { echo "Installing supervisor services." # Make supervisor read our conf file at its current location. - echo "files = ${HOME}/conf_files/pocs-supervisord.conf" | sudo tee -a /etc/supervisor/supervisord.conf + echo "files = ${HOME}/conf_files/pocs-supervisord.conf" | tee -a /etc/supervisor/supervisord.conf # Change the user and home directory. sed -i "s/chown=panoptes:panoptes/chown=${PANUSER}:${PANUSER}/g" "${HOME}/conf_files/pocs-supervisord.conf" @@ -15,8 +14,8 @@ function install_services() { sed -i "s|/home/panoptes|${HOME}|g" "${HOME}/conf_files/pocs-supervisord.conf" # Reread the supervisord conf and restart. - sudo supervisorctl reread - sudo supervisorctl update + supervisorctl reread + supervisorctl update } install_services diff --git a/resources/scripts/install-system-deps.sh b/resources/scripts/install-system-deps.sh index a9f9c0034..7063dab82 100644 --- a/resources/scripts/install-system-deps.sh +++ b/resources/scripts/install-system-deps.sh @@ -4,14 +4,14 @@ function system_deps() { echo "Installing system dependencies." # Set up passwordless sudo for all sudo group. - echo "%sudo ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/panoptes + echo "%sudo ALL=(ALL) NOPASSWD: ALL" | tee /etc/sudoers.d/panoptes # Clean up problems. - sudo apt-get -y -qq purge needrestart - sudo apt-get update --fix-missing -y -qq - sudo apt-get -y -qq full-upgrade + apt-get -y -qq purge needrestart + apt-get update --fix-missing -y -qq + apt-get -y -qq full-upgrade - sudo apt-get -y -qq install \ + apt-get -y -qq install \ ack \ astrometry.net \ astrometry-data-tycho2-10-19 \ @@ -33,7 +33,7 @@ function system_deps() { supervisor \ wget \ zsh - sudo apt-get -y -qq autoremove + apt-get -y -qq autoremove } system_deps diff --git a/resources/scripts/install-zsh.sh b/resources/scripts/install-zsh.sh index 0cbbbaef5..ac4e27b38 100644 --- a/resources/scripts/install-zsh.sh +++ b/resources/scripts/install-zsh.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -PANUSER="${PANUSER:-$USER}" -PANDIR="${PANDIR:-${HOME}/pocs}" +PANUSER="${PANUSER:-panoptes}" +PANDIR="${PANDIR:-${HOME}/POCS}" function install_zsh() { if [ ! -d "$ZSH_CUSTOM" ]; then diff --git a/resources/scripts/install.sh b/resources/scripts/install.sh index c0702db6e..77e95f86d 100644 --- a/resources/scripts/install.sh +++ b/resources/scripts/install.sh @@ -2,8 +2,8 @@ set -e echo "Installing POCS" +source ./install-pocs.sh source ./install-system-deps.sh source ./install-conda.sh -source ./install-pocs.sh source ./install-zsh.sh source ./install-services.sh diff --git a/resources/scripts/setup-user.sh b/resources/scripts/setup-user.sh index ee6756f62..274bdc2c0 100644 --- a/resources/scripts/setup-user.sh +++ b/resources/scripts/setup-user.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash -PANUSER="${PANUSER:-$USER}" - function setup_user() { # Add an SSH key if one doesn't exist. if [[ ! -f "${HOME}/.ssh/id_rsa" ]]; then