Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Dec 2014 00:51:55 +0000 (UTC)
From:      Steve Wills <swills@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r375499 - in head/net: . google-startup-scripts google-startup-scripts/files
Message-ID:  <201412250051.sBP0pto7056672@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: swills
Date: Thu Dec 25 00:51:54 2014
New Revision: 375499
URL: https://svnweb.freebsd.org/changeset/ports/375499
QAT: https://qat.redports.org/buildarchive/r375499/

Log:
  net/google-startup-scripts: create port for Google startup scripts

Added:
  head/net/google-startup-scripts/
  head/net/google-startup-scripts/Makefile   (contents, props changed)
  head/net/google-startup-scripts/distinfo   (contents, props changed)
  head/net/google-startup-scripts/files/
  head/net/google-startup-scripts/files/google-startup.in   (contents, props changed)
  head/net/google-startup-scripts/files/patch-usr_share_google_boto_boot__setup.py   (contents, props changed)
  head/net/google-startup-scripts/files/patch-usr_share_google_fetch__script   (contents, props changed)
  head/net/google-startup-scripts/files/patch-usr_share_google_first-boot   (contents, props changed)
  head/net/google-startup-scripts/files/patch-usr_share_google_get__metadata__value   (contents, props changed)
  head/net/google-startup-scripts/files/patch-usr_share_google_onboot   (contents, props changed)
  head/net/google-startup-scripts/files/patch-usr_share_google_regenerate-host-keys   (contents, props changed)
  head/net/google-startup-scripts/files/patch-usr_share_google_run-shutdown-scripts   (contents, props changed)
  head/net/google-startup-scripts/files/patch-usr_share_google_run-startup-scripts   (contents, props changed)
  head/net/google-startup-scripts/pkg-descr   (contents, props changed)
  head/net/google-startup-scripts/pkg-plist   (contents, props changed)
Modified:
  head/net/Makefile

Modified: head/net/Makefile
==============================================================================
--- head/net/Makefile	Thu Dec 25 00:13:16 2014	(r375498)
+++ head/net/Makefile	Thu Dec 25 00:51:54 2014	(r375499)
@@ -157,6 +157,7 @@
     SUBDIR += gogoc
     SUBDIR += google-cloud-sdk
     SUBDIR += google-daemon
+    SUBDIR += google-startup-scripts
     SUBDIR += googlecl
     SUBDIR += gopher
     SUBDIR += gotthard

