mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 10:58:02 +00:00
scripts: make scripts environment pure
For some reason, it doesn't always execute. I haven't bothered figuring out why tho. >_>
This commit is contained in:
parent
625a8b191a
commit
eda167bb88
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env nix-shell
|
||||||
#! nix-shell -i bash -p google-cloud-sdk
|
#! nix-shell --pure -i bash -p nix git coreutils google-cloud-sdk
|
||||||
#
|
#
|
||||||
# This is a modified script `nixos/maintainers/scripts/gce/create-gce.sh' from
|
# This is a modified script `nixos/maintainers/scripts/gce/create-gce.sh' from
|
||||||
# `nixpkgs'.
|
# `nixpkgs'.
|
||||||
@ -32,6 +32,7 @@ BUCKET_NAME="${BUCKET_NAME:-foodogsquared-operating-system-images-dumping-ground
|
|||||||
TIMESTAMP="$(date +%Y%m%d%H%M)"
|
TIMESTAMP="$(date +%Y%m%d%H%M)"
|
||||||
PACKAGE=plover-gce
|
PACKAGE=plover-gce
|
||||||
DIRECTORY=gce-image
|
DIRECTORY=gce-image
|
||||||
|
FORCE=0
|
||||||
export TIMESTAMP
|
export TIMESTAMP
|
||||||
|
|
||||||
nix build ".#$PACKAGE" -o "$DIRECTORY"
|
nix build ".#$PACKAGE" -o "$DIRECTORY"
|
||||||
@ -41,16 +42,17 @@ img_name=${IMAGE_NAME:-$(basename "$img_path")}
|
|||||||
img_id=$(echo "$img_name" | sed 's|.raw.tar.gz$||;s|\.|-|g;s|_|-|g')
|
img_id=$(echo "$img_name" | sed 's|.raw.tar.gz$||;s|\.|-|g;s|_|-|g')
|
||||||
img_family=$(echo "$img_id" | cut -d - -f1-4)
|
img_family=$(echo "$img_id" | cut -d - -f1-4)
|
||||||
|
|
||||||
if ! gsutil ls "gs://${BUCKET_NAME}/$img_name"; then
|
if [ $FORCE -eq 1 ] || ! gsutil ls "gs://${BUCKET_NAME}/$img_name"; then
|
||||||
|
[ $FORCE -eq 1 ] && FORCE_ARG="--force"
|
||||||
|
|
||||||
gsutil cp "$img_path" "gs://${BUCKET_NAME}/$img_name"
|
gsutil cp "$img_path" "gs://${BUCKET_NAME}/$img_name"
|
||||||
|
|
||||||
gcloud compute images create \
|
gcloud compute images create \
|
||||||
"$img_id" \
|
"$img_id" \
|
||||||
--source-uri "gs://${BUCKET_NAME}/$img_name" \
|
--source-uri "gs://${BUCKET_NAME}/$img_name" \
|
||||||
--family="$img_family"
|
--family="$img_family" "$FORCE_ARG"
|
||||||
|
|
||||||
gcloud compute images add-iam-policy-binding \
|
gcloud compute images add-iam-policy-binding "$img_id" \
|
||||||
"$img_id" \
|
|
||||||
--member='allAuthenticatedUsers' \
|
--member='allAuthenticatedUsers' \
|
||||||
--role='roles/compute.imageUser'
|
--role='roles/compute.imageUser'
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user