amis: run build script as normal user

This reduces the awkwardness of passing credentials to the build job.

Replace run.sh with assorted example scripts for prod, master, etc.
This commit is contained in:
Michael Marineau 2014-07-28 12:10:05 -07:00
parent f6801e6b21
commit a53ff2a03b
4 changed files with 37 additions and 8 deletions

View File

@ -61,8 +61,8 @@ do
esac
done
if [[ $(id -u) -ne 0 ]]; then
echo "$0: This command must be run as root!" >&2
if [[ $(id -u) -eq 0 ]]; then
echo "$0: This command should not be ran run as root!" >&2
exit 1
fi
@ -139,14 +139,14 @@ echo "Writing image from $IMG_URL to $dev"
# if it is on the local fs, just use it, otherwise try to download it
if [[ -n "$IMG_PATH" ]]; then
if [[ "$IMG_PATH" =~ \.bz2$ ]]; then
bunzip2 -c "$IMG_PATH" > $dev
bunzip2 -c "$IMG_PATH" | sudo dd of=$dev bs=1M
else
dd if="$IMG_PATH" of=$dev bs=1M
sudo dd if="$IMG_PATH" of=$dev bs=1M
fi
elif [[ "$IMG_URL" == gs://* ]]; then
gsutil cat "$IMG_URL" | bunzip2 > $dev
gsutil cat "$IMG_URL" | bunzip2 | sudo dd of=$dev bs=1M
else
curl --fail "$IMG_URL" | bunzip2 > $dev
curl --fail "$IMG_URL" | bunzip2 | sudo dd of=$dev bs=1M
fi
echo "Detaching $volumeid and creating snapshot"

13
oem/ami/master.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
DIR=/home/ec2-user/scripts
URL="https://commondatastorage.googleapis.com/storage.core-os.net/coreos/amd64-usr/master"
set -e
eval $(curl -f "${URL}/version.txt")
source $DIR/marineam-auth.sh
args="-b amd64-usr -g master -V ${COREOS_VERSION}"
$DIR/build_ebs_on_ec2.sh ${args} -u "${URL}/coreos_production_ami_image.bin.bz2"
$DIR/test_ami.sh -v ${args}
#$DIR/copy_ami.sh ${args}

View File

@ -11,8 +11,8 @@ if [ -z "$GROUP" -o -z "$VER" ]; then
fi
set -e
args="-b $BOARD -g $GROUP -V $VER"
sudo bash -c ". $DIR/marineam-auth.sh && $DIR/build_ebs_on_ec2.sh ${args}"
source $DIR/marineam-auth.sh
args="-b $BOARD -g $GROUP -V $VER"
$DIR/build_ebs_on_ec2.sh ${args}
$DIR/test_ami.sh -v ${args}
$DIR/copy_ami.sh ${args}

16
oem/ami/user.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
DIR=/home/ec2-user/scripts
USER=someone
TYPE=production
VERSION="367.0.0+2014-07-10-1613"
URL="http://users.developer.core-os.net/${USER}/boards/amd64-usr/${VERSION}"
set -e
eval $(curl -f "${URL}/version.txt")
source $DIR/marineam-auth.sh
args="-b amd64-usr -g ${USER} -V ${VERSION}"
$DIR/build_ebs_on_ec2.sh ${args} -u "${URL}/coreos_${TYPE}_ami_image.bin.bz2"
$DIR/test_ami.sh -v ${args}
#$DIR/copy_ami.sh ${args}