Skip to content

Commit

Permalink
script modifications so that it can work for both updatedemo.org and …
Browse files Browse the repository at this point in the history
…local
  • Loading branch information
tkfu committed Sep 9, 2022
1 parent 40de720 commit f47eb1b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
33 changes: 16 additions & 17 deletions scripts/gen-device.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,26 @@ DEVICE_UUID=${DEVICE_UUID:-$(uuidgen | tr "[:upper:]" "[:lower:]")}


CWD=$(dirname "$0")

mkdir -p "${CWD}/certs"
CERTS_DIR=$CWD/certs
wget -O ${CERTS_DIR}/client.cnf https://uptanedemo.org/client.cnf

wget -O ${CERTS_DIR}/client.ext https://uptanedemo.org/client.ext

mkdir -p "${CWD}/ota-ce-gen"
SERVER_DIR=$CWD/ota-ce-gen



wget -O ${SERVER_DIR}/server_ca.pem https://uptanedemo.org/server_ca.pem


mkdir -p "${SERVER_DIR}/devices"
SERVER_DIR=$CWD/../ota-ce-gen
DEVICES_DIR=${SERVER_DIR}/devices
wget -O ${DEVICES_DIR}/ca.crt https://uptanedemo.org/ca.crt

wget -O ${DEVICES_DIR}/ca.key https://uptanedemo.org/ca.key

# if there's no gen-server-certs in this directory, we're probably not running
# the script from the repo. In that case, we can just pull the keys, etc. from
# the uptanedemo server.
if [ ! -f gen-server-certs.sh ]; then
SERVER_DIR=$CWD/ota-ce-gen
mkdir -p "${CWD}/certs"
mkdir -p "${CWD}/ota-ce-gen"
mkdir -p "${SERVER_DIR}/devices"

wget -O ${CERTS_DIR}/client.cnf https://uptanedemo.org/client.cnf
wget -O ${CERTS_DIR}/client.ext https://uptanedemo.org/client.ext
wget -O ${SERVER_DIR}/server_ca.pem https://uptanedemo.org/server_ca.pem
wget -O ${DEVICES_DIR}/ca.crt https://uptanedemo.org/ca.crt
wget -O ${DEVICES_DIR}/ca.key https://uptanedemo.org/ca.key
fi


device_id=$DEVICE_UUID
Expand Down
13 changes: 7 additions & 6 deletions scripts/get-credentials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
set -euox pipefail

SERVER_DIR=ota-ce-gen
SERVER_BASE_URI=${1:-uptanedemo.org}

namespace="x-ats-namespace:default"
keyserver="https://keyserver.uptanedemo.org"
reposerver="https://reposerver.uptanedemo.org"
director="https://director.uptanedemo.org"
keyserver="https://keyserver.${SERVER_BASE_URI}"
reposerver="https://reposerver.${SERVER_BASE_URI}"
director="https://director.${SERVER_BASE_URI}"

curl --silent --fail ${director}/health/version || echo "$director not running"
curl --silent --fail ${keyserver}/health/version || echo "$keyserver not running"
Expand All @@ -29,14 +30,14 @@ keys=$(curl -s -f "${keyserver}/api/v1/root/${id}/keys/targets/pairs")
echo ${keys} | jq '.[0] | {keytype, keyval: {public: .keyval.public}}' > "${SERVER_DIR}/targets.pub"
echo ${keys} | jq '.[0] | {keytype, keyval: {private: .keyval.private}}' > "${SERVER_DIR}/targets.sec"

echo "http://reposerver.uptanedemo.org" > "${SERVER_DIR}/tufrepo.url"
echo "http://uptanedemo.org:30443" > "${SERVER_DIR}/autoprov.url"
echo "http://reposerver.${SERVER_BASE_URI}" > "${SERVER_DIR}/tufrepo.url"
echo "http://${SERVER_BASE_URI}:30443" > "${SERVER_DIR}/autoprov.url"

cat > "${SERVER_DIR}/treehub.json" <<END
{
"no_auth": true,
"ostree": {
"server": "http://treehub.uptanedemo.org/api/v3/"
"server": "http://treehub.${SERVER_BASE_URI}/api/v3/"
}
}
END
Expand Down

0 comments on commit f47eb1b

Please sign in to comment.