Merge pull request #1955 from crawford/ignition

coreos-base/oem-gce: remove legacy scripts
This commit is contained in:
Alex Crawford 2016-05-18 17:15:55 -07:00
commit aab6171fe7
12 changed files with 73 additions and 227 deletions

View File

@ -1,119 +0,0 @@
#cloud-config
coreos:
units:
- name: gce-add-metadata-host.service
command: start
runtime: yes
content: |
[Unit]
Description=Setup metadata in /etc/hosts
[Service]
ExecStart=/usr/share/oem/bin/gce-add-metadata-host
- name: gce-coreos-cloudinit.service
command: restart
runtime: yes
content: |
[Unit]
Requires=coreos-setup-environment.service
After=coreos-setup-environment.service
[Service]
Type=oneshot
EnvironmentFile=/etc/environment
ExecStart=/usr/share/oem/bin/gce-coreos-cloudinit
- name: gce-ssh-key.service
command: restart
runtime: yes
content: |
[Unit]
Description=Sets SSH key from metadata
[Service]
Type=oneshot
StandardOutput=journal+console
ExecStart=/usr/share/oem/bin/gce-ssh-key
- name: google-accounts-manager.service
command: start
runtime: yes
content: |
[Unit]
Description=Google Compute Engine User Accounts Manager Daemon
After=network.target
Before=sshd.service
Requires=network.target
[Service]
Type=simple
ExecStart=/usr/share/oem/python/bin/python2.7 /usr/share/oem/google-compute-daemon/manage_accounts.py
[Install]
WantedBy=multi-user.target
- name: google-address-manager.service
command: start
runtime: yes
content: |
[Unit]
Description=Google Compute Engine Address Manager Daemon
After=network.target
Requires=network.target
[Service]
Type=simple
ExecStart=/usr/share/oem/python/bin/python2.7 /usr/share/oem/google-compute-daemon/manage_addresses.py
[Install]
WantedBy=multi-user.target
- name: google-startup-scripts-onboot.service
command: start
runtime: yes
content: |
[Unit]
Description=Google Compute Engine Startup Scripts
After=network.target
After=local-fs.target
Before=sshd.service
Requires=network.target
Requires=local-fs.target
[Service]
Type=oneshot
Environment=GOOGLE_STARTUP_SCRIPTS_PREFIX=/usr/share/oem/google-startup-scripts
ExecStart=/usr/share/oem/google-startup-scripts/onboot
[Install]
WantedBy=multi-user.target
- name: google-startup-scripts.service
command: start
runtime: yes
content: |
[Unit]
Description=Google Compute Engine user startup scripts
After=network.target
After=google-startup-scripts-onboot.service
Requires=google-startup-scripts-onboot.service
Requires=network.target
[Service]
ExecStart=/usr/share/oem/google-startup-scripts/run-startup-scripts
Type=idle
[Install]
WantedBy=multi-user.target
oem:
id: gce
name: Google Compute Engine
version-id: @@OEM_VERSION_ID@@
home-url: https://cloud.google.com/products/compute-engine/
bug-report-url: https://github.com/coreos/bugs/issues
write_files:
- path: /etc/profile.d/google-cloud-sdk.sh
permissions: 0644
content: |
#!/bin/sh
alias gcloud="(docker images google/cloud-sdk || docker pull google/cloud-sdk) > /dev/null;docker run -t -i --net="host" -v $HOME/.config:/.config -v /var/run/docker.sock:/var/run/docker.sock google/cloud-sdk gcloud"
alias gcutil="(docker images google/cloud-sdk || docker pull google/cloud-sdk) > /dev/null;docker run -t -i --net="host" -v $HOME/.config:/.config google/cloud-sdk gcutil"
alias gsutil="(docker images google/cloud-sdk || docker pull google/cloud-sdk) > /dev/null;docker run -t -i --net="host" -v $HOME/.config:/.config google/cloud-sdk gsutil"

View File

@ -1,33 +0,0 @@
#!/bin/bash -e
ENV=$1
METADATA_URL="http://169.254.169.254/computeMetadata/"
if [ -z "$ENV" ]; then
echo usage: $0 /etc/environment
exit 1
fi
# test for rw
touch $ENV
if [ $? -ne 0 ]; then
echo exiting, unable to modify: $ENV
exit 1
fi
get_value() {
curl --fail --silent --show-error \
-H "X-Google-Metadata-Request: True" \
"${METADATA_URL}v1/instance/$1"
}
block-until-url "${METADATA_URL}"
external_ip=$(get_value network-interfaces/0/access-configs/0/external-ip)
public_ip=$(get_value network-interfaces/0/ip)
sed -i -e '/^COREOS_PUBLIC_IPV4=/d' \
-e '/^COREOS_PRIVATE_IPV4=/d' \
"${ENV}"
echo COREOS_PUBLIC_IPV4=${external_ip} >> $ENV
echo COREOS_PRIVATE_IPV4=${public_ip} >> $ENV

View File

@ -1,9 +0,0 @@
#!/bin/bash
entry="169.254.169.254 metadata"
grep -qs "${entry}" /etc/hosts
if [ $? -ne 0 ]; then
echo ${entry} >> /etc/hosts
fi

View File

