diff options
author | Dubiousjim <dubiousjim@gmail.com> | 2013-07-05 00:21:20 -0400 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2013-07-09 07:00:41 +0000 |
commit | 83ff539cb7fbd2fed95741ba3b9034f694b71bb9 (patch) | |
tree | beb81e271a731647ac1b167717da1f655c859d8e | |
parent | ef9fb52908d3f423e6e537b84f62cb76c7868782 (diff) | |
download | abuild-83ff539cb7fbd2fed95741ba3b9034f694b71bb9.tar.gz abuild-83ff539cb7fbd2fed95741ba3b9034f694b71bb9.tar.bz2 abuild-83ff539cb7fbd2fed95741ba3b9034f694b71bb9.tar.xz abuild-83ff539cb7fbd2fed95741ba3b9034f694b71bb9.zip |
abuild_keygen: several tweaks
* make vars local
* refactor calculation of default_name
* make non_interactive=1
* tweak error message
* tweak sed command
-rw-r--r-- | abuild-keygen.in | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/abuild-keygen.in b/abuild-keygen.in index 34af0ee..bf9d105 100644 --- a/abuild-keygen.in +++ b/abuild-keygen.in @@ -19,6 +19,7 @@ fi # ask for privkey unless non-interactive mode # returns value in global $privkey get_privkey_file() { + local emailaddr default_name emailaddr=${PACKAGER##*<} emailaddr=${emailaddr%%>*} @@ -27,16 +28,12 @@ get_privkey_file() { emailaddr=$(git config --get user.email 2>/dev/null) fi - if [ -n "$emailaddr" ]; then - default_name="$emailaddr-$(printf "%x" $(date +%s))" - else - default_name="$USER-$(printf "%x" $(date +%s))" - fi + default_name="${emailaddr:-$USER}-$(printf "%x" $(date +%s))" privkey="$abuild_home/$default_name.rsa" - [ "$non_interactive" = "yes" ] && return 0 + [ -n "$non_interactive" ] && 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): " + echo -n "Enter file in which to save the key [$privkey]: " read line if [ -n "$line" ]; then @@ -73,7 +70,7 @@ do_keygen() { if [ -n "$append_config" ]; then if [ -f "$abuild_userconf" ]; then # comment out the existing values - sed -i -e 's/^\(PACKAGER_PRIVKEY=.*\)/\#\1/' "$abuild_userconf" + sed -i -e 's/^PACKAGER_PRIVKEY=/\#&/' "$abuild_userconf" fi echo "PACKAGER_PRIVKEY=\"$privkey\"" >> "$abuild_userconf" else @@ -119,7 +116,7 @@ while true; do case $1 in -a|--append) append_config=1;; -i|--install) install_pubkey=1;; - -n) non_interactive=yes;; + -n) non_interactive=1;; -q|--quiet) quiet=1;; # suppresses msg -h|--help) usage; exit;; --) shift; break;; |