From a86673e1b089274f64b0acaab9f40839cf267a37 Mon Sep 17 00:00:00 2001 From: kruskall <99559985+kruskall@users.noreply.github.com> Date: Mon, 2 Dec 2024 06:26:57 +0100 Subject: [PATCH] feat: drop init.d support and go-daemon binaries remove init.d scripts drop go-daemon dep and daemon binaries cleanup mage tasks --- NOTICE.txt | 37 ---- dev-tools/mage/godaemon.go | 76 ------- dev-tools/packaging/packages.yml | 12 -- .../templates/deb/elastic-agent.init.sh.tmpl | 165 --------------- .../packaging/templates/deb/init.sh.tmpl | 192 ------------------ .../templates/rpm/elastic-agent.init.sh.tmpl | 114 ----------- .../packaging/templates/rpm/init.sh.tmpl | 121 ----------- go.mod | 1 - go.sum | 2 - magefile.go | 15 +- tools/tools.go | 1 - 11 files changed, 2 insertions(+), 734 deletions(-) delete mode 100644 dev-tools/mage/godaemon.go delete mode 100644 dev-tools/packaging/templates/deb/elastic-agent.init.sh.tmpl delete mode 100644 dev-tools/packaging/templates/deb/init.sh.tmpl delete mode 100644 dev-tools/packaging/templates/rpm/elastic-agent.init.sh.tmpl delete mode 100644 dev-tools/packaging/templates/rpm/init.sh.tmpl diff --git a/NOTICE.txt b/NOTICE.txt index adeff285c27..151c187f794 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -9849,43 +9849,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------- -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/winlabs/gowin32 Version: v0.0.0-20240930213947-f504d7e14639 diff --git a/dev-tools/mage/godaemon.go b/dev-tools/mage/godaemon.go deleted file mode 100644 index 121dca8b863..00000000000 --- a/dev-tools/mage/godaemon.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License 2.0; -// you may not use this file except in compliance with the Elastic License 2.0. - -package mage - -import ( - "errors" - "fmt" - "log" - "os" - "path/filepath" - - "github.com/elastic/elastic-agent/dev-tools/mage/gotool" -) - -var ( - defaultCrossBuildGoDaemon = []CrossBuildOption{ - ForPlatforms("linux"), - WithTarget("buildGoDaemon"), - } -) - -// BuildGoDaemon builds the go-daemon 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") - case "linux/386": - compileCmd = append(compileCmd, "-m32") - } - - defer DockerChown(output) - return RunCmds(compileCmd) -} - -// CrossBuildGoDaemon cross-build the go-daemon binary using the -// golang-crossbuild environment. -func CrossBuildGoDaemon(options ...CrossBuildOption) error { - fmt.Println("--- CrossBuildGoDaemon Elastic-Agent") - opts := append(defaultCrossBuildGoDaemon, options...) - return CrossBuild(opts...) -} diff --git a/dev-tools/packaging/packages.yml b/dev-tools/packaging/packages.yml index ec7008748a9..db5c3bc97ae 100644 --- a/dev-tools/packaging/packages.yml +++ b/dev-tools/packaging/packages.yml @@ -52,18 +52,12 @@ shared: content: > {{ commit }} 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/elastic-agent.sh.tmpl' mode: 0755 /lib/systemd/system/{{.BeatServiceName}}.service: template: '{{ elastic_beats_dir }}/dev-tools/packaging/templates/linux/elastic-agent.unit.tmpl' mode: 0644 - /etc/init.d/{{.BeatServiceName}}: - template: '{{ elastic_beats_dir }}/dev-tools/packaging/templates/{{.PackageType}}/elastic-agent.init.sh.tmpl' - mode: 0755 /var/lib/{{.BeatName}}/data/{{.BeatName}}-{{agent_package_version}}{{snapshot_suffix}}-{{ commit_short }}/{{.BeatName}}{{.BinaryExt}}: source: build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} mode: 0755 @@ -348,18 +342,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 812bc978199..00000000000 --- 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 b30e29d40a1..00000000000 --- 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 573f0c9496b..00000000000 --- a/dev-tools/packaging/templates/rpm/elastic-agent.init.sh.tmpl +++ /dev/null @@ -1,114 +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 - - - -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 1bd3a846705..00000000000 --- a/dev-tools/packaging/templates/rpm/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 - - - -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/go.mod b/go.mod index 889603b2f53..055719f4211 100644 --- a/go.mod +++ b/go.mod @@ -56,7 +56,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/winlabs/gowin32 v0.0.0-20240930213947-f504d7e14639 go.elastic.co/apm/module/apmgorilla/v2 v2.6.0 go.elastic.co/apm/module/apmgrpc/v2 v2.6.0 diff --git a/go.sum b/go.sum index 687b131c9ec..02c70f79bfa 100644 --- a/go.sum +++ b/go.sum @@ -1400,8 +1400,6 @@ github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFA github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= -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/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ua-parser/uap-go v0.0.0-20240611065828-3a4781585db6 h1:SIKIoA4e/5Y9ZOl0DCe3eVMLPOQzJxgZpfdHHeauNTM= github.com/ua-parser/uap-go v0.0.0-20240611065828-3a4781585db6/go.mod h1:BUbeWZiieNxAuuADTBNb3/aeje6on3DhU3rpWsQSB1E= diff --git a/magefile.go b/magefile.go index 7512386fb0e..e5b5d6ed07d 100644 --- a/magefile.go +++ b/magefile.go @@ -314,11 +314,6 @@ func GolangCrossBuild() error { return nil } -// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). -func BuildGoDaemon() error { - return devtools.BuildGoDaemon() -} - // BinaryOSS build the fleet artifact. func (Build) BinaryOSS() error { mg.Deps(Prepare.Env) @@ -665,19 +660,13 @@ func CrossBuild() error { return devtools.CrossBuild() } -// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. -func CrossBuildGoDaemon() error { - mg.Deps(EnsureCrossBuildOutputDir) - return devtools.CrossBuildGoDaemon() -} - // PackageAgentCore cross-builds and packages distribution artifacts containing // only elastic-agent binaries with no extra files or dependencies. func PackageAgentCore() { start := time.Now() defer func() { fmt.Println("packageAgentCore ran for", time.Since(start)) }() - mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.Deps(CrossBuild) devtools.UseElasticAgentCorePackaging() @@ -1001,7 +990,7 @@ func packageAgent(ctx context.Context, platforms []string, dependenciesVersion s log.Println("--- Running post packaging ") mg.Deps(Update) - mg.Deps(agentBinaryTarget, CrossBuildGoDaemon) + mg.Deps(agentBinaryTarget) mg.SerialDeps(devtools.Package, TestPackages) return nil } diff --git a/tools/tools.go b/tools/tools.go index b934a302576..93af8555932 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -11,7 +11,6 @@ package tools import ( _ "github.com/magefile/mage" - _ "github.com/tsg/go-daemon" _ "golang.org/x/tools/cmd/goimports" _ "golang.org/x/tools/cmd/stringer" _ "gotest.tools/gotestsum/cmd"