Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPEN-23 : Request User Permission for Package Installations #17

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,45 +121,45 @@ echo "The base directory is set to: $input"
NODEHOME="${input/#\~/$HOME}" # support ~ in path

# Check all things that will be needed for this script to succeed like access to docker and docker-compose
# If any check fails, attempt to install the missing dependency
command -v git >/dev/null 2>&1 || {
echo >&2 "'git' is not installed. Attempting to install git..."
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get update && sudo apt-get install -y git
elif command -v yum >/dev/null 2>&1; then
sudo yum install -y git
else
echo >&2 "Unable to install git. Please install it manually."
exit 1
# If any check fails exit with a message on what the user needs to do to fix the problem
check_and_install() {
if ! command -v $1 &>/dev/null; then
read -p "$1 is not installed. Do you want to install it? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
case $1 in
git)
sudo apt-get update && sudo apt-get install -y git || sudo yum install -y git
;;
docker)
curl -fsSL https://get.docker.com | sudo sh
sudo usermod -aG docker $USER
;;
docker-compose)
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
;;
esac
else
echo "$1 is required but not installed. Exiting."
exit 1
fi
fi
}

command -v docker >/dev/null 2>&1 || {
echo >&2 "'docker' is not installed. Attempting to install docker..."
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
rm get-docker.sh
}
# Check and install required components
check_and_install git
check_and_install docker
check_and_install docker-compose

# Verify Docker Compose installation
if ! command -v docker-compose &>/dev/null && ! docker --help | grep -q "compose"; then
echo "docker-compose or docker compose is not installed. Attempting to install docker-compose..."
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
fi

# Verify installations
command -v git >/dev/null 2>&1 || { echo >&2 "Failed to install git. Please install it manually."; exit 1; }
command -v docker >/dev/null 2>&1 || { echo >&2 "Failed to install docker. Please install it manually."; exit 1; }
if command -v docker-compose &>/dev/null; then
echo "docker-compose is installed on this machine"
elif docker --help | grep -q "compose"; then
echo "docker compose subcommand is installed on this machine"
else
echo "Failed to install docker-compose. Please install it manually."
echo "docker-compose or docker compose is not installed. Please install it manually."
exit 1
fi

echo "All required packages are installed."

export DOCKER_DEFAULT_PLATFORM=linux/amd64

docker-safe() {
Expand Down