feat: move config from arc

This commit is contained in:
Jamie Albert
2025-11-03 16:07:40 +00:00
parent 5bc91f8354
commit a533ac2102
25 changed files with 7584 additions and 352 deletions

149
scripts/init/install_nvidia.sh Executable file
View File

@@ -0,0 +1,149 @@
#!/bin/bash
# NVIDIA Driver Installation Script for Fedora Workstation
# Check if the script is run with sudo
if [ "$EUID" -ne 0 ]; then
echo "Please run this script with sudo"
exit 1
fi
# Funtion to echo colored text
color_echo() {
local color="$1"
local text="$2"
case "$color" in
"red") echo -e "\033[0;31m$text\033[0m" ;;
"green") echo -e "\033[0;32m$text\033[0m" ;;
"yellow") echo -e "\033[1;33m$text\033[0m" ;;
"blue") echo -e "\033[0;34m$text\033[0m" ;;
*) echo "$text" ;;
esac
}
# Set variables
ACTUAL_USER=$SUDO_USER
ACTUAL_HOME=$(eval echo ~$SUDO_USER)
LOG_FILE="/var/log/nvidia_driver_installation.log"
# Function to generate timestamps
get_timestamp() {
date +"%Y-%m-%d %H:%M:%S"
}
# Function to handle errors
handle_error() {
local exit_code=$?
local message="$1"
if [ $exit_code -ne 0 ]; then
color_echo \"red\" "ERROR: $message"
exit $exit_code
fi
}
echo "";
echo "╔══════════════════════════════════════════════════════════╗";
echo "║ ║";
echo "║ ███╗ ██╗██╗ ██╗██╗██████╗ ██╗ █████╗ ║";
echo "║ ████╗ ██║██║ ██║██║██╔══██╗██║██╔══██╗ ║";
echo "║ ██╔██╗ ██║██║ ██║██║██║ ██║██║███████║ ║";
echo "║ ██║╚██╗██║╚██╗ ██╔╝██║██║ ██║██║██╔══██║ ║";
echo "║ ██║ ╚████║ ╚████╔╝ ██║██████╔╝██║██║ ██║ ║";
echo "║ ╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═╝ ║";
echo "║ ║";
echo "║ ██████╗ ██████╗ ██╗██╗ ██╗███████╗██████╗ ███████╗ ║";
echo "║ ██╔══██╗██╔══██╗██║██║ ██║██╔════╝██╔══██╗██╔════╝ ║";
echo "║ ██║ ██║██████╔╝██║██║ ██║█████╗ ██████╔╝███████╗ ║";
echo "║ ██║ ██║██╔══██╗██║╚██╗ ██╔╝██╔══╝ ██╔══██╗╚════██║ ║";
echo "║ ██████╔╝██║ ██║██║ ╚████╔╝ ███████╗██║ ██║███████║ ║";
echo "║ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝╚══════╝ ║";
echo "║ ║";
echo "╚══════════════════════════════════════════════════════════╝";
echo "";
echo "This script installs NVIDIA drivers on Fedora Workstation"
echo ""
echo "IMPORTANT: This script should be run outside of the graphical user interface (GUI)."
echo "To access a bare terminal window:"
echo "1. Press Ctrl+Alt+F3 to switch to a virtual console."
echo "2. Log in with your username and password."
echo "3. Run this script with sudo."
echo "4. After installation, reboot your system"
echo ""
echo "If you're not comfortable with this process, please seek assistance from an experienced user."
echo ""
echo "Please choose the installation method:"
echo "1) RPM Fusion method (recommended)"
echo "2) NVIDIA official .run file method"
read -p "Enter your choice (1 or 2): " choice
case $choice in
1)
color_echo "blue" "RPM Fusion method selected"
# Add RPM Fusion repositories
color_echo "yellow" "Adding RPM Fusion repositories..."
dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
dnf install -y https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
handle_error "Failed to add RPM Fusion repositories"
# Update the system
color_echo "yellow" "Updating the system..."
dnf update -y
handle_error "Failed to update the system"
# Install NVIDIA drivers
color_echo "yellow" "Installing NVIDIA drivers..."
dnf install -y akmod-nvidia
handle_error "Failed to install NVIDIA drivers"
# Install CUDA (optional)
read -p "Do you want to install CUDA? (y/n): " install_cuda
if [[ $install_cuda =~ ^[Yy]$ ]]; then
color_echo "yellow" "Installing CUDA..."
dnf install -y xorg-x11-drv-nvidia-cuda
handle_error "Failed to install CUDA"
fi
;;
2)
color_echo "blue" "NVIDIA official .run file method selected"
# Install necessary packages
color_echo "yellow" "Installing necessary packages..."
dnf install -y kernel-devel kernel-headers gcc make dkms acpid libglvnd-glx libglvnd-opengl libglvnd-devel pkgconfig
handle_error "Failed to install necessary packages"
# Download the latest NVIDIA driver
color_echo "yellow" "Downloading the latest NVIDIA driver..."
driver_url=$(curl -s https://www.nvidia.com/Download/processFind.aspx?psid=101&pfid=816&osid=12&lid=1&whql=1&lang=en-us&ctk=0 | grep -o 'https://[^"]*' | grep '.run' | head -n 1)
wget $driver_url -O /tmp/nvidia_driver.run
handle_error "Failed to download NVIDIA driver"
# Stop the display manager
color_echo "blue" "Stopping the display manager..."
systemctl isolate multi-user.target
handle_error "Failed to stop the display manager"
# Install the NVIDIA driver
color_echo "yellow" "Installing the NVIDIA driver..."
bash /tmp/nvidia_driver.run --silent
handle_error "Failed to install NVIDIA driver"
# Start the display manager
color_echo "blue" "Starting the display manager..."
systemctl isolate graphical.target
handle_error "Failed to start the display manager"
;;
*)
color_echo "red" "Invalid choice. Exiting."
exit 1
;;
esac
color_echo "green" "NVIDIA driver installation completed."
echo "Installation complete. Please reboot your system to apply changes."
read -p "Do you want to reboot now? (y/n): " reboot_choice
if [[ $reboot_choice =~ ^[Yy]$ ]]; then
color_echo "green" "Rebooting the system..."
reboot
else
color_echo "blue" "Reboot postponed. Please remember to reboot your system to complete the installation."
fi

View File

@@ -10,36 +10,23 @@
# ---
set -euo pipefail
error() {
declare error_msg exit_code="$1"
shift
printf -v error_msg 'error[%d]: %s\n' "$exit_code" "$*"
printf '%s' "$error_msg" >&2
exit "${exit_code}"
}
info() {
declare info_msg
printf -v info_msg '%s\n' "$*"
printf '%s' "$info_msg"
}
# ---
# @return_code: [2] Unable to source.
# shellcheck source=/usr/local/etc/jade.sh/jade.conf
# shellcheck disable=2015
# shellcheck disable=2015,1090,1091
# ---
setup() {
declare -r conf="/usr/local/etc/jade.sh/jade.conf"
[[ -f "${conf}" ]] && . "${conf}" || error 2 "unable to source '${conf}'"
declare script_dir; script_dir="$(cd "$(dirname "$(readlink -f "$0")")" && pwd)"
. "${script_dir}/../libs/libs_cradle.sh"
declare -r conf="../config/jade.conf"
[[ -f "${conf}" ]] && . "${conf}" || cradle::error 2 "unable to source '${conf}'"
}
# ---
# @return_code: [3] Download failed.
# ---
download_file() {
scp -q "${REMOTE_HOST}:${REMOTE_PATH}" "$LOCAL_PATH" || error 3 'Download failed'
info "Downloaded: $LOCAL_PATH"
scp -q "${REMOTE_HOST}:${REMOTE_PATH}" "$LOCAL_PATH" || cradle::error 3 'Download failed'
cradle::info "Downloaded: $LOCAL_PATH"
}
# ---
@@ -48,11 +35,11 @@ download_file() {
# @return_code: [6] Upload failed.
# ---
upload_file() {
[[ -f "$LOCAL_PATH" ]] || error 4 "Local file missing: $LOCAL_PATH"
ssh -q "${REMOTE_HOST}" "[[ -f '${REMOTE_PATH}' ]] && cp -f '${REMOTE_PATH}' '${REMOTE_PATH}.bak'" || error 5 'Failed to create remote backup'
scp -q "$LOCAL_PATH" "${REMOTE_HOST}:${REMOTE_PATH}" || error 6 'Upload failed'
info "Uploaded: $LOCAL_PATH"
info "Remote file backed up to: ${REMOTE_PATH}.bak"
[[ -f "$LOCAL_PATH" ]] || cradle::error 4 "Local file missing: $LOCAL_PATH"
ssh -q "${REMOTE_HOST}" "[[ -f '${REMOTE_PATH}' ]] && cp -f '${REMOTE_PATH}' '${REMOTE_PATH}.bak'" || cradle::error 5 'Failed to create remote backup'
scp -q "$LOCAL_PATH" "${REMOTE_HOST}:${REMOTE_PATH}" || cradle::error 6 'Upload failed'
cradle::info "Uploaded: $LOCAL_PATH"
cradle::info "Remote file backed up to: ${REMOTE_PATH}.bak"
}
# ---
@@ -62,7 +49,7 @@ upload_file() {
edit_file() {
download_file
if ! command -v "$EDITOR" >/dev/null; then
error 7 "Editor not found: '$EDITOR'"
cradle::error 7 "Editor not found: '$EDITOR'"
fi
"$EDITOR" "$LOCAL_PATH"
}
@@ -75,8 +62,8 @@ upload_compose() {
upload_file
ssh -q "${REMOTE_HOST}" \
"cd '$(dirname "$REMOTE_PATH")' && exec docker compose up -d --remove-orphans" \
|| error 8 'Remote docker compose up failed'
info 'Remote docker compose up -d completed'
|| cradle::error 8 'Remote docker compose up failed'
cradle::info 'Remote docker compose up -d completed'
}
# ---
@@ -87,12 +74,12 @@ upload_compose() {
upload_restart() {
ssh -q "${REMOTE_HOST}" \
"cd '$(dirname "$REMOTE_PATH")' && exec docker compose down" \
|| error 9 'Remote docker compose down failed'
|| cradle::error 9 'Remote docker compose down failed'
upload_file
ssh -q "${REMOTE_HOST}" \
"cd '$(dirname "$REMOTE_PATH")' && exec docker compose up -d --remove-orphans" \
|| error 11 'Remote docker compose up failed during restart'
info 'Remote docker compose restart completed'
|| cradle::error 11 'Remote docker compose up failed during restart'
cradle::info 'Remote docker compose restart completed'
}
# ---
@@ -111,12 +98,12 @@ main() {
-u) mode='upload' ; shift ;;
-uc) mode='up' ; shift ;;
-ur) mode='restart' ; shift ;;
*) error 10 "Unknown option: $1 (use -d, -u, -uc, -ur)" ;;
*) cradle::error 10 "Unknown option: $1 (use -d, -u, -uc, -ur)" ;;
esac
done
command -v scp >/dev/null || error 12 "'scp' not found"
command -v ssh >/dev/null || error 13 "'ssh' not found"
command -v scp >/dev/null || cradle::error 12 "'scp' not found"
command -v ssh >/dev/null || cradle::error 13 "'ssh' not found"
case "$mode" in
download) download_file ;;
@@ -124,7 +111,7 @@ main() {
up) upload_compose ;;
restart) upload_restart ;;
'') edit_file ;;
*) error 14 "Unexpected mode: $mode" ;;
*) cradle::error 14 "Unexpected mode: $mode" ;;
esac
}

