Commit ce020315 authored by Natanael Copa's avatar Natanael Copa

abuild-keygen: support for -i to install pubkey to /etc/apk/keys

parent 9a622715
...@@ -15,6 +15,17 @@ abuild_conf=${ABUILD_CONF:-"$sysconfdir/abuild.conf"} ...@@ -15,6 +15,17 @@ 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"}
usage() {
echo "abuild-keygen $abuild_ver"
echo "usage: abuild-keygen [-ih]"
echo "options:"
echo " -i Install public key into /etc/apk/keys using sudo"
echo " -h Show this help"
echo ""
exit 1
}
# read config # read config
[ -f "$abuild_conf" ] && . "$abuild_conf" [ -f "$abuild_conf" ] && . "$abuild_conf"
...@@ -35,6 +46,14 @@ else ...@@ -35,6 +46,14 @@ else
default_name="$USER" default_name="$USER"
fi fi
while getopts "hi" opt; do
case $opt in
h) usage;;
i) install_pubkey=yes;
esac
done
shift $(( $OPTIND - 1))
mkdir -p "$abuild_home" mkdir -p "$abuild_home"
echo "Generating public/private rsa key pair for abuild" echo "Generating public/private rsa key pair for abuild"
...@@ -55,10 +74,19 @@ openssl genrsa -out "$privkey" 2048 ...@@ -55,10 +74,19 @@ openssl genrsa -out "$privkey" 2048
) )
openssl rsa -in "$privkey" -pubout -out "$pubkey" openssl rsa -in "$privkey" -pubout -out "$pubkey"
echo ""
echo "You'll need to install $pubkey into " if [ -n "$install_pubkey" ]; then
echo "/etc/apk/keys to be able to install packages and repositories signed with" echo "Installing $pubkey to /etc/apk/keys..."
echo "$privkey" 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"
fi
echo "" echo ""
echo "Please remember to make a safe backup of $privkey" echo "Please remember to make a safe backup of $privkey"
echo "" echo ""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment