initial commit
This commit is contained in:
commit
a41118e9af
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*~
|
||||
.DS_Store
|
||||
*.pkg.tar.zst
|
||||
*.pkg.tar.zst.sig
|
20
PKGBUILD
Normal file
20
PKGBUILD
Normal 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
41
genpw
Executable 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 ''
|
Loading…
Reference in New Issue
Block a user