Ubuntu install script #289

Merged
telackey merged 8 commits from dboreham/ubuntu-install-script into main 2023-04-06 19:50:51 +00:00
2 changed files with 55 additions and 21 deletions
Showing only changes of commit ab4b66060e - Show all commits

View File

@ -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

View File

@ -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