Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds go-bob-firewall #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions recipes-core/go-bob-firewall/files/go-bob-firewall-init
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: go-bob-firewall
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start Bob Firewall at boot time
# Description: Enable Bob Firewall service.
### END INIT INFO

DAEMON=/usr/bin/go-bob-firewall
NAME=go-bob-firewall
DESC="Bob Firewall"
PIDFILE=/var/run/$NAME.pid
LOGFILE=/var/log/$NAME.log

start() {
echo -n "Starting $DESC: "
echo "Starting $DESC" > /var/volatile/system-api.fifo
start-stop-daemon -S --make-pidfile -p $PIDFILE -m -b -a $DAEMON -- $DAEMON_ARGS > $LOGFILE 2>&1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the logging here will be suppressed because it is running in the background.
We had this issue with other services and this was the fix

Suggested change
start-stop-daemon -S --make-pidfile -p $PIDFILE -m -b -a $DAEMON -- $DAEMON_ARGS > $LOGFILE 2>&1
start-stop-daemon -S --make-pidfile -p $PIDFILE -m -b --exec /bin/sh -- -c "exec $DAEMON >> $LOGFILE 2>&1"

echo "$NAME."
}

stop() {
echo -n "Stopping $DESC: "
echo "Stopping $DESC" > /var/volatile/system-api.fifo
start-stop-daemon --stop --quiet --pidfile $PIDFILE
rm -f $PIDFILE
echo "$NAME."
}

restart() {
echo "Restarting $DESC: "
echo "Restarting $DESC" > /var/volatile/system-api.fifo
stop
sleep 1
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload)
restart
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
exit 1
;;
esac

exit 0
33 changes: 33 additions & 0 deletions recipes-core/go-bob-firewall/go-bob-firewall_dev.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
SUMMARY = "Bob Firewall Implementation in Go"
HOMEPAGE = "https://github.com/flashbots/go-bob-firewall"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://src/${GO_WORKDIR}/LICENSE;md5=c7bc88e866836b5160340e6c3b1aaa10"

inherit go-mod update-rc.d

INITSCRIPT_NAME = "go-bob-firewall-init"
INITSCRIPT_PARAMS = "defaults 86"

GO_IMPORT = "github.com/flashbots/go-bob-firewall"
SRC_URI = "git://${GO_IMPORT};protocol=https;branch=main \
file://go-bob-firewall-init"
SRCREV = "${AUTOREV}"

GO_INSTALL = "${GO_IMPORT}/cmd/httpserver"
GO_LINKSHARED = ""

INHIBIT_PACKAGE_DEBUG_SPLIT = '1'
INHIBIT_PACKAGE_STRIP = '1'
GO_EXTRA_LDFLAGS:append = " -s -w -buildid= -X ${GO_IMPORT}/common.Version=${PV}"

do_compile[network] = "1"

do_install:append() {
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/${INITSCRIPT_NAME} ${D}${sysconfdir}/init.d/${INITSCRIPT_NAME}

# Rename the binary
mv ${D}${bindir}/httpserver ${D}${bindir}/go-bob-firewall
}

FILES:${PN} = "${sysconfdir}/init.d/${INITSCRIPT_NAME} ${bindir}/go-bob-firewall"