Skip to content

Commit

Permalink
Merge pull request #33 from thin-edge/feat-update-tedge-log-plugin
Browse files Browse the repository at this point in the history
update to use new tedge-log-plugin binary
  • Loading branch information
reubenmiller authored Oct 11, 2023
2 parents 824d82d + 52b9346 commit 3c3cf74
Show file tree
Hide file tree
Showing 25 changed files with 56 additions and 56 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ The service definitions are also available via a tarball which can be manually i
tedgectl enable c8y-configuration-plugin
tedgectl start c8y-configuration-plugin
tedgectl enable c8y-log-plugin
tedgectl start c8y-log-plugin
tedgectl enable tedge-log-plugin
tedgectl start tedge-log-plugin
tedgectl enable c8y-firmware-plugin
tedgectl start c8y-firmware-plugin
Expand Down
2 changes: 1 addition & 1 deletion images/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ start_enable tedge-agent
#start_enable tedge-mapper-c8y "tedge-mapper c8y"
#start_enable c8y-configuration-plugin
#start_enable c8y-firmware-plugin
#start_enable c8y-log-plugin
#start_enable tedge-log-plugin

echo ""
echo "Tests passed"
6 changes: 3 additions & 3 deletions packages/_scripts/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ if command -V c8y-configuration-plugin >/dev/null 2>&1; then
tedgectl start c8y-configuration-plugin 2>/dev/null ||:
fi

if command -V c8y-log-plugin >/dev/null 2>&1; then
tedgectl enable c8y-log-plugin ||:
tedgectl start c8y-log-plugin 2>/dev/null ||:
if command -V tedge-log-plugin >/dev/null 2>&1; then
tedgectl enable tedge-log-plugin ||:
tedgectl start tedge-log-plugin 2>/dev/null ||:
fi

if command -V c8y-firmware-plugin >/dev/null 2>&1; then
Expand Down
4 changes: 2 additions & 2 deletions packages/_scripts/preremove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ set -e
tedgectl disable tedge-agent 2>/dev/null ||:
tedgectl disable tedge-mapper-c8y 2>/dev/null ||:
tedgectl disable c8y-configuration-plugin 2>/dev/null ||:
tedgectl disable c8y-log-plugin 2>/dev/null ||:
tedgectl disable tedge-log-plugin 2>/dev/null ||:
tedgectl disable c8y-firmware-plugin 2>/dev/null ||:

# stop services (ignore if not found)
tedgectl stop tedge-agent 2>/dev/null ||:
tedgectl stop tedge-mapper-c8y 2>/dev/null ||:
tedgectl stop c8y-configuration-plugin 2>/dev/null ||:
tedgectl stop c8y-log-plugin 2>/dev/null ||:
tedgectl stop tedge-log-plugin 2>/dev/null ||:
tedgectl stop c8y-firmware-plugin 2>/dev/null ||:
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Configuration file for /etc/init.d/c8y-log-plugin
# Configuration file for /etc/init.d/tedge-log-plugin

# Additional arguments to pass to /usr/bin/c8y-log-plugin.
# Additional arguments to pass to /usr/bin/tedge-log-plugin.
#command_args=

# Overwrite user
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/sbin/openrc-run
description="Thin-edge logfile retriever for Cumulocity"
command="/usr/bin/c8y-log-plugin"
description="thin-edge.io log file retriever"
command="/usr/bin/tedge-log-plugin"
: ${command_args=}
: ${command_user=root}
pidfile="/run/lock/${RC_SVCNAME}.lock"
Expand Down
15 changes: 0 additions & 15 deletions services/runit/runsvdir/c8y-log-plugin/run

This file was deleted.

15 changes: 15 additions & 0 deletions services/runit/runsvdir/tedge-log-plugin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh -e
touch "/var/log/tedge-log-plugin.log"
DAEMON_USER="root"
LOG_FILE="/var/log/tedge-log-plugin.log"
PIDFILE="/run/lock/tedge-log-plugin.lock"

mkdir -p /run/lock
chown 1777 /run/lock
touch "$PIDFILE"

if [ -n "$DAEMON_USER" ]; then
chown "$DAEMON_USER" "$PIDFILE"
chown "$DAEMON_USER" "/var/log/tedge-log-plugin.log"
fi
exec chpst -u "$DAEMON_USER" "/usr/bin/tedge-log-plugin" >> "$LOG_FILE" 2>&1

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions services/s6-overlay/s6-rc.d/c8y-log-plugin-log/run

This file was deleted.

1 change: 0 additions & 1 deletion services/s6-overlay/s6-rc.d/c8y-log-plugin/producer-for

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tedge-log-plugin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tedge-log-plugin-pipeline
2 changes: 2 additions & 0 deletions services/s6-overlay/s6-rc.d/tedge-log-plugin-log/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
sed 's/^/\x1b[34mtedge-log-plugin |\x1b[0m /' --unbuffered
1 change: 1 addition & 0 deletions services/s6-overlay/s6-rc.d/tedge-log-plugin/producer-for
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tedge-log-plugin-log
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/command/with-contenv sh
exec 2>&1
exec /usr/bin/c8y-log-plugin
exec /usr/bin/tedge-log-plugin
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[program:c8y-log-plugin]
command=/usr/bin/c8y-log-plugin
[program:tedge-log-plugin]
command=/usr/bin/tedge-log-plugin
user=root
startsecs=5
autostart=true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: c8y-log-plugin
# Provides: tedge-log-plugin
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
Expand All @@ -10,11 +10,11 @@
### END INIT INFO

