Script fixes

This commit is contained in:
David Tomaschik
2026-08-26 16:56:15 -07:00
parent 3666115090
commit ae111baa2b
8 changed files with 62 additions and 29 deletions

View File

@@ -125,8 +125,17 @@ function deb_only {
function get_latest_github_release_url {
local repo="$1"
local glob="$2"
curl -s "https://api.github.com/repos/${repo}/releases/latest" | \
jq -r --arg rx "${glob}" '.assets[] | select(.name | test($rx)) | .browser_download_url'
require jq "jq is required to parse GitHub releases."
local response
response=$(curl -s "https://api.github.com/repos/${repo}/releases/latest")
if ! echo "${response}" | jq -e '.assets' >/dev/null 2>&1; then
local msg
msg=$(echo "${response}" | jq -r '.message // "Unknown error fetching latest release."')
die "GitHub API error for ${repo}: ${msg}"
fi
echo "${response}" | jq -r --arg rx "${glob}" '.assets[] | select(.name | test($rx)) | .browser_download_url'
}
function require {

View File

@@ -8,13 +8,18 @@ if [ "$(uname)" != "Linux" ]; then
exit 1
fi
DEFAULT=`echo /media/${USER}/[bB]ackup/${USER}/`
shopt -s nullglob
matches=( /media/"${USER}"/[bB]ackup/"${USER}"/ )
shopt -u nullglob
if [ ${#matches[@]} -gt 0 ]; then
DEFAULT="${matches[0]}"
else
DEFAULT="/media/${USER}/Backup/${USER}/"
fi
DEST="${1:-${DEFAULT}}"
function verify_dest {
arr=($1)
items=${#arr[@]}
if [ $items -ne 1 ] ; then
if [ -z "$1" ] ; then
echo "Bad count of backup destinations." > /dev/stderr
exit 1
fi
@@ -25,7 +30,7 @@ function verify_dest {
echo -n "Destination $dir does not end in a /, " > /dev/stderr
echo "this is probably not what you want!" > /dev/stderr
echo "Press a key to continue, or CTRL-C to cancel." > /dev/stderr
read
read -r
fi
}

View File

@@ -1,6 +1,10 @@
#!/bin/sh
LOCKTIME="${SCREENSAVER_MIN:-5}"
LOCKER="i3lock -c 000000"
# Cleanup previously leaked background agents
pkill -x xss-lock 2>/dev/null || true
pkill -x xautolock 2>/dev/null || true
# intentionally want word splitting below
# do not quote this
/usr/bin/xss-lock -- ${LOCKER} &

View File

@@ -1,11 +1,13 @@
#!/bin/bash
set -e
if [ $# -lt 1 ] ; then
echo "Usage: $0 <kvm|vbox>" >&2
exit 1
fi
if [ `whoami` != "root" ] ; then
if [ "$(id -u)" -ne 0 ] ; then
if which sudo >/dev/null 2>&1 ; then
sudo "$0" "$@"
exit