v2.0.0: init wizard, suggest, remediate, predict, telemetry, discord-bot, Nix, Docker, Jekyll, GPG verify
This commit is contained in:
+40
-4
@@ -1,3 +1,34 @@
|
||||
GPG_KEY_URL="https://raw.githubusercontent.com/mateussiqueira/unleash/main/.github/unleash.gpg"
|
||||
|
||||
import_gpg_key() {
|
||||
local tmp_key
|
||||
tmp_key=$(mktemp)
|
||||
if curl -sL "$GPG_KEY_URL" -o "$tmp_key" 2>/dev/null; then
|
||||
gpg --import "$tmp_key" 2>/dev/null || true
|
||||
fi
|
||||
rm -f "$tmp_key"
|
||||
}
|
||||
|
||||
verify_gpg_signature() {
|
||||
local file="$1"
|
||||
local sig="$2"
|
||||
if ! command -v gpg &>/dev/null; then
|
||||
warn "GPG not available — skipping signature verification"
|
||||
return 0
|
||||
fi
|
||||
import_gpg_key
|
||||
if gpg --verify "$sig" "$file" 2>/dev/null; then
|
||||
info "GPG signature valid"
|
||||
return 0
|
||||
else
|
||||
warn "GPG signature invalid or missing"
|
||||
echo -n "Continue without verification? [y/N] "
|
||||
read -r ans
|
||||
[ "$ans" != "y" ] && [ "$ans" != "Y" ] && error_exit "Aborted"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
do_self_update() {
|
||||
header "Unleash Update"
|
||||
|
||||
@@ -9,16 +40,12 @@ do_self_update() {
|
||||
local api_url="https://api.github.com/repos/${repo}/releases/latest"
|
||||
local tmp_dir
|
||||
tmp_dir=$(mktemp -d)
|
||||
local current_sha
|
||||
current_sha=$(git -C "$SCRIPT_DIR" rev-parse HEAD 2>/dev/null || echo "unknown")
|
||||
|
||||
begin "Checking latest release"
|
||||
local release_data
|
||||
release_data=$(curl -s "$api_url" 2>/dev/null || true)
|
||||
local latest_tag
|
||||
latest_tag=$(echo "$release_data" | grep '"tag_name"' | head -1 | sed -E 's/.*"v?([^"]+)".*/\1/')
|
||||
local latest_sha
|
||||
latest_sha=$(echo "$release_data" | grep '"target_commitish"' | head -1 | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
|
||||
if [ -z "$latest_tag" ]; then
|
||||
end_fail; echo " No network or invalid response"
|
||||
@@ -37,13 +64,22 @@ do_self_update() {
|
||||
|
||||
begin "Downloading latest unleash"
|
||||
local dl_url="https://raw.githubusercontent.com/${repo}/main/unleash"
|
||||
local sig_url="${dl_url}.sig"
|
||||
local tmp="$tmp_dir/unleash"
|
||||
local sig_tmp="$tmp_dir/unleash.sig"
|
||||
if curl -sL "$dl_url" -o "$tmp" && [ -s "$tmp" ]; then
|
||||
curl -sL "$sig_url" -o "$sig_tmp" 2>/dev/null || true
|
||||
end_ok
|
||||
else
|
||||
end_fail; error_exit "Download failed"
|
||||
fi
|
||||
|
||||
if [ -s "$sig_tmp" ]; then
|
||||
begin "Verifying GPG signature"
|
||||
verify_gpg_signature "$tmp" "$sig_tmp"
|
||||
end_ok
|
||||
fi
|
||||
|
||||
begin "Verifying syntax"
|
||||
if bash -n "$tmp" 2>/dev/null; then
|
||||
end_ok
|
||||
|
||||
Reference in New Issue
Block a user