dir="/var"
DAEMON="/usr/bin/c8y-log-plugin"
DAEMON="/usr/bin/tedge-log-plugin"
DAEMON_USER="root"
DAEMON_ARGS=""

name="c8y-log-plugin"
name="tedge-log-plugin"
PIDFILE=/run/lock/$name.lock
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"
Expand Down Expand Up @@ -61,7 +61,7 @@ is_running() {
# shellcheck disable=SC2009
# Use ps/grep fallback as busybox does not support the "ps -p" option
if command -V pidof >/dev/null 2>&1; then
pidof c8y-log-plugin >/dev/null
pidof tedge-log-plugin >/dev/null
else
PROCESSES=$(ps -x || ps)
[ -f "$PIDFILE" ] && (echo "$PROCESSES" | grep "^[[:blank:]]*$(get_pid)" >/dev/null 2>&1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/sh
#/etc/init.d/c8y-log-plugin: Thin-edge logfile retriever for Cumulocity
#/etc/init.d/tedge-log-plugin: thin-edge.io log file retriever

### BEGIN INIT INFO
# Provides: c8y-log-plugin
# Short-Description: Thin-edge logfile retriever for Cumulocity
# Provides: tedge-log-plugin
# Short-Description: thin-edge.io log file retriever
# Required-Start: $all
# Required-Stop: $all
# Should-Start:
Expand All @@ -19,24 +19,24 @@ set -e

PATH=/bin:/usr/bin:/sbin:/usr/sbin

test -x "/usr/bin/c8y-log-plugin" || exit 0
test -x "/usr/bin/tedge-log-plugin" || exit 0

# For configuration of the init script use the file
# /etc/default/c8y-log-plugin, do not edit this init script.
# /etc/default/tedge-log-plugin, do not edit this init script.

# Set run_service to 1 to start c8y-log-plugin or 0 to disable it.
# Set run_service to 1 to start tedge-log-plugin or 0 to disable it.
run_service=1

DAEMON_ARGS=""
DAEMON_USER="root"
LOG_FILE=/var/log/c8y-log-plugin.log
LOG_FILE=/var/log/tedge-log-plugin.log

export TEDGE_RUN_LOCK_FILES="false"

[ -e "/etc/default/c8y-log-plugin" ] && . "/etc/default/c8y-log-plugin"
[ -e "/etc/default/tedge-log-plugin" ] && . "/etc/default/tedge-log-plugin"

DAEMON=/usr/bin/c8y-log-plugin
PIDFILE=/run/lock/c8y-log-plugin.lock
DAEMON=/usr/bin/tedge-log-plugin
PIDFILE=/run/lock/tedge-log-plugin.lock

STOP_RETRY_SCHEDULE='TERM/30/KILL/1'

Expand Down Expand Up @@ -75,7 +75,7 @@ fi
do_start() {
if [ $run_service = 1 ]
then
log_begin_msg "Starting c8y-log-plugin daemon..."
log_begin_msg "Starting tedge-log-plugin daemon..."

# Create log file with given user so it can write to it (for non-root users)
touch "$LOG_FILE"
Expand All @@ -92,7 +92,7 @@ do_start() {
do_stop() {
if [ $run_service = 1 ]
then
log_begin_msg "Stopping c8y-log-plugin daemon..."
log_begin_msg "Stopping tedge-log-plugin daemon..."

if start-stop-daemon --stop --quiet --oknodo --retry "$STOP_RETRY_SCHEDULE" --pidfile "${PIDFILE}" --user "${DAEMON_USER}"; then
log_end_msg 0
Expand All @@ -119,7 +119,7 @@ case "$1" in

try-restart|force-reload)
if [ $run_service = 0 ]; then exit 0; fi
log_daemon_msg "Restarting c8y-log-plugin"
log_daemon_msg "Restarting tedge-log-plugin"
# force-reload is the same as reload or try-restart according
# to its definition, the reload is not implemented here, so
# force-reload is the alias of try-restart here, but it should
Expand All @@ -134,7 +134,7 @@ case "$1" in
;;

*)
echo "Usage: /etc/init.d/c8y-log-plugin {start|stop|status|restart|try-restart|force-reload}" >&2
echo "Usage: /etc/init.d/tedge-log-plugin {start|stop|status|restart|try-restart|force-reload}" >&2
exit 1

esac
Expand Down
6 changes: 3 additions & 3 deletions services/template-input/tedge-log-plugin
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME=c8y-log-plugin
COMMAND=/usr/bin/c8y-log-plugin
NAME=tedge-log-plugin
COMMAND=/usr/bin/tedge-log-plugin
#COMMAND_ARGS=
COMMAND_USER=root
DESCRIPTION="Thin-edge logfile retriever for Cumulocity"
DESCRIPTION="thin-edge.io log file retriever"

0 comments on commit 3c3cf74

Please sign in to comment.