diff --git a/config/apcupsd/changeme b/config/apcupsd/changeme
new file mode 100644
index 000000000..166b6e0cb
--- /dev/null
+++ b/config/apcupsd/changeme
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# This shell script if placed in /etc/apcupsd
+# will be called by /etc/apcupsd/apccontrol when apcupsd
+# detects that the battery should be replaced.
+# We send an email message to root to notify him.
+#
+
+FROM="enter from email address"
+TO="enter to email address"
+
+HOSTNAME=`hostname`
+MSG="$HOSTNAME Battery needs changing now on UPS $1"
+#
+(
+echo From: $FROM
+echo To: $TO
+echo Subject: $MSG
+echo " "
+echo "$MSG"
+echo " "
+echo -ne $(echo "\r\n"; while read line; do echo "$line\r\n"; done < <(echo "$(/sbin/apcaccess status)"))
+) | sudo -u nobody /usr/sbin/sendmail -t -f $FROM
+exit 0
diff --git a/config/apcupsd/commfailure b/config/apcupsd/commfailure
new file mode 100644
index 000000000..4771dcfa7
--- /dev/null
+++ b/config/apcupsd/commfailure
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# This shell script if placed in /etc/apcupsd
+# will be called by /etc/apcupsd/apccontrol when apcupsd
+# loses contact with the UPS (i.e. the serial connection is not responding).
+# We send an email message to root to notify him.
+#
+
+FROM="enter from email address"
+TO="enter to email address"
+
+HOSTNAME=`hostname`
+MSG="$HOSTNAME Communications with UPS $1 lost"
+(
+echo From: $FROM
+echo To: $TO
+echo Subject: $MSG
+echo " "
+echo "$MSG"
+echo " "
+echo -ne $(echo "\r\n"; while read line; do echo "$line\r\n"; done < <(echo "$(/sbin/apcaccess status)"))
+) | sudo -u nobody /usr/sbin/sendmail -t -f $FROM
+exit 0
diff --git a/config/apcupsd/commok b/config/apcupsd/commok
new file mode 100644
index 000000000..5871eda5d
--- /dev/null
+++ b/config/apcupsd/commok
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# This shell script if placed in /etc/apcupsd
+# will be called by /etc/apcupsd/apccontrol when apcupsd
+# restores contact with the UPS (i.e. the serial connection is restored).
+# We send an email message to root to notify him.
+#
+
+FROM="enter from email address"
+TO="enter to email address"
+
+HOSTNAME=`hostname`
+MSG="$HOSTNAME Communications with UPS $1 restored"
+#
+(
+echo From: $FROM
+echo To: $TO
+echo Subject: $MSG
+echo " "
+echo "$MSG"
+echo " "
+echo -ne $(echo "\r\n"; while read line; do echo "$line\r\n"; done < <(echo "$(/sbin/apcaccess status)"))
+) | sudo -u nobody /usr/sbin/sendmail -t -f $FROM
+exit 0
diff --git a/config/apcupsd/offbattery b/config/apcupsd/offbattery
new file mode 100644
index 000000000..99e773c42
--- /dev/null
+++ b/config/apcupsd/offbattery
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# This shell script if placed in /etc/apcupsd
+# will be called by /etc/apcupsd/apccontrol when the    
+# UPS goes back on to the mains after a power failure.
+# We send an email message to root to notify him.
+#
+
+FROM="enter from email address"
+TO="enter to email address"
+
+HOSTNAME=`hostname`
+MSG="$HOSTNAME Power has returned on UPS $1"
+#
+(
+echo From: $FROM
+echo To: $TO
+echo Subject: $MSG
+echo " "
+echo "$MSG"
+echo " "
+echo -ne $(echo "\r\n"; while read line; do echo "$line\r\n"; done < <(echo "$(/sbin/apcaccess status)"))
+) | sudo -u nobody /usr/sbin/sendmail -t -f $FROM
+exit 0
diff --git a/config/apcupsd/onbattery b/config/apcupsd/onbattery
new file mode 100644
index 000000000..b1df7dafd
--- /dev/null
+++ b/config/apcupsd/onbattery
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# This shell script if placed in /etc/apcupsd
+# will be called by /etc/apcupsd/apccontrol when the UPS
+# goes on batteries.
+# We send an email message to root to notify him.
+#
+
+FROM="enter from email address"
+TO="enter to email address"
+
+HOSTNAME=`hostname`
+MSG="$HOSTNAME Power Failure on UPS $1"
+#
+(
+echo From: $FROM
+echo To: $TO
+echo Subject: $MSG
+echo " "
+echo "$MSG"
+echo " "
+echo -ne $(echo "\r\n"; while read line; do echo "$line\r\n"; done < <(echo "$(/sbin/apcaccess status)"))
+) | sudo -u nobody /usr/sbin/sendmail -t -f $FROM
+exit 0
diff --git a/lfs/apcupsd b/lfs/apcupsd
index 8ed9bbd8c..82b55272b 100644
--- a/lfs/apcupsd
+++ b/lfs/apcupsd
@@ -1,7 +1,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007-2023  IPFire Team  <info@ipfire.org>                     #
+# Copyright (C) 2007-2024  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
@@ -34,7 +34,7 @@ DL_FROM    = $(URL_IPFIRE)
 DIR_APP    = $(DIR_SRC)/$(THISAPP)
 TARGET     = $(DIR_INFO)/$(THISAPP)
 PROG       = apcupsd
-PAK_VER    = 11
+PAK_VER    = 2
 
 DEPS       =
 
@@ -82,14 +82,18 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
 	@$(PREBUILD)
 	@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
 	$(UPDATE_AUTOMAKE)
-	cd $(DIR_APP) && ./configure --prefix=/usr --enable-usb --enable-cgi \
-					--with-cgi-bin=/srv/web/ipfire/cgi-bin
+	cd $(DIR_APP) && ./configure \
+			--prefix=/usr \
+			--enable-usb \
+			--enable-cgi \
+			--with-cgi-bin=/srv/web/ipfire/cgi-bin
 	cd $(DIR_APP) && make $(MAKETUNING)
 	cd $(DIR_APP) && make install
-
-	#install initscripts
+	# Copy the IPFire specific scripts for apccontrol to use.
+	# These have been modified to be able to use the dma mail agent in IPFire.
+	cp -rf $(DIR_SRC)/config/apcupsd/* /etc/apcupsd/
+	# install initscripts
 	$(call INSTALL_INITSCRIPTS,$(SERVICES))
-
 	ln -sf ../init.d/apcupsd /etc/rc.d/rc3.d/S65apcupsd
 	ln -sf ../init.d/apcupsd /etc/rc.d/rc0.d/K35apcupsd
 	ln -sf ../init.d/apcupsd /etc/rc.d/rc6.d/K35apcupsd