View File

@@ -1,91 +0,0 @@
#!/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
declare -gr WORD_LIST='/usr/share/dict/japg.list'
declare -gr DEFAULT_DELIM='-'
declare -gi DEFAULT_WORDS=5
# ---
# @usage: error <exit_code> <message>
# @description: Print an error message to stderr and exit with a specific code.
# @arg: $1 - The exit code to use.
# @arg: $* - The error message to print.
# @return_code: [N] The specified exit code.
# ---
error() {
declare exit_code="$1"
shift
printf 'error: %s\n' "$*" >&2
exit "${exit_code}"
}
# ---
# @description: Print an informational message to stdout.
# @arg: $* - The message to print.
# ---
info() {
printf '%s\n' "$*"
}
# ---
# @description: Perform initial setup checks.
# Verifies the word list file exists and xclip is installed.
# @global: WORD_LIST - Path to the word list file.
# @return_code: [2] Word-list file not found.
# @return_code: [3] Required tool 'xclip' not found.
# ---
setup() {
[[ -f "${WORD_LIST}" ]] || error 2 "Word-list not found: $WORD_LIST"
command -v xclip >/dev/null || error 3 "xclip not found (install xclip)"
}
# ---
# @description: Main routine to generate and copy the passphrase.
# @arg: $1 - Number of words (optional, defaults to DEFAULT_WORDS).
# @arg: $2 - Delimiter (optional, defaults to DEFAULT_DELIM).
# @global: WORD_LIST - Path to the word list file.
# @global: DEFAULT_WORDS - Default number of words.
# @global: DEFAULT_DELIM - Default delimiter.
# @return_code: [1] General error (inherits from set -e).
# @return_code: [4] Invalid number of words provided.
# @return_code: [2] Word-list not found (inherited from setup).
# @return_code: [3] xclip not found (inherited from setup).
# ---
main() {
setup
declare num_words="${1:-$DEFAULT_WORDS}"
declare delim="${2:-$DEFAULT_DELIM}"
[[ "${num_words}" =~ ^[1-9][0-9]*$ ]] || error 4 "num_words must be a positive integer"
declare -a words
mapfile -t words < <(shuf -n "$num_words" "$WORD_LIST") || error 1 "Failed to read words from list"
declare i
for i in "${!words[@]}"; do
words[i]="${words[i]^}"
done
declare dig_idx=$(( RANDOM % num_words ))
words[dig_idx]+=$(( RANDOM % 10 ))
declare pass
IFS="$delim"
printf -v pass '%s' "${words[*]}" || error 1 "Failed to construct passphrase"
printf '%s' "$pass" | xclip -selection clipboard || error 1 "Failed to copy passphrase to clipboard"
info "Generated password: $pass"
info "Password copied to clipboard."
}
main "$@"

