mirror of
https://git.FreeBSD.org/ports.git
synced 2025-01-04 06:15:24 +00:00
Add amazon-ssm-agent, an "Agent" which can be run on systems to enable
remote code execution via the Amazon Simple Systems Manager (SSM) service.
This commit is contained in:
parent
05a0ed9ad2
commit
7d390a59a4
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=423636
@ -27,6 +27,7 @@
|
||||
SUBDIR += aimage
|
||||
SUBDIR += aird
|
||||
SUBDIR += am-utils
|
||||
SUBDIR += amazon-ssm-agent
|
||||
SUBDIR += amrstat
|
||||
SUBDIR += amtc
|
||||
SUBDIR += anacron
|
||||
|
39
sysutils/amazon-ssm-agent/Makefile
Normal file
39
sysutils/amazon-ssm-agent/Makefile
Normal file
@ -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 <bsd.port.mk>
|
3
sysutils/amazon-ssm-agent/distinfo
Normal file
3
sysutils/amazon-ssm-agent/distinfo
Normal file
@ -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
|
27
sysutils/amazon-ssm-agent/files/amazon-ssm-agent.in
Normal file
27
sysutils/amazon-ssm-agent/files/amazon-ssm-agent.in
Normal file
@ -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"
|
@ -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/"
|
@ -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
|
||||
}
|
||||
|
11
sysutils/amazon-ssm-agent/files/patch-agent_log_log__unix.go
Normal file
11
sysutils/amazon-ssm-agent/files/patch-agent_log_log__unix.go
Normal file
@ -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"
|
||||
)
|
@ -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)
|
||||
|
11
sysutils/amazon-ssm-agent/files/patch-agent_ssm_service.go
Normal file
11
sysutils/amazon-ssm-agent/files/patch-agent_ssm_service.go
Normal file
@ -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)
|
||||
}
|
39
sysutils/amazon-ssm-agent/files/patch-makefile
Normal file
39
sysutils/amazon-ssm-agent/files/patch-makefile
Normal file
@ -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"
|
6
sysutils/amazon-ssm-agent/pkg-descr
Normal file
6
sysutils/amazon-ssm-agent/pkg-descr
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user