diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2010-12-20 13:22:29 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2010-12-20 13:22:29 +0000 |
commit | 18fa4231dc27ea8a34446c6a4c4c3815f413494c (patch) | |
tree | 536b269ea4eb462157a7c75f378b2b94f31b0b9a /abuild-keygen.in | |
parent | e524bc68e9679694d39f41f1f8388f294851fd7c (diff) | |
download | abuild-18fa4231dc27ea8a34446c6a4c4c3815f413494c.tar.gz abuild-18fa4231dc27ea8a34446c6a4c4c3815f413494c.tar.bz2 abuild-18fa4231dc27ea8a34446c6a4c4c3815f413494c.tar.xz abuild-18fa4231dc27ea8a34446c6a4c4c3815f413494c.zip |
abuild-keygen: implement -n for non-interactive mode
Diffstat (limited to 'abuild-keygen.in')
-rw-r--r-- | abuild-keygen.in | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/abuild-keygen.in b/abuild-keygen.in index af1ad90..6eefc16 100644 --- a/abuild-keygen.in +++ b/abuild-keygen.in @@ -15,6 +15,19 @@ abuild_conf=${ABUILD_CONF:-"$sysconfdir/abuild.conf"} abuild_home=${ABUILD_USERDIR:-"$HOME/.abuild"} abuild_userconf=${ABUILD_USERCONF:-"$abuild_home/abuild.conf"} +# ask for privkey unless non-interactive mode +# returns value in global $privkey +get_privkey_file() { + privkey="$abuild_home/$default_name.rsa" + [ "$non_interactive" = "yes" ] && return 0 + echo "Generating public/private rsa key pair for abuild" + echo -n "Enter file in which to save the key ($abuild_home/$default_name.rsa): " + + read line + if [ -n "$line" ]; then + privkey="$line" + fi +} usage() { echo "abuild-keygen $abuild_ver" @@ -23,6 +36,7 @@ usage() { echo " -a Set PACKAGER_PRIVKEY=<generated key> in $abuild_userconf" echo " -i Install public key into /etc/apk/keys using sudo" echo " -h Show this help" + echo " -n Non-interactive. Use defaults" echo "" exit 1 } @@ -47,26 +61,19 @@ else default_name="$USER-$(printf "%x" $(date +%s))" fi -while getopts "ahi" opt; do +while getopts "ahin" opt; do case $opt in a) append_config=yes;; h) usage;; - i) install_pubkey=yes; + i) install_pubkey=yes;; + n) non_interactive=yes;; esac done shift $(( $OPTIND - 1)) mkdir -p "$abuild_home" -echo "Generating public/private rsa key pair for abuild" -echo -n "Enter file in which to save the key ($abuild_home/$default_name.rsa): " - -read line -if [ -z "$line" ]; then - privkey="$abuild_home/$default_name.rsa" -else - privkey="$line" -fi +get_privkey_file pubkey="$privkey.pub" # generate the private key in a subshell with stricter umask |