commit a41118e9afa5325577997ef733d15a3a1aad54b1 Author: Sebastian Hugentobler Date: Thu Jun 22 09:46:21 2023 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..765efc1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*~ +.DS_Store +*.pkg.tar.zst +*.pkg.tar.zst.sig diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..f1130cb --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,20 @@ +# Maintainer: Sebastian Hugentobler + +pkgname=genpw +pkgver=0.1.0 +pkgrel=1 +pkgdesc="Generate random passwords of a specified length." +arch=("any") +url="https://code.vanwa.ch" +license=('MIT') +depends=("coreutils") +source=( + "genpw" +) +sha256sums=("a45fcc797851b494de1a3f21e10435a754d955e340a8f3a686b7f83fca85ec9a") + +package() { + cd "$srcdir/" + + install -Dm 755 genpw "$pkgdir/usr/bin/genpw" +} diff --git a/genpw b/genpw new file mode 100755 index 0000000..6081cef --- /dev/null +++ b/genpw @@ -0,0 +1,41 @@ +#!/usr/bin/env sh +set -o errexit +set -o nounset + +pw_length=24 + +display_help() { + echo "Usage: $0 [option...] " >&2 + echo + echo " -l, password length [default: $pw_length]" + echo " -h, display this help and exit" + echo +} + +parse_args() { + while getopts ":hl:" opt; do + case $opt in + h) + display_help + exit 0 + ;; + l) + pw_length=$OPTARG + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + display_help + exit 1 + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + display_help + exit 1 + ;; + esac + done +} + +parse_args "$@" +tr -dc A-Za-z0-9