Skip to content
Snippets Groups Projects
Commit 05c2443a authored by Natanael Copa's avatar Natanael Copa
Browse files

abuild-keygen: implement -q for quiet mode

parent 18fa4231
No related branches found
No related tags found
No related merge requests found
......@@ -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 ""
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment