-
Notifications
You must be signed in to change notification settings - Fork 15
feature(distribution): upload packages to s3 #120
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
Merged
+981
β8
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1cbce7e
feat: enhance upload scripts for APK and RPM packages
94c133a
refactor: improve upload scripts and architecture validation
f5c0162
refactor: rename architecture detection function for clarity
aab2269
feat: add S3 environment variable validation and improve architectureβ¦
693e37b
feat: add validation for APK private key and RPM signing key ID
6feffc6
feat: add validation for INFISICAL_CLI_REPO_SIGNING_KEY_ID in APK andβ¦
ed01935
feat: consolidate validation for INFISICAL_CLI_REPO_SIGNING_KEY_ID inβ¦
a0477fa
fix: improve S3 environment variable validation and streamline uploadβ¦
53364d6
feat: add setup scripts for Infisical CLI installation on various Linβ¦
dc25514
Update relay.go
varonix0 de47570
Update relay.go
varonix0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,199 @@ | ||
| #!/bin/sh | ||
| # | ||
| # Infisical CLI Alpine Repository Setup Script | ||
| # The core commands execute start from the "MAIN" section below. | ||
| # | ||
|
|
||
| set -e | ||
|
|
||
| # Environment variables that can be set | ||
| PKG_URL="${PKG_URL:-https://artifacts-cli.infisical.com}" | ||
| PACKAGE_NAME="${PACKAGE_NAME:-infisical}" | ||
| RSA_KEY_URL="${RSA_KEY_URL:-${PKG_URL}/apk/infisical.rsa.pub}" | ||
|
|
||
| # Colors (basic POSIX-compatible) | ||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| BOLD='\033[1m' | ||
| NC='\033[0m' # No Color | ||
|
|
||
| echo_status() { | ||
| local status=$1 | ||
| local message=$2 | ||
| if [ "$status" = "OK" ]; then | ||
| printf "${GREEN}[ OK ]${NC} %s\n" "$message" | ||
| elif [ "$status" = "FAIL" ]; then | ||
| printf "${RED}[ FAIL ]${NC} %s\n" "$message" | ||
| elif [ "$status" = "RUN" ]; then | ||
| printf "[ .. ] %s\r" "$message" | ||
| fi | ||
| } | ||
|
|
||
| die() { | ||
| echo | ||
| printf "${RED}${BOLD}Error:${NC} %s\n" "$1" | ||
| echo | ||
| printf "${BOLD}For assistance, please visit:${NC}\n" | ||
| echo " https://github.com/Infisical/infisical" | ||
| echo | ||
| exit 1 | ||
| } | ||
|
|
||
| check_tool() { | ||
| local tool=$1 | ||
| echo_status "RUN" "Checking for required tool '$tool'..." | ||
| if command -v "$tool" > /dev/null 2>&1; then | ||
| echo_status "OK" "Checking for required tool '$tool'" | ||
| return 0 | ||
| else | ||
| echo_status "FAIL" "Checking for required tool '$tool'" | ||
| die "$tool is not installed, but is required by this script." | ||
| fi | ||
| } | ||
|
|
||
| detect_arch() { | ||
| echo_status "RUN" "Detecting system architecture..." | ||
| local raw_arch=$(uname -m) | ||
| case "$raw_arch" in | ||
| x86_64|amd64) | ||
| arch="x86_64" | ||
| ;; | ||
| aarch64|arm64) | ||
| arch="aarch64" | ||
| ;; | ||
| *) | ||
| echo_status "FAIL" "Detecting system architecture" | ||
| die "Unsupported architecture: $raw_arch. Supported: x86_64, aarch64" | ||
| ;; | ||
| esac | ||
| echo_status "OK" "Architecture detected: $arch" | ||
| } | ||
|
|
||
| import_rsa_key() { | ||
| echo_status "RUN" "Importing '${PACKAGE_NAME}' repository RSA key..." | ||
|
|
||
| # Create keys directory if it doesn't exist | ||
| mkdir -p /etc/apk/keys | ||
|
|
||
| # Download and install RSA public key | ||
| if wget -q -O "/etc/apk/keys/${PACKAGE_NAME}.rsa.pub" "${RSA_KEY_URL}"; then | ||
| chmod 644 "/etc/apk/keys/${PACKAGE_NAME}.rsa.pub" | ||
| echo_status "OK" "Importing '${PACKAGE_NAME}' repository RSA key" | ||
| else | ||
| echo_status "FAIL" "Importing '${PACKAGE_NAME}' repository RSA key" | ||
| die "Could not download RSA key from ${RSA_KEY_URL}" | ||
| fi | ||
| } | ||
|
|
||
| setup_repository() { | ||
| local repo_file="/etc/apk/repositories" | ||
| local repo_url="${PKG_URL}/apk/stable/main/${arch}" | ||
|
|
||
| echo_status "RUN" "Adding '${PACKAGE_NAME}' repository..." | ||
|
|
||
| # Check if repository already exists | ||
| if grep -q "${repo_url}" "${repo_file}" 2>/dev/null; then | ||
| echo_status "OK" "Repository already configured" | ||
| return 0 | ||
| fi | ||
|
|
||
| # Add repository | ||
| echo "${repo_url}" >> "${repo_file}" | ||
| echo_status "OK" "Adding '${PACKAGE_NAME}' repository" | ||
| } | ||
|
|
||
| update_apk() { | ||
| echo_status "RUN" "Updating Alpine repository cache..." | ||
| if apk update > /dev/null 2>&1; then | ||
| echo_status "OK" "Updating Alpine repository cache" | ||
| else | ||
| echo_status "FAIL" "Updating Alpine repository cache" | ||
| die "Failed to update APK cache. Please check your network connection." | ||
| fi | ||
| } | ||
|
|
||
| usage() { | ||
| cat << EOF | ||
| Usage: $0 [options] | ||
|
|
||
| Options: | ||
| -h, --help Display this help message | ||
| -r, --remove Remove the repository configuration | ||
|
|
||
| Environment variables: | ||
| PKG_URL Base URL for packages (default: https://artifacts-cli.infisical.com) | ||
| PACKAGE_NAME Package name (default: infisical) | ||
|
|
||
| EOF | ||
| exit 0 | ||
| } | ||
|
|
||
| remove_repository() { | ||
| echo "Removing ${PACKAGE_NAME} repository configuration..." | ||
|
|
||
| # Remove from repositories file | ||
| if [ -f /etc/apk/repositories ]; then | ||
| sed -i "\|${PKG_URL}/apk|d" /etc/apk/repositories | ||
| echo_status "OK" "Removed repository from /etc/apk/repositories" | ||
| fi | ||
|
|
||
| # Remove RSA key | ||
| if [ -f "/etc/apk/keys/${PACKAGE_NAME}.rsa.pub" ]; then | ||
| rm -f "/etc/apk/keys/${PACKAGE_NAME}.rsa.pub" | ||
| echo_status "OK" "Removed RSA key" | ||
| fi | ||
|
|
||
| # Update cache | ||
| apk update > /dev/null 2>&1 | ||
|
|
||
| echo | ||
| echo "Repository removed successfully." | ||
| exit 0 | ||
| } | ||
|
|
||
| # | ||
| # MAIN | ||
| # | ||
|
|
||
| # Parse arguments | ||
| while [ $# -gt 0 ]; do | ||
| case "$1" in | ||
| -h|--help) | ||
| usage | ||
| ;; | ||
| -r|--remove) | ||
| remove_repository | ||
| ;; | ||
| *) | ||
| echo "Unknown option: $1" | ||
| usage | ||
| ;; | ||
| esac | ||
| shift | ||
| done | ||
|
|
||
| echo | ||
| echo "Executing the setup script for the '${PACKAGE_NAME}' repository..." | ||
| echo | ||
|
|
||
| # Check for root privileges | ||
| if [ "$(id -u)" -ne 0 ]; then | ||
| die "This script must be run as root (e.g., using sudo)" | ||
| fi | ||
|
|
||
| # Check requirements | ||
| check_tool "wget" | ||
|
|
||
| # Setup | ||
| detect_arch | ||
| import_rsa_key | ||
| setup_repository | ||
| update_apk | ||
|
|
||
| echo | ||
| printf "${GREEN}${BOLD}Success!${NC} The repository has been installed successfully.\n" | ||
| echo | ||
| echo "You can now install ${PACKAGE_NAME} with:" | ||
| echo | ||
| printf " ${BOLD}apk add ${PACKAGE_NAME}${NC}\n" | ||
| echo |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.