-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40516dd
commit 02839fd
Showing
4 changed files
with
153 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -x | ||
|
||
TMP_INSTALL_DIR="${TMPDIR:-/tmp}/novops-install" | ||
INSTALL_DIR="/usr/local/bin" | ||
YELLOW='\e[0;33m' | ||
RESET='\033[0m' | ||
|
||
# Check required tools are available | ||
if ! curl --version > /dev/null | ||
then | ||
echo "Error: curl is not installed. Please install curl first." >&2 | ||
exit 1 | ||
fi | ||
|
||
if ! unzip -v > /dev/null | ||
then | ||
echo "Error: unzip is not installed. Please install unzip first." >&2 | ||
exit 1 | ||
fi | ||
|
||
# Detect OS and Architecture | ||
OS=$(uname | tr '[:upper:]' '[:lower:]') | ||
ARCH=$(uname -m) | ||
case $ARCH in | ||
x86_64) | ||
ARCH="x86_64" | ||
;; | ||
aarch64) | ||
ARCH="aarch64" | ||
;; | ||
arm64) | ||
ARCH="aarch64" # macOS sometimes reports ARM as arm64 | ||
;; | ||
*) | ||
echo "Unsupported architecture: $ARCH" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
# Define installation directory and zip file | ||
RELEASE_FILE_PREFIX="novops_${OS}_${ARCH}" | ||
|
||
ZIP_NAME="${RELEASE_FILE_PREFIX}.zip" | ||
ZIP_PATH="${TMP_INSTALL_DIR}/${ZIP_NAME}" | ||
|
||
CHECKSUM_NAME="${RELEASE_FILE_PREFIX}.sha256sum" | ||
CHECKSUM_PATH="${TMP_INSTALL_DIR}/${CHECKSUM_NAME}" | ||
|
||
NOVOPS_BIN_TMP_PATH="${TMP_INSTALL_DIR}/novops" | ||
|
||
ZIP_URL="https://github.com/PierreBeucher/novops/releases/latest/download/${ZIP_NAME}" | ||
CHECKSUM_URL="https://github.com/PierreBeucher/novops/releases/latest/download/${CHECKSUM_NAME}" | ||
|
||
# Download and unzip the package | ||
mkdir -p $TMP_INSTALL_DIR | ||
curl -L "${ZIP_URL}" -o "${ZIP_PATH}" | ||
unzip -o "${ZIP_PATH}" -d "${TMP_INSTALL_DIR}" | ||
|
||
# Checksum | ||
curl -L "${CHECKSUM_URL}" -o "${CHECKSUM_PATH}" | ||
sha256sum -c "${CHECKSUM_PATH}" | ||
|
||
if [ $? -eq 0 ]; then | ||
echo "Checksum verification succeeded." | ||
else | ||
echo "Checksum verification failed." | ||
exit 1 | ||
fi | ||
|
||
# Only need sudo to copy to install dir | ||
if [ "$(id -u)" -eq 0 ]; then | ||
mv "${NOVOPS_BIN_TMP_PATH}" "${INSTALL_DIR}" | ||
else | ||
sudo mv "${NOVOPS_BIN_TMP_PATH}" "${INSTALL_DIR}" | ||
fi | ||
|
||
rm "${ZIP_PATH}" | ||
rm "${CHECKSUM_PATH}" | ||
|
||
# Check if /usr/local/bin is in the PATH | ||
# Use case statement for POSIX-compliant pattern matching | ||
case ":${PATH}:" in | ||
*:/usr/local/bin:*) | ||
echo "Novops installed successfully." | ||
;; | ||
*) | ||
echo "${YELLOW}Warning: /usr/local/bin is not in your PATH, novops commands may not work.${RESET}" >&2 | ||
;; | ||
esac | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -x | ||
|
||
# | ||
# Manual script to test Novops installation script with various shells | ||
# | ||
|
||
# bash dash zsh fish ksh tcsh csh curl unzip | ||
|
||
|
||
function test_novops_install() { | ||
local image=$1 | ||
shift # Shift the first argument to get rid of the image name, leaving only commands | ||
|
||
# Run the docker container with the specified image and commands | ||
if docker run -it --rm -v "$PWD:/local" -w /local "$image" /bin/sh -c "$*"; then | ||
echo "OK: $image" | ||
else | ||
echo "NOT OK: $image" | ||
exit 1 | ||
fi | ||
} | ||
|
||
test_novops_install alpine:3.19.1 "apk update && apk add curl unzip && ./install.sh && novops --version" | ||
test_novops_install debian:12.5-slim "apt update && apt install curl unzip -y && ./install.sh && novops --version" | ||
test_novops_install ubuntu:22.04 "apt update && apt install curl unzip -y && ./install.sh && novops --version" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
#!/usr/bin/env sh | ||
|
||
# | ||
# Manual script to test various shells | ||
|