Added: head/net/google-startup-scripts/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/google-startup-scripts/Makefile	Thu Dec 25 00:51:54 2014	(r375499)
@@ -0,0 +1,55 @@
+# Created by: Steve Wills <swills@FreeBSD.org>
+# $FreeBSD$
+
+PORTNAME=	google-startup-scripts
+PORTVERSION=	1.2.1
+CATEGORIES=	net
+MASTER_SITES=	GHR
+
+MAINTAINER=	swills@FreeBSD.org
+COMMENT=	Startup scripts that interact with Google Compute Engine VMs
+
+BUILD_DEPENDS=	python:${PORTSDIR}/lang/python
+RUN_DEPENDS=	python:${PORTSDIR}/lang/python \
+		curl:${PORTSDIR}/ftp/curl \
+		bash:${PORTSDIR}/shells/bash \
+		flock:${PORTSDIR}/sysutils/flock
+
+USES=		python shebangfix
+USE_GITHUB=	yes
+GH_ACCOUNT=	GoogleCloudPlatform
+GH_PROJECT=	compute-image-packages
+USE_RC_SUBR=	google-startup
+WRKSRC_SUBDIR=	${PORTNAME}
+
+SHEBANG_FILES= usr/share/google/fetch_script \
+		usr/share/google/first-boot \
+		usr/share/google/get_metadata_value \
+		usr/share/google/onboot \
+		usr/share/google/regenerate-host-keys \
+		usr/share/google/run-scripts \
+		usr/share/google/run-shutdown-scripts \
+		usr/share/google/run-startup-scripts \
+		usr/share/google/set-hostname \
+		usr/share/google/boto/boot_setup.py
+
+post-patch:
+	@${RM} ${WRKSRC}/usr/share/google/safe_format_and_mount \
+		${WRKSRC}/usr/share/google/virtionet-irq-affinity
+	@${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' \
+		${WRKSRC}/usr/share/google/fetch_script \
+		${WRKSRC}/usr/share/google/first-boot \
+		${WRKSRC}/usr/share/google/onboot \
+		${WRKSRC}/usr/share/google/run-shutdown-scripts \
+		${WRKSRC}/usr/share/google/run-startup-scripts \
+		${WRKSRC}/usr/share/google/boto/boot_setup.py
+	@${RM} ${WRKSRC}/usr/share/google/*.bak \
+		${WRKSRC}/usr/share/google/*.orig
+
+do-build:
+	${PYTHON_CMD} -m compileall ${WRKSRC}/usr/share/google/boto
+
+do-install:
+	cd ${WRKSRC}/usr/share ; ${COPYTREE_BIN} google ${STAGEDIR}${PREFIX}/share
+
+.include <bsd.port.mk>

Added: head/net/google-startup-scripts/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/google-startup-scripts/distinfo	Thu Dec 25 00:51:54 2014	(r375499)
@@ -0,0 +1,2 @@
+SHA256 (google-startup-scripts-1.2.1.tar.gz) = e70805809bd3e1a52f191391bd5a2255dd794169ba6402f0a3c46f2def67e13a
+SIZE (google-startup-scripts-1.2.1.tar.gz) = 65967

Added: head/net/google-startup-scripts/files/google-startup.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/google-startup-scripts/files/google-startup.in	Thu Dec 25 00:51:54 2014	(r375499)
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: google-startup
+# BEFORE: LOGIN
+# REQUIRE: syslogd
+# KEYWORD: shutdown
+#
+# Add the following line to /etc/rc.conf to enable google-startup:
+#
+# google_startup_enable="YES"
+#
+
+. /etc/rc.subr
+
+name="google_startup"
+rcvar="google_startup_enable"
+start_cmd="google_start"
+stop_cmd="google_stop"
+
+google_start()
+{
+  %%PREFIX%%/share/google/onboot
+  %%PREFIX%%/share/google/run-startup-scripts
+}
+
+google_stop()
+{
+  %%PREFIX%%/share/google/run-shutdown-scripts
+}
+
+google_startup_enable=${google_startup_enable:-"NO"}
+
+load_rc_config "${name}"
+run_rc_command "$1"

Added: head/net/google-startup-scripts/files/patch-usr_share_google_boto_boot__setup.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/google-startup-scripts/files/patch-usr_share_google_boto_boot__setup.py	Thu Dec 25 00:51:54 2014	(r375499)
@@ -0,0 +1,15 @@
+--- usr/share/google/boto/boot_setup.py.orig	2014-12-05 20:59:35 UTC
++++ usr/share/google/boto/boot_setup.py
+@@ -31,9 +31,9 @@ import urllib2
+ 
+ NUMERIC_PROJECT_ID_URL=('http://169.254.169.254/'
+                         'computeMetadata/v1/project/numeric-project-id')
+-SYSTEM_BOTO_CONFIG_TEMPLATE='/etc/boto.cfg.template'
+-SYSTEM_BOTO_CONFIG='/etc/boto.cfg'
+-AUTH_PLUGIN_DIR='/usr/share/google/boto/boto_plugins'
++SYSTEM_BOTO_CONFIG_TEMPLATE='%%PREFIX%%/etc/boto.cfg.template'
++SYSTEM_BOTO_CONFIG='%%PREFIX%%/etc/boto.cfg'
++AUTH_PLUGIN_DIR='%%PREFIX%%/share/google/boto/boto_plugins'
+ 
+ 
+ def GetNumericProjectId():

Added: head/net/google-startup-scripts/files/patch-usr_share_google_fetch__script
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/google-startup-scripts/files/patch-usr_share_google_fetch__script	Thu Dec 25 00:51:54 2014	(r375499)
@@ -0,0 +1,29 @@
+--- usr/share/google/fetch_script.orig	2014-12-24 22:40:30 UTC
++++ usr/share/google/fetch_script
+@@ -84,7 +84,7 @@ function download_url_with_logfile() {
+ 
+   # Unauthenticated download of the object.
+   log "Downloading url from ${url} to ${dest} using curl"
+-  curl --max-time "${CURL_TIMEOUT}" --retry "${CURL_RETRY_LIMIT}" \
++  curl -s --max-time "${CURL_TIMEOUT}" --retry "${CURL_RETRY_LIMIT}" \
+     2>> "${logfile}" -o "${dest}" -- "${url}" && return 0;
+ 
+   log "Failed to download $url"
+@@ -108,7 +108,7 @@ function download_url() {
+ 
+ function get_metadata_attribute() {
+   local readonly varname=$1
+-  /usr/share/google/get_metadata_value "attributes/${varname}"
++  %%PREFIX%%/share/google/get_metadata_value "attributes/${varname}"
+   return $?
+ }
+ 
+@@ -135,7 +135,7 @@ function fetch_script() {
+       echo "${metadata_script}" > "${script}"
+       log "${script_type} script found in metadata."
+     else
+-      log $(curl "http://metadata.google.internal/computeMetadata/v1/instance/?recursive=True" -H "Metadata-Flavor: Google")
++      log $(curl -s "http://metadata.google.internal/computeMetadata/v1/instance/?recursive=True" -H "Metadata-Flavor: Google")
+       log "No ${script_type} script found in metadata."
+     fi
+   fi

Added: head/net/google-startup-scripts/files/patch-usr_share_google_first-boot
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/google-startup-scripts/files/patch-usr_share_google_first-boot	Thu Dec 25 00:51:54 2014	(r375499)
@@ -0,0 +1,22 @@
+--- usr/share/google/first-boot.orig	2014-12-24 22:40:30 UTC
++++ usr/share/google/first-boot
+@@ -31,7 +31,7 @@ function log() {
+ 
+ function get_instance_id() {
+   # Do not retry to get the metadata value on failures.
+-  MDS_TRIES=1 ${PREFIX}/usr/share/google/get_metadata_value id 2>/dev/null
++  MDS_TRIES=1 ${PREFIX}%%PREFIX%%/share/google/get_metadata_value id 2>/dev/null
+ }
+ 
+ # Output the instance id.
+@@ -80,8 +80,8 @@ log "Running first-boot"
+ declare -r INSTANCE_ID=$(cat ${INSTANCE_FILE})
+ 
+ # Regenerate host keys for ssh.
+-if [[ -x ${PREFIX}/usr/share/google/regenerate-host-keys ]]; then
+-  ${PREFIX}/usr/share/google/regenerate-host-keys
++if [[ -x ${PREFIX}%%PREFIX%%/share/google/regenerate-host-keys ]]; then
++  ${PREFIX}%%PREFIX%%/share/google/regenerate-host-keys
+ fi
+ 
+ # Make a per-instance data directory.

Added: head/net/google-startup-scripts/files/patch-usr_share_google_get__metadata__value
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/google-startup-scripts/files/patch-usr_share_google_get__metadata__value	Thu Dec 25 00:51:54 2014	(r375499)
@@ -0,0 +1,11 @@
+--- usr/share/google/get_metadata_value.orig	2014-12-24 22:41:29 UTC
++++ usr/share/google/get_metadata_value
+@@ -26,7 +26,7 @@ function metadata_get_url_code() {
+ 
+ function print_metadata_value() {
+   local readonly tmpfile=$(mktemp)
+-  curl -f "${1}" -H "Metadata-Flavor: Google" > ${tmpfile} 2>/dev/null
++  curl -s -f "${1}" -H "Metadata-Flavor: Google" > ${tmpfile} 2>/dev/null
+   local readonly return_code=$?
+   # If the command completed successfully, print the metadata value to stdout.
+   if [[ ${return_code} == 0 ]]; then

Added: head/net/google-startup-scripts/files/patch-usr_share_google_onboot
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/google-startup-scripts/files/patch-usr_share_google_onboot	Thu Dec 25 00:51:54 2014	(r375499)
@@ -0,0 +1,46 @@
+--- usr/share/google/onboot.orig	2014-12-24 22:40:30 UTC
++++ usr/share/google/onboot
+@@ -33,7 +33,7 @@ else
+     declare -r LOGGER=/bin/logger
+ fi
+ 
+-declare -r BOTO_SETUP_SCRIPT=/usr/share/google/boto/boot_setup.py
++declare -r BOTO_SETUP_SCRIPT=%%PREFIX%%/share/google/boto/boot_setup.py
+ declare -r GOOGLE_ENVIRONMENT=/var/run/google.environment
+ 
+ function log() {
+@@ -42,20 +42,20 @@ function log() {
+ }
+ 
+ function virtionet_irq_affinity() {
+-  if [[ -x /usr/share/google/virtionet-irq-affinity ]]; then
+-    /usr/share/google/virtionet-irq-affinity
++  if [[ -x %%PREFIX%%/share/google/virtionet-irq-affinity ]]; then
++    %%PREFIX%%/share/google/virtionet-irq-affinity
+   fi
+ }
+ 
+ function first_boot() {
+-  if [[ -x /usr/share/google/first-boot ]]; then
+-    /usr/share/google/first-boot
++  if [[ -x %%PREFIX%%/share/google/first-boot ]]; then
++    %%PREFIX%%/share/google/first-boot
+   fi
+ }
+ 
+ function get_metadata_value() {
+   local readonly varname=$1
+-  /usr/share/google/get_metadata_value ${varname}
++  %%PREFIX%%/share/google/get_metadata_value ${varname}
+   return $?
+ }
+ 
+@@ -106,7 +106,7 @@ function print_ssh_key_fingerprints() {
+   return 0
+ }
+ 
+-virtionet_irq_affinity
++#virtionet_irq_affinity
+ first_boot
+ do_init
+ print_ssh_key_fingerprints

Added: head/net/google-startup-scripts/files/patch-usr_share_google_regenerate-host-keys
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/google-startup-scripts/files/patch-usr_share_google_regenerate-host-keys	Thu Dec 25 00:51:54 2014	(r375499)
@@ -0,0 +1,20 @@
+--- usr/share/google/regenerate-host-keys.orig	2014-12-24 22:40:30 UTC
++++ usr/share/google/regenerate-host-keys
+@@ -29,7 +29,7 @@ sshd_cmd() {
+   if [[ -x /etc/init.d/ssh || -f /etc/init/ssh.conf ]]; then
+     service ssh ${cmd}
+   fi
+-  if [[ -x /etc/init.d/sshd || -f /etc/init/sshd.conf ]]; then
++  if [[ -x /etc/init.d/sshd || -f /etc/init/sshd.conf || -f /etc/rc.d/sshd ]]; then
+     service sshd ${cmd}
+   fi
+ }
+@@ -55,7 +55,7 @@ generate_key() {
+ 
+ regenerate_host_keys() {
+   log "Regenerating SSH Host Keys for: $new_ip_address (previously $old_ip_address)."
+-  rm -f /etc/ssh/ssh_host_key /etc/ssh_host_key.pub # SSH1 RSA key.
++  rm -f /etc/ssh/ssh_host_key /etc/ssh/ssh_host_key.pub # SSH1 RSA key.
+   for key_file in /etc/ssh/ssh_host_*_key; do
+     # Parse out the type of key, matching the * in the for loop command above.
+     key_type=$(basename "${key_file}" _key)

Added: head/net/google-startup-scripts/files/patch-usr_share_google_run-shutdown-scripts
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/google-startup-scripts/files/patch-usr_share_google_run-shutdown-scripts	Thu Dec 25 00:51:54 2014	(r375499)
@@ -0,0 +1,10 @@
+--- usr/share/google/run-shutdown-scripts.orig	2014-12-24 22:40:30 UTC
++++ usr/share/google/run-shutdown-scripts
+@@ -27,5 +27,5 @@ declare -r SHUTDOWN_SCRIPT=/var/run/goog
+ # buffers to disk.
+ #
+ # The shutdown script blocks other shutdown operations from proceeding.
+-/usr/share/google/fetch_script ${SHUTDOWN_SCRIPT} shutdown
+-/usr/share/google/run-scripts ${SHUTDOWN_SCRIPT} shutdown
++%%PREFIX%%/share/google/fetch_script ${SHUTDOWN_SCRIPT} shutdown
++%%PREFIX%%/share/google/run-scripts ${SHUTDOWN_SCRIPT} shutdown

Added: head/net/google-startup-scripts/files/patch-usr_share_google_run-startup-scripts
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/google-startup-scripts/files/patch-usr_share_google_run-startup-scripts	Thu Dec 25 00:51:54 2014	(r375499)
@@ -0,0 +1,13 @@
+--- usr/share/google/run-startup-scripts.orig	2014-12-24 22:40:30 UTC
++++ usr/share/google/run-startup-scripts
+@@ -21,7 +21,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/
+ declare -r STARTUP_SCRIPT=/var/run/google.startup.script
+ 
+ # Make sure all udev changes settle before running startup scripts.
+-udevadm settle
++#udevadm settle
+ 
+-/usr/share/google/fetch_script ${STARTUP_SCRIPT} startup
+-/usr/share/google/run-scripts ${STARTUP_SCRIPT} startup
++%%PREFIX%%/share/google/fetch_script ${STARTUP_SCRIPT} startup
++%%PREFIX%%/share/google/run-scripts ${STARTUP_SCRIPT} startup

Added: head/net/google-startup-scripts/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/google-startup-scripts/pkg-descr	Thu Dec 25 00:51:54 2014	(r375499)
@@ -0,0 +1,3 @@
+A set of startup scripts that interact with the virtual machine environment.
+
+WWW: https://github.com/GoogleCloudPlatform/compute-image-packages/tree/master/google-startup-scripts

Added: head/net/google-startup-scripts/pkg-plist
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/google-startup-scripts/pkg-plist	Thu Dec 25 00:51:54 2014	(r375499)
@@ -0,0 +1,13 @@
+share/google/boto/boot_setup.py
+share/google/boto/boot_setup.pyc
+share/google/boto/boto_plugins/compute_auth.py
+share/google/boto/boto_plugins/compute_auth.pyc
+share/google/fetch_script
+share/google/first-boot
+share/google/get_metadata_value
+share/google/onboot
+share/google/regenerate-host-keys
+share/google/run-scripts
+share/google/run-shutdown-scripts
+share/google/run-startup-scripts
+share/google/set-hostname



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412250051.sBP0pto7056672>