Added installation for Slackware and separated the systemd.

Wed, 05 May 2021 20:31:26 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 05 May 2021 20:31:26 +0200
changeset 744
b8ccc85675a0
parent 743
7a4adede7d3f
child 745
3addb8cfcc3e

Added installation for Slackware and separated the systemd.

tools/Makefile file | annotate | diff | comparison | revisions
tools/bmsd.init file | annotate | diff | comparison | revisions
tools/init.debian file | annotate | diff | comparison | revisions
tools/init.slackware file | annotate | diff | comparison | revisions
tools/setup.slackware file | annotate | diff | comparison | revisions
--- a/tools/Makefile	Wed May 05 15:42:47 2021 +0200
+++ b/tools/Makefile	Wed May 05 20:31:26 2021 +0200
@@ -16,8 +16,19 @@
 		rm -f filelist Makefile.bak
 
 install:
-		${INSTALL} -c -g root -o root -m 0755 bmsd.init /etc/init.d/bmsd
-		[ -x /bin/systemctl ] && /bin/systemctl daemon-reload
+		@if [ -x /lib/systemd/systemd ]; then \
+			${INSTALL} -c -g root -o root -m 0755 init.debian /etc/init.d/bmsd ; \
+			echo "${INSTALL} -c -g root -o root -m 0755 init.debian /etc/init.d/bmsd" ; \
+			[ -x /bin/systemctl ] && /bin/systemctl daemon-reload ; \
+			echo "[ -x /bin/systemctl ] && /bin/systemctl daemon-reload" ; \
+		elif [ -f /etc/slackware-version ]; then \
+			${INSTALL} -c -g root -o root -m 0755 init.slackware /etc/rc.d/init.d/bmsd ; \
+			echo "${INSTALL} -c -g root -o root -m 0755 init.slackware /etc/rc.d/init.d/bmsd" ; \
+			${INSTALL} -c -g root -o root -m 0755 setup.slackware /var/log/setup/setup.bmsd ; \
+			echo "${INSTALL} -c -g root -o root -m 0755 setup.slackware /var/log/setup/setup.bmsd" ; \
+		else \
+			echo "Unsupported distribution" ; \
+		fi
 
 filelist:	Makefile
 		BASE=`pwd`; \
