Skip to content

Commit

Permalink
Remove from functions so just scripts run.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtgee committed Nov 19, 2024
1 parent abffede commit 1b191ab
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 77 deletions.
28 changes: 12 additions & 16 deletions resources/scripts/install-conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
45 changes: 19 additions & 26 deletions resources/scripts/install-pocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
2 changes: 1 addition & 1 deletion resources/scripts/install-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
64 changes: 31 additions & 33 deletions resources/scripts/install-system-deps.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion resources/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions resources/scripts/setup-user.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 1b191ab

Please sign in to comment.