From 563f1c1d32436503a39db8fa8f1880998d289b90 Mon Sep 17 00:00:00 2001 From: Ashley Kleynhans Date: Wed, 24 Aug 2022 20:18:47 +0200 Subject: [PATCH] fix(install): Fixed various bugs in the Debian installation scripts (#1967) --- .../local/debian/LocalDebianRedisService.java | 2 +- .../src/main/resources/debian/init.sh | 22 +- .../src/main/resources/debian/install.sh | 68 ++---- .../src/main/resources/debian/pre-bake.sh | 43 +--- .../main/resources/services/redis/install.sh | 3 +- install/Installer.sh | 157 +++---------- install/debian/InstallHalyard.sh | 209 ++++-------------- 7 files changed, 97 insertions(+), 407 deletions(-) diff --git a/halyard-deploy/src/main/java/com/netflix/spinnaker/halyard/deploy/spinnaker/v1/service/local/debian/LocalDebianRedisService.java b/halyard-deploy/src/main/java/com/netflix/spinnaker/halyard/deploy/spinnaker/v1/service/local/debian/LocalDebianRedisService.java index f2303c8e98..ee6aa70afb 100644 --- a/halyard-deploy/src/main/java/com/netflix/spinnaker/halyard/deploy/spinnaker/v1/service/local/debian/LocalDebianRedisService.java +++ b/halyard-deploy/src/main/java/com/netflix/spinnaker/halyard/deploy/spinnaker/v1/service/local/debian/LocalDebianRedisService.java @@ -54,7 +54,7 @@ LogCollector getLocalLogCollector() { @Override public String installArtifactCommand(DeploymentDetails deploymentDetails) { - return "apt-get -q -y --force-yes install redis-server && (systemctl start redis-server.service || true)"; + return "apt-get -q -y --allow-unauthenticated --allow-downgrades --allow-remove-essential --allow-change-held-packages install redis-server && (systemctl start redis-server.service || true)"; } @Override diff --git a/halyard-deploy/src/main/resources/debian/init.sh b/halyard-deploy/src/main/resources/debian/init.sh index d4812ce4e8..015fedbb69 100644 --- a/halyard-deploy/src/main/resources/debian/init.sh +++ b/halyard-deploy/src/main/resources/debian/init.sh @@ -1,23 +1,4 @@ -source /etc/os-release - -if [ "$VERSION_ID" = "14.04" ]; then - cat > /etc/init/spinnaker.conf < /lib/systemd/system/spinnaker.service < /lib/systemd/system/spinnaker.service < /dev/null -} - -function add_java_apt_repository() { - # Only Ubuntu prior to 18.04 LTS requires this PPA - if [ "${DISTRIB_RELEASE%%.*}" -lt "18" ]; then - echo "Adding Java PPA repository for Ubuntu version less than 18.04" - add-apt-repository -y ppa:openjdk-r/ppa - fi -} - -function install_java() { - set +e - local java_version=$(java -version 2>&1 head -1) - set -e - - if [[ "$java_version" == *11.0* ]]; then - echo "Java dependency is already installed" - return 0; + # Most probably not required since the repo would already + # need to exist in order to install the spinnaker-halyard + # package in the first place. + if [ ! -f /etc/apt/sources.list.d/spinnaker.list ]; then + echo "Adding Spinnaker apt repository" + REPOSITORY_HOST=$(echo $REPOSITORY_URL | cut -d/ -f3) + curl -fsSL https://us-apt.pkg.dev/doc/repo-signing-key.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/spinnaker.gpg > /dev/null + echo "deb [signed-by=/usr/share/keyrings/spinnaker.gpg arch=all] $REPOSITORY_URL apt main" | tee /etc/apt/sources.list.d/spinnaker.list > /dev/null fi - - echo "Installing Java" - apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages unzip - apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages openjdk-11-jre-headless - - # https://bugs.launchpad.net/ubuntu/+source/ca-certificates-java/+bug/983302 - # It seems a circular dependency was introduced on 2016-04-22 with an openjdk-8 release, where - # the JRE relies on the ca-certificates-java package, which itself relies on the JRE. - # This causes the /etc/ssl/certs/java/cacerts file to never be generated, causing a startup - # failure in Clouddriver. - echo "Reinstalling Java CA certificates" - dpkg --purge --force-depends ca-certificates-java - apt-get install ca-certificates-java } echo "Updating apt package lists..." -if [ -n "$INSTALL_REDIS" ]; then - add_redis_apt_repository -fi - if [ -n "$PREPARE_ENVIRONMENT" ]; then - add_java_apt_repository add_spinnaker_apt_repository {%upstart-init%} fi @@ -116,10 +78,6 @@ apt-get update ||: echo "Installing desired components..." -if [ -n "$PREPARE_ENVIRONMENT" ]; then - install_java -fi - if [ -z "$(getent group spinnaker)" ]; then groupadd spinnaker fi diff --git a/halyard-deploy/src/main/resources/debian/pre-bake.sh b/halyard-deploy/src/main/resources/debian/pre-bake.sh index 55b2ea5e80..b96d345cfb 100644 --- a/halyard-deploy/src/main/resources/debian/pre-bake.sh +++ b/halyard-deploy/src/main/resources/debian/pre-bake.sh @@ -29,17 +29,15 @@ else DISTRO=$(uname -s) fi -# If not Ubuntu 14.xx.x or higher - if [ "$DISTRO" = "Ubuntu" ]; then - if [ "${DISTRIB_RELEASE%%.*}" -lt "14" ]; then + if [ "${DISTRIB_RELEASE%%.*}" -lt "18" ]; then echo "Not a supported version of Ubuntu" - echo "Version is $DISTRIB_RELEASE we require 14.04" + echo "Version is $DISTRIB_RELEASE we require 18.04 or higher." exit 1 fi else echo "Not a supported operating system: " $DISTRO - echo "It's recommended you use Ubuntu 14.04." + echo "It's recommended you use Ubuntu 18.04 or higher." echo "" echo "Please file an issue against https://github.com/spinnaker/spinnaker/issues" echo "if you'd like to see support for your OS and version" @@ -47,39 +45,16 @@ else fi function add_spinnaker_apt_repository() { - REPOSITORY_HOST=$(echo $REPOSITORY_URL | cut -d/ -f3) - if [[ "$REPOSITORY_HOST" == "dl.bintray.com" ]]; then - REPOSITORY_ORG=$(echo $REPOSITORY_URL | cut -d/ -f4) - # Personal repositories might not be signed, so conditionally check. - gpg="" - gpg=$(curl -s -f "https://bintray.com/user/downloadSubjectPublicKey?username=$REPOSITORY_ORG") || true - if [[ ! -z "$gpg" ]]; then - echo "$gpg" | apt-key add - - fi + if [ ! -f /etc/apt/sources.list.d/spinnaker.list ]; then + echo "Adding Spinnaker apt repository" + REPOSITORY_HOST=$(echo $REPOSITORY_URL | cut -d/ -f3) + curl -fsSL https://us-apt.pkg.dev/doc/repo-signing-key.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/spinnaker.gpg > /dev/null + echo "deb [signed-by=/usr/share/keyrings/spinnaker.gpg arch=all] $REPOSITORY_URL apt main" | tee /etc/apt/sources.list.d/spinnaker.list > /dev/null fi - echo "deb $REPOSITORY_URL $DISTRIB_CODENAME spinnaker" | tee /etc/apt/sources.list.d/spinnaker.list > /dev/null -} - -function add_java_apt_repository() { - add-apt-repository -y ppa:openjdk-r/ppa -} - -function install_java() { - apt-get install -y --force-yes unzip - apt-get install -y --force-yes openjdk-8-jdk - - # https://bugs.launchpad.net/ubuntu/+source/ca-certificates-java/+bug/983302 - # It seems a circular dependency was introduced on 2016-04-22 with an openjdk-8 release, where - # the JRE relies on the ca-certificates-java package, which itself relies on the JRE. - # This causes the /etc/ssl/certs/java/cacerts file to never be generated, causing a startup - # failure in Clouddriver. - dpkg --purge --force-depends ca-certificates-java - apt-get install ca-certificates-java } echo "Updating apt package lists..." -add_java_apt_repository add_spinnaker_apt_repository {%upstart-init%} @@ -87,8 +62,6 @@ apt-get update ||: echo "Installing desired components..." -install_java - if [ -z "$(getent group spinnaker)" ]; then groupadd spinnaker fi diff --git a/halyard-deploy/src/main/resources/services/redis/install.sh b/halyard-deploy/src/main/resources/services/redis/install.sh index dcf6a6f08d..5ef7f74011 100644 --- a/halyard-deploy/src/main/resources/services/redis/install.sh +++ b/halyard-deploy/src/main/resources/services/redis/install.sh @@ -1,2 +1 @@ -add-apt-repository -y ppa:chris-lea/redis-server -apt-get -q -y --force-yes install redis-server={%version%} redis-tools={%version%} \ No newline at end of file +apt-get -q -y --allow-unauthenticated --allow-downgrades --allow-remove-essential --allow-change-held-packages install redis-server={%version%} redis-tools={%version%} diff --git a/install/Installer.sh b/install/Installer.sh index 43b1fe6158..e40911d57b 100755 --- a/install/Installer.sh +++ b/install/Installer.sh @@ -5,14 +5,15 @@ set -e set -o pipefail -REPOSITORY_URL="https://dl.bintray.com/spinnaker-releases/debians" -SPINNAKER_REPOSITORY_URL="https://dl.bintray.com/spinnaker-releases/debians" +REPOSITORY_URL="https://us-apt.pkg.dev/projects/spinnaker-community" +SPINNAKER_REPOSITORY_URL="https://us-apt.pkg.dev/projects/spinnaker-community" SPINNAKER_DOCKER_REGISTRY="us-docker.pkg.dev/spinnaker-community/docker" SPINNAKER_GCE_PROJECT="marketplace-spinnaker-release" -CONFIG_BUCKET="halconfig" +CONFIG_BUCKET="halconfig" VERSION="" HALYARD_STARTUP_TIMEOUT_SECONDS=120 +HAL_USER="spinnaker" if [ -z "$RELEASE_TRACK" ]; then >&2 echo "RELEASE_TRACK env var must be set (nightly or stable)" @@ -23,7 +24,6 @@ fi # We can only currently support limited releases # First guess what sort of operating system - if [ -f /etc/lsb-release ]; then . /etc/lsb-release DISTRO=$DISTRIB_ID @@ -40,17 +40,15 @@ else DISTRO=$(uname -s) fi -# If not Ubuntu 14.xx.x or higher - if [ "$DISTRO" = "Ubuntu" ]; then - if [ "${DISTRIB_RELEASE%%.*}" -lt "14" ]; then + if [ "${DISTRIB_RELEASE%%.*}" -lt "18" ]; then echo "Not a supported version of Ubuntu" - echo "Version is $DISTRIB_RELEASE we require 14.04" + echo "Version is $DISTRIB_RELEASE we require 18.04 or higher." exit 1 fi else echo "Not a supported operating system: " - echo "It's recommended you use Ubuntu 14.04" + echo "It's recommended you use Ubuntu 18.04 or higher." echo "" echo "Please file an issue against github.com/spinnaker/halyard/issues " echo "if you'd like to see support for your OS and version" @@ -62,7 +60,7 @@ function print_usage() { cat <] - [--local-install] [--home_dir ] + [--local-install] -y Accept all default options during install (non-interactive mode). @@ -85,9 +83,6 @@ usage: $0 [-y] [--quiet] [--dependencies_only] --version Specify the exact version of Halyard to install. - --user Specify the user to run Halyard as. This - user must exist. - --dependencies_only Do not install any Spinnaker services. Only install the dependencies. This is intended for development scenarios only. @@ -95,12 +90,9 @@ usage: $0 [-y] [--quiet] [--dependencies_only] --local-install For Spinnaker and Java packages, download packages and install using dpkg instead of apt. Use this option only if you are having - issues with the bintray repositories. + issues with the repositories. If you use this option you must manually - install openjdk-8-jdk. - - --home_dir Override where user home directories reside - example: /export/home vs /home. + install openjdk-11-jre-headless. EOF } @@ -141,11 +133,6 @@ function process_args() { CONFIG_BUCKET="$1" shift ;; - --user) - echo "user" - HAL_USER="$1" - shift - ;; --version) echo "version" VERSION="$1" @@ -166,14 +153,6 @@ function process_args() { --quiet|-q) QUIET=true ;; - --home_dir) - homebase="$1" - if [ "$(basename $homebase)" = "spinnaker" ]; then - echo "stripping trailing 'spinnaker' from --home_dir=$homebase" - homebase=$(dirname $homebase) - fi - shift - ;; --help|-help|-h) print_usage exit 13 @@ -186,38 +165,20 @@ function process_args() { } function add_apt_repositories() { - # Spinnaker - # DL Repo goes here - REPOSITORY_HOST=$(echo $REPOSITORY_URL | cut -d/ -f3) - if [ "$REPOSITORY_HOST" = "dl.bintray.com" ]; then - REPOSITORY_ORG=$(echo $REPOSITORY_URL | cut -d/ -f4) - # Personal repositories might not be signed, so conditionally check. - gpg="" - gpg=$(curl -s -f "https://bintray.com/user/downloadSubjectPublicKey?username=$REPOSITORY_ORG") || true - if [ -n "$gpg" ]; then - echo "$gpg" | apt-key add - - fi + if [ ! -f /etc/apt/sources.list.d/spinnaker.list ]; then + REPOSITORY_HOST=$(echo $REPOSITORY_URL | cut -d/ -f3) + curl -fsSL https://us-apt.pkg.dev/doc/repo-signing-key.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/spinnaker.gpg > /dev/null + echo "deb [signed-by=/usr/share/keyrings/spinnaker.gpg arch=all] $REPOSITORY_URL apt main" | tee /etc/apt/sources.list.d/spinnaker.list > /dev/null fi - echo "deb $REPOSITORY_URL ${DISTRIB_CODENAME}-${RELEASE_TRACK} spinnaker" | tee /etc/apt/sources.list.d/halyard.list > /dev/null - # Java 8 - # https://launchpad.net/~openjdk-r/+archive/ubuntu/ppa - add-apt-repository -y ppa:openjdk-r/ppa apt-get update ||: } function install_java() { if [ -z "$DOWNLOAD" ]; then - apt-get install -y --force-yes openjdk-8-jdk - - # https://bugs.launchpad.net/ubuntu/+source/ca-certificates-java/+bug/983302 - # It seems a circular dependency was introduced on 2016-04-22 with an openjdk-8 release, where - # the JRE relies on the ca-certificates-java package, which itself relies on the JRE. D'oh! - # This causes the /etc/ssl/certs/java/cacerts file to never be generated, causing a startup - # failure in Clouddriver. - dpkg --purge --force-depends ca-certificates-java - apt-get install ca-certificates-java - elif [[ "x`java -version 2>&1|head -1`" != *"1.8.0"* ]]; then - echo "you must manually install java 8 and then rerun this script; exiting" + echo "$(tput bold)Installing Java...$(tput sgr0)" + apt-get install -y --allow-unauthenticated --allow-downgrades --allow-remove-essential --allow-change-held-packages openjdk-11-jre-headless + elif [[ "x`java -version 2>&1|head -1`" != *"11.0"* ]]; then + echo "You must manually install Java 11 and then rerun this script; exiting" exit 13 fi } @@ -229,7 +190,7 @@ function install_halyard() { if [ -n "$VERSION" ]; then installed_package="$package=$VERSION" fi - apt-get install -y --force-yes --allow-unauthenticated $installed_package + apt-get install -y --allow-unauthenticated --allow-downgrades --allow-remove-essential --allow-change-held-packages $installed_package local apt_status=$? if [ $apt_status -ne 0 ]; then if [ -n "$DOWNLOAD" ] && [ "$apt_status" -eq "100" ]; then @@ -239,10 +200,10 @@ function install_halyard() { version="${package}_${VERSION}_all.deb" debfile=$version else - version=`curl $REPOSITORY_URL/dists/${DISTRIB_CODENAME}-${RELEASE_TRACK}/spinnaker/binary-amd64/Packages | grep "^Filename" | grep $package | awk '{print $2}' | awk -F'/' '{print $NF}' | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -1` + version=`curl -s $REPOSITORY_URL/dists/apt/main/binary-all/Packages | grep "^Filename" | grep $package | awk '{print $2}' | awk -F'/' '{print $NF}' | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -1` debfile=`echo $version | awk -F "/" '{print $NF}'` fi - filelocation=`curl $REPOSITORY_URL/dists/${DISTRIB_CODENAME}-${RELEASE_TRACK}/spinnaker/binary-amd64/Packages | grep "^Filename" | grep $version | awk '{print $2}'` + filelocation=`curl -s $REPOSITORY_URL/dists/apt/main/binary-all/Packages | grep "^Filename" | grep $version | awk '{print $2}'` curl -L -o /tmp/$debfile $REPOSITORY_URL/$filelocation dpkg -i /tmp/$debfile && rm -f /tmp/$debfile else @@ -262,18 +223,17 @@ function configure_bash_completion() { yes="y" fi - local home=$(getent passwd $HAL_USER | cut -d: -f6) completion_script="/etc/bash_completion.d/hal" if [ "$yes" = "y" ] || [ "$yes = "Y" ] || [ "$yes = "yes" ] || [ "$yes" = "" ]; then local bashrc hal --print-bash-completion | tee $completion_script > /dev/null if [ -z "$YES" ]; then echo "" - read -p "Where is your bash RC? [default=$home/.bashrc]: " bashrc + read -p "Where is your bash RC? [default=$HOME/.bashrc]: " bashrc fi if [ -z "$bashrc" ]; then - bashrc="$home/.bashrc" + bashrc="$HOME/.bashrc" fi if [ -z "$(grep $completion_script $bashrc)" ]; then @@ -288,27 +248,8 @@ function configure_bash_completion() { } -function get_user() { - local user - - user=$(who -m | awk '{print $1;}') - if [ -z "$YES" ]; then - if [ "$user" = "root" ] || [ -z "$user" ]; then - read -p "Please supply a non-root user to run Halyard as: " user - fi - fi - - echo $user -} - function configure_halyard_defaults() { - home=$(getent passwd $HAL_USER | cut -d: -f6) - local halconfig_dir="$home/.hal" - - echo "$(tput bold)Halconfig will be stored at $halconfig_dir/config$(tput sgr0)" - - mkdir -p $halconfig_dir - chown $HAL_USER $halconfig_dir + echo "$(tput bold)Halconfig will be stored at /home/spinnaker/.hal/config$(tput sgr0)" mkdir -p /opt/spinnaker/config chmod +rx /opt/spinnaker/config @@ -316,7 +257,7 @@ function configure_halyard_defaults() { cat > /opt/spinnaker/config/halyard.yml < /opt/spinnaker/config/halyard-user - - cat > $halconfig_dir/uninstall.sh < /tmp/uninstall-halyard.sh <&2 echo "You have not supplied a user to run Halyard as." - exit 1 -fi - -if [ "$HAL_USER" = "root" ]; then - >&2 echo "Halyard may not be run as root. Supply a user to run Halyard as: " - >&2 echo " sudo bash $0 --user " - exit 1 -fi - -set +e -getent passwd $HAL_USER &> /dev/null - -if [ "$?" != "0" ]; then - >&2 echo "Supplied user $HAL_USER does not exist" - exit 1 -fi -set -e - configure_halyard_defaults echo "$(tput bold)Configuring external apt repos...$(tput sgr0)" add_apt_repositories - -echo "$(tput bold)Installing Java 8...$(tput sgr0)" - install_java if [ -n "$DEPENDENCIES_ONLY" ]; then @@ -398,9 +310,6 @@ fi ## Spinnaker echo "$(tput bold)Installing Halyard...$(tput sgr0)" install_halyard -groupadd spinnaker || true -usermod -G spinnaker -a $HAL_USER || true - configure_bash_completion printf 'Waiting for the Halyard daemon to start running' diff --git a/install/debian/InstallHalyard.sh b/install/debian/InstallHalyard.sh index b02a95abc6..3240b9afac 100644 --- a/install/debian/InstallHalyard.sh +++ b/install/debian/InstallHalyard.sh @@ -2,21 +2,11 @@ set -e -function check_migration_needed() { - set +e +SPINNAKER_REPOSITORY_URL="https://us-apt.pkg.dev/projects/spinnaker-community" +SPINNAKER_DOCKER_REGISTRY="us-docker.pkg.dev/spinnaker-community/docker" +SPINNAKER_GCE_PROJECT="marketplace-spinnaker-release" +CONFIG_BUCKET="halconfig" - which dpkg &> /dev/null - if [ "$?" = "0" ]; then - dpkg -s spinnaker-halyard &> /dev/null - - if [ "$?" != "1" ]; then - >&2 echo "Attempting to install halyard while a debian installation is present." - >&2 echo "Please visit: https://spinnaker.io/setup/install/halyard_migration/" - exit 1 - fi - fi - set -e -} function process_args() { while [ "$#" -gt "0" ] @@ -24,15 +14,6 @@ function process_args() { local key="$1" shift case $key in - --halyard-bucket-base-url) - echo "halyard-bucket-base-url" - HALYARD_BUCKET_BASE_URL="$1" - shift - ;; - --download-with-gsutil) - echo "download-with-gsutil" - DOWNLOAD_WITH_GSUTIL=true - ;; --spinnaker-repository) echo "spinnaker-repo" SPINNAKER_REPOSITORY_URL="$1" @@ -53,11 +34,6 @@ function process_args() { CONFIG_BUCKET="$1" shift ;; - --user) - echo "user" - HAL_USER="$1" - shift - ;; --version) echo "version" HALYARD_VERSION="$1" @@ -78,81 +54,29 @@ function process_args() { done } -function get_user() { - local user - - user=$(whoami) - if [ -z "$YES" ]; then - if [ "$user" = "root" ] || [ -z "$user" ]; then - read -p "Please supply a non-root user to run Halyard as: " user - fi - fi - - echo $user -} - -function get_home() { - getent passwd $HAL_USER | cut -d: -f6 -} - function configure_defaults() { - if [ -z "$HAL_USER" ]; then - HAL_USER=$(get_user) - fi - - if [ -z "$HAL_USER" ]; then - >&2 echo "You have not supplied a user to run Halyard as." - exit 1 - fi - - if [ "$HAL_USER" = "root" ]; then - >&2 echo "Halyard may not be run as root. Supply a user to run Halyard as: " - >&2 echo " sudo bash $0 --user " - exit 1 - fi - - set +e - getent passwd $HAL_USER &> /dev/null - - if [ "$?" != "0" ]; then - >&2 echo "Supplied user $HAL_USER does not exist" - exit 1 - fi - set -e - if [ -z "$HALYARD_VERSION" ]; then - HALYARD_VERSION="stable" + HALYARD_VERSION=`curl -s $SPINNAKER_REPOSITORY_URL/dists/apt/main/binary-all/Packages \ + | grep "^Filename" \ + | grep spinnaker-halyard \ + | awk '{print $2}' \ + | awk -F'/' '{print $NF}' \ + | sort -t. -k 1,1n -k 2,2n -k 3,3n \ + | tail -1 \ + | cut -d '_' -f 2` fi echo "$(tput bold)Halyard version will be $HALYARD_VERSION $(tput sgr0)" - - if [ -z "$HALYARD_BUCKET_BASE_URL" ]; then - HALYARD_BUCKET_BASE_URL="gs://spinnaker-artifacts/halyard" - fi - - echo "$(tput bold)Halyard will be downloaded from $HALYARD_BUCKET_BASE_URL $(tput sgr0)" - - if [ -z "$CONFIG_BUCKET" ]; then - CONFIG_BUCKET="halconfig" - fi - - echo "$(tput bold)Halyard config will come from bucket gs://$CONFIG_BUCKET $(tput sgr0)" - - home=$(get_home) - local halconfig_dir="$home/.hal" - - echo "$(tput bold)Halconfig will be stored at $halconfig_dir/config$(tput sgr0)" - - mkdir -p $halconfig_dir - chown $HAL_USER $halconfig_dir + echo "$(tput bold)Halyard will be downloaded from the spinnaker-community repository $(tput sgr0)" + echo "$(tput bold)Halconfig will be stored at /home/spinnaker/.hal/config$(tput sgr0)" mkdir -p /opt/spinnaker/config - chmod a+rx /opt/spinnaker/config + chmod +rx /opt/spinnaker/config cat > /opt/spinnaker/config/halyard.yml < /opt/spinnaker/config/halyard-user - - cat > $halconfig_dir/uninstall.sh < /tmp/uninstall-halyard.sh <] [--user=] +usage: $0 [-y] [--version=] -y Accept all default options during install (non-interactive mode). @@ -226,22 +151,18 @@ usage: $0 [-y] [--version=] [--user=] --version Specify the exact version of Halyard to install. - - --user Specify the user to run Halyard as. This - user must exist. EOF } function check_java() { - if ! which java 2>&1 > /dev/null; then - echo "Couldn't find a 'java' binary in your \$PATH. Halyard requires Java to run." - exit 1 + echo "$(tput bold)Installing Java...$(tput sgr0)" + apt-get update + apt-get install -y openjdk-11-jre-headless fi } function configure_bash_completion() { - local yes echo "" if [ -z "$YES" ]; then read -p "Would you like to configure halyard to use bash auto-completion? [default=Y]: " yes @@ -250,7 +171,6 @@ function configure_bash_completion() { fi if [ "$yes" = "y" ] || [ "$yes = "Y" ] || [ "$yes = "yes" ] || [ "$yes" = "" ]; then - local home=$(get_home) completion_script="/etc/bash_completion.d/hal" mkdir -p $(dirname $completion_script) @@ -259,11 +179,11 @@ function configure_bash_completion() { local bashrc if [ -z "$YES" ]; then echo "" - read -p "Where is your bash RC? [default=$home/.bashrc]: " bashrc + read -p "Where is your bash RC? [default=$HOME/.bashrc]: " bashrc fi if [ -z "$bashrc" ]; then - bashrc="$home/.bashrc" + bashrc="$HOME/.bashrc" fi if [ -z "$(grep $completion_script $bashrc)" ]; then @@ -278,52 +198,13 @@ function configure_bash_completion() { } function install_halyard() { - TEMPDIR=$(mktemp -d installhalyard.XXXX) - pushd $TEMPDIR - local gcs_bucket_and_file - - if [[ "$HALYARD_BUCKET_BASE_URL" != gs://* ]]; then - >&2 echo "Currently installing halyard is only supported from a GCS bucket." - >&2 echo "The --halyard-install-url parameter must start with 'gs://'." - exit 1 - else - gcs_bucket_and_file=${HALYARD_BUCKET_BASE_URL:5}/$HALYARD_VERSION/debian/halyard.tar.gz - fi - - if [ -n "$DOWNLOAD_WITH_GSUTIL" ]; then - gsutil cp gs://$gcs_bucket_and_file halyard.tar.gz - else - curl -O https://storage.googleapis.com/$gcs_bucket_and_file - fi - - tar --no-same-owner -xvf halyard.tar.gz -C /opt - - - if which systemd-sysusers &>/dev/null; then - if [ ! -d "/usr/lib/sysusers.d" ]; then - if [ ! -L "/usr/lib/sysusers.d" ]; then - echo "Creating /usr/lib/sysusers.d directory." - install -dm755 -o root -g root /usr/lib/sysusers.d - fi - fi - cat > /usr/lib/sysusers.d/halyard.conf < /dev/null || true - - else - groupadd halyard || true - groupadd spinnaker || true - fi - - usermod -G halyard -a $HAL_USER || true - usermod -G spinnaker -a $HAL_USER || true - chown $HAL_USER:halyard /opt/halyard - - mv /opt/hal /usr/local/bin - chmod a+rx /usr/local/bin/hal + curl -fsSL https://us-apt.pkg.dev/doc/repo-signing-key.gpg \ + | gpg --dearmor \ + | tee /usr/share/keyrings/spinnaker.gpg > /dev/null + echo "deb [signed-by=/usr/share/keyrings/spinnaker.gpg arch=all] ${SPINNAKER_REPOSITORY_URL} apt main" \ + | tee /etc/apt/sources.list.d/spinnaker-community.list > /dev/null + apt update + apt install -y spinnaker-halyard if [ -f /opt/update-halyard ]; then mv /opt/update-halyard /usr/local/bin @@ -331,23 +212,13 @@ EOL else echo "No update script supplied with installer..." fi - - mkdir -p /var/log/spinnaker/halyard - chown $HAL_USER:halyard /var/log/spinnaker/halyard - chmod 755 /var/log/spinnaker /var/log/spinnaker/halyard - - popd - rm -rf $TEMPDIR } -check_migration_needed - process_args $@ configure_defaults - check_java install_halyard - -su -l -c "hal -v" -s /bin/bash $HAL_USER - configure_bash_completion + +HALYARD_INSTALLED_VERSION=$(hal -v) +echo "$(tput bold)Halyard version: ${HALYARD_INSTALLED_VERSION}$(tput sgr0)"