4 # Copyright (c) 2018 Wind River Systems, Inc.
6 # SPDX-License-Identifier: Apache-2.0
9 # This script takes the names of packaged helm charts as arguments.
10 # It installs them in the on-node helm chart repository and regenerates
11 # the repository index.
14 # We want to run as the "www" user and scripts can't be setuid. The
15 # sudoers permissions are set up to allow wrsroot to run this script
16 # as the "www" user without a password.
17 if [ $USER != "www" ]; then
18 exec sudo -u www $0 $@
25 REPO_BASE='/www/pages/helm_charts'
27 # First argument is always the repo where the charts need to be placed
29 echo "Usage: helm-upload <repo name> <chart 1> .. <chart N>"
33 # Make sure the repo directory exists
34 REPO_DIR="${REPO_BASE}/$1"
35 if [ ! -e $REPO_DIR ]; then
36 echo "$REPO_DIR doesn't exist."
44 # QUESTION: should we disallow overwriting an existing file?
45 # The versions are embedded in the filename, so it shouldn't
49 echo Problem adding $FILE to helm chart registry.
55 echo Cannot read file ${FILE}.
61 # Now re-index the helm repository if we successfully copied in
63 if [ $REINDEX -eq 1 ]; then
64 /usr/sbin/helm repo index $REPO_DIR