initial commit

This commit is contained in:
Sebastian Hugentobler 2023-06-22 09:46:21 +02:00
commit a41118e9af
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
3 changed files with 65 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*~
.DS_Store
*.pkg.tar.zst
*.pkg.tar.zst.sig

20
PKGBUILD Normal file
View File

@ -0,0 +1,20 @@
# Maintainer: Sebastian Hugentobler <shu@vanwa.ch>
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"
}

41
genpw Executable file
View File

@ -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 </dev/urandom | head -c "$pw_length"
echo ''