From 1b191abc9b166a96eb02d781f96b0b1d2c6865e6 Mon Sep 17 00:00:00 2001 From: Wilfred Tyler Gee Date: Tue, 19 Nov 2024 12:44:46 -1000 Subject: [PATCH] Remove from functions so just scripts run. --- resources/scripts/install-conda.sh | 28 +++++------ resources/scripts/install-pocs.sh | 45 +++++++---------- resources/scripts/install-services.sh | 2 +- resources/scripts/install-system-deps.sh | 64 ++++++++++++------------ resources/scripts/install.sh | 2 +- resources/scripts/setup-user.sh | 3 ++ 6 files changed, 67 insertions(+), 77 deletions(-) diff --git a/resources/scripts/install-conda.sh b/resources/scripts/install-conda.sh index a0421976b..d92b0ab30 100644 --- a/resources/scripts/install-conda.sh +++ b/resources/scripts/install-conda.sh @@ -4,25 +4,21 @@ CONDA_URL="https://github.com/conda-forge/miniforge/releases/latest/download/Min CONDA_ENV_NAME=conda-pocs PANDIR="${PANDIR:-${HOME}/POCS}" -function install_conda() { - echo "Installing miniforge conda" +echo "Installing miniforge conda" - wget -q "${CONDA_URL}" -O install-miniforge.sh - /bin/sh install-miniforge.sh -b -f -p "${HOME}/conda" - rm install-miniforge.sh +wget -q "${CONDA_URL}" -O install-miniforge.sh +/bin/sh install-miniforge.sh -b -f -p "${HOME}/conda" +rm install-miniforge.sh - source "${HOME}/conda/etc/profile.d/conda.sh" +source "${HOME}/conda/etc/profile.d/conda.sh" - # Initialize conda for the shells. - "${HOME}/conda/bin/conda" init bash zsh +# Initialize conda for the shells. +"${HOME}/conda/bin/conda" init bash zsh - echo "Creating POCS conda environment" - "${HOME}/conda/bin/conda" create -y -q -n "${CONDA_ENV_NAME}" python=3 +echo "Creating POCS conda environment" +"${HOME}/conda/bin/conda" create -y -q -n "${CONDA_ENV_NAME}" python=3 - # Activate by default - echo "conda activate ${CONDA_ENV_NAME}" >>"${HOME}/.zshrc" +# Activate by default +echo "conda activate ${CONDA_ENV_NAME}" >>"${HOME}/.zshrc" - "${HOME}/conda/bin/conda" env update -p "${HOME}/conda/envs/${CONDA_ENV_NAME}" -f "${PANDIR}/environment.yaml" -} - -install_conda +"${HOME}/conda/bin/conda" env update -p "${HOME}/conda/envs/${CONDA_ENV_NAME}" -f "${PANDIR}/environment.yaml" diff --git a/resources/scripts/install-pocs.sh b/resources/scripts/install-pocs.sh index 04fb46509..92ba28f7c 100644 --- a/resources/scripts/install-pocs.sh +++ b/resources/scripts/install-pocs.sh @@ -3,32 +3,25 @@ CODE_BRANCH=${CODE_BRANCH:-"develop"} PANDIR="${PANDIR:-${HOME}/POCS}" -function get_pocs_repo() { - # Check if PANDIR exists and if not, clone. - if [ -d "${PANDIR}" ]; then - echo "POCS repo already exists." - return - fi +# 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}" - cd -} +echo "Cloning POCS repo." +git clone https://github.com/panoptes/POCS "${PANDIR}" +cd "${PANDIR}" +git checkout "${CODE_BRANCH}" +cd -function make_directories() { - echo "Creating directories." - mkdir -p "${HOME}/logs" - mkdir -p "${HOME}/images" - mkdir -p "${HOME}/json_store" - mkdir -p "${HOME}/keys" +echo "Creating POCS directories." +mkdir -p "${HOME}/logs" +mkdir -p "${HOME}/images" +mkdir -p "${HOME}/json_store" +mkdir -p "${HOME}/keys" - # Link the needed POCS folders. - ln -s "${PANDIR}/conf_files" "${HOME}" - ln -s "${PANDIR}/resources" "${HOME}" - ln -s "${PANDIR}/notebooks" "${HOME}" -} - -get_pocs_repo -make_directories +# Link the needed POCS folders. +ln -s "${PANDIR}/conf_files" "${HOME}" +ln -s "${PANDIR}/resources" "${HOME}" +ln -s "${PANDIR}/notebooks" "${HOME}" diff --git a/resources/scripts/install-services.sh b/resources/scripts/install-services.sh index 62cdaf59e..808a2c388 100644 --- a/resources/scripts/install-services.sh +++ b/resources/scripts/install-services.sh @@ -6,7 +6,7 @@ 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" | tee -a /etc/supervisor/supervisord.conf + echo "files = ${HOME}/conf_files/pocs-supervisord.conf" | sudo 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" diff --git a/resources/scripts/install-system-deps.sh b/resources/scripts/install-system-deps.sh index 7063dab82..3f7aa1eed 100644 --- a/resources/scripts/install-system-deps.sh +++ b/resources/scripts/install-system-deps.sh @@ -1,39 +1,37 @@ #!/usr/bin/env bash -function system_deps() { - echo "Installing system dependencies." +echo "Installing system dependencies." - # Set up passwordless sudo for all sudo group. - echo "%sudo ALL=(ALL) NOPASSWD: ALL" | tee /etc/sudoers.d/panoptes +# Clean up problems. +apt-get update --fix-missing -y - # Clean up problems. - apt-get -y -qq purge needrestart - apt-get update --fix-missing -y -qq - apt-get -y -qq full-upgrade +# Upgrade. +apt-get -y full-upgrade - apt-get -y -qq install \ - ack \ - astrometry.net \ - astrometry-data-tycho2-10-19 \ - byobu \ - curl \ - dcraw \ - exiftool \ - fonts-powerline \ - gcc \ - gphoto2 \ - htop \ - httpie \ - jo \ - jq \ - libcfitsio-bin \ - make \ - nano \ - vim-nox \ - supervisor \ - wget \ - zsh - apt-get -y -qq autoremove -} +apt-get -y install \ + ack \ + astrometry.net \ + astrometry-data-tycho2-10-19 \ + byobu \ + curl \ + dcraw \ + exiftool \ + fonts-powerline \ + gcc \ + git \ + gphoto2 \ + htop \ + httpie \ + jo \ + jq \ + libcfitsio-bin \ + make \ + nano \ + python3 \ + python3-pip \ + supervisor \ + vim-nox \ + wget \ + zsh -system_deps +apt-get -y autoremove diff --git a/resources/scripts/install.sh b/resources/scripts/install.sh index 77e95f86d..116ab00b5 100644 --- a/resources/scripts/install.sh +++ b/resources/scripts/install.sh @@ -2,8 +2,8 @@ set -e echo "Installing POCS" +sudo /bin/bash install-system-deps.sh source ./install-pocs.sh -source ./install-system-deps.sh source ./install-conda.sh source ./install-zsh.sh source ./install-services.sh diff --git a/resources/scripts/setup-user.sh b/resources/scripts/setup-user.sh index 274bdc2c0..387fa6396 100644 --- a/resources/scripts/setup-user.sh +++ b/resources/scripts/setup-user.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash function setup_user() { + # Set up passwordless sudo for all sudo group. + echo "%sudo ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/panoptes + # Add an SSH key if one doesn't exist. if [[ ! -f "${HOME}/.ssh/id_rsa" ]]; then echo "Adding ssh key"