Skip to content

Commit

Permalink
cmd-init: use sudo when creating src/config.json
Browse files Browse the repository at this point in the history
When following the steps for building SCOS I ran
`cosa init --variant scos https://github.com/openshift/os.git`
and got a failure. Let's run this with `sudo` if we have the
privileges to do so.
  • Loading branch information
dustymabe committed Jun 13, 2023
1 parent e070cb1 commit 0334d4a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cmd-init
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,14 @@ if [[ -n "${VARIANT}" ]] && [[ "${VARIANT}" != "default" ]]; then
fatal "Could not find the manifests (${manifest} & ${image}) for the '${VARIANT}' variant"
fi
echo "Using variant: '${VARIANT}'"
cat > "src/config.json" <<EOF
# Use sudo if we have privileges as we've seen some permissions
# issues creating this file when running on local developer workstations
if has_privileges; then
tee_cmd='sudo tee'
else
tee_cmd='tee'
fi
$tee_cmd "src/config.json" <<EOF
{
"coreos-assembler.config-variant": "${VARIANT}"
}
Expand Down

0 comments on commit 0334d4a

Please sign in to comment.