From ab4b66060eace34f7da5fe756b318bd27a09fac7 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Wed, 5 Apr 2023 21:23:42 -0600 Subject: [PATCH] Update scripts --- scripts/first_time_setup.sh | 11 ++++-- scripts/quick-install-ubuntu.sh | 65 ++++++++++++++++++++++++--------- 2 files changed, 55 insertions(+), 21 deletions(-) diff --git a/scripts/first_time_setup.sh b/scripts/first_time_setup.sh index e8900ce7..997c6173 100755 --- a/scripts/first_time_setup.sh +++ b/scripts/first_time_setup.sh @@ -1,8 +1,11 @@ -#!/bin/bash - +#!/usr/bin/env bash +# Script to automate the steps needed to make a cloned project repo runnable on the path +# (beware of PATH having some other file with the same name ahead of ours) +if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then + set -x + echo PATH is $PATH +fi python3 -m venv venv source ./venv/bin/activate pip install --editable . pip install shiv -shiv -c laconic-so -o laconic-so . -./laconic-so --verbose --local-stack setup-repositories diff --git a/scripts/quick-install-ubuntu.sh b/scripts/quick-install-ubuntu.sh index 293b3f59..c317bdb7 100755 --- a/scripts/quick-install-ubuntu.sh +++ b/scripts/quick-install-ubuntu.sh @@ -5,9 +5,29 @@ fi install_dir=~/bin +# First display a reasonable warning to the user unless run with -y +if ! [[ $# -eq 1 && $1 == "-y" ]]; then + echo "**************************************************************************************" + echo "This script installs Laconic Stack Orchestrator into: ${install_dir}" + echo "It also *removes* any existing docker installed on this machine then installs" + echo "the latest docker release as well as other required packages." + echo "Only proceed if you are sure you want to make those changes to this machine." + echo "**************************************************************************************" + read -p "Are you sure you want to proceed? " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]] + then + exit 1 + fi +fi + # This script assumes root permissions on a fresh Ubuntu Digital Ocean droplet # with these recommended specs: 16 GB Memory / 8 Intel vCPUs / 320 GB Disk +# TODO: +# Check python3 is available +# Check machine resources are sufficient + # dismiss the popups export DEBIAN_FRONTEND=noninteractive @@ -25,8 +45,12 @@ done # Enable stop on error now, since we needed it off for the code above set -euo pipefail ## https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +echo "**************************************************************************************" +echo "Removing existing docker packages" sudo apt -y remove $installed_packages_to_remove +echo "**************************************************************************************" +echo "Installing dependencies" sudo apt -y update # laconic-so depends on jq @@ -49,37 +73,44 @@ echo \ # Penny in the update jar sudo apt -y update -# Install docker +echo "**************************************************************************************" +echo "Installing docker sudo apt -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin # Allow the current user to use Docker sudo usermod -aG docker $USER +echo "**************************************************************************************" +echo "Installing laconic-so # install latest `laconic-so` install_filename=${install_dir}/laconic-so mkdir -p ${install_dir} curl -L -o ${install_filename} https://github.com/cerc-io/stack-orchestrator/releases/latest/download/laconic-so chmod +x ${install_filename} -# set here for this script +echo "**************************************************************************************" +# Check if our PATH line is already there +path_add_command="export PATH=\$PATH:${install_dir}" +if ! grep -q "${path_add_command}" ~/.profile +then + echo "Adding this line to the end of ~/.profile:" + echo ${path_add_command} + echo ${path_add_command} >> ~/.profile +fi + +# PATH set here for commands run in this script export PATH=$PATH:${install_dir} +echo Installed laconic-so version: $(laconic-so version) -# added to profile, manually running `source ~/.profile` is then required -echo "Adding this to ~/.profile: export PATH=$PATH:${install_dir}" -echo "export PATH=$PATH:${install_dir}" >> ~/.profile - -# TODO: run this manually again after the script ends -# source ~/.profile - -# verify operation -laconic-so version - -echo "The Laconic Stack Orchestrator program has been installed at ${install_filename}" +echo "**************************************************************************************" +echo "The Laconic Stack Orchestrator program laconic-so has been installed at ${install_filename}" echo "The directory ${install_dir} has been added to PATH in new shells via ~/.profile" echo "Either open a new shell to use laconic-so on the PATH, or run this command in this shell:" -echo "export PATH=$PATH:${install_dir}" - +echo "export PATH=\$PATH:${install_dir}" +echo "**************************************************************************************" # Message the user to check docker is working for them -echo "Please test that docker installed correctly by running this command:" +echo "Please test that docker is correctly installed and working for your user by running the" +echo "command below (it should print a message beginning \"Hello from Docker!\"):" +echo echo "docker run hello-world" - +echo