diff --git a/NOTICE.txt b/NOTICE.txt index 284ea99049f0..d78b8d99f696 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -23008,43 +23008,6 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------------- -Dependency : github.com/tsg/go-daemon -Version: v0.0.0-20200207173439-e704b93fd89b -Licence type (autodetected): BSD-3-Clause --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/github.com/tsg/go-daemon@v0.0.0-20200207173439-e704b93fd89b/LICENSE: - -Copyright (c) 2013-2014 Alexandre Fiori. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * The names of authors or contributors may NOT be used to endorse or -promote products derived from this software without specific prior -written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -------------------------------------------------------------------------------- Dependency : github.com/ugorji/go/codec Version: v1.1.8 diff --git a/auditbeat/magefile.go b/auditbeat/magefile.go index 1f17ed60fae6..cf9c37653a8b 100644 --- a/auditbeat/magefile.go +++ b/auditbeat/magefile.go @@ -65,21 +65,11 @@ func GolangCrossBuild() error { ) } -// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). -func BuildGoDaemon() error { - return devtools.BuildGoDaemon() -} - // CrossBuild cross-builds the beat for all target platforms. func CrossBuild() error { return devtools.CrossBuild() } -// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. -func CrossBuildGoDaemon() error { - return devtools.CrossBuildGoDaemon() -} - // AssembleDarwinUniversal merges the darwin/amd64 and darwin/arm64 into a single // universal binary using `lipo`. It assumes the darwin/amd64 and darwin/arm64 // were built and only performs the merge. @@ -100,7 +90,7 @@ func Package() { auditbeat.CustomizePackaging(auditbeat.OSSPackaging) mg.SerialDeps(Fields, Dashboards, Config, devtools.GenerateModuleIncludeListGo) - mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.Deps(CrossBuild) mg.SerialDeps(devtools.Package, TestPackages) } diff --git a/dev-tools/mage/godaemon.go b/dev-tools/mage/godaemon.go deleted file mode 100644 index c328703634b3..000000000000 --- a/dev-tools/mage/godaemon.go +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to Elasticsearch B.V. under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Elasticsearch B.V. licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package mage - -import ( - "errors" - "log" - "os" - "path/filepath" - - "github.com/elastic/beats/v7/dev-tools/mage/gotool" -) - -var ( - defaultCrossBuildGoDaemon = []CrossBuildOption{ - ForPlatforms("linux"), - WithTarget("buildGoDaemon"), - } -) - -// BuildGoDaemon builds the go-deamon binary. -func BuildGoDaemon() error { - if GOOS != "linux" { - return errors.New("go-daemon only builds for linux") - } - - if os.Getenv("GOLANG_CROSSBUILD") != "1" { - return errors.New("Use the crossBuildGoDaemon target. buildGoDaemon can " + - "only be executed within the golang-crossbuild docker environment.") - } - - // Test if binaries are up-to-date. - godaemonDir, err := gotool.ListModuleCacheDir("github.com/tsg/go-daemon") - if err != nil { - return err - } - input := filepath.Join(godaemonDir, "src", "god.c") - output := MustExpand("build/golang-crossbuild/god-{{.Platform.GOOS}}-{{.Platform.Arch}}") - if IsUpToDate(output, input) { - log.Println(">>> buildGoDaemon is up-to-date for", Platform.Name) - return nil - } - - // Determine what compiler to use based on CC that is set by golang-crossbuild. - cc := os.Getenv("CC") - if cc == "" { - cc = "cc" - } - - compileCmd := []string{ - cc, - input, - "-o", createDir(output), - "-lpthread", "-static", - } - switch Platform.Name { - case "linux/amd64": - compileCmd = append(compileCmd, "-m64") - } - - defer DockerChown(output) - return RunCmds(compileCmd) -} - -// CrossBuildGoDaemon cross-build the go-daemon binary using the -// golang-crossbuild environment. -func CrossBuildGoDaemon(options ...CrossBuildOption) error { - opts := append(defaultCrossBuildGoDaemon, options...) - return CrossBuild(opts...) -} diff --git a/dev-tools/mage/target/build/build.go b/dev-tools/mage/target/build/build.go index 3f09bff735b9..fbc7f725cd6c 100644 --- a/dev-tools/mage/target/build/build.go +++ b/dev-tools/mage/target/build/build.go @@ -38,21 +38,11 @@ func GolangCrossBuild() error { return devtools.GolangCrossBuild(devtools.DefaultGolangCrossBuildArgs()) } -// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). -func BuildGoDaemon() error { - return devtools.BuildGoDaemon() -} - // CrossBuild cross-builds the beat for all target platforms. func CrossBuild() error { return devtools.CrossBuild() } -// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. -func CrossBuildGoDaemon() error { - return devtools.CrossBuildGoDaemon() -} - // AssembleDarwinUniversal merges the darwin/amd64 and darwin/arm64 into a single // universal binary using `lipo`. It's automatically invoked by CrossBuild whenever // the darwin/amd64 and darwin/arm64 are present. diff --git a/dev-tools/packaging/packages.yml b/dev-tools/packaging/packages.yml index 0c7acfe07e11..b92eec37877d 100644 --- a/dev-tools/packaging/packages.yml +++ b/dev-tools/packaging/packages.yml @@ -49,18 +49,12 @@ shared: /usr/share/{{.BeatName}}/kibana: source: _meta/kibana.generated mode: 0644 - /usr/share/{{.BeatName}}/bin/{{.BeatName}}-god: - source: build/golang-crossbuild/god-{{.GOOS}}-{{.Platform.Arch}} - mode: 0755 /usr/bin/{{.BeatName}}: template: '{{ elastic_beats_dir }}/dev-tools/packaging/templates/linux/beatname.sh.tmpl' mode: 0755 /lib/systemd/system/{{.BeatServiceName}}.service: template: '{{ elastic_beats_dir }}/dev-tools/packaging/templates/linux/systemd.unit.tmpl' mode: 0644 - /etc/init.d/{{.BeatServiceName}}: - template: '{{ elastic_beats_dir }}/dev-tools/packaging/templates/{{.PackageType}}/init.sh.tmpl' - mode: 0755 # MacOS pkg spec for community beats. - &macos_beat_pkg_spec diff --git a/dev-tools/packaging/templates/deb/elastic-agent.init.sh.tmpl b/dev-tools/packaging/templates/deb/elastic-agent.init.sh.tmpl deleted file mode 100644 index 812bc978199d..000000000000 --- a/dev-tools/packaging/templates/deb/elastic-agent.init.sh.tmpl +++ /dev/null @@ -1,165 +0,0 @@ -#!/bin/sh -### BEGIN INIT INFO -# Provides: {{.ServiceName}} -# Required-Start: $local_fs $network $syslog -# Required-Stop: $local_fs $network $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: {{.Description}} -# Description: {{.BeatName | title}} is a shipper part of the Elastic Beats -# family. Please see: https://www.elastic.co/beats -### END INIT INFO - -# Do NOT "set -e" - -# PATH should only include /usr/* if it runs after the mountnfs.sh script -PATH=/sbin:/usr/sbin:/bin:/usr/bin -DESC="{{.Description}}" -NAME="{{.BeatName}}" -DAEMON=/usr/share/${NAME}/bin/${NAME} -DAEMON_ARGS="-c /etc/${NAME}/${NAME}.yml --path.home /usr/share/${NAME} --path.config /etc/${NAME} --path.logs /var/log/${NAME}" -PIDFILE=/var/run/{{.ServiceName}}.pid -WRAPPER="/usr/share/${NAME}/bin/${NAME}-god" -BEAT_USER="{{.BeatUser}}" -WRAPPER_ARGS="-r / -n -p $PIDFILE" -SCRIPTNAME=/etc/init.d/{{.ServiceName}} - - -# Exit if the package is not installed -[ -x "$DAEMON" ] || exit 0 - -# Read configuration variable file if it is present -[ -r /etc/default/{{.ServiceName}} ] && . /etc/default/{{.ServiceName}} - -DEFAULT_GODEBUG="madvdontneed=1" -export GODEBUG=${GODEBUG-$DEFAULT_GODEBUG} - -[ "$BEAT_USER" != "root" ] && WRAPPER_ARGS="$WRAPPER_ARGS -u $BEAT_USER" -USER_WRAPPER="su" -USER_WRAPPER_ARGS="$BEAT_USER -c" - -if command -v runuser >/dev/null 2>&1; then - USER_WRAPPER="runuser" -fi - -# Load the VERBOSE setting and other rcS variables -. /lib/init/vars.sh - -# Define LSB log_* functions. -# Depend on lsb-base (>= 3.2-14) to ensure that this file is present -# and status_of_proc is working. -. /lib/lsb/init-functions - -# -# Function that starts the daemon/service -# -do_start() -{ - # Return - # 0 if daemon has been started - # 1 if daemon was already running - # 2 if daemon could not be started - start-stop-daemon --start \ - --pidfile $PIDFILE \ - --exec $WRAPPER -- $WRAPPER_ARGS -- $DAEMON $DAEMON_ARGS \ - || return 2 -} - -# -# Function that stops the daemon/service -# -do_stop() -{ - # Return - # 0 if daemon has been stopped - # 1 if daemon was already stopped - # 2 if daemon could not be stopped - # other if a failure occurred - start-stop-daemon --stop --quiet --retry=TERM/5/KILL/5 --pidfile $PIDFILE --exec $WRAPPER - RETVAL="$?" - [ "$RETVAL" = 2 ] && return 2 - # Wait for children to finish too if this is a daemon that forks - # and if the daemon is only ever run from this initscript. - # If the above conditions are not satisfied then add some other code - # that waits for the process to drop all resources that could be - # needed by services started subsequently. A last resort is to - # sleep for some time. - start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON - [ "$?" = 2 ] && return 2 - # Many daemons don't delete their pidfiles when they exit. - rm -f $PIDFILE - return "$RETVAL" -} - -# -# Function that sends a SIGHUP to the daemon/service -# -do_reload() { - # - # If the daemon can reload its configuration without - # restarting (for example, when it is sent a SIGHUP), - # then implement that here. - # - start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --exec $DAEMON - return 0 -} - -case "$1" in - start) - [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" - do_start - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; - stop) - [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" - do_stop - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; - status) - status_of_proc "$WRAPPER" "$NAME" && exit 0 || exit $? - ;; - #reload|force-reload) - # - # If do_reload() is not implemented then leave this commented out - # and leave 'force-reload' as an alias for 'restart'. - # - #log_daemon_msg "Reloading $DESC" "$NAME" - #do_reload - #log_end_msg $? - #;; - restart|force-reload) - # - # If the "reload" option is implemented then remove the - # 'force-reload' alias - # - log_daemon_msg "Restarting $DESC" "$NAME" - do_stop - case "$?" in - 0|1) - do_start - case "$?" in - 0) log_end_msg 0 ;; - 1) log_end_msg 1 ;; # Old process is still running - *) log_end_msg 1 ;; # Failed to start - esac - ;; - *) - # Failed to stop - log_end_msg 1 - ;; - esac - ;; - *) - #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 - echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 - exit 3 - ;; -esac - -: diff --git a/dev-tools/packaging/templates/deb/init.sh.tmpl b/dev-tools/packaging/templates/deb/init.sh.tmpl deleted file mode 100644 index b30e29d40a1c..000000000000 --- a/dev-tools/packaging/templates/deb/init.sh.tmpl +++ /dev/null @@ -1,192 +0,0 @@ -#!/bin/sh -### BEGIN INIT INFO -# Provides: {{.ServiceName}} -# Required-Start: $local_fs $network $syslog -# Required-Stop: $local_fs $network $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: {{.Description}} -# Description: {{.BeatName | title}} is a shipper part of the Elastic Beats -# family. Please see: https://www.elastic.co/beats -### END INIT INFO - -# Do NOT "set -e" - -# PATH should only include /usr/* if it runs after the mountnfs.sh script -PATH=/sbin:/usr/sbin:/bin:/usr/bin -DESC="{{.Description}}" -NAME="{{.BeatName}}" -DAEMON=/usr/share/${NAME}/bin/${NAME} -DAEMON_ARGS="-c /etc/${NAME}/${NAME}.yml --path.home /usr/share/${NAME} --path.config /etc/${NAME} --path.data /var/lib/${NAME} --path.logs /var/log/${NAME}" -TEST_ARGS="-e test config" -PIDFILE=/var/run/{{.ServiceName}}.pid -WRAPPER="/usr/share/${NAME}/bin/${NAME}-god" -BEAT_USER="{{.BeatUser}}" -WRAPPER_ARGS="-r / -n -p $PIDFILE" -SCRIPTNAME=/etc/init.d/{{.ServiceName}} - - -# Exit if the package is not installed -[ -x "$DAEMON" ] || exit 0 - -# Read configuration variable file if it is present -[ -r /etc/default/{{.ServiceName}} ] && . /etc/default/{{.ServiceName}} - -DEFAULT_GODEBUG="madvdontneed=1" -export GODEBUG=${GODEBUG-$DEFAULT_GODEBUG} - -[ "$BEAT_USER" != "root" ] && WRAPPER_ARGS="$WRAPPER_ARGS -u $BEAT_USER" -USER_WRAPPER="su" -USER_WRAPPER_ARGS="$BEAT_USER -c" - -if command -v runuser >/dev/null 2>&1; then - USER_WRAPPER="runuser" -fi - -# Load the VERBOSE setting and other rcS variables -. /lib/init/vars.sh - -# Define LSB log_* functions. -# Depend on lsb-base (>= 3.2-14) to ensure that this file is present -# and status_of_proc is working. -. /lib/lsb/init-functions - -# -# Function that calls runs the service in foreground -# to test its configuration. -# -do_test() -{ - $USER_WRAPPER $USER_WRAPPER_ARGS "$DAEMON $DAEMON_ARGS $TEST_ARGS" -} - -# -# Function that starts the daemon/service -# -do_start() -{ - # Return - # 0 if daemon has been started - # 1 if daemon was already running - # 2 if daemon could not be started - start-stop-daemon --start \ - --pidfile $PIDFILE \ - --exec $WRAPPER -- $WRAPPER_ARGS -- $DAEMON $DAEMON_ARGS \ - || return 2 -} - -# -# Function that stops the daemon/service -# -do_stop() -{ - # Return - # 0 if daemon has been stopped - # 1 if daemon was already stopped - # 2 if daemon could not be stopped - # other if a failure occurred - start-stop-daemon --stop --quiet --retry=TERM/5/KILL/5 --pidfile $PIDFILE --exec $WRAPPER - RETVAL="$?" - [ "$RETVAL" = 2 ] && return 2 - # Wait for children to finish too if this is a daemon that forks - # and if the daemon is only ever run from this initscript. - # If the above conditions are not satisfied then add some other code - # that waits for the process to drop all resources that could be - # needed by services started subsequently. A last resort is to - # sleep for some time. - start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON - [ "$?" = 2 ] && return 2 - # Many daemons don't delete their pidfiles when they exit. - rm -f $PIDFILE - return "$RETVAL" -} - -# -# Function that sends a SIGHUP to the daemon/service -# -do_reload() { - # - # If the daemon can reload its configuration without - # restarting (for example, when it is sent a SIGHUP), - # then implement that here. - # - start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --exec $DAEMON - return 0 -} - -case "$1" in - start) - [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" - do_test - case "$?" in - 0) ;; - *) - log_end_msg 1 - exit 1 - ;; - esac - do_start - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; - stop) - [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" - do_stop - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; - status) - status_of_proc "$WRAPPER" "$NAME" && exit 0 || exit $? - ;; - #reload|force-reload) - # - # If do_reload() is not implemented then leave this commented out - # and leave 'force-reload' as an alias for 'restart'. - # - #log_daemon_msg "Reloading $DESC" "$NAME" - #do_reload - #log_end_msg $? - #;; - restart|force-reload) - # - # If the "reload" option is implemented then remove the - # 'force-reload' alias - # - log_daemon_msg "Restarting $DESC" "$NAME" - do_test - case "$?" in - 0) ;; - *) - log_end_msg 1 # Old process is still running - exit 1 - ;; - esac - - do_stop - case "$?" in - 0|1) - do_start - case "$?" in - 0) log_end_msg 0 ;; - 1) log_end_msg 1 ;; # Old process is still running - *) log_end_msg 1 ;; # Failed to start - esac - ;; - *) - # Failed to stop - log_end_msg 1 - ;; - esac - ;; - *) - #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 - echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 - exit 3 - ;; -esac - -: diff --git a/dev-tools/packaging/templates/rpm/elastic-agent.init.sh.tmpl b/dev-tools/packaging/templates/rpm/elastic-agent.init.sh.tmpl deleted file mode 100644 index 25c87d29fd96..000000000000 --- a/dev-tools/packaging/templates/rpm/elastic-agent.init.sh.tmpl +++ /dev/null @@ -1,121 +0,0 @@ -#!/bin/bash -# -# {{.ServiceName}} {{.BeatName}} shipper -# -# chkconfig: 2345 98 02 -# description: Starts and stops a single {{.BeatName}} instance on this system -# - -### BEGIN INIT INFO -# Provides: {{.ServiceName}} -# Required-Start: $local_fs $network $syslog -# Required-Stop: $local_fs $network $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: {{.Description}} -# Description: {{.BeatName | title}} is a shipper part of the Elastic Beats -# family. Please see: https://www.elastic.co/beats -### END INIT INFO - -# Exit with an informative message if functions does not exist. -# This has been removed from RHEL9, but exists on other RPM-based -# distributions in the support matrix. -if [ ! -f /etc/rc.d/init.d/functions ]; then - echo "SysV-style init script service management is not supported on this system, use systemctl instead" - exit 1 -fi - - -PATH=/usr/bin:/sbin:/bin:/usr/sbin -export PATH - -[ -f /etc/sysconfig/{{.ServiceName}} ] && . /etc/sysconfig/{{.ServiceName}} -pidfile=${PIDFILE-/var/run/{{.ServiceName}}.pid} -agent=${BEATS_AGENT-/usr/share/{{.BeatName}}/bin/{{.BeatName}}} -args="-c /etc/{{.BeatName}}/{{.BeatName}}.yml --path.home /usr/share/{{.BeatName}} --path.config /etc/{{.BeatName}} --path.logs /var/log/{{.BeatName}}" -beat_user="${BEAT_USER:-{{.BeatUser}}}" -wrapper="/usr/share/{{.BeatName}}/bin/{{.BeatName}}-god" -wrapperopts="-r / -n -p $pidfile" -user_wrapper="su" -user_wrapperopts="$beat_user -c" -RETVAL=0 -DEFAULT_GODEBUG="madvdontneed=1" -export GODEBUG=${GODEBUG-$DEFAULT_GODEBUG} - -# Source function library. -. /etc/rc.d/init.d/functions - -# Determine if we can use the -p option to daemon, killproc, and status. -# RHEL < 5 can't. -if status | grep -q -- '-p' 2>/dev/null; then - daemonopts="--pidfile $pidfile" - pidopts="-p $pidfile" -fi - -if command -v runuser >/dev/null 2>&1; then - user_wrapper="runuser" -fi - -[ "$beat_user" != "root" ] && wrapperopts="$wrapperopts -u $beat_user" - -start() { - echo -n $"Starting {{.BeatName}}: " - if [ $? -ne 0 ]; then - echo - exit 1 - fi - daemon $daemonopts $wrapper $wrapperopts -- $agent $args - RETVAL=$? - echo - return $RETVAL -} - -stop() { - echo -n $"Stopping {{.BeatName}}: " - killproc $pidopts $wrapper - RETVAL=$? - echo - [ $RETVAL = 0 ] && rm -f ${pidfile} -} - -restart() { - if [ $? -ne 0 ]; then - return 1 - fi - stop - start -} - -rh_status() { - status $pidopts $wrapper - RETVAL=$? - return $RETVAL -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - restart - ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart - ;; - status) - rh_status - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|condrestart}" - exit 1 -esac - -exit $RETVAL diff --git a/dev-tools/packaging/templates/rpm/init.sh.tmpl b/dev-tools/packaging/templates/rpm/init.sh.tmpl deleted file mode 100644 index 8e4c9731e9c9..000000000000 --- a/dev-tools/packaging/templates/rpm/init.sh.tmpl +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/bash -# -# {{.ServiceName}} {{.BeatName}} shipper -# -# chkconfig: 2345 98 02 -# description: Starts and stops a single {{.BeatName}} instance on this system -# - -### BEGIN INIT INFO -# Provides: {{.ServiceName}} -# Required-Start: $local_fs $network $syslog -# Required-Stop: $local_fs $network $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: {{.Description}} -# Description: {{.BeatName | title}} is a shipper part of the Elastic Beats -# family. Please see: https://www.elastic.co/beats -### END INIT INFO - -# Exit with an informative message if functions does not exist. -# This has been removed from RHEL9, but exists on other RPM-based -# distributions in the support matrix. -if [ ! -f /etc/rc.d/init.d/functions ]; then - echo "SysV-style init script service management is not supported on this system, use systemctl instead" - exit 1 -fi - - -PATH=/usr/bin:/sbin:/bin:/usr/sbin -export PATH - -[ -f /etc/sysconfig/{{.ServiceName}} ] && . /etc/sysconfig/{{.ServiceName}} -pidfile=${PIDFILE-/var/run/{{.ServiceName}}.pid} -agent=${BEATS_AGENT-/usr/share/{{.BeatName}}/bin/{{.BeatName}}} -args="-c /etc/{{.BeatName}}/{{.BeatName}}.yml --path.home /usr/share/{{.BeatName}} --path.config /etc/{{.BeatName}} --path.data /var/lib/{{.BeatName}} --path.logs /var/log/{{.BeatName}}" -test_args="-e test config" -beat_user="${BEAT_USER:-{{.BeatUser}}}" -wrapper="/usr/share/{{.BeatName}}/bin/{{.BeatName}}-god" -wrapperopts="-r / -n -p $pidfile" -user_wrapper="su" -user_wrapperopts="$beat_user -c" -RETVAL=0 -DEFAULT_GODEBUG="madvdontneed=1" -export GODEBUG=${GODEBUG-$DEFAULT_GODEBUG} - -# Source function library. -. /etc/rc.d/init.d/functions - -# Determine if we can use the -p option to daemon, killproc, and status. -# RHEL < 5 can't. -if status | grep -q -- '-p' 2>/dev/null; then - daemonopts="--pidfile $pidfile" - pidopts="-p $pidfile" -fi - -if command -v runuser >/dev/null 2>&1; then - user_wrapper="runuser" -fi - -[ "$beat_user" != "root" ] && wrapperopts="$wrapperopts -u $beat_user" - -test() { - $user_wrapper $user_wrapperopts "$agent $args $test_args" -} - -start() { - echo -n $"Starting {{.BeatName}}: " - test - if [ $? -ne 0 ]; then - echo - exit 1 - fi - daemon $daemonopts $wrapper $wrapperopts -- $agent $args - RETVAL=$? - echo - return $RETVAL -} - -stop() { - echo -n $"Stopping {{.BeatName}}: " - killproc $pidopts $wrapper - RETVAL=$? - echo - [ $RETVAL = 0 ] && rm -f ${pidfile} -} - -restart() { - test - if [ $? -ne 0 ]; then - return 1 - fi - stop - start -} - -rh_status() { - status $pidopts $wrapper - RETVAL=$? - return $RETVAL -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - restart - ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart - ;; - status) - rh_status - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|condrestart}" - exit 1 -esac - -exit $RETVAL diff --git a/filebeat/magefile.go b/filebeat/magefile.go index a8defd10562c..f11c70d5ebb5 100644 --- a/filebeat/magefile.go +++ b/filebeat/magefile.go @@ -65,21 +65,11 @@ func GolangCrossBuild() error { return filebeat.GolangCrossBuild() } -// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). -func BuildGoDaemon() error { - return devtools.BuildGoDaemon() -} - // CrossBuild cross-builds the beat for all target platforms. func CrossBuild() error { return filebeat.CrossBuild() } -// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. -func CrossBuildGoDaemon() error { - return devtools.CrossBuildGoDaemon() -} - // AssembleDarwinUniversal merges the darwin/amd64 and darwin/arm64 into a single // universal binary using `lipo`. It assumes the darwin/amd64 and darwin/arm64 // were built and only performs the merge. @@ -100,7 +90,7 @@ func Package() { filebeat.CustomizePackaging() mg.Deps(Update) - mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.Deps(CrossBuild) mg.SerialDeps(devtools.Package, TestPackages) } diff --git a/go.mod b/go.mod index f295ab111110..30e164dbb301 100644 --- a/go.mod +++ b/go.mod @@ -119,7 +119,6 @@ require ( github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 - github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b github.com/ugorji/go/codec v1.1.8 github.com/vmware/govmomi v0.39.0 go.elastic.co/ecszap v1.0.2 diff --git a/go.sum b/go.sum index 6bab262fcf18..f9614f640f35 100644 --- a/go.sum +++ b/go.sum @@ -915,8 +915,6 @@ github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+F github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tommyers-elastic/dashboard-api-go/v3 v3.0.0-20240913150833-a945473a8f25 h1:o24r+NDexzdlwgqI0Dglq2I/cdONYRACikcUmYmovtQ= github.com/tommyers-elastic/dashboard-api-go/v3 v3.0.0-20240913150833-a945473a8f25/go.mod h1:COGDRzuD05ZS/zp0lDCTDFhx6kAuuNdhDjY0y2ifi5o= -github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b h1:X/8hkb4rQq3+QuOxpJK7gWmAXmZucF0EI1s1BfBLq6U= -github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b/go.mod h1:jAqhj/JBVC1PwcLTWd6rjQyGyItxxrhpiBl8LSuAGmw= github.com/ugorji/go v1.1.8/go.mod h1:0lNM99SwWUIRhCXnigEMClngXBk/EmpTXa7mgiewYWA= github.com/ugorji/go/codec v1.1.8 h1:4dryPvxMP9OtkjIbuNeK2nb27M38XMHLGlfNSNph/5s= github.com/ugorji/go/codec v1.1.8/go.mod h1:X00B19HDtwvKbQY2DcYjvZxKQp8mzrJoQ6EgoIY/D2E= diff --git a/heartbeat/magefile.go b/heartbeat/magefile.go index 650cd421a212..894c31480c6c 100644 --- a/heartbeat/magefile.go +++ b/heartbeat/magefile.go @@ -60,7 +60,7 @@ func Package() { heartbeat.CustomizePackaging() mg.Deps(Update) - mg.Deps(build.CrossBuild, build.CrossBuildGoDaemon) + mg.Deps(build.CrossBuild) mg.SerialDeps(devtools.Package, TestPackages) } diff --git a/libbeat/docs/tab-widgets/start-filebeat.asciidoc b/libbeat/docs/tab-widgets/start-filebeat.asciidoc index bbaf47d3faf1..285b2cff35ca 100644 --- a/libbeat/docs/tab-widgets/start-filebeat.asciidoc +++ b/libbeat/docs/tab-widgets/start-filebeat.asciidoc @@ -7,13 +7,6 @@ sudo service {beatname_pkg} start ---- -// tag::initd-note[] -NOTE: If you use an `init.d` script to start {beatname_uc}, you can't specify command -line flags (see {beatname_url}/command-line-options.html[Command reference]). To specify flags, start {beatname_uc} in -the foreground. - -// end::initd-note[] - Also see {beatname_url}/running-with-systemd.html[{beatname_uc} and systemd]. // end::deb[] @@ -23,8 +16,6 @@ Also see {beatname_url}/running-with-systemd.html[{beatname_uc} and systemd]. sudo service {beatname_pkg} start ---- -include::start.asciidoc[tag=initd-note] - Also see {beatname_url}/running-with-systemd.html[{beatname_uc} and systemd]. // end::rpm[] diff --git a/libbeat/docs/tab-widgets/start.asciidoc b/libbeat/docs/tab-widgets/start.asciidoc index 6ca8e35521f3..1c551fcf6946 100644 --- a/libbeat/docs/tab-widgets/start.asciidoc +++ b/libbeat/docs/tab-widgets/start.asciidoc @@ -7,13 +7,6 @@ sudo service {beatname_pkg} start ---------------------------------------------------------------------- -// tag::initd-note[] -NOTE: If you use an `init.d` script to start {beatname_uc}, you can't specify command -line flags (see {beatname_url}/command-line-options.html[Command reference]). To specify flags, start {beatname_uc} in -the foreground. - -// end::initd-note[] - Also see {beatname_url}/running-with-systemd.html[{beatname_uc} and systemd]. // end::deb[] @@ -23,8 +16,6 @@ Also see {beatname_url}/running-with-systemd.html[{beatname_uc} and systemd]. sudo service {beatname_pkg} start ---------------------------------------------------------------------- -include::start.asciidoc[tag=initd-note] - Also see {beatname_url}/running-with-systemd.html[{beatname_uc} and systemd]. // end::rpm[] diff --git a/metricbeat/magefile.go b/metricbeat/magefile.go index 7bf9f7de48b0..3ab1d05bb634 100644 --- a/metricbeat/magefile.go +++ b/metricbeat/magefile.go @@ -86,7 +86,7 @@ func Package() { devtools.PackageKibanaDashboardsFromBuildDir() mg.Deps(Update) - mg.Deps(build.CrossBuild, build.CrossBuildGoDaemon) + mg.Deps(build.CrossBuild) mg.SerialDeps(devtools.Package, TestPackages) } diff --git a/packetbeat/magefile.go b/packetbeat/magefile.go index 1676118f7063..cfdf06fc79b1 100644 --- a/packetbeat/magefile.go +++ b/packetbeat/magefile.go @@ -58,21 +58,11 @@ func GolangCrossBuild() error { return packetbeat.GolangCrossBuild() } -// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). -func BuildGoDaemon() error { - return devtools.BuildGoDaemon() -} - // CrossBuild cross-builds the beat for all target platforms. func CrossBuild() error { return packetbeat.CrossBuild() } -// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. -func CrossBuildGoDaemon() error { - return devtools.CrossBuildGoDaemon() -} - // AssembleDarwinUniversal merges the darwin/amd64 and darwin/arm64 into a single // universal binary using `lipo`. It assumes the darwin/amd64 and darwin/arm64 // were built and only performs the merge. @@ -93,7 +83,7 @@ func Package() { packetbeat.CustomizePackaging() mg.Deps(Update) - mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.Deps(CrossBuild) mg.SerialDeps(devtools.Package, TestPackages) } diff --git a/tools/tools.go b/tools/tools.go index fe36ef49adea..be352b8fdc3c 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -26,7 +26,6 @@ import ( _ "github.com/magefile/mage" _ "github.com/pierrre/gotestcover" _ "github.com/stretchr/testify/assert" - _ "github.com/tsg/go-daemon" _ "golang.org/x/tools/cmd/goimports" _ "golang.org/x/tools/cmd/stringer" _ "gotest.tools/gotestsum/cmd" diff --git a/winlogbeat/scripts/mage/package.go b/winlogbeat/scripts/mage/package.go index 20cde9f551b7..5f79aa8d08b3 100644 --- a/winlogbeat/scripts/mage/package.go +++ b/winlogbeat/scripts/mage/package.go @@ -19,6 +19,7 @@ package mage import ( "fmt" + "log" "os" "time" @@ -45,7 +46,7 @@ func init() { // Use VERSION_QUALIFIER to control the version qualifier. func Package() { start := time.Now() - defer func() { fmt.Println("package ran for", time.Since(start)) }() + defer func() { log.Println("package ran for", time.Since(start)) }() switch SelectLogic { case devtools.OSSProject: @@ -57,7 +58,7 @@ func Package() { devtools.PackageKibanaDashboardsFromBuildDir() mg.Deps(Update.All) - mg.Deps(build.CrossBuild, build.CrossBuildGoDaemon) + mg.Deps(build.CrossBuild) mg.SerialDeps(devtools.Package, pkg.PackageTest) } diff --git a/x-pack/agentbeat/magefile.go b/x-pack/agentbeat/magefile.go index 888ebb8bb582..982f774e6452 100644 --- a/x-pack/agentbeat/magefile.go +++ b/x-pack/agentbeat/magefile.go @@ -91,16 +91,6 @@ func CrossBuild() error { ) } -// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). -func BuildGoDaemon() error { - return devtools.BuildGoDaemon() -} - -// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. -func CrossBuildGoDaemon() error { - return devtools.CrossBuildGoDaemon() -} - // AssembleDarwinUniversal merges the darwin/amd64 and darwin/arm64 into a single // universal binary using `lipo`. It assumes the darwin/amd64 and darwin/arm64 // were built and only performs the merge. diff --git a/x-pack/auditbeat/magefile.go b/x-pack/auditbeat/magefile.go index 45b340954815..f58ca1d9a4d5 100644 --- a/x-pack/auditbeat/magefile.go +++ b/x-pack/auditbeat/magefile.go @@ -58,16 +58,6 @@ func CrossBuild() error { return devtools.CrossBuild() } -// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). -func BuildGoDaemon() error { - return devtools.BuildGoDaemon() -} - -// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. -func CrossBuildGoDaemon() error { - return devtools.CrossBuildGoDaemon() -} - // AssembleDarwinUniversal merges the darwin/amd64 and darwin/arm64 into a single // universal binary using `lipo`. It assumes the darwin/amd64 and darwin/arm64 // were built and only performs the merge. @@ -97,7 +87,7 @@ func Package() { auditbeat.CustomizePackaging(auditbeat.XPackPackaging) mg.SerialDeps(Update) - mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.Deps(CrossBuild) mg.SerialDeps(devtools.Package, TestPackages) } diff --git a/x-pack/filebeat/magefile.go b/x-pack/filebeat/magefile.go index aaf1326de35a..b0bb464c4fc5 100644 --- a/x-pack/filebeat/magefile.go +++ b/x-pack/filebeat/magefile.go @@ -59,16 +59,6 @@ func CrossBuild() error { return filebeat.CrossBuild() } -// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). -func BuildGoDaemon() error { - return devtools.BuildGoDaemon() -} - -// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. -func CrossBuildGoDaemon() error { - return devtools.CrossBuildGoDaemon() -} - // AssembleDarwinUniversal merges the darwin/amd64 and darwin/arm64 into a single // universal binary using `lipo`. It assumes the darwin/amd64 and darwin/arm64 // were built and only performs the merge. @@ -94,7 +84,7 @@ func Package() { filebeat.CustomizePackaging() mg.Deps(Update) - mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.Deps(CrossBuild) mg.SerialDeps(devtools.Package, TestPackages) } diff --git a/x-pack/heartbeat/magefile.go b/x-pack/heartbeat/magefile.go index c10004340319..4573ff75a2ef 100644 --- a/x-pack/heartbeat/magefile.go +++ b/x-pack/heartbeat/magefile.go @@ -56,7 +56,7 @@ func Package() { heartbeat.CustomizePackaging() mg.Deps(Update) - mg.Deps(build.CrossBuild, build.CrossBuildGoDaemon) + mg.Deps(build.CrossBuild) mg.SerialDeps(devtools.Package, TestPackages) } diff --git a/x-pack/metricbeat/magefile.go b/x-pack/metricbeat/magefile.go index 1de1a064d1f3..fe3becc21de5 100644 --- a/x-pack/metricbeat/magefile.go +++ b/x-pack/metricbeat/magefile.go @@ -71,16 +71,6 @@ func CrossBuild() error { return devtools.CrossBuild() } -// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). -func BuildGoDaemon() error { - return devtools.BuildGoDaemon() -} - -// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. -func CrossBuildGoDaemon() error { - return devtools.CrossBuildGoDaemon() -} - // UnitTest executes the unit tests (Go and Python). func UnitTest() { mg.SerialDeps(GoUnitTest, PythonUnitTest) @@ -164,7 +154,7 @@ func Package() { devtools.PackageKibanaDashboardsFromBuildDir() mg.Deps(Update, metricbeat.PrepareModulePackagingXPack) - mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.Deps(CrossBuild) mg.SerialDeps(devtools.Package, TestPackages) } diff --git a/x-pack/osquerybeat/magefile.go b/x-pack/osquerybeat/magefile.go index ef846eccbb0b..dae39ed840da 100644 --- a/x-pack/osquerybeat/magefile.go +++ b/x-pack/osquerybeat/magefile.go @@ -186,11 +186,6 @@ func GolangCrossBuild() error { return devtools.GolangCrossBuild(devtools.DefaultGolangCrossBuildArgs()) } -// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). -func BuildGoDaemon() error { - return devtools.BuildGoDaemon() -} - // CrossBuild cross-builds the beat for all target platforms. func CrossBuild() error { // Building osquerybeat @@ -206,11 +201,6 @@ func CrossBuildExt() error { return devtools.CrossBuild(devtools.InDir("x-pack", "osquerybeat", "ext", "osquery-extension")) } -// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. -func CrossBuildGoDaemon() error { - return devtools.CrossBuildGoDaemon() -} - // AssembleDarwinUniversal merges the darwin/amd64 and darwin/arm64 into a single // universal binary using `lipo`. It assumes the darwin/amd64 and darwin/arm64 // were built and only performs the merge. @@ -232,7 +222,7 @@ func Package() { osquerybeat.CustomizePackaging() mg.Deps(Update, osquerybeat.FetchOsqueryDistros) - mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.Deps(CrossBuild) mg.SerialDeps(devtools.Package, TestPackages) } diff --git a/x-pack/packetbeat/magefile.go b/x-pack/packetbeat/magefile.go index 220c430e5d84..b3a08effafe3 100644 --- a/x-pack/packetbeat/magefile.go +++ b/x-pack/packetbeat/magefile.go @@ -83,16 +83,6 @@ func CrossBuild() error { ) } -// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). -func BuildGoDaemon() error { - return devtools.BuildGoDaemon() -} - -// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. -func CrossBuildGoDaemon() error { - return devtools.CrossBuildGoDaemon() -} - // AssembleDarwinUniversal merges the darwin/amd64 and darwin/arm64 into a single // universal binary using `lipo`. It assumes the darwin/amd64 and darwin/arm64 // were built and only performs the merge. @@ -118,7 +108,7 @@ func Package() { packetbeat.CustomizePackaging() mg.Deps(Update) - mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.Deps(CrossBuild) mg.SerialDeps(devtools.Package, TestPackages) }