summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sysutils/checkrestart/Makefile11
-rw-r--r--sysutils/checkrestart/distinfo6
-rw-r--r--sysutils/checkrestart/files/checkrestart.in70
-rw-r--r--sysutils/checkrestart/pkg-message16
4 files changed, 98 insertions, 5 deletions
diff --git a/sysutils/checkrestart/Makefile b/sysutils/checkrestart/Makefile
index 2c6632c7dbbd..a533d89be565 100644
--- a/sysutils/checkrestart/Makefile
+++ b/sysutils/checkrestart/Makefile
@@ -2,7 +2,7 @@
PORTNAME= checkrestart
DISTVERSIONPREFIX= v
-DISTVERSION= 0.4.0
+DISTVERSION= 0.5.0
CATEGORIES= sysutils
MAINTAINER= tom@hur.st
@@ -14,11 +14,18 @@ LICENSE_FILE= ${WRKSRC}/LICENSE.txt
USE_GITHUB= yes
GH_ACCOUNT= Freaky
+SUB_FILES= checkrestart
+
PLIST_FILES= bin/checkrestart \
- share/man/man1/checkrestart.1.gz
+ share/man/man1/checkrestart.1.gz \
+ etc/periodic/daily/checkrestart
+
+PERIODIC_DAILY= etc/periodic/daily
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/checkrestart ${STAGEDIR}${PREFIX}/bin
${INSTALL_MAN} ${WRKSRC}/checkrestart.1 ${STAGEDIR}${MAN1PREFIX}/share/man/man1
+ @${MKDIR} ${STAGEDIR}${PREFIX}/${PERIODIC_DAILY}
+ ${INSTALL_SCRIPT} ${WRKDIR}/checkrestart ${STAGEDIR}${PREFIX}/${PERIODIC_DAILY}
.include <bsd.port.mk>
diff --git a/sysutils/checkrestart/distinfo b/sysutils/checkrestart/distinfo
index 4f8e654d3143..4f36ba52bcd1 100644
--- a/sysutils/checkrestart/distinfo
+++ b/sysutils/checkrestart/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1584926860
-SHA256 (Freaky-checkrestart-v0.4.0_GH0.tar.gz) = 9c578b7f0c881a10bea040da2c8525c2132bb47f1d85ca05ba6f6a9c6e61b1b4
-SIZE (Freaky-checkrestart-v0.4.0_GH0.tar.gz) = 5306
+TIMESTAMP = 1585601339
+SHA256 (Freaky-checkrestart-v0.5.0_GH0.tar.gz) = c37f40ad618d978fe413c71c367af5aefaeb1d600d72725294df8b3523e20e9c
+SIZE (Freaky-checkrestart-v0.5.0_GH0.tar.gz) = 5659
diff --git a/sysutils/checkrestart/files/checkrestart.in b/sysutils/checkrestart/files/checkrestart.in
new file mode 100644
index 000000000000..349ed8d44f62
--- /dev/null
+++ b/sysutils/checkrestart/files/checkrestart.in
@@ -0,0 +1,70 @@
+#!/bin/sh
+# $FreeBSD$
+
+if [ -r /etc/defaults/periodic.conf ]; then
+ . /etc/defaults/periodic.conf
+ source_periodic_confs
+fi
+
+: "${daily_checkrestart_enable:=NO}"
+: "${daily_checkrestart_weekdays:=1234567}" # Days of the week to run, Monday=1
+: "${daily_checkrestart_users:=}" # User names or IDs to check
+: "${daily_checkrestart_jails:=}" # Jail names or IDs to check
+: "${daily_checkrestart_procs:=}" # Process names or IDs to check
+
+checkrestartcmd=/usr/local/bin/checkrestart
+hflag=""
+rc=0
+
+export COLUMNS=80
+
+checkrestart() {
+ local result
+ result="$(${checkrestartcmd} ${hflag} "$@" -- ${daily_checkrestart_procs} 2>&1)"
+ if [ "$result" ]; then
+ echo "${result}"
+ rc=3
+ fi
+ hflag="-H"
+}
+
+checkrestart_each_user() {
+ if [ -n "${daily_checkrestart_users}" ]; then
+ for user in ${daily_checkrestart_users}; do
+ checkrestart -u "${user}" "$@"
+ done
+ else
+ checkrestart "$@"
+ fi
+}
+
+checkrestart_start() {
+ if [ -n "${daily_checkrestart_jails}" ]; then
+ for jail in ${daily_checkrestart_jails}; do
+ checkrestart_each_user -j "${jail}"
+ done
+ else
+ checkrestart_each_user
+ fi
+}
+
+checkday() {
+ if echo "${daily_checkrestart_weekdays}" | grep -vq '^[1-7, ]*$'; then
+ echo "daily_checkrestart_weekdays must have values 1-7"
+ exit 2
+ fi
+
+ echo "${daily_checkrestart_weekdays}" | grep -Fq "$(date +%u)"
+}
+
+case "${daily_checkrestart_enable}" in
+ [Yy][Ee][Ss])
+ if checkday; then
+ echo
+ echo 'Checking for stale processes:'
+ checkrestart_start
+ fi
+ ;;
+esac
+
+exit $rc
diff --git a/sysutils/checkrestart/pkg-message b/sysutils/checkrestart/pkg-message
new file mode 100644
index 000000000000..dd8510c29198
--- /dev/null
+++ b/sysutils/checkrestart/pkg-message
@@ -0,0 +1,16 @@
+[
+{ type: install,
+ message: <<EOM
+In order to enable periodic(8) checks, set the following in /etc/periodic.conf
+
+# Required
+daily_checkrestart_enable="YES"
+
+# Optional
+daily_checkrestart_weekdays="1 4" # only run on Monday and Thursday
+daily_checkrestart_jails="0 web" # limit to jails 0 and web
+daily_checkrestart_users="root www" # limit to root and www users
+daily_checkrestart_procs="smbd httpd" # limit to samba and httpd
+EOM
+}
+]