2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 NEC and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 function isinstalled {
12 source /etc/os-release; echo ${ID/*, /}
14 if [[ ${ID/*, /} =~ "centos" ]]; then
15 if rpm -q "$@" >/dev/null 2>&1; then
23 elif [[ ${ID/*, /} =~ "ubuntu" ]]; then
24 if dpkg-query -W -f'${Status}' "$@" 2>/dev/null | grep -q "ok installed"; then
28 sudo apt-get install -y "$1"
32 echo "Distro not supported"
38 if ! isinstalled gnupg2; then
39 echo "error with install"
44 then echo "error gsutil not installed";
48 if gpg2 --list-keys | grep "opnfv-helpdesk@rt.linuxfoundation.org"; then
49 echo "Key Already available"
51 if [ -z "$NODE_NAME" ];
52 then echo "Cannot find node name"
54 elif gsutil ls gs://opnfv-signing-keys | grep $NODE_NAME; then
55 echo "Importing key for '$NODE_NAME'"
56 gsutil cp gs://opnfv-signing-keys/"$NODE_NAME"-subkey .
57 gpg2 --import "$NODE_NAME"-subkey
58 rm -f "$NODE_NAME"-subkey
60 echo "No keys found locally or remotely for host, skipping import"