mirror of
https://git.freebsd.org/ports.git
synced 2025-06-03 03:46:30 -04:00
net/google-startup-scripts: create port for Google startup scripts
This commit is contained in:
parent
9b887b2d34
commit
1ebab2e45c
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=375499
14 changed files with 276 additions and 0 deletions
|
@ -157,6 +157,7 @@
|
||||||
SUBDIR += gogoc
|
SUBDIR += gogoc
|
||||||
SUBDIR += google-cloud-sdk
|
SUBDIR += google-cloud-sdk
|
||||||
SUBDIR += google-daemon
|
SUBDIR += google-daemon
|
||||||
|
SUBDIR += google-startup-scripts
|
||||||
SUBDIR += googlecl
|
SUBDIR += googlecl
|
||||||
SUBDIR += gopher
|
SUBDIR += gopher
|
||||||
SUBDIR += gotthard
|
SUBDIR += gotthard
|
||||||
|
|
55
net/google-startup-scripts/Makefile
Normal file
55
net/google-startup-scripts/Makefile
Normal file
|
@ -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>
|
2
net/google-startup-scripts/distinfo
Normal file
2
net/google-startup-scripts/distinfo
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
SHA256 (google-startup-scripts-1.2.1.tar.gz) = e70805809bd3e1a52f191391bd5a2255dd794169ba6402f0a3c46f2def67e13a
|
||||||
|
SIZE (google-startup-scripts-1.2.1.tar.gz) = 65967
|
36
net/google-startup-scripts/files/google-startup.in
Normal file
36
net/google-startup-scripts/files/google-startup.in
Normal file
|
@ -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"
|
|
@ -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():
|
|
@ -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
|
|
@ -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.
|
|
@ -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
|
|
@ -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
|
|
@ -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)
|
|
@ -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
|
|
@ -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
|
3
net/google-startup-scripts/pkg-descr
Normal file
3
net/google-startup-scripts/pkg-descr
Normal file
|
@ -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
|
13
net/google-startup-scripts/pkg-plist
Normal file
13
net/google-startup-scripts/pkg-plist
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue