mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-22 15:01:00 +02:00
init commit of interoute oem files
This commit is contained in:
parent
b416b59087
commit
703a987f35
61
sdk_container/src/third_party/coreos-overlay/coreos-base/oem-interoute/files/cloud-config.yml
vendored
Normal file
61
sdk_container/src/third_party/coreos-overlay/coreos-base/oem-interoute/files/cloud-config.yml
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
#cloud-config
|
||||
|
||||
coreos:
|
||||
units:
|
||||
- name: vmtoolsd.service
|
||||
command: start
|
||||
content: |
|
||||
[Unit]
|
||||
Description=VMware Tools Agent
|
||||
Documentation=http://open-vm-tools.sourceforge.net/
|
||||
ConditionVirtualization=vmware
|
||||
|
||||
[Service]
|
||||
ExecStartPre=/usr/bin/ln -sfT /usr/share/oem/vmware-tools /etc/vmware-tools
|
||||
ExecStart=/usr/share/oem/bin/vmtoolsd
|
||||
TimeoutStopSec=5
|
||||
- name: cloudstack-ssh-key.service
|
||||
command: restart
|
||||
runtime: yes
|
||||
content: |
|
||||
[Unit]
|
||||
Description=Sets SSH key from metadata
|
||||
Requires=coreos-setup-environment.service
|
||||
After=coreos-setup-environment.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
StandardOutput=journal+console
|
||||
EnvironmentFile=/etc/environment
|
||||
ExecStart=/usr/share/oem/bin/cloudstack-ssh-key
|
||||
- name: cloudstack-cloudinit.service
|
||||
command: restart
|
||||
runtime: yes
|
||||
content: |
|
||||
[Unit]
|
||||
Description=Cloudinit from CloudStack-style metadata
|
||||
Requires=coreos-setup-environment.service
|
||||
After=coreos-setup-environment.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
EnvironmentFile=/etc/environment
|
||||
ExecStart=/usr/share/oem/bin/cloudstack-coreos-cloudinit
|
||||
- name: cloudstack-set-guest-password.service
|
||||
runtime: yes
|
||||
content: |
|
||||
[Unit]
|
||||
Description=CloudStack Guest Password Reset
|
||||
Requires=coreos-setup-environment.service
|
||||
After=coreos-setup-environment.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/share/oem/bin/cloudstack-set-guest-password
|
||||
EnvironmentFile=/etc/environment
|
||||
oem:
|
||||
id: interoute
|
||||
name: Interoute
|
||||
version-id: @@OEM_VERSION_ID@@
|
||||
home-url: http://interoute.com/
|
||||
bug-report-url: https://github.com/coreos/bugs/issues
|
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
DHCP_SERVER=${NIC_1_GATEWAY}
|
||||
USERDATA_URL="http://${DHCP_SERVER}/latest/user-data"
|
||||
|
||||
block-until-url "${USERDATA_URL}"
|
||||
coreos-cloudinit --from-url="${USERDATA_URL}"
|
@ -0,0 +1,101 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Installation steps (ArchLinux using base/dhcpcd-6.0.5-1)
|
||||
#
|
||||
# Install "wget" and "dhcpcd"
|
||||
# $ pacman -S wget dhcpcd
|
||||
# $ systemctl enable dhcpcd@eth0
|
||||
# Copy script to /usr/lib/systemd/scripts/
|
||||
# $ cp -v cloudstack-set-guest-password \
|
||||
# /usr/lib/systemd/scripts/
|
||||
# Copy the service file to /usr/lib/systemd/system/
|
||||
# $ cp -v cloudstack-set-guest-password.service \
|
||||
# /usr/lib/systemd/system/
|
||||
# Enable the service
|
||||
# $ systemctl enable cloudstack-set-guest-password.service
|
||||
|
||||
# Modified: Dong Xie, 02-09-2015
|
||||
|
||||
user=root
|
||||
password_received=0
|
||||
|
||||
if [ ! -x /usr/sbin/chpasswd ]; then
|
||||
logger -t "cloudstack" "$0 requires /usr/sbin/chpasswd command"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PASSWORD_SERVER_IP=${NIC_1_GATEWAY}
|
||||
|
||||
if [ -n $PASSWORD_SERVER_IP ]; then
|
||||
logger -t "cloudstack" "Found password server IP $PASSWORD_SERVER_IP"
|
||||
logger -t "cloudstack" "Sending request to password server at $PASSWORD_SERVER_IP"
|
||||
password=$(wget -q -t 3 -T 20 -O - --header "DomU_Request: send_my_password" $PASSWORD_SERVER_IP:8080)
|
||||
if [ $? -ne 0 ]; then
|
||||
logger -t "cloudstack" "Failed to run wget correctly. Network not ready?"
|
||||
exit 1
|
||||
fi
|
||||
password=$(echo $password | tr -d '\r')
|
||||
logger -t "cloudstack" "Got password as - $password - "
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
logger -t "cloudstack" "Got response from server at $PASSWORD_SERVER_IP"
|
||||
|
||||
case $password in
|
||||
"")
|
||||
logger -t "cloudstack" "Password server at $PASSWORD_SERVER_IP did not have any password for the VM"
|
||||
;;
|
||||
|
||||
"bad_request")
|
||||
logger -t "cloudstack" "VM sent an invalid request to password server at $PASSWORD_SERVER_IP"
|
||||
;;
|
||||
|
||||
"saved_password")
|
||||
logger -t "cloudstack" "VM has already saved a password from the password server at $PASSWORD_SERVER_IP"
|
||||
;;
|
||||
|
||||
*)
|
||||
logger -t "cloudstack" "VM got a valid password from server at $PASSWORD_SERVER_IP"
|
||||
password_received=1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
logger -t "cloudstack" "Failed to send request to password server at $PASSWORD_SERVER_IP"
|
||||
fi
|
||||
else
|
||||
logger -t "cloudstack" "Could not find password server IP for $interface"
|
||||
fi
|
||||
|
||||
if [ "$password_received" == "1" ]; then
|
||||
logger -t "cloudstack" "Changing password ..."
|
||||
echo $user:$password | /usr/sbin/chpasswd
|
||||
|
||||
if [ $? -gt 0 ]; then
|
||||
logger -t "cloudstack" "Failed to change password for user $user"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
logger -t "cloudstack" "Successfully changed password for user $user"
|
||||
logger -t "cloudstack" "Sending acknowledgment to password server at $PASSWORD_SERVER_IP"
|
||||
|
||||
wget -t 3 -T 20 -O - --header "DomU_Request: saved_password" $PASSWORD_SERVER_IP:8080
|
||||
fi
|
||||
|
||||
exit 0
|
||||
# vim: set ts=2 sw=2 expandtab
|
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
DHCP_SERVER=${NIC_1_GATEWAY}
|
||||
KEY_URL="http://${DHCP_SERVER}/latest/meta-data/public-keys"
|
||||
|
||||
block-until-url "${KEY_URL}"
|
||||
curl --fail -s "${KEY_URL}" | update-ssh-keys -a cloudstack
|
@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
ENV=$1
|
||||
leases_dir="/run/systemd/netif/leases"
|
||||
|
||||
if [[ -z "$ENV" ]]; then
|
||||
echo "usage: $0 /etc/environment" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure that the file is writable
|
||||
touch $ENV
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "$0: unable to modify ${ENV}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Clean up values
|
||||
sed -i -e '/^COREOS_PUBLIC_IPV4=/d' \
|
||||
-e '/^COREOS_PRIVATE_IPV4=/d' \
|
||||
"${ENV}"
|
||||
|
||||
sed -i -e '/^NIC_[0-9]*_IPV4=/d' \
|
||||
-e '/^NIC_[0-9]*_GATEWAY=/d' \
|
||||
"${ENV}"
|
||||
|
||||
# Fetch number of NIC
|
||||
nic_count=$(ip link show | grep ens | wc -l)
|
||||
|
||||
# Loop until all lease files ready
|
||||
while true; do
|
||||
if [[ $(find "${leases_dir}" -maxdepth 1 -type f -size +1c | wc -l) -ge $nic_count ]]; then
|
||||
break
|
||||
fi
|
||||
sleep .5
|
||||
done
|
||||
|
||||
# Get leases in var
|
||||
leases=$(find "${leases_dir}" -type f | sort)
|
||||
|
||||
# Take first lease which should be the default NIC
|
||||
default_lease=$(echo "${leases}" | head -n1)
|
||||
DHCP_SERVER=$(cat $default_lease | awk -F= '/SERVER_ADDRESS/ { print $2 }')
|
||||
METADATA_URL="http://${DHCP_SERVER}/latest/meta-data/"
|
||||
|
||||
block-until-url "${METADATA_URL}"
|
||||
|
||||
PUBLIC_IP=$(curl --fail -s "${METADATA_URL}public-ipv4")
|
||||
echo COREOS_PUBLIC_IPV4=${PUBLIC_IP} >> $ENV
|
||||
|
||||
PRIVATE_IP=$(curl --fail -s "${METADATA_URL}local-ipv4")
|
||||
echo COREOS_PRIVATE_IPV4=${PRIVATE_IP} >> $ENV
|
||||
|
||||
# Loop to export interoute style info into ENV
|
||||
count=1
|
||||
for lease in $leases;
|
||||
do
|
||||
ip=$(cat $lease | awk -F= '/^ADDRESS/ { print $2 }')
|
||||
gateway=$(cat $lease | awk -F= '/SERVER_ADDRESS/ { print $2 }')
|
||||
echo "NIC_${count}_IPV4"=${ip} >> $ENV
|
||||
echo "NIC_${count}_GATEWAY"=${gateway} >> $ENV
|
||||
count=$(expr $count + 1)
|
||||
done
|
||||
|
1
sdk_container/src/third_party/coreos-overlay/coreos-base/oem-interoute/files/oem-release
vendored
Normal file
1
sdk_container/src/third_party/coreos-overlay/coreos-base/oem-interoute/files/oem-release
vendored
Normal file
@ -0,0 +1 @@
|
||||
OEM_ID=interoute
|
@ -0,0 +1,42 @@
|
||||
#
|
||||
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
|
||||
# Copyright (c) 2014 CoreOS, Inc.. All rights reserved.
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header:$
|
||||
#
|
||||
|
||||
EAPI=5
|
||||
|
||||
DESCRIPTION="OEM suite for Interoute images"
|
||||
HOMEPAGE=""
|
||||
SRC_URI=""
|
||||
|
||||
LICENSE="Apache-2.0"
|
||||
SLOT="0"
|
||||
KEYWORDS="amd64"
|
||||
IUSE=""
|
||||
|
||||
DEPEND="
|
||||
app-emulation/open-vm-tools
|
||||
"
|
||||
RDEPEND="${DEPEND}"
|
||||
|
||||
# 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}/cloudstack-set-guest-password"
|
||||
dobin "${FILESDIR}/cloudstack-ssh-key"
|
||||
dobin "${FILESDIR}/cloudstack-coreos-cloudinit"
|
||||
dobin "${FILESDIR}/coreos-setup-environment"
|
||||
|
||||
insinto "/usr/share/oem"
|
||||
doins "${T}/cloud-config.yml"
|
||||
doins "${FILESDIR}/oem-release"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user