Merge pull request #1282 from packethost/oem-packet

Packet image OEM
This commit is contained in:
Alex Crawford 2015-07-10 08:39:27 -07:00
commit 5278dc6ce2
4 changed files with 91 additions and 0 deletions

View File

@ -0,0 +1,41 @@
#cloud-config
coreos:
units:
- name: oem-reset-interfaces.service
command: start
content: |
[Unit]
Description=Reset the bond.
[Service]
Type=oneshot
ExecStart=/usr/share/oem/bin/reset-interfaces.sh
- name: oem-cloudinit.service
command: restart
runtime: yes
content: |
[Unit]
Description=Cloudinit from Packet metadata
After=oem-reset-interfaces.service
Requires=oem-reset-interfaces.service
[Service]
Type=oneshot
ExecStart=/usr/bin/coreos-cloudinit --oem=packet
- name: oem-phone-home.service
command: start
content: |
[Unit]
Description=Basic setup tasks to initialize the machine.
Wants=sys-devices-virtual-net-bond0.device
After=sys-devices-virtual-net-bond0.device
[Service]
Type=oneshot
ExecStart=/usr/share/oem/bin/phone-home.sh
oem:
id: packet
name: Packet
version-id: @@OEM_VERSION_ID@@
home-url: https://packet.net
bug-report-url: https://github.com/coreos/bugs/issues

View File

@ -0,0 +1,13 @@
#!/bin/bash
set -e
API_URL=$(curl -s https://metadata.packet.net/metadata | jq ".api_url" | sed -e 's/^"//' -e 's/"$//')
while ! wget --inet4-only --spider --quiet "${API_URL}/build_info.txt"; do
echo "$0: API unavailable: $API_URL" >&2
sleep 2
done
logger "Making a call to tell the packet API this machine is online."
curl -X POST $API_URL/phone-home
logger "This device has been announced to the packet API."

View File

@ -0,0 +1,8 @@
#!/bin/bash
set -e
logger "Hard reset of all network interfaces due to upstream systemd-networkd issue: https://github.com/coreos/bugs/issues/36 ."
ip link set enp1s0f0 down
ip link set enp1s0f1 down
ip link del bond0
systemctl restart systemd-networkd

View File

@ -0,0 +1,29 @@
# Copyright (c) 2014 CoreOS, Inc.. All rights reserved.
# Distributed under the terms of the GNU General Public License v2
EAPI=5
DESCRIPTION="OEM suite for Packet images"
HOMEPAGE=""
SRC_URI=""
LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="amd64 x86"
# no source directory
S="${WORKDIR}"
src_prepare() {
sed -e "s\\@@OEM_VERSION_ID@@\\${PVR}\\g" \
${FILESDIR}/cloud-config.yml > ${T}/cloud-config.yml || die
}
src_install() {
into "/usr/share/oem"
dobin ${FILESDIR}/phone-home.sh
dobin ${FILESDIR}/reset-interfaces.sh
insinto "/usr/share/oem"
doins ${T}/cloud-config.yml
}