Skip to content

Commit

Permalink
Init scripts and cmdline options.
Browse files Browse the repository at this point in the history
  • Loading branch information
mnellemann committed Oct 10, 2024
1 parent 2c5f652 commit db5ef98
Show file tree
Hide file tree
Showing 20 changed files with 358 additions and 53 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Syslog Director
# Syslog Director

All received messages are written to *stdout* and/or forwarded to one or more remote logging destinations.

Expand Down Expand Up @@ -84,6 +84,12 @@ Forwarding to a Grafana Loki server.
/opt/syslogd/bin/syslogd --to-loki http://remotehost:3100
```

Receive log messages in sent with the GELF protocol:

```shell
/opt/syslogd/bin/syslogd --port 12201 --format GELF
```

Started from a tmux session, listening for syslog messages and forwarding to a remote Graylog server:

```shell
Expand Down
62 changes: 36 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.redline_rpm.header.Os

plugins {
id 'java'
id 'groovy'
Expand All @@ -21,7 +23,6 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.4'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.4'
implementation 'org.apache.commons:commons-collections4:4.4'

testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
}

Expand Down Expand Up @@ -61,17 +62,38 @@ jacocoTestCoverageVerification {
}
limit {
counter = 'BRANCH'
minimum = 0.3
minimum = 0.1
}
limit {
counter = 'CLASS'
minimum = 0.4
minimum = 0.3
}
}
}
}
check.dependsOn jacocoTestCoverageVerification

jar {
manifest {
attributes(
'Created-By' : "Gradle ${gradle.gradleVersion}",
'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}",
'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Build-User' : System.properties['user.name'],
'Build-Version' : gitVersion(),
'Build-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ss.SSSZ").toString(),
)
}
}

tasks.register("packages") {
group "build"
dependsOn ":build"
dependsOn ":buildDeb"
dependsOn ":buildRpm"
}


ospackage {
packageName = 'syslogd'
release = '1'
Expand All @@ -98,31 +120,19 @@ ospackage {

}

buildRpm {
dependsOn startShadowScripts
os = "LINUX"
}

buildDeb {
dependsOn startShadowScripts
installUtils file('scripts/utils.sh') as File
installUtils file('scripts/config.sh') as File
preUninstall file('scripts/deb-pre-rm.sh') as File
postInstall file('scripts/deb-post-inst.sh') as File
}

jar {
manifest {
attributes(
'Created-By' : "Gradle ${gradle.gradleVersion}",
'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}",
'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Build-User' : System.properties['user.name'],
'Build-Version' : gitVersion(),
'Build-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ss.SSSZ").toString(),
)
}
}

tasks.register("packages") {
group "build"
dependsOn ":build"
dependsOn ":buildDeb"
dependsOn ":buildRpm"
buildRpm {
dependsOn startShadowScripts
installUtils file('scripts/utils.sh') as File
installUtils file('scripts/config.sh') as File
preUninstall file('scripts/rpm-pre-rm.sh') as File
postTrans file('scripts/rpm-post-inst.sh') as File
os Os.LINUX
}
4 changes: 3 additions & 1 deletion doc/syslogd.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Description=Syslog Director
[Service]
TimeoutStartSec=0
Restart=always
ExecStart=/opt/syslogd/bin/syslogd --port 514 --no-ansi
ExecStart=/opt/syslogd/bin/syslogd --port 514 --format RFC-3164 --no-ansi
#ExecStart=/opt/syslogd/bin/syslogd --port 514 --format RFC-5424 --no-ansi
#ExecStart=/opt/syslogd/bin/syslogd --port 12201 --format GELF --no-ansi

[Install]
WantedBy=default.target
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id = syslogd
name = syslogd
group = biz.nellemann.syslogd
version = 1.3.6
version = 1.4.1
description = "Syslog Director"
6 changes: 6 additions & 0 deletions scripts/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

service_name="syslogd"
sysv_source="/opt/syslogd/doc/syslogd.sh"
#config_source="/opt/syslogd/doc/syslogd.toml"
systemd_source="/opt/syslogd/doc/syslogd.service"
19 changes: 19 additions & 0 deletions scripts/deb-post-inst.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
# shellcheck disable=SC2154
# Debian post install script
# See https://wiki.debian.org/MaintainerScripts
# $1 == "configure"
# $1 == "upgrade"

#echo "Running Debian Post Install Script with: $@"

# Configure package
if [ "$1" = "configure" ] ; then
test -n "$config_source" && install_config "$service_name" "$config_source"
install_service "$service_name" "$sysv_source" "$systemd_source"
fi

# Upgrade package
if [ "$1" = "upgrade" ] ; then
refresh_servie "$service_name"
fi
23 changes: 23 additions & 0 deletions scripts/deb-pre-rm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh
# shellcheck disable=SC2154
# Debian pre removal script
# See https://wiki.debian.org/MaintainerScripts
# $1 == "upgrade"
# $1 == "remove"
# $1 == "purge"

#echo "Running Debian Pre Removal Script with: $@"

# shellcheck disable=SC3037
if [ "$1" = "upgrade" ] ; then
# We don't do anything
echo -n ""
fi

if [ "$1" = "remove" ] ; then
remove_service "$service_name"
fi

if [ "$1" = "purge" ] ; then
test -n "$config_source" && remove_config "$service_name"
fi
17 changes: 17 additions & 0 deletions scripts/rpm-post-inst.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
# shellcheck disable=SC2154
# RedHat postTrans script
# $1 == 1 for install
# $1 == 2 for upgrade

#echo "Running RedHat Post Transaction Script with: $@"

# Install
if [ "$1" = "1" ] ; then
test -n "$config_source" && install_config "$service_name" "$config_source"
install_service "$service_name" "$sysv_source" "$systemd_source"
fi

refresh_service "$service_name"

exit 0
15 changes: 15 additions & 0 deletions scripts/rpm-pre-rm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
# shellcheck disable=SC2154
# RedHat pre Uninstall script
# $1 == 1 for upgrade
# $1 == 0 for uninstall

#echo "Running RedHat Pre Un-Install Script with: $@"

# Uninstall
if [ "$1" = "0" ] ; then
test -n "$config_source" && remove_config "$service_name"
remove_service "$service_name"
fi

exit 0
Loading

0 comments on commit db5ef98

Please sign in to comment.