--- a/tools/bmsd.init	Wed May 05 15:42:47 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-#! /bin/sh
-### BEGIN INIT INFO
-# Provides:          bmsd
-# Required-Start:    $local_fs $remote_fs $network $syslog
-# Required-Stop:     $local_fs $remote_fs $network $syslog
-# Should-Start:      mosquitto
-# Should-Stop:       mosquitto
-# Default-Start:     2 3 4 5
-# Default-Stop:      0 1 6
-# Short-Description: Brewery Management Daemon
-# Description:       This program is the central daemon to collect data
-#                    from and control remote devices in a brewery. It is
-#                    the production and inventory database.
-### END INIT INFO
-
-# Author: Michiel Broek <mbroek@mbse.eu>
-
-# Do NOT "set -e"
-
-# PATH should only include /usr/* if it runs after the mountnfs.sh script
-PATH=/sbin:/usr/sbin:/bin:/usr/bin
-DESC="Brewery Management Daemon"
-NAME=bmsd
-DAEMON=/var/lib/bms/bin/$NAME
-#DAEMON_ARGS="--options args"
-PIDFILE=/var/lib/bms/.bms/run/$NAME.pid
-SCRIPTNAME=/etc/init.d/$NAME
-
-# Exit if the package is not installed
-[ -x "$DAEMON" ] || exit 0
-
-# Read configuration variable file if it is present
-[ -r /etc/default/$NAME ] && . /etc/default/$NAME
-
-# Load the VERBOSE setting and other rcS variables
-. /lib/init/vars.sh
-
-# Define LSB log_* functions.
-# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
-# and status_of_proc is working.
-. /lib/lsb/init-functions
-
-#
-# Function that starts the daemon/service
-#
-do_start()
-{
-	# Return
-        #   0 if daemon has been started
-        #   1 if daemon was already running
-        #   other if daemon could not be started or a failure occured
-	start-stop-daemon --start --chuid brewery --exec $DAEMON
-}
-
-#
-# Function that stops the daemon/service
-#
-do_stop()
-{
-	# Return
-        #   0 if daemon has been stopped
-        #   1 if daemon was already stopped
-        #   other if daemon could not be stopped or a failure occurred
-	start-stop-daemon --stop --retry=TERM/30/KILL/5 --pidfile $PIDFILE --exec $DAEMON
-}
-
-#
-# Function that sends a SIGHUP to the daemon/service
-#
-do_reload() {
-	#
-	# If the daemon can reload its configuration without
-	# restarting (for example, when it is sent a SIGHUP),
-	# then implement that here.
-	#
-	return 0
-}
-
-case "$1" in
-  start)
-	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
-	do_start
-	case "$?" in
-		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
-		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
-	esac
-	;;
-  stop)
-	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
-	do_stop
-	case "$?" in
-		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
-		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
-	esac
-	;;
-  status)
-	status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
-	;;
-  #reload|force-reload)
-	#
-	# If do_reload() is not implemented then leave this commented out
-	# and leave 'force-reload' as an alias for 'restart'.
-	#
-	#log_daemon_msg "Reloading $DESC" "$NAME"
-	#do_reload
-	#log_end_msg $?
-	#;;
-  restart|force-reload)
-	#
-	# If the "reload" option is implemented then remove the
-	# 'force-reload' alias
-	#
-	log_daemon_msg "Restarting $DESC" "$NAME"
-	do_stop
-	case "$?" in
-	  0|1)
-		do_start
-		case "$?" in
-			0) log_end_msg 0 ;;
-			1) log_end_msg 1 ;; # Old process is still running
-			*) log_end_msg 1 ;; # Failed to start
-		esac
-		;;
-	  *)
-		# Failed to stop
-		log_end_msg 1
-		;;
-	esac
-	;;
-  *)
-	echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
-	exit 3
-	;;
-esac
-
-:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/init.debian	Wed May 05 20:31:26 2021 +0200
@@ -0,0 +1,136 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          bmsd
+# Required-Start:    $local_fs $remote_fs $network $syslog
+# Required-Stop:     $local_fs $remote_fs $network $syslog
+# Should-Start:      mosquitto
+# Should-Stop:       mosquitto
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Brewery Management Daemon
+# Description:       This program is the central daemon to collect data
+#                    from and control remote devices in a brewery. It is
+#                    the production and inventory database.
+### END INIT INFO
+
+# Author: Michiel Broek <mbroek@mbse.eu>
+
+# Do NOT "set -e"
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="Brewery Management Daemon"
+NAME=bmsd
+DAEMON=/var/lib/bms/bin/$NAME
+#DAEMON_ARGS="--options args"
+PIDFILE=/var/lib/bms/.bms/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
+# and status_of_proc is working.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+	# Return
+        #   0 if daemon has been started
+        #   1 if daemon was already running
+        #   other if daemon could not be started or a failure occured
+	start-stop-daemon --start --chuid brewery --exec $DAEMON
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+	# Return
+        #   0 if daemon has been stopped
+        #   1 if daemon was already stopped
+        #   other if daemon could not be stopped or a failure occurred
+	start-stop-daemon --stop --retry=TERM/30/KILL/5 --pidfile $PIDFILE --exec $DAEMON
+}
+
+#
+# Function that sends a SIGHUP to the daemon/service
+#
+do_reload() {
+	#
+	# If the daemon can reload its configuration without
+	# restarting (for example, when it is sent a SIGHUP),
+	# then implement that here.
+	#
+	return 0
+}
+
+case "$1" in
+  start)
+	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+	do_start
+	case "$?" in
+		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+	esac
+	;;
+  stop)
+	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+	do_stop
+	case "$?" in
+		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+	esac
+	;;
+  status)
+	status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+	;;
+  #reload|force-reload)
+	#
+	# If do_reload() is not implemented then leave this commented out
+	# and leave 'force-reload' as an alias for 'restart'.
+	#
+	#log_daemon_msg "Reloading $DESC" "$NAME"
+	#do_reload
+	#log_end_msg $?
+	#;;
+  restart|force-reload)
+	#
+	# If the "reload" option is implemented then remove the
+	# 'force-reload' alias
+	#
+	log_daemon_msg "Restarting $DESC" "$NAME"
+	do_stop
+	case "$?" in
+	  0|1)
+		do_start
+		case "$?" in
+			0) log_end_msg 0 ;;
+			1) log_end_msg 1 ;; # Old process is still running
+			*) log_end_msg 1 ;; # Failed to start
+		esac
+		;;
+	  *)
+		# Failed to stop
+		log_end_msg 1
+		;;
+	esac
+	;;
+  *)
+	echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+	exit 3
+	;;
+esac
+
+:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/init.slackware	Wed May 05 20:31:26 2021 +0200
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# bmsd init script for Slackware.
+#
+# Copyright 2021 Michiel Broek, the Netherlands.
+
+
+case "$1" in
+  start)
+    echo -n "Starting Brewery Management System: "
+    if [ -f /var/lib/bms/.bms/bms.config ]; then
+      if [ -f /var/lib/bms/.bms/run/bmsd.pid ]; then
+  	echo "already running."
+      else
+	su - brewery -c "/var/lib/bms/bin/bmsd"  >/dev/null 2>/dev/null
+	sleep 1
+        echo "done."
+      fi
+    else
+      echo "not configured."
+    fi
+    ;;
+
+  stop)
+    echo -n "Stopping Brewery Management System: "
+    if [ -f /var/lib/bms/.bms/run/bmsd.pid ]; then
+      kill $(cat /var/lib/bms/.bms/run/bmsd.pid)
+      sleep 3
+      rm -f /var/lib/bms/.bms/run/bmsd.pid
+      echo "done."
+    else
+      echo "wasn't running."
+    fi
+    ;;
+
+  restart)
+    $0 stop
+    sleep 1
+    $0 start
+    ;;
+
+  *)
+    echo "usage: $0 {start|stop|restart}"
+esac
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/setup.slackware	Wed May 05 20:31:26 2021 +0200
@@ -0,0 +1,24 @@
+#!/bin/sh
+#BLURB="Enable/disable the Brewery Management System at boot"
+#
+# System setup script for Slackware
+#
+#
+T_PX=$1
+TMP=/var/log/setup/tmp
+if [ "$COLOR" = "on" -o -r $TMP/SeTcolor ]; then
+  dialog --title "ENABLE BMS DAEMON AT BOOT?" --yesno \
+ "BMS is a Brewery Management System running as a central controller \
+  in a micro or home brewery. It can control remote devices used to \
+  control fermentation, and log measured values." 10 70
+  if [ $? = 0 ]; then
+    mkdir -p /etc/rc.d/rc0.d /etc/rc.d/rc1.d /etc/rc.d/rc3.d /etc/rc.d/rc4.d /etc/rc.d/rc6
+    ln -s /etc/rc.d/init.d/bmsd /etc/rc.d/rc0.d/K15bmsd
+    ln -s /etc/rc.d/init.d/bmsd /etc/rc.d/rc1.d/K15bmsd
+    ln -s /etc/rc.d/init.d/bmsd /etc/rc.d/rc3.d/S85bmsd
+    ln -s /etc/rc.d/init.d/bmsd /etc/rc.d/rc4.d/S85bmsd
+    ln -s /etc/rc.d/init.d/bmsd /etc/rc.d/rc6.d/K15bmsd
+  else
+    rm -f /etc/rc.d/rc{0,1,6}.d/K15bmsd /etc/rc.d/rc{3,4}.d/S85bmsd
+  fi
+fi

mercurial