mirror of
https://gitlab.alpinelinux.org/alpine/abuild.git
synced 2025-01-02 20:42:43 +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_home=${ABUILD_USERDIR:-"$HOME/.abuild"}
|
||||||
abuild_userconf=${ABUILD_USERCONF:-"$abuild_home/abuild.conf"}
|
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
|
# ask for privkey unless non-interactive mode
|
||||||
# returns value in global $privkey
|
# returns value in global $privkey
|
||||||
get_privkey_file() {
|
get_privkey_file() {
|
||||||
@ -29,6 +35,7 @@ get_privkey_file() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# print usage and exit
|
||||||
usage() {
|
usage() {
|
||||||
echo "abuild-keygen $abuild_ver"
|
echo "abuild-keygen $abuild_ver"
|
||||||
echo "usage: abuild-keygen [-ih]"
|
echo "usage: abuild-keygen [-ih]"
|
||||||
@ -37,6 +44,7 @@ usage() {
|
|||||||
echo " -i Install public key into /etc/apk/keys using sudo"
|
echo " -i Install public key into /etc/apk/keys using sudo"
|
||||||
echo " -h Show this help"
|
echo " -h Show this help"
|
||||||
echo " -n Non-interactive. Use defaults"
|
echo " -n Non-interactive. Use defaults"
|
||||||
|
echo " -q Quiet mode"
|
||||||
echo ""
|
echo ""
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@ -61,12 +69,13 @@ else
|
|||||||
default_name="$USER-$(printf "%x" $(date +%s))"
|
default_name="$USER-$(printf "%x" $(date +%s))"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while getopts "ahin" opt; do
|
while getopts "ahinq" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
a) append_config=yes;;
|
a) append_config=yes;;
|
||||||
h) usage;;
|
h) usage;;
|
||||||
i) install_pubkey=yes;;
|
i) install_pubkey=yes;;
|
||||||
n) non_interactive=yes;;
|
n) non_interactive=yes;;
|
||||||
|
q) quiet=-quiet;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( $OPTIND - 1))
|
shift $(( $OPTIND - 1))
|
||||||
@ -85,15 +94,15 @@ openssl rsa -in "$privkey" -pubout -out "$pubkey"
|
|||||||
|
|
||||||
|
|
||||||
if [ -n "$install_pubkey" ]; then
|
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 mkdir -p /etc/apk/keys
|
||||||
sudo cp -i "$pubkey" /etc/apk/keys/
|
sudo cp -i "$pubkey" /etc/apk/keys/
|
||||||
else
|
else
|
||||||
|
|
||||||
echo ""
|
msg ""
|
||||||
echo "You'll need to install $pubkey into "
|
msg "You'll need to install $pubkey into "
|
||||||
echo "/etc/apk/keys to be able to install packages and repositories signed with"
|
msg "/etc/apk/keys to be able to install packages and repositories signed with"
|
||||||
echo "$privkey"
|
msg "$privkey"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$append_config" ]; then
|
if [ -n "$append_config" ]; then
|
||||||
@ -103,15 +112,15 @@ if [ -n "$append_config" ]; then
|
|||||||
fi
|
fi
|
||||||
echo "PACKAGER_PRIVKEY=\"$privkey\"" >> "$abuild_userconf"
|
echo "PACKAGER_PRIVKEY=\"$privkey\"" >> "$abuild_userconf"
|
||||||
else
|
else
|
||||||
echo ""
|
msg ""
|
||||||
echo "You might want add following line to $abuild_userconf:"
|
msg "You might want add following line to $abuild_userconf:"
|
||||||
echo ""
|
msg ""
|
||||||
echo "PACKAGER_PRIVKEY=\"$privkey\""
|
msg "PACKAGER_PRIVKEY=\"$privkey\""
|
||||||
echo ""
|
msg ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
msg ""
|
||||||
echo "Please remember to make a safe backup of your private key:"
|
msg "Please remember to make a safe backup of your private key:"
|
||||||
echo "$privkey"
|
msg "$privkey"
|
||||||
echo ""
|
msg ""
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user