mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-21 22:41:09 +02:00
Merge pull request #970 from higebu/niftycloud
add(coreos-base/oem-niftycloud): added initial oem for niftycloud
This commit is contained in:
commit
20784dd141
57
sdk_container/src/third_party/coreos-overlay/coreos-base/oem-niftycloud/files/cloud-config.yml
vendored
Normal file
57
sdk_container/src/third_party/coreos-overlay/coreos-base/oem-niftycloud/files/cloud-config.yml
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
#cloud-config
|
||||
|
||||
coreos:
|
||||
units:
|
||||
- name: oem-ens192.network
|
||||
content: |
|
||||
[Match]
|
||||
Name=ens192
|
||||
|
||||
[Network]
|
||||
DHCP=v4
|
||||
DNS=8.8.8.8
|
||||
DNS=8.8.4.4
|
||||
- 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
|
||||
ExecStartPost=/usr/share/oem/bin/vmware-toolbox-cmd timesync enable
|
||||
TimeoutStopSec=5
|
||||
- name: niftycloud-coreos-cloudinit.service
|
||||
command: restart
|
||||
runtime: yes
|
||||
content: |
|
||||
[Unit]
|
||||
After=coreos-setup-environment.service
|
||||
After=vmtoolsd.service
|
||||
Requires=coreos-setup-environment.service
|
||||
Requires=vmtoolsd.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
EnvironmentFile=/etc/environment
|
||||
ExecStart=/usr/share/oem/bin/niftycloud-coreos-cloudinit
|
||||
- name: niftycloud-ssh-key.service
|
||||
command: restart
|
||||
runtime: yes
|
||||
content: |
|
||||
[Unit]
|
||||
Description=Sets SSH key from vmtoolsd
|
||||
[Service]
|
||||
Type=oneshot
|
||||
StandardOutput=journal+console
|
||||
ExecStart=/usr/share/oem/bin/niftycloud-ssh-key
|
||||
|
||||
oem:
|
||||
id: niftycloud
|
||||
name: NIFTY Cloud
|
||||
version-id: @@OEM_VERSION_ID@@
|
||||
home-url: http://cloud.nifty.com/
|
||||
bug-report-url: https://github.com/coreos/bugs/issues
|
35
sdk_container/src/third_party/coreos-overlay/coreos-base/oem-niftycloud/files/coreos-setup-environment
vendored
Executable file
35
sdk_container/src/third_party/coreos-overlay/coreos-base/oem-niftycloud/files/coreos-setup-environment
vendored
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
ENV=$1
|
||||
|
||||
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
|
||||
|
||||
sed -i -e '/^COREOS_PUBLIC_IPV4=/d' \
|
||||
-e '/^COREOS_PRIVATE_IPV4=/d' \
|
||||
"${ENV}"
|
||||
|
||||
function get_ip () {
|
||||
IF=$1
|
||||
IP=
|
||||
while [ 1 ]; do
|
||||
IP=$(ip addr show $IF | awk '/inet /{print $2}' | awk -F'/' '{print $1}')
|
||||
if [ "$IP" != "" ]; then
|
||||
break
|
||||
fi
|
||||
sleep .1
|
||||
done
|
||||
echo $IP
|
||||
}
|
||||
|
||||
echo COREOS_PUBLIC_IPV4=$(get_ip ens192) >> $ENV
|
||||
echo COREOS_PRIVATE_IPV4=$(get_ip ens224) >> $ENV
|
@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
VMTOOLSD=""
|
||||
if [ -x /usr/share/oem/bin/vmtoolsd ]; then
|
||||
VMTOOLSD="/usr/share/oem/bin/vmtoolsd"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
USER_DATA_DIR=/var/lib/coreos-niftycloud
|
||||
USER_DATA_PATH=${USER_DATA_DIR}/user-data
|
||||
USER_DATA_FLAG=$(${VMTOOLSD} --cmd 'info-get guestinfo.set_user_data')
|
||||
|
||||
if [ "$USER_DATA_FLAG" == "1" ]; then
|
||||
TMPFILE=$(mktemp /tmp/XXXXXX-cloud-init)
|
||||
${VMTOOLSD} --cmd 'info-get guestinfo.user_data' | openssl enc -d -base64 > "${TMPFILE}"
|
||||
if [ -s "${TMPFILE}" ]; then
|
||||
coreos-cloudinit --from-file="${TMPFILE}" || exit $?
|
||||
if [ "$(head -n 1 ${TMPFILE} | tr -d '\r' | tr -d '\n')" = "#cloud-config" ]; then
|
||||
mkdir -p ${USER_DATA_DIR}
|
||||
cp -p ${TMPFILE} ${USER_DATA_PATH}
|
||||
fi
|
||||
else
|
||||
echo "guestinfo.user_data undefined." >&2
|
||||
exit 1
|
||||
fi
|
||||
${VMTOOLSD} --cmd 'info-set guestinfo.set_user_data 0'
|
||||
elif [ -f ${USER_DATA_PATH} ]; then
|
||||
coreos-cloudinit --from-file="${USER_DATA_PATH}" || exit $?
|
||||
fi
|
25
sdk_container/src/third_party/coreos-overlay/coreos-base/oem-niftycloud/files/niftycloud-ssh-key
vendored
Normal file
25
sdk_container/src/third_party/coreos-overlay/coreos-base/oem-niftycloud/files/niftycloud-ssh-key
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
set -e
|
||||
|
||||
VMTOOLSD=""
|
||||
if [ -x /usr/share/oem/bin/vmtoolsd ]; then
|
||||
VMTOOLSD="/usr/share/oem/bin/vmtoolsd"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
INIT=$(${VMTOOLSD} --cmd 'info-get guestinfo.init' 2>&1)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "guestinfo.init undefined."
|
||||
${VMTOOLSD} --cmd 'info-set guestinfo.init_result 9999'
|
||||
exit 0
|
||||
fi
|
||||
echo "guestinfo.init: $INIT"
|
||||
|
||||
if [ $INIT == "1" ]; then
|
||||
${VMTOOLSD} --cmd 'info-get guestinfo.ssh_authorized_key' | update-ssh-keys -a "niftycloud" -
|
||||
${VMTOOLSD} --cmd 'info-set guestinfo.init 0'
|
||||
fi
|
||||
|
||||
${VMTOOLSD} --cmd 'info-set guestinfo.init_result 1'
|
@ -0,0 +1,36 @@
|
||||
# Copyright (c) 2014 NIFTY Corp.. All rights reserved.
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=5
|
||||
|
||||
DESCRIPTION="OEM suite for NIFTY Cloud images"
|
||||
HOMEPAGE=""
|
||||
SRC_URI=""
|
||||
|
||||
LICENSE="Apache-2.0"
|
||||
SLOT="0"
|
||||
KEYWORDS="amd64"
|
||||
IUSE=""
|
||||
|
||||
# no source directory
|
||||
S="${WORKDIR}"
|
||||
|
||||
DEPEND="
|
||||
app-emulation/open-vm-tools
|
||||
"
|
||||
RDEPEND="${DEPEND}"
|
||||
|
||||
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}/niftycloud-ssh-key
|
||||
dobin ${FILESDIR}/niftycloud-coreos-cloudinit
|
||||
dobin ${FILESDIR}/coreos-setup-environment
|
||||
|
||||
insinto "/usr/share/oem"
|
||||
doins ${T}/cloud-config.yml
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user