summaryrefslogtreecommitdiff
path: root/abuild-keygen.in
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2010-12-20 13:33:45 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2010-12-20 13:33:45 +0000
commit05c2443ad1c57a5ce89004c986c9c70a4216335b (patch)
tree7def068cd4d7ce054ad62a3059aa346e19dbcf8f /abuild-keygen.in
parent18fa4231dc27ea8a34446c6a4c4c3815f413494c (diff)
downloadabuild-05c2443ad1c57a5ce89004c986c9c70a4216335b.tar.gz
abuild-05c2443ad1c57a5ce89004c986c9c70a4216335b.tar.bz2
abuild-05c2443ad1c57a5ce89004c986c9c70a4216335b.tar.xz
abuild-05c2443ad1c57a5ce89004c986c9c70a4216335b.zip
abuild-keygen: implement -q for quiet mode
Diffstat (limited to 'abuild-keygen.in')
-rw-r--r--abuild-keygen.in39
1 files changed, 24 insertions, 15 deletions
diff --git a/abuild-keygen.in b/abuild-keygen.in
index 6eefc16..93d1ea2 100644
--- a/abuild-keygen.in
+++ b/abuild-keygen.in
@@ -15,6 +15,12 @@ abuild_conf=${ABUILD_CONF:-"$sysconfdir/abuild.conf"}
abuild_home=${ABUILD_USERDIR:-"$HOME/.abuild"}
abuild_userconf=${ABUILD_USERCONF:-"$abuild_home/abuild.conf"}
+# echo message unless quite mode
+msg() {
+ [ -n "$quiet" ] && return 0
+ echo "$@"
+}
+
# ask for privkey unless non-interactive mode
# returns value in global $privkey
get_privkey_file() {
@@ -29,6 +35,7 @@ get_privkey_file() {
fi
}
+# print usage and exit
usage() {
echo "abuild-keygen $abuild_ver"
echo "usage: abuild-keygen [-ih]"
@@ -37,6 +44,7 @@ usage() {
echo " -i Install public key into /etc/apk/keys using sudo"
echo " -h Show this help"
echo " -n Non-interactive. Use defaults"
+ echo " -q Quiet mode"
echo ""
exit 1
}
@@ -61,12 +69,13 @@ else
default_name="$USER-$(printf "%x" $(date +%s))"
fi
-while getopts "ahin" opt; do
+while getopts "ahinq" opt; do
case $opt in
a) append_config=yes;;
h) usage;;
i) install_pubkey=yes;;
n) non_interactive=yes;;
+ q) quiet=-quiet;;
esac
done
shift $(( $OPTIND - 1))
@@ -85,15 +94,15 @@ openssl rsa -in "$privkey" -pubout -out "$pubkey"
if [ -n "$install_pubkey" ]; then
- echo "Installing $pubkey to /etc/apk/keys..."
+ msg "Installing $pubkey to /etc/apk/keys..."
sudo mkdir -p /etc/apk/keys
sudo cp -i "$pubkey" /etc/apk/keys/
else
- echo ""
- echo "You'll need to install $pubkey into "
- echo "/etc/apk/keys to be able to install packages and repositories signed with"
- echo "$privkey"
+ msg ""
+ msg "You'll need to install $pubkey into "
+ msg "/etc/apk/keys to be able to install packages and repositories signed with"
+ msg "$privkey"
fi
if [ -n "$append_config" ]; then
@@ -103,15 +112,15 @@ if [ -n "$append_config" ]; then
fi
echo "PACKAGER_PRIVKEY=\"$privkey\"" >> "$abuild_userconf"
else
- echo ""
- echo "You might want add following line to $abuild_userconf:"
- echo ""
- echo "PACKAGER_PRIVKEY=\"$privkey\""
- echo ""
+ msg ""
+ msg "You might want add following line to $abuild_userconf:"
+ msg ""
+ msg "PACKAGER_PRIVKEY=\"$privkey\""
+ msg ""
fi
-echo ""
-echo "Please remember to make a safe backup of your private key:"
-echo "$privkey"
-echo ""
+msg ""
+msg "Please remember to make a safe backup of your private key:"
+msg "$privkey"
+msg ""