mirror of
https://gitlab.alpinelinux.org/alpine/abuild.git
synced 2024-12-21 22:50:03 +00:00
abuild-keygen: implement -q for quiet mode
This commit is contained in:
parent
18fa4231dc
commit
05c2443ad1
@ -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 ""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user