init commit: jatools bundle 2025-10-20
This commit is contained in:
54
scripts/japg.sh
Executable file
54
scripts/japg.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
# ---
|
||||
# @file_name: japg.sh
|
||||
# @version: 1.0.0
|
||||
# @description: Generate a passphrase
|
||||
# @author: Jamie Albert (empty_produce)
|
||||
# @author_contact: <mailto:empty.produce@flatmail.me>
|
||||
# @license: GNU Affero General Public License v3.0 (Included in LICENSE)
|
||||
# Copyright (C) 2025, Jamie Albert
|
||||
# ---
|
||||
set -euo pipefail
|
||||
WORD_LIST='/usr/share/dict/japg.list'
|
||||
DEFAULT_WORDS=5
|
||||
DEFAULT_DELIM='-'
|
||||
error() { printf 'Error: %s\n' "$*" >&2; exit 1; }
|
||||
info() { printf '%s\n' "$*"; }
|
||||
|
||||
# ---
|
||||
# Description: Main routine.
|
||||
# Globals: WORD_LIST, DEFAULT_WORDS, DEFAULT_DELIM
|
||||
# ---
|
||||
main() {
|
||||
local num_words=${1:-$DEFAULT_WORDS}
|
||||
local delim=${2:-$DEFAULT_DELIM}
|
||||
|
||||
[[ "$num_words" =~ ^[1-9][0-9]*$ ]] || error "num_words must be a positive integer"
|
||||
[[ -f "$WORD_LIST" ]] || error "Word-list not found: $WORD_LIST"
|
||||
command -v xclip >/dev/null || error "xclip not found (install xclip)"
|
||||
|
||||
# 1. Pick words
|
||||
local -a words
|
||||
mapfile -t words < <(shuf -n "$num_words" "$WORD_LIST")
|
||||
|
||||
# 2. Capitalise every word
|
||||
local i
|
||||
for i in "${!words[@]}"; do
|
||||
words[i]=$(printf '%s' "${words[i]}" | sed 's/^\(.\)/\U\1/')
|
||||
done
|
||||
|
||||
# 3. Append digit to one random word
|
||||
local dig_idx=$(( RANDOM % num_words ))
|
||||
words[dig_idx]+=$(( RANDOM % 10 ))
|
||||
|
||||
# 4. Join with delimiter
|
||||
local pass
|
||||
pass=$(IFS="$delim"; printf '%s' "${words[*]}")
|
||||
|
||||
# 5. Copy and report
|
||||
printf '%s' "$pass" | xclip -selection clipboard
|
||||
info "Generated password: $pass"
|
||||
info "Password copied to clipboard."
|
||||
}
|
||||
|
||||
main "$@"
|
||||
72
scripts/jascp.sh
Executable file
72
scripts/jascp.sh
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env bash
|
||||
# ---
|
||||
# @file_name: jascp.sh
|
||||
# @version: 1.2.0
|
||||
# @project_name: jascp (Just Another SCP)
|
||||
# @description: Download-only, upload-only, or download-edit-upload helper.
|
||||
# @author: Jamie Albert (empty_produce)
|
||||
# @author_contact: <mailto:empty.produce@flatmail.me>
|
||||
# @license: GNU Affero General Public License v3.0 (Included in LICENSE)
|
||||
# Copyright (C) 2025, Jamie Albert
|
||||
# ---
|
||||
set -euo pipefail
|
||||
REMOTE_HOST='root@hephaestus'
|
||||
REMOTE_PATH='/home/oc/docker_config/compose.yml'
|
||||
LOCAL_PATH='/tmp/compose.yml'
|
||||
EDITOR="codium"
|
||||
error() { printf 'Error: %s\n' "$*" >&2; exit 1; }
|
||||
info() { printf '%s\n' "$*"; }
|
||||
|
||||
# ---
|
||||
# Description: Download remote file to local path.
|
||||
# Globals: REMOTE_HOST, REMOTE_PATH, LOCAL_PATH
|
||||
# ---
|
||||
download_file() {
|
||||
scp -q "${REMOTE_HOST}:${REMOTE_PATH}" "$LOCAL_PATH" || error 'Download failed'
|
||||
info "Downloaded → $LOCAL_PATH"
|
||||
}
|
||||
|
||||
# ---
|
||||
# Description: Upload local file to remote host.
|
||||
# Globals: REMOTE_HOST, REMOTE_PATH, LOCAL_PATH
|
||||
# ---
|
||||
upload_file() {
|
||||
[[ -f $LOCAL_PATH ]] || error "Local file missing: $LOCAL_PATH"
|
||||
scp -q "$LOCAL_PATH" "${REMOTE_HOST}:${REMOTE_PATH}" || error 'Upload failed'
|
||||
info "Uploaded ← $LOCAL_PATH"
|
||||
}
|
||||
|
||||
# ---
|
||||
# Description: Download, edit, then upload.
|
||||
# Globals: REMOTE_HOST, REMOTE_PATH, LOCAL_PATH, EDITOR
|
||||
# ---
|
||||
edit_cycle() {
|
||||
download_file
|
||||
command -v "$EDITOR" >/dev/null || error "Editor '$EDITOR' not found"
|
||||
"$EDITOR" "$LOCAL_PATH"
|
||||
}
|
||||
|
||||
# ---
|
||||
# Description: Parse flags and run chosen mode.
|
||||
# Return Code: 0 on success
|
||||
# ---
|
||||
main() {
|
||||
local mode=''
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-d) mode='download'; shift ;;
|
||||
-u) mode='upload'; shift ;;
|
||||
*) error "Unknown option: $1 (use -d or -u)" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
command -v scp >/dev/null || error 'scp not found'
|
||||
|
||||
case "$mode" in
|
||||
download) download_file ;;
|
||||
upload) upload_file ;;
|
||||
'') edit_cycle ;;
|
||||
*) error "Unexpected mode: $mode" ;;
|
||||
}
|
||||
|
||||
main "$@"
|
||||
112
scripts/jau.sh
Executable file
112
scripts/jau.sh
Executable file
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env bash
|
||||
# ---
|
||||
# @file_name: jau.sh
|
||||
# @version: 1.0.0
|
||||
# @description: Full system update handler for Fedora-based systems with DNF and Flatpak
|
||||
# @author: Jamie Albert (empty_produce)
|
||||
# @author_contact: <mailto:empty.produce@flatmail.me>
|
||||
#
|
||||
# @license: GNU Affero General Public License v3.0 (Included in LICENSE)
|
||||
# Copyright (C) 2025, Jamie Albert
|
||||
# ---
|
||||
set -euo pipefail
|
||||
error() { printf 'Error: %s\n' "$*" >&2; exit 1; }
|
||||
info() { printf '%s\n' "$*"; }
|
||||
|
||||
# ---
|
||||
# Description: Install package if missing.
|
||||
# ---
|
||||
install_if_missing() {
|
||||
local pkg=$1
|
||||
if ! command -v "$pkg" &>/dev/null; then
|
||||
info "Installing missing dependency: $pkg"
|
||||
sudo dnf install -y "$pkg" || error "Failed to install $pkg"
|
||||
else
|
||||
info "Dependency satisfied: $pkg"
|
||||
fi
|
||||
}
|
||||
|
||||
# ---
|
||||
# Description: Refresh DNF cache and update all packages.
|
||||
# ---
|
||||
run_dnf_update() {
|
||||
info "Refreshing DNF cache..."
|
||||
sudo dnf -y makecache --refresh || error "Failed to refresh DNF cache"
|
||||
|
||||
info "Updating all packages..."
|
||||
sudo dnf -y update || error "DNF update failed"
|
||||
}
|
||||
|
||||
# ---
|
||||
# Description: Handle leftover RPM configuration files.
|
||||
# ---
|
||||
handle_rpmconf() {
|
||||
if command -v rpmconf &>/dev/null; then
|
||||
info "Handling leftover RPM configuration files..."
|
||||
sudo rpmconf -a || error "rpmconf execution failed"
|
||||
else
|
||||
info "rpmconf not available; skipping config file handling"
|
||||
fi
|
||||
}
|
||||
|
||||
# ---
|
||||
# Description: Install security updates if any exist.
|
||||
# ---
|
||||
install_security_updates() {
|
||||
info "Checking for security updates..."
|
||||
if sudo dnf check-update --security &>/dev/null; then
|
||||
info "Installing security updates..."
|
||||
sudo dnf -y update --security || error "Security update failed"
|
||||
else
|
||||
info "No security updates available."
|
||||
fi
|
||||
}
|
||||
|
||||
# ---
|
||||
# Description: Remove unused packages and clean cache.
|
||||
# ---
|
||||
cleanup_packages() {
|
||||
info "Removing unused dependencies..."
|
||||
sudo dnf -y autoremove || error "DNF autoremove failed"
|
||||
|
||||
info "Cleaning cached package data..."
|
||||
sudo dnf clean all || error "DNF clean failed"
|
||||
}
|
||||
|
||||
# ---
|
||||
# Description: Update Flatpak applications and remove unused runtimes.
|
||||
# ---
|
||||
update_flatpak() {
|
||||
if command -v flatpak &>/dev/null; then
|
||||
info "Updating Flatpak applications..."
|
||||
flatpak update -y || error "Flatpak update failed"
|
||||
|
||||
info "Removing unused Flatpak runtimes..."
|
||||
flatpak uninstall --unused -y || error "Flatpak cleanup failed"
|
||||
else
|
||||
info "Flatpak not installed; skipping Flatpak updates"
|
||||
fi
|
||||
}
|
||||
|
||||
# ---
|
||||
# Description: Main routine.
|
||||
# Globals: FORCE_ROOT
|
||||
# ---
|
||||
main() {
|
||||
|
||||
info "Starting system updates..."
|
||||
|
||||
install_if_missing rpmconf
|
||||
install_if_missing flatpak
|
||||
|
||||
run_dnf_update
|
||||
handle_rpmconf
|
||||
install_security_updates
|
||||
cleanup_packages
|
||||
update_flatpak
|
||||
|
||||
info "System updates completed successfully."
|
||||
}
|
||||
|
||||
trap 'error "Command failed at line $LINENO"' ERR
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user