@ -1,34 +0,0 @@
#!/bin/bash
METADATA_URL="http://169.254.169.254/computeMetadata/"
TMPFILE=$(mktemp /tmp/XXXXXX-cloud-init)
if [[ $? -ne 0 || ! -f "${TMPFILE}" ]]; then
echo "Failed to create temp file for user-data" >&2
exit 1
fi
trap "rm -f '${TMPFILE}'" EXIT
try_cloudinit() {
local id="$1"
local url="${METADATA_URL}v1/${id}/attributes/user-data"
echo "Trying to fetch $id user-data..."
curl --fail --silent --show-error \
-H "X-Google-Metadata-Request: True" \
-o "${TMPFILE}" "${url}"
ret=$?
if [[ $ret -ne 0 && $ret -ne 22 ]]; then
echo "curl failed with error code $ret" >&2
return $ret
elif [[ $ret -eq 22 || ! -s "${TMPFILE}" ]]; then
echo "$id user-data is missing or empty, skipping"
return 0
fi
coreos-cloudinit --from-file="${TMPFILE}"
return $?
}
block-until-url "${METADATA_URL}"
try_cloudinit project && try_cloudinit instance

View File

@ -1,22 +0,0 @@
#!/bin/bash -e
set -e
URL_PREFIX="http://169.254.169.254/computeMetadata/v1beta1/"
update_keys() {
local id="$1"
local url="${URL_PREFIX}${id}/attributes/sshKeys"
# The key may have a username: prerix which must be stripped
local keys=$(curl --fail -s "$url" | sed -re 's/^\w*://')
if [[ -n "$keys" ]]; then
update-ssh-keys -a "gce-$id" <<<"$keys"
fi
}
block-until-url "$URL_PREFIX"
# Generally sshKeys is only defined per-project
# but might as well support per-instance too.
update_keys project
update_keys instance

View File

@ -0,0 +1,5 @@
ID=gce
VERSION_ID=@@OEM_VERSION_ID@@
NAME="Google Compute Engine"
HOME_URL="https://cloud.google.com/products/compute-engine/"
BUG_REPORT_URL="https://github.com/coreos/bugs/issues"

View File

@ -0,0 +1,12 @@
[Unit]
Description=Google Compute Engine User Accounts Manager Daemon
After=network.target
Before=sshd.service
Requires=network.target
[Service]
Type=simple
ExecStart=/usr/share/oem/python/bin/python2.7 /usr/share/oem/google-compute-daemon/manage_accounts.py
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,11 @@
[Unit]
Description=Google Compute Engine Address Manager Daemon
After=network.target
Requires=network.target
[Service]
Type=simple
ExecStart=/usr/share/oem/python/bin/python2.7 /usr/share/oem/google-compute-daemon/manage_addresses.py
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,11 @@
[Unit]
Description=Google Compute Engine Clock Sync Daemon
After=network.target
Requires=network.target
[Service]
Type=simple
ExecStart=/usr/share/oem/python/bin/python2.7 /usr/share/oem/google-compute-daemon/manage_clock_sync.py
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,15 @@
[Unit]
Description=Google Compute Engine Startup Scripts
After=network.target
After=local-fs.target
Before=sshd.service
Requires=network.target
Requires=local-fs.target
[Service]
Type=oneshot
Environment=GOOGLE_SCRIPTS_PREFIX=/usr/share/oem/google-startup-scripts
ExecStart=/usr/share/oem/google-startup-scripts/onboot
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,14 @@
[Unit]
Description=Google Compute Engine user startup scripts
After=network.target
After=google-startup-scripts-onboot.service
Requires=google-startup-scripts-onboot.service
Requires=network.target
[Service]
Environment=GOOGLE_SCRIPTS_PREFIX=/usr/share/oem/google-startup-scripts
ExecStart=/usr/share/oem/google-startup-scripts/run-startup-scripts
Type=idle
[Install]
WantedBy=multi-user.target

View File

@ -16,23 +16,18 @@ IUSE=""
S="${WORKDIR}" S="${WORKDIR}"
RDEPEND=" RDEPEND="
app-emulation/google-compute-daemon ~app-emulation/google-compute-daemon-${PV}
app-emulation/google-startup-scripts ~app-emulation/google-startup-scripts-${PV}
" "
src_prepare() { src_prepare() {
sed -e "s\\@@OEM_VERSION_ID@@\\${PVR}\\g" \ sed -e "s\\@@OEM_VERSION_ID@@\\${PVR}\\g" \
"${FILESDIR}/cloud-config.yml" > "${T}/cloud-config.yml" || die "${FILESDIR}/oem-release" > "${T}/oem-release" || die
} }
src_install() { src_install() {
into "/usr/share/oem"
dobin "${FILESDIR}/gce-ssh-key"
dobin "${FILESDIR}/gce-coreos-cloudinit"
dobin "${FILESDIR}/gce-add-metadata-host"
dobin "${FILESDIR}/coreos-setup-environment"
insinto "/usr/share/oem" insinto "/usr/share/oem"
doins "${T}/cloud-config.yml"
doins "${FILESDIR}/grub.cfg" doins "${FILESDIR}/grub.cfg"
doins "${T}/oem-release"
doins -r "${FILESDIR}/units"
} }