View File

@@ -1,63 +0,0 @@
#!/usr/bin/env bash
# ---
# @file_name: jarm.sh
# @version: 1.0.0
# @description: Lazy script for mounting rclone
# @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
# ---
# @usage: error <exit_code> <message>
# @description: Print an error message to stderr and exit with a specific code.
# @arg: $1 - The exit code to use.
# @arg: $* - The error message to print.
# @return_code: [N] The specified exit code.
# ---
error() {
declare error_msg exit_code="$1"
shift
printf -v error_msg 'error[%d]: %s\n' "$exit_code" "$*"
printf '%s' "$error_msg" >&2
exit "${exit_code}"
}
# ---
# @description: Print an informational message to stdout.
# @arg: $* - The message to print.
# ---
info() {
declare info_msg
printf -v info_msg '%s\n' "$*"
printf '%s' "$info_msg"
}
# ---
# @description: Mount koofr_vault to location
# ---
rclone_mount_koofr() {
info "Mounting koofr..."
/usr/bin/rclone mount koofr: /home/jamie/dao/storage/koofr &
}
# ---
# @description: Mount koofr_vault to location
# ---
rclone_mount_koofr_vault() {
info "Mounting vault..."
/usr/bin/rclone mount koofr_vault: /home/jamie/dao/storage/vault &
}
# ---
# @description: main function call
# @return_code: [2] Failed to mount koofr to dir.
# @return_code: [3] Failed to mount vault to dir.
main() {
rclone_mount_koofr || error 2 "Failed to mount koofr."
rclone_mount_koofr_vault || error 3 "Failed to mount vault."
}
main "$@"

View File

