diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2025-11-27 20:46:19 -0500 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2025-11-27 20:46:19 -0500 |
| commit | 09e3e8fde2f251f54803f129b9ffb68930e455ae (patch) | |
| tree | ff6f0b53ccfff43313469f10b2d4b72c771723f0 /executables | |
| parent | Ignore other gpg files (diff) | |
| download | dotfiles-09e3e8fde2f251f54803f129b9ffb68930e455ae.zip | |
update openbsd install
Diffstat (limited to 'executables')
| -rwxr-xr-x | executables/bin/get-password | 36 | ||||
| -rwxr-xr-x | executables/bin/gh-clone-all | 102 | ||||
| -rwxr-xr-x | executables/bin/migrate-to-sourcehut | 76 | ||||
| -rwxr-xr-x | executables/bin/optimize-image | 83 |
4 files changed, 0 insertions, 297 deletions
diff --git a/executables/bin/get-password b/executables/bin/get-password deleted file mode 100755 index 3b83bb7..0000000 --- a/executables/bin/get-password +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -set -e - -VAULT="Private" -CREDENTIAL="" - -main() { - parse_args "$@" - op read "op://$VAULT/$CREDENTIAL/password" -} - -parse_args() { - while [ $# -gt 0 ]; do - case "$1" in - --vault) - VAULT="$2" - shift 2 - ;; - --credential) - CREDENTIAL="$2" - shift 2 - ;; - *) - echo "Usage: $0 [--vault <name>] --credential <name>" - exit 1 - ;; - esac - done - - if [ -z "$CREDENTIAL" ]; then - echo "Invalid or empty CREDENTIAL" >&2 - exit 1 - fi -} - -main "$@" diff --git a/executables/bin/gh-clone-all b/executables/bin/gh-clone-all deleted file mode 100755 index 77de93a..0000000 --- a/executables/bin/gh-clone-all +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env bash -# Clone all repositories from a GitHub user or organization using the gh CLI. -# -# Usage: -# gh-clone-all [--exclude-archived] [--exclude-forks] [--pull] <github-entity> [target-directory] -# -# Args: -# --exclude-archived: If set, skip archived repos (default: include all) -# --exclude-forks: If set, skip forked repos -# --pull: If set, pull latest changes in existing repos -# --limit: The maximum number of repos to clone (default: 10000) -# <github-entity>: The GitHub username or org (e.g. eugenetriguba) -# [target-directory]: Optional directory to clone repos into -set -euo pipefail - -EXCLUDE_ARCHIVED=0 -EXCLUDE_FORKS=0 -PULL_EXISTING=0 -ENTITY="" -TARGET_DIR="." -LIMIT=10000 - -main() { - parse_args "$@" - clone_all_repos -} - -parse_args() { - while [[ $# -gt 0 ]]; do - case "$1" in - --exclude-archived) - EXCLUDE_ARCHIVED=1 - shift - ;; - --exclude-forks) - EXCLUDE_FORKS=1 - shift - ;; - --pull) - PULL_EXISTING=1 - shift - ;; - --limit) - LIMIT="$2" - shift 2 - ;; - -*) - usage - ;; - *) - if [[ -z "$ENTITY" ]]; then - ENTITY="$1" - elif [[ "$TARGET_DIR" == "." ]]; then - TARGET_DIR="$1" - else - usage - fi - shift - ;; - esac - done - if [[ -z "$ENTITY" ]]; then - usage - fi - mkdir -p "$TARGET_DIR" -} - -usage() { - echo "Usage: $0 [--exclude-archived] [--exclude-forks] [--pull] [--limit] <github-entity> [target-directory]" - exit 1 -} - -clone_all_repos() { - gh repo list "$ENTITY" --limit "$LIMIT" --json name,sshUrl,archivedAt,isFork | - jq -c '.[]' | while read -r repo; do - NAME=$(echo "$repo" | jq -r '.name') - CLONE_URL=$(echo "$repo" | jq -r '.sshUrl') - ARCHIVED_AT=$(echo "$repo" | jq -r '.archivedAt') - IS_FORK=$(echo "$repo" | jq -r '.isFork') - DEST="$TARGET_DIR/$NAME" - if [[ "$EXCLUDE_ARCHIVED" -eq 1 && "$ARCHIVED_AT" != "null" ]]; then - continue - fi - if [[ "$EXCLUDE_FORKS" -eq 1 && "$IS_FORK" == "true" ]]; then - continue - fi - if [[ -d "$DEST" ]]; then - echo "Repo $NAME already exists." - if [[ "$PULL_EXISTING" -eq 1 ]]; then - echo "Pulling latest changes in $DEST" - git -C "$DEST" pull --ff-only || echo "Warning: git pull failed in $DEST, continuing..." - else - echo "Skipping $NAME (already exists)" - fi - continue - fi - echo "Cloning $CLONE_URL into $DEST" - git clone "$CLONE_URL" "$DEST" - done -} - -main "$@" diff --git a/executables/bin/migrate-to-sourcehut b/executables/bin/migrate-to-sourcehut deleted file mode 100755 index d7e471a..0000000 --- a/executables/bin/migrate-to-sourcehut +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -set -euo pipefail -set -x - -REPOS_DIR="$HOME/src/" -SOURCEHUT_USER="eugenetriguba" - -main() { - parse_args "$@" - - cd "$REPOS_DIR" - for repo in */; do - if [ -d "$repo/.git" ]; then - echo "Processing $repo..." - cd "$repo" - - if ! git remote | grep -q "^origin$"; then - echo "No origin remote found for $repo, skipping..." - cd .. - continue - fi - - if ! git remote get-url origin | grep -q "git.sr.ht"; then - echo "Migrating $repo to SourceHut..." - - local repo_name - repo_name=$(git remote get-url origin | cut -d '/' -f 2 | cut -d '.' -f 1) - git remote remove origin - git remote add origin "git@git.sr.ht:~${SOURCEHUT_USER}/${repo_name}" - - local current_branch - current_branch=$(git branch --show-current) - if [ "$current_branch" = "master" ]; then - echo "Renaming master branch to main..." - git branch -m master main - fi - - git push --push-option visiblity="private" -u origin main - git push origin main --tags - fi - - cd .. - fi - done -} - -parse_args() { - while [[ $# -gt 0 ]]; do - case "$1" in - --repos-dir) - REPOS_DIR="$2" - shift 2 - ;; - --sourcehut-user) - SOURCEHUT_USER="$2" - shift 2 - ;; - *) - echo "Usage: $0 [--repos-dir <path>] [--sourcehut-user <username>]" - exit 1 - ;; - esac - - if [[ -z "$REPOS_DIR" || ! -d "$REPOS_DIR" ]]; then - echo "Invalid or empty REPOS_DIR: $REPOS_DIR" - exit 1 - fi - - if [[ -z "$SOURCEHUT_USER" ]]; then - echo "SOURCEHUT_USER must be specified." - exit 1 - fi - done -} - -main "$@" diff --git a/executables/bin/optimize-image b/executables/bin/optimize-image deleted file mode 100755 index 075684b..0000000 --- a/executables/bin/optimize-image +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh -set -e - -quality=85 -source_img_path="" -result_img_path="" - -main() { - parse_args "$@" - - original_size=$(get_file_size "$source_img_path") - echo "Optimizing: $source_img_path -> $result_img_path (quality: $quality%)" - magick "$source_img_path" -strip -quality "${quality}%" "$result_img_path" - new_size=$(get_file_size "$result_img_path") - echo "File size: $original_size -> $new_size" -} - -parse_args() { - while [ $# -gt 0 ]; do - case $1 in - --quality) - if [ -n "$2" ] && [ "$2" -ge 1 ] && [ "$2" -le 100 ] 2>/dev/null; then - quality="$2" - shift 2 - else - echo "Error: --quality requires a number between 1 and 100" - exit 1 - fi - ;; - -h | --help) - print_usage - exit 0 - ;; - -*) - echo "Error: Unknown option $1" - print_usage - exit 1 - ;; - *) - if [ -z "$source_img_path" ]; then - source_img_path="$1" - else - echo "Error: Too many arguments" - print_usage - exit 1 - fi - shift - ;; - esac - done - - if [ -z "$source_img_path" ]; then - echo "Error: source image path is required" - print_usage - exit 1 - fi - - if [ ! -f "$source_img_path" ]; then - echo "Error: Source file '$source_img_path' does not exist" - exit 1 - fi - - result_img_path="${source_img_path%.*}.webp" -} - -print_usage() { - echo "Usage: $0 [OPTIONS] <source-img-path>" - echo "" - echo "Options:" - echo " --quality <value> Set quality (1-100, default: 85)" - echo " -h, --help Show this help message" - echo "" - echo "Examples:" - echo " $0 input.jpg" - echo " $0 --quality 90 input.jpg" - echo " $0 --quality 80 input.png" -} - -get_file_size() { - du -h "$1" | awk '{ print $1 }' -} - -main "$@" |