diff --git a/sysutils/Makefile b/sysutils/Makefile index ebeb0af12d02..2a66e987e342 100644 --- a/sysutils/Makefile +++ b/sysutils/Makefile @@ -27,6 +27,7 @@ SUBDIR += aimage SUBDIR += aird SUBDIR += am-utils + SUBDIR += amazon-ssm-agent SUBDIR += amrstat SUBDIR += amtc SUBDIR += anacron diff --git a/sysutils/amazon-ssm-agent/Makefile b/sysutils/amazon-ssm-agent/Makefile new file mode 100644 index 000000000000..1887f7d350ef --- /dev/null +++ b/sysutils/amazon-ssm-agent/Makefile @@ -0,0 +1,39 @@ +# $FreeBSD$ + +PORTNAME= amazon-ssm-agent +PORTVERSION= v1.2.252.0 +CATEGORIES= sysutils + +MAINTAINER= cperciva@FreeBSD.org +COMMENT= Amazon Simple Systems Manager Agent + +LICENSE= Amazon +LICENSE_NAME= Amazon Software License +LICENSE_FILE= ${WRKSRC}/LICENSE +LICENSE_PERMS= dist-mirror dist-sell pkg-mirror pkg-sell auto-accept + +BUILD_DEPENDS= bash:shells/bash \ + go:lang/go +RUN_DEPENDS= ${LOCALBASE}/share/certs/ca-root-nss.crt:security/ca_root_nss + +USE_GITHUB= yes +GH_ACCOUNT= aws + +WRKSRC= ${WRKDIR}/src/github.com/aws/amazon-ssm-agent +USES= gmake +MAKEFILE= makefile +ALL_TARGET= build-freebsd +INSTALL_TARGET= install-freebsd +MAKE_ARGS= SKIP_CHECKSTYLE="YES" DESTDIR=${STAGEDIR}${PREFIX} + +PLIST_FILES= etc/amazon/ssm/amazon-ssm-agent.json.template \ + etc/amazon/ssm/seelog_unix.xml.template \ + sbin/amazon-ssm-agent + +USE_RC_SUBR= amazon-ssm-agent + +post-extract: + ${MKDIR} ${WRKDIR}/src/github.com/aws + ${MV} ${WRKDIR}/${PORTNAME}-${PORTVERSION:S/v//} ${WRKSRC} + +.include diff --git a/sysutils/amazon-ssm-agent/distinfo b/sysutils/amazon-ssm-agent/distinfo new file mode 100644 index 000000000000..16f0e190d1f6 --- /dev/null +++ b/sysutils/amazon-ssm-agent/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1468390545 +SHA256 (aws-amazon-ssm-agent-v1.2.252.0_GH0.tar.gz) = 94e9633eadd0a78e5e1b9071b4f75c238dbbb78761f75d45461f8b0f5a5fbf24 +SIZE (aws-amazon-ssm-agent-v1.2.252.0_GH0.tar.gz) = 4562897 diff --git a/sysutils/amazon-ssm-agent/files/amazon-ssm-agent.in b/sysutils/amazon-ssm-agent/files/amazon-ssm-agent.in new file mode 100644 index 000000000000..b8c9ebbf5b7a --- /dev/null +++ b/sysutils/amazon-ssm-agent/files/amazon-ssm-agent.in @@ -0,0 +1,27 @@ +#!/bin/sh + +# $FreeBSD$ +# +# PROVIDE: amazon-ssm-agent +# REQUIRE: LOGIN +# KEYWORD: shutdown +# +# Add the following lines to /etc/rc.conf.local or /etc/rc.conf +# to enable this service: +# +# amazon_ssm_agent_enable: Set to YES to enable the Amazon SSM Agent + +. /etc/rc.subr + +name="amazon_ssm_agent" +rcvar=amazon_ssm_agent_enable + +load_rc_config $name + +: ${amazon_ssm_agent_enable="NO"} + +pidfile="/var/run/${name}.pid" +command="/usr/sbin/daemon" +command_args="-f -P ${pidfile} %%PREFIX%%/sbin/amazon-ssm-agent" + +run_rc_command "$1" diff --git a/sysutils/amazon-ssm-agent/files/patch-agent_appconfig_constants__unix.go b/sysutils/amazon-ssm-agent/files/patch-agent_appconfig_constants__unix.go new file mode 100644 index 000000000000..9221e6340777 --- /dev/null +++ b/sysutils/amazon-ssm-agent/files/patch-agent_appconfig_constants__unix.go @@ -0,0 +1,20 @@ +--- agent/appconfig/constants_unix.go.orig 2016-07-06 21:51:35 UTC ++++ agent/appconfig/constants_unix.go +@@ -18,7 +18,7 @@ package appconfig + + const ( + // Program Folder +- DefaultProgramFolder = "/etc/amazon/ssm/" ++ DefaultProgramFolder = "/usr/local/etc/amazon/ssm/" + + // AppConfig Path + AppConfigPath = DefaultProgramFolder + AppConfigFileName +@@ -27,7 +27,7 @@ const ( + DownloadRoot = "/var/log/amazon/ssm/download/" + + // DefaultDataStorePath represents the directory for storing system data +- DefaultDataStorePath = "/var/lib/amazon/ssm/" ++ DefaultDataStorePath = "/var/run/amazon/ssm/" + + // UpdaterArtifactsRoot represents the directory for storing update related information + UpdaterArtifactsRoot = "/var/lib/amazon/ssm/update/" diff --git a/sysutils/amazon-ssm-agent/files/patch-agent_fileutil_fileutil__unix.go b/sysutils/amazon-ssm-agent/files/patch-agent_fileutil_fileutil__unix.go new file mode 100644 index 000000000000..12d53231b8b5 --- /dev/null +++ b/sysutils/amazon-ssm-agent/files/patch-agent_fileutil_fileutil__unix.go @@ -0,0 +1,15 @@ +--- agent/fileutil/fileutil_unix.go.orig 2016-07-06 21:51:35 UTC ++++ agent/fileutil/fileutil_unix.go +@@ -85,9 +85,9 @@ func GetDiskSpaceInfo() (diskSpaceInfo D + + // return DiskSpaceInfo with calculated bytes + return DiskSpaceInfo{ +- AvailBytes: (int64)(stat.Bavail * bSize), // available space = # of available blocks * block size +- FreeBytes: (int64)(stat.Bfree * bSize), // free space = # of free blocks * block size +- TotalBytes: (int64)(stat.Blocks * bSize), // total space = # of total blocks * block size ++ AvailBytes: (int64)((uint64)(stat.Bavail) * bSize), // available space = # of available blocks * block size ++ FreeBytes: (int64)(stat.Bfree * bSize), // free space = # of free blocks * block size ++ TotalBytes: (int64)(stat.Blocks * bSize), // total space = # of total blocks * block size + }, nil + } + diff --git a/sysutils/amazon-ssm-agent/files/patch-agent_log_log__unix.go b/sysutils/amazon-ssm-agent/files/patch-agent_log_log__unix.go new file mode 100644 index 000000000000..1bbb3bf68b6f --- /dev/null +++ b/sysutils/amazon-ssm-agent/files/patch-agent_log_log__unix.go @@ -0,0 +1,11 @@ +--- agent/log/log_unix.go.orig 2016-07-06 21:51:35 UTC ++++ agent/log/log_unix.go +@@ -24,7 +24,7 @@ const ( + // DefaultSeelogConfigFilePath specifies the default seelog location + // The underlying logger is based of https://github.com/cihub/seelog + // See Seelog documentation to customize the logger +- DefaultSeelogConfigFilePath = "/etc/amazon/ssm/seelog.xml" ++ DefaultSeelogConfigFilePath = "/usr/local/etc/amazon/ssm/seelog.xml" + + DefaultLogDir = "/var/log/amazon/ssm" + ) diff --git a/sysutils/amazon-ssm-agent/files/patch-agent_platform_platform__unix.go b/sysutils/amazon-ssm-agent/files/patch-agent_platform_platform__unix.go new file mode 100644 index 000000000000..8256d0686d25 --- /dev/null +++ b/sysutils/amazon-ssm-agent/files/patch-agent_platform_platform__unix.go @@ -0,0 +1,37 @@ +--- agent/platform/platform_unix.go.orig 2016-07-06 21:51:35 UTC ++++ agent/platform/platform_unix.go +@@ -20,6 +20,7 @@ import ( + "os" + "os/exec" + "path/filepath" ++ "runtime" + "strings" + + "github.com/aws/amazon-ssm-agent/agent/fileutil" +@@ -29,6 +30,7 @@ import ( + const ( + systemReleaseCommand = "/etc/system-release" + redhatReleaseCommand = "/etc/redhat-release" ++ unameCommand = "/usr/bin/uname" + lsbReleaseCommand = "lsb_release" + fetchingDetailsMessage = "fetching platform details from %v" + errorOccurredMessage = "There was an error running %v, err: %v" +@@ -94,6 +96,18 @@ func getPlatformDetails(log log.T) (name + versionData := strings.Split(data[1], "(") + version = strings.TrimSpace(versionData[0]) + } ++ } else if runtime.GOOS == "freebsd" { ++ log.Debugf(fetchingDetailsMessage, unameCommand) ++ ++ if contentsBytes, err = exec.Command(unameCommand, "-sr").Output(); err != nil { ++ log.Debugf(fetchingDetailsMessage, lsbReleaseCommand, err) ++ return ++ } ++ log.Debugf(commandOutputMessage, contentsBytes) ++ ++ data := strings.Split(string(contentsBytes), " ") ++ name = strings.TrimSpace(data[0]) ++ version = strings.TrimSpace(data[1]) + } else { + log.Debugf(fetchingDetailsMessage, lsbReleaseCommand) + diff --git a/sysutils/amazon-ssm-agent/files/patch-agent_ssm_service.go b/sysutils/amazon-ssm-agent/files/patch-agent_ssm_service.go new file mode 100644 index 000000000000..7059eba0c89d --- /dev/null +++ b/sysutils/amazon-ssm-agent/files/patch-agent_ssm_service.go @@ -0,0 +1,11 @@ +--- agent/ssm/service.go.orig 2016-07-06 21:51:35 UTC ++++ agent/ssm/service.go +@@ -128,6 +128,8 @@ func (svc *sdkService) UpdateInstanceInf + params.PlatformType = aws.String(ssm.PlatformTypeWindows) + case "linux": + params.PlatformType = aws.String(ssm.PlatformTypeLinux) ++ case "freebsd": ++ params.PlatformType = aws.String(ssm.PlatformTypeLinux) + default: + return nil, fmt.Errorf("Cannot report platform type of unrecognized OS. %v", goOS) + } diff --git a/sysutils/amazon-ssm-agent/files/patch-makefile b/sysutils/amazon-ssm-agent/files/patch-makefile new file mode 100644 index 000000000000..04e5c30c924e --- /dev/null +++ b/sysutils/amazon-ssm-agent/files/patch-makefile @@ -0,0 +1,39 @@ +--- makefile.orig 2016-07-06 21:51:35 UTC ++++ makefile +@@ -26,13 +26,15 @@ endif + export GOPATH + + checkstyle:: ++ifndef SKIP_CHECKSTYLE + # Run checkstyle script + $(BGO_SPACE)/Tools/src/checkstyle.sh ++endif + + coverage:: build-linux + $(BGO_SPACE)/Tools/src/coverage.sh github.com/aws/amazon-ssm-agent/agent/... + +-build:: build-linux build-windows build-linux-386 build-windows-386 ++build:: build-linux build-freebsd build-windows build-linux-386 build-windows-386 + + prepack:: prepack-linux prepack-linux-386 prepack-windows prepack-windows-386 + +@@ -75,6 +77,19 @@ build-linux: checkstyle copy-src pre-bui + GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o $(BGO_SPACE)/bin/linux_amd64/updater -v \ + $(BGO_SPACE)/agent/update/updater/updater.go $(BGO_SPACE)/agent/update/updater/updater_unix.go + ++.PHONY: build-freebsd ++build-freebsd: checkstyle copy-src pre-build ++ @echo "Build for freebsd agent" ++ GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -w" -o $(BGO_SPACE)/bin/freebsd_amd64/amazon-ssm-agent -v \ ++ $(BGO_SPACE)/agent/agent.go $(BGO_SPACE)/agent/agent_unix.go $(BGO_SPACE)/agent/agent_parser.go ++ ++install-freebsd: ++ @echo "Install for freebsd agent" ++ install -m 555 $(BGO_SPACE)/bin/freebsd_amd64/amazon-ssm-agent $(DESTDIR)$(PREFIX)/sbin/ ++ mkdir -p $(DESTDIR)$(PREFIX)/etc/amazon/ssm ++ install -m 644 $(BGO_SPACE)/bin/amazon-ssm-agent.json.template $(DESTDIR)$(PREFIX)/etc/amazon/ssm ++ install -m 644 $(BGO_SPACE)/bin/seelog_unix.xml $(DESTDIR)$(PREFIX)/etc/amazon/ssm/seelog_unix.xml.template ++ + .PHONY: build-darwin + build-darwin: checkstyle copy-src pre-build + @echo "Rebuild for darwin agent" diff --git a/sysutils/amazon-ssm-agent/pkg-descr b/sysutils/amazon-ssm-agent/pkg-descr new file mode 100644 index 000000000000..b8449cb68fc0 --- /dev/null +++ b/sysutils/amazon-ssm-agent/pkg-descr @@ -0,0 +1,6 @@ +Amazon SSM (Simple Systems Manager) is a service for remotely controlling +(executing code on) EC2 instances. This port provides the SSM "Agent", +which polls an Amazon Web Services API for commands, spawns them, and +sends their output back. + +WWW: https://github.com/aws/amazon-ssm-agent