@@ -10,145 +10,122 @@
# ---
set -euo pipefail
# ---
# @usage: error <exit_code> <message>
# @description: Print an error message to stderr and exit with a specific code.
# @arg: $1 - The exit code to use.
# @arg: $* - The error message to print.
# @return_code: [N] The specified exit code.
# ---
error() {
declare exit_code="$1"
shift
declare error_msg
printf -v error_msg 'error[%d]: %s\n' "$exit_code" "$*"
printf '%s' "$error_msg" >&2
exit "${exit_code}"
}
# ---
# @description: Print an informational message to stdout.
# @arg: $* - The message to print.
# ---
info() {
declare info_msg
printf -v info_msg '%s\n' "$*"
printf '%s' "$info_msg"
}
# ---
# @description: Perform initial setup checks. Verifies required base commands (dnf, sudo) are available.
# @return_code: [2] Required tool 'sudo' not found.
# @return_code: [3] Required tool 'dnf' not found.
# shellcheck disable=1091
# ---
setup() {
command -v sudo >/dev/null || error 2 "sudo not found"
sudo sh -c 'command -v dnf >/dev/null' || error 3 "dnf not found (script requires a DNF-based system)"
declare script_dir; script_dir="$(cd "$(dirname "$(readlink -f "$0")")" && pwd)"
. "${script_dir}/../libs/libs_cradle.sh"
command -v sudo >/dev/null || cradle::error 2 "sudo not found"
sudo sh -c 'command -v dnf >/dev/null' || cradle::error 3 "dnf not found (script requires a DNF-based system)"
}
# ---
# @description: Install package if missing.
# @arg: $1 - The name of the package/command to check and install.
# @return_code: [1] General error (inherits from set -e).
# @return_code: [1] General cradle::error (inherits from set -e).
# @return_code: [4] Failed to install the specified package.
# ---
install_if_missing() {
declare pkg="$1"
if ! command -v "$pkg" &>/dev/null; then
info "Installing missing dependency: $pkg"
sudo dnf install -y "$pkg" || error 4 "Failed to install $pkg"
cradle::info "Installing missing dependency: $pkg"
sudo dnf install -y "$pkg" || cradle::error 4 "Failed to install $pkg"
else
info "Dependency satisfied: $pkg"
cradle::info "Dependency satisfied: $pkg"
fi
}
# ---
# @description: Refresh DNF cache and update all packages.
# @return_code: [1] General error (inherits from set -e).
# @return_code: [1] General cradle::error (inherits from set -e).
# @return_code: [5] Failed to refresh DNF cache.
# @return_code: [6] DNF update failed.
# ---
run_dnf_update() {
info "Refreshing DNF cache..."
sudo dnf -y makecache --refresh || error 5 "Failed to refresh DNF cache"
cradle::info "Refreshing DNF cache..."
sudo dnf -y makecache --refresh || cradle::error 5 "Failed to refresh DNF cache"
info "Updating all packages..."
sudo dnf -y update || error 6 "DNF update failed"
cradle::info "Updating all packages..."
sudo dnf -y update || cradle::error 6 "DNF update failed"
}
# ---
# @description: Handle leftover RPM configuration files.
# @return_code: [1] General error (inherits from set -e).
# @return_code: [1] General cradle::error (inherits from set -e).
# @return_code: [7] rpmconf execution failed.
# ---
handle_rpmconf() {
if command -v rpmconf &>/dev/null; then
info "Handling leftover RPM configuration files..."
sudo rpmconf -a || error 7 "rpmconf execution failed"
cradle::info "Handling leftover RPM configuration files..."
sudo rpmconf -a || cradle::error 7 "rpmconf execution failed"
else
info "rpmconf not available; skipping config file handling"
cradle::info "rpmconf not available; skipping config file handling"
fi
}
# ---
# @description: Install security updates if any exist.
# @return_code: [1] General error (inherits from set -e).
# @return_code: [1] General cradle::error (inherits from set -e).
# @return_code: [8] Security update failed.
# ---
install_security_updates() {
info "Checking for security updates..."
cradle::info "Checking for security updates..."
# dnf check-update returns 100 if updates are available, 1 on error, 0 if not.
# We only want to proceed if it returns 100 (success with updates) or 0 (no updates).
# Using || true prevents set -e from triggering on exit code 100.
if sudo dnf check-update --security &>/dev/null || [[ $? -eq 100 ]]; then
info "Installing security updates..."
sudo dnf -y update --security || error 8 "Security update failed"
cradle::info "Installing security updates..."
sudo dnf -y update --security || cradle::error 8 "Security update failed"
else
info "No security updates available."
cradle::info "No security updates available."
fi
}
# ---
# @description: Remove unused packages and clean cache.
# @return_code: [1] General error (inherits from set -e).
# @return_code: [1] General cradle::error (inherits from set -e).
# @return_code: [9] DNF autoremove failed.
# @return_code: [10] DNF clean failed.
# ---
cleanup_packages() {
info "Removing unused dependencies..."
sudo dnf -y autoremove || error 9 "DNF autoremove failed"
cradle::info "Removing unused dependencies..."
sudo dnf -y autoremove || cradle::error 9 "DNF autoremove failed"
info "Cleaning cached package data..."
sudo dnf clean all || error 10 "DNF clean failed"
cradle::info "Cleaning cached package data..."
sudo dnf clean all || cradle::error 10 "DNF clean failed"
}
# ---
# @description: Update Flatpak applications and remove unused runtimes.
# @return_code: [1] General error (inherits from set -e).
# @return_code: [1] General cradle::error (inherits from set -e).
# @return_code: [11] Flatpak update failed.
# @return_code: [12] Flatpak cleanup failed.
# ---
update_flatpak() {
if command -v flatpak &>/dev/null; then
info "Updating Flatpak applications..."
flatpak update -y || error 11 "Flatpak update failed"
cradle::info "Updating Flatpak applications..."
flatpak update -y || cradle::error 11 "Flatpak update failed"
info "Removing unused Flatpak runtimes..."
flatpak uninstall --unused -y || error 12 "Flatpak cleanup failed"
cradle::info "Removing unused Flatpak runtimes..."
flatpak uninstall --unused -y || cradle::error 12 "Flatpak cleanup failed"
else
info "Flatpak not installed; skipping Flatpak updates"
cradle::info "Flatpak not installed; skipping Flatpak updates"
fi
}
# ---
# @description: Main routine.
# @arg: $@ - Command-line arguments (currently unused).
# @return_code: [1] General error (inherits from set -e).
# @return_code: [1] General cradle::error (inherits from set -e).
# @return_code: [N] Errors from called functions (e.g., setup, install_if_missing, etc.).
# ---
main() {
setup
info "Starting system updates..."
cradle::info "Starting system updates..."
install_if_missing rpmconf
install_if_missing flatpak
run_dnf_update
@@ -156,7 +133,7 @@ main() {
install_security_updates
cleanup_packages
update_flatpak
info "System updates completed successfully."
cradle::info "System updates completed successfully."
}
main "$@"

66
scripts/pwgen.sh Executable file
View File

@@ -0,0 +1,66 @@
#!/usr/bin/env bash
# ---
# @file_name: pwgen.sh
# @version: 1.0.1
# @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
declare -gr WORD_LIST='/usr/share/dict/japg.list'
declare -gr DEFAULT_DELIM='-'
declare -gi DEFAULT_WORDS=5
# ---
# @return_code: [2] Word-list file not found.
# @return_code: [3] Required tool 'xclip' not found.
# shellcheck disable=1091,1090
# ---
setup() {
declare script_dir; script_dir="$(cd "$(dirname "$(readlink -f "$0")")" && pwd)"
. "${script_dir}/../libs/libs_cradle.sh"
[[ -f "${WORD_LIST}" ]] || cradle::error 2 "Word-list not found: $WORD_LIST"
command -v xclip >/dev/null || cradle::error 3 "xclip not found (install xclip)"
}
# ---
# @arg: $1 - Number of words (optional, defaults to DEFAULT_WORDS).
# @arg: $2 - Delimiter (optional, defaults to DEFAULT_DELIM).
# @return_code: [1] General cradle::error (inherits from set -e).
# @return_code: [4] Invalid number of words provided.
# @return_code: [2] Word-list not found (inherited from setup).
# @return_code: [3] xclip not found (inherited from setup).
# ---
main() {
setup
declare num_words="${1:-$DEFAULT_WORDS}"
declare delim="${2:-$DEFAULT_DELIM}"
[[ "${num_words}" =~ ^[1-9][0-9]*$ ]] || cradle::error 4 "num_words must be a positive integer"
declare -a words
mapfile -t words < <(shuf -n "$num_words" "$WORD_LIST") || cradle::error 1 "Failed to read words from list"
declare i
for i in "${!words[@]}"; do
words[i]="${words[i]^}"
done
declare dig_idx=$(( RANDOM % num_words ))
words[dig_idx]+=$(( RANDOM % 10 ))
declare pass
IFS="$delim"
printf -v pass '%s' "${words[*]}" || cradle::error 1 "Failed to construct passphrase"
printf '%s' "$pass" | xclip -selection clipboard || cradle::error 1 "Failed to copy passphrase to clipboard"
cradle::info "Generated password: $pass"
cradle::info "Password copied to clipboard."
}
main "$@"

32
scripts/rclone_mount.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# ---
# @file_name: rclone_mount.sh
# @version: 1.0.0
# @description: Lazy script for mounting rclone
# @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
rclone_mount_koofr() {
echo "Mounting koofr..."
/usr/bin/rclone mount koofr: /home/jamie/dao/storage/koofr &
}
rclone_mount_koofr_vault() {
echo "Mounting vault..."
/usr/bin/rclone mount koofr_vault: /home/jamie/dao/storage/vault &
}
# ---
# @return_code: [2] Failed to mount koofr to dir.
# @return_code: [3] Failed to mount vault to dir.
# ---
main() {
rclone_mount_koofr || { echo "[2] Failed to mount koofr."; exit 2; }
rclone_mount_koofr_vault || { echo "[2] Failed to mount koofr vault."; exit 3; }
}
main "$@"