summaryrefslogtreecommitdiff
path: root/app-admin/cancd/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /app-admin/cancd/files
reinit the tree, so we can have metadata
Diffstat (limited to 'app-admin/cancd/files')
-rw-r--r--app-admin/cancd/files/cancd-0.1.0-build.patch14
-rw-r--r--app-admin/cancd/files/cancd-0.1.0-c-cleanup.patch65
-rw-r--r--app-admin/cancd/files/cancd-conf.d19
-rw-r--r--app-admin/cancd/files/cancd-init.d22
-rw-r--r--app-admin/cancd/files/netconsole-conf.d27
-rw-r--r--app-admin/cancd/files/netconsole-init.d67
6 files changed, 214 insertions, 0 deletions
diff --git a/app-admin/cancd/files/cancd-0.1.0-build.patch b/app-admin/cancd/files/cancd-0.1.0-build.patch
new file mode 100644
index 000000000000..b1c99b1cd565
--- /dev/null
+++ b/app-admin/cancd/files/cancd-0.1.0-build.patch
@@ -0,0 +1,14 @@
+fix building with newer glibc
+
+http://bugs.gentoo.org/246734
+
+--- cancd.c
++++ cancd.c
+@@ -36,6 +36,7 @@
+ #include <libgen.h>
+ #include <getopt.h>
+ #include <stdarg.h>
++#include <limits.h>
+ #include <sys/socket.h>
+ #include <arpa/inet.h>
+ #include <netinet/in.h>
diff --git a/app-admin/cancd/files/cancd-0.1.0-c-cleanup.patch b/app-admin/cancd/files/cancd-0.1.0-c-cleanup.patch
new file mode 100644
index 000000000000..47defb3e43b2
--- /dev/null
+++ b/app-admin/cancd/files/cancd-0.1.0-c-cleanup.patch
@@ -0,0 +1,65 @@
+diff -Nuar --exclude '*~' --exclude '*.orig' --exclude Makefile cancd-0.1.0/cancd.c cancd-0.1.0.new/cancd.c
+--- cancd-0.1.0/cancd.c 2005-08-18 11:47:48.000000000 -0700
++++ cancd-0.1.0.new/cancd.c 2006-03-17 17:09:46.402025517 -0800
+@@ -199,7 +199,7 @@
+ char *path;
+ };
+
+-static int make_tree(const char *path, int mode)
++static int make_tree(const char *path, mode_t mode)
+ {
+ struct stat stat_buf;
+ char *ptr, *tmp;
+@@ -319,7 +319,7 @@
+ static int open_socket()
+ {
+ int rc;
+- struct sockaddr_in servaddr = {0, };
++ struct sockaddr_in servaddr;
+
+ sock_fd = socket(PF_INET, SOCK_DGRAM, 0);
+ if (sock_fd < 0)
+@@ -438,7 +438,7 @@
+ int rc;
+ static int block = 1;
+
+- rc = recvfrom(sock_fd, buf, bufsize, 0,
++ rc = recvfrom(fd, buf, bufsize, 0,
+ (struct sockaddr *)from, fromlen);
+ if (rc < 0)
+ {
+@@ -569,7 +569,7 @@
+
+ static int valid_format()
+ {
+- struct in_addr addr = {0, };
++ struct in_addr addr;
+ char *name;
+ int rc;
+
+@@ -599,9 +599,11 @@
+ exit(rc);
+ }
+
++/*
+ extern char *optarg;
+ extern int optopt;
+ extern int opterr;
++*/
+ static int parse_options(int argc, char *argv[])
+ {
+ int c;
+@@ -641,11 +643,11 @@
+ optarg);
+ print_usage(-EINVAL);
+ }
+- log_prefix = optarg;
++ log_prefix = strdup(optarg);
+ break;
+
+ case 'o':
+- log_format = optarg;
++ log_format = strdup(optarg);
+ if (!log_format || !*log_format || !valid_format())
+ {
+ fprintf(stderr,
diff --git a/app-admin/cancd/files/cancd-conf.d b/app-admin/cancd/files/cancd-conf.d
new file mode 100644
index 000000000000..7b4dd27383c0
--- /dev/null
+++ b/app-admin/cancd/files/cancd-conf.d
@@ -0,0 +1,19 @@
+#!/sbin/openrc-run
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# user to run as, root strongly discouraged
+# user should have /bin/false for a shell
+# but file access into /var
+CHUID='adm:nobody'
+
+# port to listen on
+CANCD_PORT=6667
+
+# directory to output to
+CRASH_DIR=/var/crash
+
+# one file per minute, one dir per host/date
+#CRASH_FORMAT="%Q/%Y-%m-%d/%H:%M.log"
+# one file per day, one dir per host
+CRASH_FORMAT="%Q/%Y-%m-%d.log"
diff --git a/app-admin/cancd/files/cancd-init.d b/app-admin/cancd/files/cancd-init.d
new file mode 100644
index 000000000000..eb0d34e1a2ee
--- /dev/null
+++ b/app-admin/cancd/files/cancd-init.d
@@ -0,0 +1,22 @@
+#!/sbin/openrc-run
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net
+}
+
+start() {
+ mkdir -p ${CRASH_DIR}
+ chown ${CHUID} ${CRASH_DIR}
+ chmod 700 ${CRASH_DIR}
+ ebegin "Starting cancd"
+ start-stop-daemon --start --quiet --user ${CHUID} --exec /usr/sbin/cancd -- -p ${CANCD_PORT} -l "${CRASH_DIR}" -o "${CRASH_FORMAT}"
+ eend ${?}
+}
+
+stop() {
+ ebegin "Stopping cancd"
+ start-stop-daemon --stop --quiet --exec /usr/sbin/cancd
+ eend ${?}
+}
diff --git a/app-admin/cancd/files/netconsole-conf.d b/app-admin/cancd/files/netconsole-conf.d
new file mode 100644
index 000000000000..aad2fc797172
--- /dev/null
+++ b/app-admin/cancd/files/netconsole-conf.d
@@ -0,0 +1,27 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# required!
+TGT_IP=''
+
+DEVICE=eth0
+
+SRC_IP=''
+# will default to first address on $DEVICE
+# must be specified if the device does not have an IP at init time
+SRC_PORT=6665 # default
+
+# note that cancd daemon uses 6667 as default
+# but netconsole.txt says 6666 is the default
+TGT_PORT=6667
+
+# if you want to broadcast, specify 'broadcast' here.
+# it's a security hole on an untrusted network.
+TGT_MAC=''
+
+LOGLEVEL='1'
+# LOGLEVEL are the kernel console logging levels
+# [0..7] = EMERG,ALERT,CRIT,ERR,WARNING,NOTICE,INFO,DEBUG
+# 1 means only kernel panics are reported (default)
+# this affects all console logging
+# see syslog(2) for more info
diff --git a/app-admin/cancd/files/netconsole-init.d b/app-admin/cancd/files/netconsole-init.d
new file mode 100644
index 000000000000..dfb28eb9eac0
--- /dev/null
+++ b/app-admin/cancd/files/netconsole-init.d
@@ -0,0 +1,67 @@
+#!/sbin/openrc-run
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net
+}
+
+start() {
+ checkconfig || return 1
+ if [ -z "${TGT_MAC}" ]; then
+ LC_ALL=C /bin/ping -nq -c 3 "${TGT_IP}" -I "${DEVICE}" 1>/dev/null 2>/dev/null
+ ret=$?
+ # ping worked, try arp
+ if [ $ret -eq 0 ]; then
+ TGT_MAC="$(LC_ALL=C arp -an -i ${DEVICE} ${TGT_IP} |egrep -v 'incomplete|no match' | awk '{print $4}')"
+ fi
+ elif [ "${TGT_MAC}" = "broadcast" ]; then
+ TGT_MAC=''
+ fi
+ ebegin "Starting netconsole ${SRC_IP}:${SRC_PORT}(${DEVICE}) -> ${TGT_IP}:${TGT_PORT} ${TGT_MAC}"
+ # else we use the MAC that we are given
+ modprobe netconsole netconsole=${SRC_PORT}@${SRC_IP}/${DEVICE},${TGT_PORT}@${TGT_IP}/${TGT_MAC}
+ ret=$?
+ [ $ret -eq 0 ] && dmesg -n ${LOGLEVEL}
+ eend $ret
+}
+
+stop() {
+ ebegin "Stopping netconsole"
+ modprobe -r netconsole
+ eend $?
+}
+
+checkconfig() {
+ # kernel uses 15 internally
+ if [ "$LOGLEVEL" -lt 0 -o "${LOGLEVEL}" -gt 15 ]; then
+ eerror "Invalid kernel console loglevel."
+ return 1
+ fi
+
+ if [ "$SRC_PORT" -le 0 ]; then
+ eerror "Invalid source port."
+ return 1
+ fi
+
+ LC_ALL=C ifconfig "${DEVICE}" 1>/dev/null 2>/dev/null
+ ret=$?
+
+ if [ -z "${DEVICE}" -o "${ret}" -gt 0 ]; then
+ eerror "Source device invalid."
+ return 1
+ fi
+
+ if [ "$TGT_PORT" -le 0 ]; then
+ eerror "Invalid target port."
+ return 1
+ fi
+
+ if [ -z "$TGT_IP" ]; then
+ eerror "Unspecified target address."
+ return 1
+ fi
+
+ return 0
+}
+# vim: ts=4 sw=4 sts=4: