<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dhorton</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dhorton"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Dhorton"/>
	<updated>2026-04-30T15:06:04Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Apcupsd&amp;diff=27539</id>
		<title>Apcupsd</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Apcupsd&amp;diff=27539"/>
		<updated>2024-10-12T15:48:11Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Configuring and Testing Email Alerts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Using apcupsd to Monitor a USB-Attached APC UPS ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the apcupsd package to monitor and report the statistics for an APC branded USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any APC or compatible model should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring apcupsd ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package for apcupsd. After that, we&#039;ll rename the default configuration file and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
Installation is by an APK package.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add apcupsd&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is one main configuration file called &#039;&#039;/etc/apcupsd/apcupsd.conf&#039;&#039; that has all the tunable parameters along with many comments. We&#039;ll keep the original as a reference and then edit the parameters to suit.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# mv /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf~&lt;br /&gt;
 alpine:/# grep -v &#039;^\s*$\|^\s*\#&#039; /etc/apcupsd/apcupsd.conf~ &amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, edit the parameters in &#039;&#039;/etc/apcupsd/apcupsd.conf&#039;&#039; using the backup copy of the original file as a reference for comments. Some of the important parameters are listed below in order of appearance.&lt;br /&gt;
&lt;br /&gt;
* UPSNAME - This is to identify your UPS. Exact format is not important, but keep it short and don&#039;t use spaces.&lt;br /&gt;
* UPSCABLE - For a USB attached UPS, use the value &#039;&#039;usb&#039;&#039;&lt;br /&gt;
* USBTYPE - Similar to USBCABLE, use &#039;&#039;usb&#039;&#039;&lt;br /&gt;
* DEVICE - For a USB attached UPS, the parameter is not needed. Comment this line by using a # at the beginning.&lt;br /&gt;
&lt;br /&gt;
These four changes are enough to get started. Everything else can be left as default. Read the comments in the original &#039;&#039;apcupsd.conf~&#039;&#039; file to find out what the other parameters do and if you want to use them.&lt;br /&gt;
&lt;br /&gt;
{{Note|The comments in the config file say UPSNAME should be eight characters or less. This appears to be a limitation of using the parameter for storing the name in the UPS&#039;s EPROM. If you&#039;re not planning to update EPROM, longer names do not appear to cause problems. See the config section after &#039;&#039;Configuration statements used in updating the UPS EPROM&#039;&#039; for more detail. }}&lt;br /&gt;
&lt;br /&gt;
== Starting apcupsd ==&lt;br /&gt;
&lt;br /&gt;
The apcupsd package installs a service that allows you to control apcupsd using the standard tools. The following example shows how to start it and ensure it starts each time the system boots.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# rc-service apcupsd start&lt;br /&gt;
 * Starting APC UPS daemon ...&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add apcupsd&lt;br /&gt;
 * service apcupsd added to runlevel default&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Checking the Configuration ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;apcaccess&#039;&#039;&#039; command will communicate with the UPS via the apcupsd daemon&#039;s network port and report back what it finds. This is a good way to test your connection and configuration.&lt;br /&gt;
&lt;br /&gt;
A successful test will look similar to what&#039;s shown below. &lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apcaccess&lt;br /&gt;
 APC      : 001,043,1022&lt;br /&gt;
 DATE     : 2024-10-12 15:31:10 +0000&lt;br /&gt;
 HOSTNAME : alpine.home&lt;br /&gt;
 VERSION  : 3.14.14 (31 May 2016) unknown&lt;br /&gt;
 UPSNAME  : SmartUPS_1000&lt;br /&gt;
 CABLE    : USB Cable&lt;br /&gt;
 DRIVER   : USB UPS Driver&lt;br /&gt;
 UPSMODE  : Stand Alone&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The actual list of reported parameters is much longer, but the first few lines show the ones that have been customized in the configuration thus far. If you see the message &#039;&#039;Error contacting apcupsd @ localhost:3551: Connection refused&#039;&#039;, check to ensure the apcupsd service is running.&lt;br /&gt;
&lt;br /&gt;
== Configuring and Testing Email Alerts ==&lt;br /&gt;
&lt;br /&gt;
{{Note|In order to receive notifications, you must have mail delivery setup and working on your Alpine host. In addition, you should have an alias that sends email intended for root to a regular user. See the Alpine HOWTO [[Small-Time_Email_with_Exim_and_Dovecot]] for help with that.}}&lt;br /&gt;
&lt;br /&gt;
apcupsd will send alerts for important events using shell scripts in the /etc/apcupsd directory. These scripts and their alert functions are listed below.&lt;br /&gt;
&lt;br /&gt;
* changeme - sends an alert when batteries have reached the end of their useful life&lt;br /&gt;
* commfailure - apcupsd cannot communicate with the UPS&lt;br /&gt;
* commok - communication with the UPS has been restored after a failure&lt;br /&gt;
* offbattery - the UPS is back to running on mains power after running on battery&lt;br /&gt;
* onbattery - the ups has switched to battery power&lt;br /&gt;
&lt;br /&gt;
All of the scripts have a similar setup and rely on two environment variables, SYSADMIN and APCUPSD_MAIL, to deliver email alerts. To test the alerts, temporarily export these two variables and run one of the scripts from the command-line. The example below shows how to send a test alert for battery change.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# export SYSADMIN=root&lt;br /&gt;
 alpine:/# export APCUPSD_MAIL=mail&lt;br /&gt;
 alpine:/# sh /etc/apcupsd/changeme&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If all goes well, you should receive an email telling you the UPS battery needs changing NOW. If you find you need to use different values for SYSADMIN or APCUPSD_MAIL, be sure to make those changes in &#039;&#039;/etc/apcupsd/apccontrol&#039;&#039;. The exported variables used in the test are temporary and will lost after you log out.&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
&lt;br /&gt;
Further configuration can be done to initiate automatic shutdown using the parameters in apcupsd.conf (see the original commented file apcupsd.conf~ for details.) You may also monitor the UPS via home automation using Home Assistant and the [https://www.home-assistant.io/integrations/apcupsd/ APC UPS Daemon integration].&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Apcupsd&amp;diff=27538</id>
		<title>Apcupsd</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Apcupsd&amp;diff=27538"/>
		<updated>2024-10-12T15:46:52Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Using apcupsd to Monitor a USB-Attached APC UPS ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the apcupsd package to monitor and report the statistics for an APC branded USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any APC or compatible model should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring apcupsd ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package for apcupsd. After that, we&#039;ll rename the default configuration file and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
Installation is by an APK package.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add apcupsd&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is one main configuration file called &#039;&#039;/etc/apcupsd/apcupsd.conf&#039;&#039; that has all the tunable parameters along with many comments. We&#039;ll keep the original as a reference and then edit the parameters to suit.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# mv /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf~&lt;br /&gt;
 alpine:/# grep -v &#039;^\s*$\|^\s*\#&#039; /etc/apcupsd/apcupsd.conf~ &amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, edit the parameters in &#039;&#039;/etc/apcupsd/apcupsd.conf&#039;&#039; using the backup copy of the original file as a reference for comments. Some of the important parameters are listed below in order of appearance.&lt;br /&gt;
&lt;br /&gt;
* UPSNAME - This is to identify your UPS. Exact format is not important, but keep it short and don&#039;t use spaces.&lt;br /&gt;
* UPSCABLE - For a USB attached UPS, use the value &#039;&#039;usb&#039;&#039;&lt;br /&gt;
* USBTYPE - Similar to USBCABLE, use &#039;&#039;usb&#039;&#039;&lt;br /&gt;
* DEVICE - For a USB attached UPS, the parameter is not needed. Comment this line by using a # at the beginning.&lt;br /&gt;
&lt;br /&gt;
These four changes are enough to get started. Everything else can be left as default. Read the comments in the original &#039;&#039;apcupsd.conf~&#039;&#039; file to find out what the other parameters do and if you want to use them.&lt;br /&gt;
&lt;br /&gt;
{{Note|The comments in the config file say UPSNAME should be eight characters or less. This appears to be a limitation of using the parameter for storing the name in the UPS&#039;s EPROM. If you&#039;re not planning to update EPROM, longer names do not appear to cause problems. See the config section after &#039;&#039;Configuration statements used in updating the UPS EPROM&#039;&#039; for more detail. }}&lt;br /&gt;
&lt;br /&gt;
== Starting apcupsd ==&lt;br /&gt;
&lt;br /&gt;
The apcupsd package installs a service that allows you to control apcupsd using the standard tools. The following example shows how to start it and ensure it starts each time the system boots.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# rc-service apcupsd start&lt;br /&gt;
 * Starting APC UPS daemon ...&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add apcupsd&lt;br /&gt;
 * service apcupsd added to runlevel default&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Checking the Configuration ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;apcaccess&#039;&#039;&#039; command will communicate with the UPS via the apcupsd daemon&#039;s network port and report back what it finds. This is a good way to test your connection and configuration.&lt;br /&gt;
&lt;br /&gt;
A successful test will look similar to what&#039;s shown below. &lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apcaccess&lt;br /&gt;
 APC      : 001,043,1022&lt;br /&gt;
 DATE     : 2024-10-12 15:31:10 +0000&lt;br /&gt;
 HOSTNAME : alpine.home&lt;br /&gt;
 VERSION  : 3.14.14 (31 May 2016) unknown&lt;br /&gt;
 UPSNAME  : SmartUPS_1000&lt;br /&gt;
 CABLE    : USB Cable&lt;br /&gt;
 DRIVER   : USB UPS Driver&lt;br /&gt;
 UPSMODE  : Stand Alone&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The actual list of reported parameters is much longer, but the first few lines show the ones that have been customized in the configuration thus far. If you see the message &#039;&#039;Error contacting apcupsd @ localhost:3551: Connection refused&#039;&#039;, check to ensure the apcupsd service is running.&lt;br /&gt;
&lt;br /&gt;
== Configuring and Testing Email Alerts ==&lt;br /&gt;
&lt;br /&gt;
{{Note|In order to receive notifications, you must have mail delivery setup and working on your Alpine host. In addition, you should have an alias that sends email intended for root to a regular user. See the Alpine HOWTO [[Small-Time_Email_with_Exim_and_Dovecot]] for help with that.}}&lt;br /&gt;
&lt;br /&gt;
apcupsd will send alerts for important events using shell scripts in the /etc/apcupsd directory. These scripts and their alert functions are listed below.&lt;br /&gt;
&lt;br /&gt;
* changeme - sends an alert when batteries have reached the end of their useful life&lt;br /&gt;
* commfailure - apcupsd cannot communicate with the UPS&lt;br /&gt;
* commok - communication with the UPS has been restored after a failure&lt;br /&gt;
* offbattery - the UPS is back to running on mains power after running on battery&lt;br /&gt;
* onbattery - the ups has switched to battery power&lt;br /&gt;
&lt;br /&gt;
All of the scripts have a similar setup and rely on two environment variables, SYSADMIN and APCUPSD_MAIL, to deliver email alerts. To test the alerts, temporarily export these two variables and run one of the scripts from the command-line. The example below shows how to send a test alert for battery change.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# export SYSADMIN=root&lt;br /&gt;
 alpine:/# export APCUPSD_MAIL=mail&lt;br /&gt;
 alpine:/# sh /etc/apcupsd/changeme&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If all goes well, you should receive an email telling you the UPS battery needs changing NOW. If you find you need to use different values for SYSADMIN or APCUPSD_MAIL, be sure to make those changes in /etc/apcupsd/apccontrol. The exported variables used in the test are temporary and will lost after you log out.&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
&lt;br /&gt;
Further configuration can be done to initiate automatic shutdown using the parameters in apcupsd.conf (see the original commented file apcupsd.conf~ for details.) You may also monitor the UPS via home automation using Home Assistant and the [https://www.home-assistant.io/integrations/apcupsd/ APC UPS Daemon integration].&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Apcupsd&amp;diff=27537</id>
		<title>Apcupsd</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Apcupsd&amp;diff=27537"/>
		<updated>2024-10-12T15:41:36Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Using apcupsd to Monitor a USB-Attached APC UPS ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the apcupsd package to monitor and report the statistics for an APC branded USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any APC or compatible model should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring apcupsd ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package for apcupsd. After that, we&#039;ll rename the default configuration file and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
Installation is by an APK package.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add apcupsd&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is one main configuration file called &#039;&#039;/etc/apcupsd/apcupsd.conf&#039;&#039; that has all the tunable parameters along with many comments. We&#039;ll keep the original as a reference and then edit the parameters to suit.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# mv /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf~&lt;br /&gt;
 alpine:/# grep -v &#039;^\s*$\|^\s*\#&#039; /etc/apcupsd/apcupsd.conf~ &amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, edit the parameters in &#039;&#039;/etc/apcupsd/apcupsd.conf&#039;&#039; using the backup copy of the original file as a reference for comments. Some of the important parameters are listed below in order of appearance.&lt;br /&gt;
&lt;br /&gt;
* UPSNAME - This is to identify your UPS. Exact format is not important, but keep it short and don&#039;t use spaces.&lt;br /&gt;
* UPSCABLE - For a USB attached UPS, use the value &#039;&#039;usb&#039;&#039;&lt;br /&gt;
* USBTYPE - Similar to USBCABLE, use &#039;&#039;usb&#039;&#039;&lt;br /&gt;
* DEVICE - For a USB attached UPS, the parameter is not needed. Comment this line by using a # at the beginning.&lt;br /&gt;
&lt;br /&gt;
These four changes are enough to get started. Everything else can be left as default. Read the comments in the original &#039;&#039;apcupsd.conf~&#039;&#039; file to find out what the other parameters do and if you want to use them.&lt;br /&gt;
&lt;br /&gt;
{{Note|The comments in the config file say UPSNAME should be eight characters or less. This appears to be a limitation of using the parameter for storing the name in the UPS&#039;s EPROM. If you&#039;re not planning to update EPROM, longer names do not appear to cause problems. See the config section after &#039;&#039;Configuration statements used in updating the UPS EPROM&#039;&#039; for more detail. }}&lt;br /&gt;
&lt;br /&gt;
== Starting apcupsd ==&lt;br /&gt;
&lt;br /&gt;
The apcupsd package installs a service that allows you to control apcupsd using the standard tools. The following example shows how to start it and ensure it starts each time the system boots.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# rc-service apcupsd start&lt;br /&gt;
 * Starting APC UPS daemon ...&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add apcupsd&lt;br /&gt;
 * service apcupsd added to runlevel default&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Checking the Configuration ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;apcaccess&#039;&#039;&#039; command will communicate with the UPS via the apcupsd daemon&#039;s network port and report back what it finds. This is a good way to test your connection and configuration.&lt;br /&gt;
&lt;br /&gt;
A successful test will look similar to what&#039;s shown below. &lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apcaccess&lt;br /&gt;
 APC      : 001,043,1022&lt;br /&gt;
 DATE     : 2024-10-12 15:31:10 +0000&lt;br /&gt;
 HOSTNAME : alpine.home&lt;br /&gt;
 VERSION  : 3.14.14 (31 May 2016) unknown&lt;br /&gt;
 UPSNAME  : SmartUPS_1000&lt;br /&gt;
 CABLE    : USB Cable&lt;br /&gt;
 DRIVER   : USB UPS Driver&lt;br /&gt;
 UPSMODE  : Stand Alone&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The actual list of reported parameters is much longer, but the first few lines show the ones that have been customized in the configuration thus far. If you see the message &#039;&#039;Error contacting apcupsd @ localhost:3551: Connection refused&#039;&#039;, check to ensure the apcupsd service is running.&lt;br /&gt;
&lt;br /&gt;
== Configuring and Testing Email Alerts ==&lt;br /&gt;
&lt;br /&gt;
{{Note|In order to receive notifications, you must have mail delivery setup and working on your Alpine host. In addition, you should have an alias that sends email intended for root to a regular user. See the Alpine HOWTO [[Small-Time_Email_with_Exim_and_Dovecot]] for help with that.}}&lt;br /&gt;
&lt;br /&gt;
apcupsd will send alerts for important events using shell scripts in the /etc/apcupsd directory. These scripts and their alert functions are listed below.&lt;br /&gt;
&lt;br /&gt;
* changeme - sends an alert when batteries have reached the end of their useful life&lt;br /&gt;
* commfailure - apcupsd cannot communicate with the UPS&lt;br /&gt;
* commok - communication with the UPS has been restored after a failure&lt;br /&gt;
* offbattery - the UPS is back to running on mains power after running on battery&lt;br /&gt;
* onbattery - the ups has switched to battery power&lt;br /&gt;
&lt;br /&gt;
All of the scripts have a similar setup and rely on two environment variables, SYSADMIN and APCUPSD_MAIL, to deliver email alerts. To test the alerts, temporarily export these two variables and run one of the scripts from the command-line. The example below shows how to send a test alert for battery change.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# export SYSADMIN=root&lt;br /&gt;
 alpine:/# export APCUPSD_MAIL=mail&lt;br /&gt;
 alpine:/# sh /etc/apcupsd/changeme&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If all goes well, you should receive an email telling you the UPS battery needs changing NOW.&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
&lt;br /&gt;
Further configuration can be done to initiate automatic shutdown using the parameters in apcupsd.conf (see the original commented file apcupsd.conf~ for details.) You may also monitor the UPS via home automation using Home Assistant and the [https://www.home-assistant.io/integrations/apcupsd/ APC UPS Daemon integration].&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Apcupsd&amp;diff=27536</id>
		<title>Apcupsd</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Apcupsd&amp;diff=27536"/>
		<updated>2024-10-12T15:26:18Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|Work in Progress}}&lt;br /&gt;
&lt;br /&gt;
== Using apcupsd to Monitor a USB-Attached APC UPS ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the apcupsd package to monitor and report the statistics for an APC branded USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any APC or compatible model should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring apcupsd ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package for apcupsd. After that, we&#039;ll rename the default configuration file and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
Installation is by an APK package.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add apcupsd&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is one main configuration file called &#039;&#039;/etc/apcupsd/apcupsd.conf&#039;&#039; that has all the tunable parameters along with many comments. We&#039;ll keep the original as a reference and then edit the parameters to suit.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# mv /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf~&lt;br /&gt;
 alpine:/# grep -v &#039;^\s*$\|^\s*\#&#039; /etc/apcupsd/apcupsd.conf~ &amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, edit the parameters in &#039;&#039;/etc/apcupsd/apcupsd.conf&#039;&#039; using the backup copy of the original file as a reference for comments. Some of the important parameters are listed below in order of appearance.&lt;br /&gt;
&lt;br /&gt;
* UPSNAME - This is to identify your UPS. Exact format is not important, but keep it short and don&#039;t use spaces.&lt;br /&gt;
* UPSCABLE - For a USB attached UPS, use the value &#039;&#039;usb&#039;&#039;&lt;br /&gt;
* USBTYPE - Similar to USBCABLE, use &#039;&#039;usb&#039;&#039;&lt;br /&gt;
* DEVICE - For a USB attached UPS, the parameter is not needed. Comment this line by using a # at the beginning.&lt;br /&gt;
&lt;br /&gt;
These four changes are enough to get started. Everything else can be left as default. Read the comments in the original &#039;&#039;apcupsd.conf~&#039;&#039; file to find out what the other parameters do and if you want to use them.&lt;br /&gt;
&lt;br /&gt;
{{Note|The comments in the config file say UPSNAME should be eight characters or less. This appears to be a limitation of using the parameter for storing the name in the UPS&#039;s EPROM. If you&#039;re not planning to update EPROM, longer names do not appear to cause problems. See the config section after &#039;&#039;Configuration statements used in updating the UPS EPROM&#039;&#039; for more detail. }}&lt;br /&gt;
&lt;br /&gt;
== Starting apcupsd ==&lt;br /&gt;
&lt;br /&gt;
The apcupsd package installs a service that allows you to control apcupsd using the standard tools. The following example shows how to start it and ensure it starts each time the system boots.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# rc-service apcupsd start&lt;br /&gt;
 * Starting APC UPS daemon ...&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add apcupsd&lt;br /&gt;
 * service apcupsd added to runlevel default&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuring and Testing Email Alerts ==&lt;br /&gt;
&lt;br /&gt;
{{Note|In order to receive notifications, you must have mail delivery setup and working on your Alpine host. In addition, you should have an alias that sends email intended for root to a regular user. See the Alpine HOWTO [[Small-Time_Email_with_Exim_and_Dovecot]] for help with that.}}&lt;br /&gt;
&lt;br /&gt;
apcupsd will send alerts for important events using shell scripts in the /etc/apcupsd directory. These scripts and their alert functions are listed below.&lt;br /&gt;
&lt;br /&gt;
* changeme - sends an alert when batteries have reached the end of their useful life&lt;br /&gt;
* commfailure - apcupsd cannot communicate with the UPS&lt;br /&gt;
* commok - communication with the UPS has been restored after a failure&lt;br /&gt;
* offbattery - the UPS is back to running on mains power after running on battery&lt;br /&gt;
* onbattery - the ups has switched to battery power&lt;br /&gt;
&lt;br /&gt;
All of the scripts have a similar setup and rely on two environment variables, SYSADMIN and APCUPSD_MAIL, to deliver email alerts. To test the alerts, temporarily export these two variables and run one of the scripts from the command-line. The example below shows how to send a test alert for battery change.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# export SYSADMIN=root&lt;br /&gt;
 alpine:/# export APCUPSD_MAIL=mail&lt;br /&gt;
 alpine:/# sh /etc/apcupsd/changeme&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If all goes well, you should receive an email telling you the UPS battery needs changing NOW.&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
&lt;br /&gt;
Further configuration can be done to initiate automatic shutdown using the parameters in apcupsd.conf (see the original commented file for details.) You may also monitor the UPS via home automation using Home Assistant and the [https://www.home-assistant.io/integrations/apcupsd/ APC UPS Daemon integration].&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Apcupsd&amp;diff=27535</id>
		<title>Apcupsd</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Apcupsd&amp;diff=27535"/>
		<updated>2024-10-12T14:21:24Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|Work in Progress}}&lt;br /&gt;
&lt;br /&gt;
== Using apcupsd to Monitor a USB-Attached APC UPS ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the apcupsd package to monitor and report the statistics for an APC branded USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any APC or compatible model should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring apcupsd ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename the default configuration file and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
Installation is by an APK package.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add apcupsd&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is one main configuration file called &#039;&#039;/etc/apcupsd/apcupsd.conf&#039;&#039; that has all the tunable parameters along with many comments. We&#039;ll keep the original as a reference and then edit the parameters to suit.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cp /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf~&lt;br /&gt;
 alpine:/# grep -v &#039;^\s*$\|^\s*\#&#039; /etc/apcupsd/apcupsd.conf~ &amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, edit the parameters in &#039;&#039;/etc/apcupsd/apcupsd.conf&#039;&#039; using the backup copy of the original file as a reference for comments. Some of the important parameters are listed below in order of appearance.&lt;br /&gt;
&lt;br /&gt;
* UPSNAME - This is to identify your UPS. Exact format is not important, but keep it short and don&#039;t use spaces.&lt;br /&gt;
* UPSCABLE - For a USB attached UPS, use the value &#039;&#039;usb&#039;&#039;&lt;br /&gt;
* USBTYPE - Similar to USBCABLE, use &#039;&#039;usb&#039;&#039;&lt;br /&gt;
* DEVICE - For a USB attached UPS, the parameter is not needed. Comment this line by using a # at the beginning.&lt;br /&gt;
&lt;br /&gt;
These four changes are enough to get started. Everything else can be left as default. Read the comments in the original &#039;&#039;apcupsd.conf~&#039;&#039; file to find out what the other parameters do.&lt;br /&gt;
&lt;br /&gt;
== Starting apcupsd ==&lt;br /&gt;
The apcupsd package installs a service that allows you to control apcupsd using the standard tools. The following example shows how to start it and ensure it starts each time the system boots.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# rc-service apcupsd start&lt;br /&gt;
 * Starting APC UPS daemon ...&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add apcupsd&lt;br /&gt;
 * service apcupsd added to runlevel default&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuring and Testing Email Alerts ==&lt;br /&gt;
{{Note|In order to receive notifications, you must have mail delivery setup and working on your Alpine host. In addition, you should have an alias that sends email intended for root to a regular user. See the Alpine HOWTO [[Small-Time_Email_with_Exim_and_Dovecot]] for help with that.}}&lt;br /&gt;
&lt;br /&gt;
apcupsd will send alerts for important events using shell scripts in the /etc/apcupsd directory. These scripts and their alert functions are listed below.&lt;br /&gt;
&lt;br /&gt;
* changeme - sends an alert when batteries have reached the end of their useful life&lt;br /&gt;
* commfailure - apcupsd cannot communicate with the UPS&lt;br /&gt;
* commok - communication with the UPS has been restored after a failure&lt;br /&gt;
* offbattery - the UPS is back to running on mains power after running on battery&lt;br /&gt;
* onbattery - the ups has switched to battery power&lt;br /&gt;
&lt;br /&gt;
All of the scripts have a similar setup and rely on two environment variables, SYSADMIN and APCUPSD_MAIL, to deliver email alerts. To test the alerts, temporarily export these two variables and run one of the scripts from the command-line. The example below shows how to send a test alert for battery change.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# export SYSADMIN=root&lt;br /&gt;
 alpine:/# export APCUPSD_MAIL=mail&lt;br /&gt;
 alpine:/# sh /etc/apcupsd/changeme&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If all goes well, you should receive an email telling you the UPS battery needs changing NOW.&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
Further configuration can be done to initiate automatic shutdown using the parameters in apcupsd.conf (see the original commented file for details.) You may also monitor the UPS via home automation using Home Assistant and the [https://www.home-assistant.io/integrations/apcupsd/ APC UPS Daemon integration].&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Apcupsd&amp;diff=27534</id>
		<title>Apcupsd</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Apcupsd&amp;diff=27534"/>
		<updated>2024-10-12T14:14:18Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|Work in Progress}}&lt;br /&gt;
&lt;br /&gt;
== Using apcupsd to Monitor a USB-Attached APC UPS ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the apcupsd package to monitor and report the statistics for an APC branded USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any APC or compatible model should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring apcupsd ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename the default configuration file and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
Installation is by an APK package.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add apcupsd&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is one main configuration file called &#039;&#039;/etc/apcupsd/apcupsd.conf&#039;&#039; that has all the tunable parameters along with many comments. We&#039;ll keep the original as a reference and then edit the parameters to suit.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cp /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf~&lt;br /&gt;
 alpine:/# grep -v &#039;^\s*$\|^\s*\#&#039; /etc/apcupsd/apcupsd.conf~ &amp;gt;/etc/apcupsd/apcupsd.conf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, edit the parameters in &#039;&#039;/etc/apcupsd/apcupsd.conf&#039;&#039; using the backup copy of the original file as a reference for comments. Some of the important parameters are listed below in order of appearance.&lt;br /&gt;
&lt;br /&gt;
* UPSNAME - This is to identify your UPS. Exact format is not important, but keep it short and don&#039;t use spaces.&lt;br /&gt;
* UPSCABLE - For a USB attached UPS, use the value &#039;&#039;usb&#039;&#039;&lt;br /&gt;
* USBTYPE - Similar to USBCABLE, use &#039;&#039;usb&#039;&#039;&lt;br /&gt;
* DEVICE - For a USB attached UPS, the parameter is not needed. Comment this line by using a # at the beginning.&lt;br /&gt;
&lt;br /&gt;
These four changes are enough to get started. Everything else can be left as default. Read the comments in the original &#039;&#039;apcupsd.conf~&#039;&#039; file to find out what the other parameters do.&lt;br /&gt;
&lt;br /&gt;
== Starting apcupsd ==&lt;br /&gt;
The apcupsd package installs a service that allows you to control apcupsd using the standard tools. The following example shows how to start it and ensure it starts each time the system boots.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# rc-service apcupsd start&lt;br /&gt;
 * Starting APC UPS daemon ...&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add apcupsd&lt;br /&gt;
 * service apcupsd added to runlevel default&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuring and Testing Email Alerts ==&lt;br /&gt;
{{Note|In order to receive notifications, you must have mail delivery setup and working on your Alpine host. In addition, you should have an alias that sends email intended for root to a regular user. See the Alpine HOWTO [[Small-Time_Email_with_Exim_and_Dovecot]] for help with that.}}&lt;br /&gt;
&lt;br /&gt;
apcupsd will send alerts for important events using shell scripts in the /etc/apcupsd directory. These scripts and their alert functions are listed below.&lt;br /&gt;
&lt;br /&gt;
* changeme - sends an alert when batteries have reached the end of their useful life&lt;br /&gt;
* commfailure - apcupsd cannot communicate with the UPS&lt;br /&gt;
* commok - communication with the UPS has been restored after a failure&lt;br /&gt;
* offbattery - the UPS is back to running on mains power after running on battery&lt;br /&gt;
* onbattery - the ups has switched to battery power&lt;br /&gt;
&lt;br /&gt;
All of the scripts have a similar setup and rely on two environment variables, SYSADMIN and APCUPSD_MAIL, to deliver email alerts. To test the alerts, temporarily export these two variables and run one of the scripts from the command-line. The example below shows how to send a test alert for battery change.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# export SYSADMIN=root&lt;br /&gt;
 alpine:/# export APCUPSD_MAIL=mail&lt;br /&gt;
 alpine:/# sh /etc/apcupsd/changeme&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If all goes well, you should receive an email telling you the UPS battery needs changing NOW.&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Apcupsd&amp;diff=27533</id>
		<title>Apcupsd</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Apcupsd&amp;diff=27533"/>
		<updated>2024-10-12T13:26:21Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: Created page with &amp;quot;{{Warning|Work in Progress}}  == Installing and Configuring apcupsd == This wiki page shows how to install and configure the apcupsd package to monitor and report the statistics for an APC branded USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any APC or compatible model should work.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|Work in Progress}}&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring apcupsd ==&lt;br /&gt;
This wiki page shows how to install and configure the apcupsd package to monitor and report the statistics for an APC branded USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any APC or compatible model should work.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Tutorials_and_Howtos&amp;diff=27532</id>
		<title>Tutorials and Howtos</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Tutorials_and_Howtos&amp;diff=27532"/>
		<updated>2024-10-12T13:22:56Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Other Servers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Todo|This material has been re-organized..., but grouping should be checked: &#039;&#039;&#039;Howtos are smaller articles&#039;&#039;&#039; and &#039;&#039;&#039;tutorials are more detailed document&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
[[Image:package_edutainment.svg|right|link=]]&lt;br /&gt;
{{TOC left}}&lt;br /&gt;
&#039;&#039;&#039;Welcome to Tutorials and Howtos, a place of basic and advanced configuration tasks for your Alpine Linux.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The tutorials are hands-on&#039;&#039;&#039; and the reader is expected to try and achieve the goals described in each step, possibly with the help of a good example. The output in one step is the starting point for the following step.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Howtos are smaller articles&#039;&#039;&#039; explaining how to perform a particular task with Alpine Linux, that expects a minimal knowledge from reader to perform actions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; contributions on those pages must be complete articles as well as requesting topics to be covered, don&#039;t override already made contributions. If you want to request a topic, please add your request in this page&#039;s [[Talk:Tutorials_and_Howtos|Discussion]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Clear}}&lt;br /&gt;
&lt;br /&gt;
= Howtos =&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
&lt;br /&gt;
=== Miscellaneous ===&lt;br /&gt;
&lt;br /&gt;
* [[Ansible]] &#039;&#039;(Configuration management)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Monitoring ===&lt;br /&gt;
&lt;br /&gt;
* [[Awstats]] &#039;&#039;(Free log file analyzer)&#039;&#039;&lt;br /&gt;
* [[Cacti: traffic analysis and monitoring network]] &#039;&#039;(Front-end for rrdtool networking monitor)&#039;&#039;&lt;br /&gt;
* [[Cvechecker]] &#039;&#039;(Compare installed packages for Common Vulnerabilities Exposure)&#039;&#039; &amp;lt;!-- Monitoring and Security --&amp;gt;&lt;br /&gt;
* [[Linfo]]&lt;br /&gt;
* [[Obtaining user information via SNMP]] &#039;&#039;(Using squark-auth-snmp as a Squid authentication helper)&#039;&#039; &amp;lt;!-- Networking and Server, &amp;lt;== Using squark-auth-snmp --&amp;gt;&lt;br /&gt;
* [[PhpSysInfo]] &#039;&#039;(A simple application that displays information about the host it&#039;s running on)&#039;&#039;&lt;br /&gt;
* [[Matomo]] &#039;&#039;(A real time web analytics software program)&#039;&#039;&lt;br /&gt;
* [[Setting up A Network Monitoring and Inventory System]] &#039;&#039;(Nagios + OpenAudit and related components)&#039;&#039; &amp;lt;!-- draft, solution, Networking and Monitoring and Server --&amp;gt;&lt;br /&gt;
** [[Setting up NRPE daemon]] &#039;&#039;(Performs remote Nagios checks)&#039;&#039; &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Setting Up Fprobe And Ntop|Ntop]] &#039;&#039;(NetFlow collection and analysis using a remote fprobe instance; for alpine 3.10-3.12 only)&#039;&#039; &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Setting up lm_sensors]]&lt;br /&gt;
* [[SqStat]] &#039;&#039;(Script to look at active squid users connections)&#039;&#039;&lt;br /&gt;
* [[Traffic monitoring]] &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
** [[Setting up monitoring using rrdtool (and rrdcollect)]]&lt;br /&gt;
** [[Setting up traffic monitoring using rrdtool (and snmp)]] &amp;lt;!-- Monitoring --&amp;gt;&lt;br /&gt;
* [[Zabbix|Zabbix - the professional complete manager]] &#039;&#039;(Monitor and track the status of network services and hardware)&#039;&#039;&lt;br /&gt;
* [[ZoneMinder video camera security and surveillance]]&lt;br /&gt;
&lt;br /&gt;
=== Networking ===&lt;br /&gt;
&lt;br /&gt;
* Alpine Wall &#039;&#039;(a new firewall management framework)&#039;&#039;&lt;br /&gt;
** [[Alpine Wall]]&lt;br /&gt;
** [https://git.alpinelinux.org/awall/about/ Alpine Wall User&#039;s Guide]&lt;br /&gt;
** [[How-To Alpine Wall]]&lt;br /&gt;
* [[Freeradius Active Directory Integration]]&lt;br /&gt;
* [[GNUnet]]&lt;br /&gt;
* [[Setting up a OpenVPN server|OpenVPN server]] &#039;&#039;(Allowing single users or devices to remotely connect to your network)&#039;&#039;&lt;br /&gt;
* [[OpenVSwitch]]&lt;br /&gt;
* [[Using Alpine on Windows domain with IPSEC isolation]]&lt;br /&gt;
* [[Configure a Wireguard interface (wg)|Wireguard]]&lt;br /&gt;
&lt;br /&gt;
=== Telephony ===&lt;br /&gt;
&lt;br /&gt;
* [[FreePBX|FreePBX on Alpine Linux]]&lt;br /&gt;
* [[Setting up Zaptel/Asterisk on Alpine]]&lt;br /&gt;
* [[Kamailio]] &#039;&#039;(SIP Server, formerly OpenSER)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Backup and data migration ==&lt;br /&gt;
&lt;br /&gt;
* [[Alpine local backup|Alpine local backup (lbu)]] &#039;&#039;(Permanently store your modifications in case your box needs reboot)&#039;&#039;&lt;br /&gt;
** [[Back Up a Flash Memory Installation]]&lt;br /&gt;
** [[Manually editing a existing apkovl]]&lt;br /&gt;
* [[Migrating data]]&lt;br /&gt;
* [[Rsnapshot]] - setting up periodic backups&lt;br /&gt;
&lt;br /&gt;
== Desktop ==&lt;br /&gt;
* [[Daily driver guide]]&lt;br /&gt;
* [[Alpine and UEFI]]&lt;br /&gt;
* [[Default applications]]&lt;br /&gt;
* Desktop cloud&lt;br /&gt;
** [[Nextcloud]] &#039;&#039;(Self hostable cloud suite - Dropbox Alternative)&#039;&#039;&lt;br /&gt;
* [[Desktop environments and Window managers]] (overall information only)&lt;br /&gt;
* [[Gaming on Alpine]]&lt;br /&gt;
* [[Printer Setup]]&lt;br /&gt;
* [[Remote Desktop Server]]&lt;br /&gt;
* Sound Systems&lt;br /&gt;
** [[ALSA]]&lt;br /&gt;
** [[PipeWire]]&lt;br /&gt;
** [[PulseAudio]]&lt;br /&gt;
&lt;br /&gt;
== Power management ==&lt;br /&gt;
&lt;br /&gt;
* [[Configure action when power-button is pressed]]&lt;br /&gt;
* [[Suspend on LID close]]&lt;br /&gt;
* [[Configure Wake-on-LAN]]&lt;br /&gt;
&lt;br /&gt;
== Networking ==&lt;br /&gt;
&lt;br /&gt;
* [[Bluetooth]] - Instructions for installing and configuring Bluetooth&lt;br /&gt;
* [[Bonding]] - Bond (or aggregate) multiple ethernet interfaces&lt;br /&gt;
* [[Bridge]] - Configuring a network bridge&lt;br /&gt;
** [[Bridge wlan0 to eth0]]&lt;br /&gt;
* [[Configure Networking]]&lt;br /&gt;
* [[How to configure static routes]]&lt;br /&gt;
* Modem&lt;br /&gt;
** [[Using HSDPA modem]]&lt;br /&gt;
** [[Using serial modem]]&lt;br /&gt;
* [[mDNS]] - Howto implement multicast DNS resolution in Alpine. &lt;br /&gt;
* [[Multi ISP]] &#039;&#039;(Dual-ISP setup with load-balancing and automatic failover)&#039;&#039;&lt;br /&gt;
* [[PXE boot]]&lt;br /&gt;
* Wi-Fi&lt;br /&gt;
** [[Wi-Fi|Connecting to a wireless access point]]&lt;br /&gt;
** [[How to setup a wireless access point]] &#039;&#039;(Setting up Secure Wireless AP w/ WPA encryption with bridge to wired network)&#039;&#039;&lt;br /&gt;
* [[VLAN]]&lt;br /&gt;
&lt;br /&gt;
== Other Architectures ==&lt;br /&gt;
&lt;br /&gt;
=== ARM ===&lt;br /&gt;
&lt;br /&gt;
* [[Alpine on ARM]]&lt;br /&gt;
&lt;br /&gt;
==== Raspberry Pi ====&lt;br /&gt;
&lt;br /&gt;
* [[Raspberry Pi Bluetooth Speaker|Raspberry Pi - Bluetooth Speaker]]&lt;br /&gt;
* [[Raspberry Pi|Raspberry Pi - Installation]]&lt;br /&gt;
* [[Linux Router with VPN on a Raspberry Pi|Raspberry Pi - Router with VPN]]&lt;br /&gt;
* [[Linux Router with VPN on a Raspberry Pi (IPv6)|Raspberry Pi - Router with VPN (IPv6)]]&lt;br /&gt;
* [[Classic install or sys mode on Raspberry Pi|Raspberry Pi - Sys mode install]]&lt;br /&gt;
* [[Raspberry Pi LVM on LUKS|Raspberry Pi - Sys mode install - LVM on LUKS]]&lt;br /&gt;
* [[RPI Video Receiver|Raspberry Pi - Video Receiver]] &#039;&#039;(network video decoder using Rasperry Pi and omxplayer)&#039;&#039;&lt;br /&gt;
* [[Raspberry Pi 3 - Browser Client]] - kiosk or digital sign&lt;br /&gt;
* [[Raspberry Pi 3 - Configuring it as wireless access point -AP Mode]]&lt;br /&gt;
* [[Raspberry Pi 3 - Setting Up Bluetooth]]&lt;br /&gt;
* [[Raspberry Pi 4 - Persistent system acting as a NAS and Time Machine]]&lt;br /&gt;
* [[How to set up Alpine as a wireless router|Raspberry Pi Zero W - Wireless router]] &#039;&#039;(Setting up a firewalled, Wireless AP with wired network on a Pi Zero W)&#039;&#039;&lt;br /&gt;
* [[RPI Video Receiver]]&lt;br /&gt;
&lt;br /&gt;
=== IBM Z (IBM z Systems) ===&lt;br /&gt;
&lt;br /&gt;
* [[s390x|s390x - Installation]]&lt;br /&gt;
&lt;br /&gt;
=== PowerPC ===&lt;br /&gt;
&lt;br /&gt;
* [[Ppc64le|Powerpc64le - Installation]]&lt;br /&gt;
&lt;br /&gt;
== Post-Install ==&lt;br /&gt;
&lt;br /&gt;
* [[CPU frequency scaling]]&lt;br /&gt;
* [[Repositories#Enabling_the_community_repository|Enable Community repository]] &#039;&#039;(Providing additional packages)&#039;&#039;&lt;br /&gt;
* [[Enable Serial Console on Boot]]&lt;br /&gt;
* [[Alpine Linux Init System|Init System (OpenRC)]] &#039;&#039;(Configure a service to automatically boot at next reboot)&#039;&#039;&lt;br /&gt;
** [[Multiple Instances of Services|Init System - Multiple Instances of Services]]&lt;br /&gt;
** [[Writing Init Scripts|Init System - Writing Init Scripts]]&lt;br /&gt;
* [[Installing Oracle Java|Oracle Java (installation)]]&lt;br /&gt;
* [[IGMPproxy]]&lt;br /&gt;
* [[Alpine Package Keeper|Package Management (apk)]] &#039;&#039;(How to add/remove packages on your Alpine)&#039;&#039;&lt;br /&gt;
** [[Comparison with other distros|Package Management - Comparison with other distros]]&lt;br /&gt;
* [[Running glibc programs]]&lt;br /&gt;
* [[Setting up a new user]]&lt;br /&gt;
* [[Upgrading Alpine]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Remote Administration ==&lt;br /&gt;
&lt;br /&gt;
* ACF&lt;br /&gt;
** [[Changing passwords for ACF|ACF - changing passwords]]&lt;br /&gt;
** [[Generating SSL certs with ACF]] &amp;lt;!-- Generating SSL certs with ACF 1.9 --&amp;gt;&lt;br /&gt;
** [[setup-acf| ACF - setup]] &#039;&#039;(Configures ACF (webconfiguration/webmin) so you can manage your box through https)&#039;&#039;&lt;br /&gt;
* [[Setting up a SSH server]] &#039;&#039;(Using ssh is a good way to administer your box remotely)&#039;&#039;&lt;br /&gt;
** [[HOWTO OpenSSH 2FA with password and Google Authenticator |OpenSSH 2FA]] &#039;&#039;(A simple two factor setup for OpenSSH)&#039;&#039;&lt;br /&gt;
* [[OpenVCP]] &#039;&#039;(VServer Control Panel)&#039;&#039;&lt;br /&gt;
* [[PhpMyAdmin]] &#039;&#039;(Web-based administration tool for MYSQL)&#039;&#039;&lt;br /&gt;
* [[PhpPgAdmin]] &#039;&#039;(Web-based administration tool for PostgreSQL)&#039;&#039;&lt;br /&gt;
* [[Webmin]] &#039;&#039;(A web-based interface for Linux system)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Server ==&lt;br /&gt;
&lt;br /&gt;
* [[Hosting services on Alpine]] &#039;&#039;(Hosting mail, webservices and other services)&#039;&#039;&lt;br /&gt;
* [[Hosting Web/Email services on Alpine]]&lt;br /&gt;
&lt;br /&gt;
=== DNS ===&lt;br /&gt;
&lt;br /&gt;
* [[DNSCrypt-Proxy]] &#039;&#039;Encrypt and authenticate DNS calls from your system&#039;&#039;&lt;br /&gt;
* [[Setting up nsd DNS server]]&lt;br /&gt;
* [[Setting up unbound DNS server]]&lt;br /&gt;
* [[TinyDNS Format]]&lt;br /&gt;
&lt;br /&gt;
=== HTTP ===&lt;br /&gt;
&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
** [[Apache with php-fpm]]&lt;br /&gt;
** [[Setting Up Apache with PHP]]&lt;br /&gt;
** [[Apache authentication: NTLM Single Signon]]&lt;br /&gt;
* [[Darkhttpd]]&lt;br /&gt;
* [[Lighttpd]]&lt;br /&gt;
** [[Lighttpd Advanced security]]&lt;br /&gt;
** [[Setting Up Lighttpd With FastCGI]]&lt;br /&gt;
* [[Nginx]]&lt;br /&gt;
** [[Nginx as reverse proxy with acme (letsencrypt)]]&lt;br /&gt;
** [[Nginx with PHP]]&lt;br /&gt;
* Squid Proxy&lt;br /&gt;
** [[Obtaining user information via SNMP]] &#039;&#039;(Using squark-auth-snmp as a Squid authentication helper)&#039;&#039; &amp;lt;!-- Networking and Server, &amp;lt;== Using squark-auth-snmp --&amp;gt;&lt;br /&gt;
** [[Setting up Explicit Squid Proxy]]&lt;br /&gt;
** [[Setting up Transparent Squid Proxy]] &#039;&#039;(Covers Squid proxy and URL Filtering system)&#039;&#039;&lt;br /&gt;
** [[SqStat]] &#039;&#039;(Script to look at active squid users connections)&#039;&#039;&lt;br /&gt;
* [[Tomcat]]&lt;br /&gt;
&lt;br /&gt;
==== Hostable Content ====&lt;br /&gt;
&lt;br /&gt;
* [[DokuWiki]]&lt;br /&gt;
* [[Drupal]] &#039;&#039;(Content Management System (CMS) written in PHP)&#039;&#039;&lt;br /&gt;
* [[Kopano]] &#039;&#039;(Microsoft Outlook compatible Groupware)&#039;&#039;&lt;br /&gt;
* [[Mahara]] &#039;&#039;(E-portfolio and social networking system)&#039;&#039;&lt;br /&gt;
* [[MediaWiki]] &#039;&#039;(Free web-based wiki software application)&#039;&#039;&lt;br /&gt;
* [[Pastebin]] &#039;&#039;(Pastebin software application)&#039;&#039;&lt;br /&gt;
* [[WordPress]] &#039;&#039;(Web software to create website or blog)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== IRC ===&lt;br /&gt;
&lt;br /&gt;
* [[NgIRCd]] &#039;&#039;(Server for Internet Relay Chat/IRC)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Mail ===&lt;br /&gt;
&lt;br /&gt;
* Exim/Dovecot&lt;br /&gt;
** [[Small-Time Email with Exim and Dovecot]] &#039;&#039;(A simple configuration for your home network.)&lt;br /&gt;
** [[Setting up dovecot with imap and tls]]&lt;br /&gt;
* [[relay email to gmail (msmtp, mailx, sendmail]]&lt;br /&gt;
* [[Roundcube]] &#039;&#039;(Webmail system)&#039;&#039;&lt;br /&gt;
* [[Setting up postfix with virtual domains]]&lt;br /&gt;
* Server protection&lt;br /&gt;
** [[Setting up clamsmtp]]&lt;br /&gt;
&lt;br /&gt;
=== Other Servers ===&lt;br /&gt;
&lt;br /&gt;
* [[apcupsd]] &#039;&#039;(UPS Monitoring with apcupsd)&#039;&#039;&lt;br /&gt;
* [[Chrony and GPSD | Chrony, gpsd, and a garmin LVC 18 as a Stratum 1 NTP source ]]&lt;br /&gt;
* [[Glpi]] &#039;&#039;(Manage inventory of technical resources)&#039;&#039;&lt;br /&gt;
* [[How to setup a Alpine Linux mirror]]&lt;br /&gt;
* [[Setting up an NFS server|nfs-server]]&lt;br /&gt;
* [[nut-ups|NUT UPS]] &#039;&#039;(UPS Monitoring with Network UPS Tools)&#039;&#039;&lt;br /&gt;
* [[Odoo]]&lt;br /&gt;
* [[Configure OpenLDAP | OpenLDAP]] &#039;&#039;(Installing and configuring the Alpine package for OpenLDAP)&#039;&#039;&lt;br /&gt;
* [[Setting up a LLDAP server|lldap-server]] &#039;&#039;(Directory Server)&#039;&#039;&lt;br /&gt;
* [[Setting up a samba-ad-dc|samba-ad-dc]] &#039;&#039;(Active Directory compatible domain controller)&#039;&#039;&lt;br /&gt;
* [[Setting up a Samba server|samba-server]] &#039;&#039;(standard file sharing)&#039;&#039;&lt;br /&gt;
* [[Setting up Transmission (bittorrent) with Clutch WebUI]]&lt;br /&gt;
&lt;br /&gt;
=== Software development ===&lt;br /&gt;
&lt;br /&gt;
* [[Cgit]]&lt;br /&gt;
* [[OsTicket]] &#039;&#039;(Ticket system)&#039;&#039;&lt;br /&gt;
* [[Patchwork]] &#039;&#039;(Patch review management system)&#039;&#039;&lt;br /&gt;
* [[Redmine]] &#039;&#039;(Project management system)&#039;&#039;&lt;br /&gt;
* [[Request Tracker]] &#039;&#039;(Ticket system)&#039;&#039;&lt;br /&gt;
* [[Setting up trac wiki|Trac]] &#039;&#039;(Enhanced wiki and issue tracking system for software development projects)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Storage ==&lt;br /&gt;
&lt;br /&gt;
* [[Setting up disks manually|Manual partitioning]]&lt;br /&gt;
* [[Disk Replication with DRBD|DRBD: Disk Replication]]&lt;br /&gt;
* [[Filesystems]]&lt;br /&gt;
** [[Burning ISOs]]&lt;br /&gt;
* [[Setting up iSCSI|iSCSI Setup]]&lt;br /&gt;
** [[iSCSI Raid and Clustered File Systems]]&lt;br /&gt;
** [[Linux iSCSI Target (TCM)|iSCSI Target (TCM)/LinuxIO (LIO)]]&lt;br /&gt;
** [[Linux iSCSI Target (tgt)|User space iSCSI Target (tgt)]]&lt;br /&gt;
* [[Setting up Logical Volumes with LVM|LVM Setup]]&lt;br /&gt;
** [[Setting up LVM on GPT-labeled disks|LVM on GPT-labeled disks]]&lt;br /&gt;
** [[Installing on GPT LVM|LVM on GPT-labeled disks (updated)]]&lt;br /&gt;
** [[LVM on LUKS]]&lt;br /&gt;
* RAID&lt;br /&gt;
** [[Raid Administration]]&lt;br /&gt;
** [[Setting up a software RAID array]]&lt;br /&gt;
* ZFS&lt;br /&gt;
** [[Root on ZFS with native encryption]]&lt;br /&gt;
** [[Setting up ZFS on LUKS]]&lt;br /&gt;
** [[Setting up ZFS with native encryption]]&lt;br /&gt;
** [[ZFS scrub and trim]]&lt;br /&gt;
* [[CEPH|CEPH]]&lt;br /&gt;
&lt;br /&gt;
== Virtualization ==&lt;br /&gt;
&lt;br /&gt;
* [[Docker]]&lt;br /&gt;
* [[Installing Alpine in a virtual machine]]&lt;br /&gt;
** [[Install Alpine on VMware ESXi]]&lt;br /&gt;
* [[KVM]] &#039;&#039;(Setting up Alpine as a KVM hypervisor)&#039;&#039;&lt;br /&gt;
* [[LXC]] &#039;&#039;(Setting up a Linux container in Alpine Linux)&#039;&#039;&lt;br /&gt;
* [[QEMU]]&lt;br /&gt;
* Xen&lt;br /&gt;
** [[Xen Dom0]] &#039;&#039;(Setting up Alpine as a dom0 for Xen hypervisor)&#039;&#039;&lt;br /&gt;
** [[Xen Dom0 on USB or SD]]&lt;br /&gt;
** [[Create Alpine Linux PV DomU|Xen DomU (paravirtualized)]]&lt;br /&gt;
** [[Xen LiveCD]]&lt;br /&gt;
** [[Xen PCI Passthrough]]&lt;br /&gt;
&lt;br /&gt;
= Tutorials =&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [[TTY_Autologin|TTY Autologin]]&lt;br /&gt;
* [[Kexec|Faster rebooting with kexec]]&lt;br /&gt;
* [[Dynamic Multipoint VPN (DMVPN)]] combined with [[Small Office Services]]&lt;br /&gt;
* [[DIY Fully working Alpine Linux for Allwinner and Other ARM SOCs]]&lt;br /&gt;
* [[Fault Tolerant Routing with Alpine Linux]]&lt;br /&gt;
* [[High Availability High Performance Web Cache]] &#039;&#039;(uCarp + HAProxy for High Availability Services such as Squid web proxy)&#039;&#039;&lt;br /&gt;
* [[Linux iSCSI Target (TCM)]]&lt;br /&gt;
* [[ISP Mail Server 3.x HowTo]]] &#039;&#039;(Postfix+PostfixAdmin+DoveCot+Roundcube+ClamAV+Spamd - A full-service ISP mail server)&#039;&#039;&lt;br /&gt;
* [[Replacing non-Alpine Linux with Alpine remotely]]&lt;br /&gt;
* [[Setting up A Network Monitoring and Inventory System]] &#039;&#039;(Nagios + OpenAudit and related components)&#039;&#039; &amp;lt;!-- draft --&amp;gt;&lt;br /&gt;
* [[Streaming Security Camera Video with VLC]]&lt;br /&gt;
* [[Install Alpine on a btrfs filesystem with refind as boot manager]]&lt;br /&gt;
&lt;br /&gt;
== Newbie corner ==&lt;br /&gt;
&lt;br /&gt;
* [[How to get regular stuff working]] &#039;&#039;some notes on need-to-know topics&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Servers ==&lt;br /&gt;
&lt;br /&gt;
* [[Alpine production deploy]]&lt;br /&gt;
** [[Production Web server: Lighttpd|Production web server: Lighttpd‎‎]]&lt;br /&gt;
** [[MySQL|Production database: MySQL]]&lt;br /&gt;
** [[Production LAMP system: Lighttpd + PHP + MySQL‎‎]]&lt;br /&gt;
* Alpine production monitoring&lt;br /&gt;
** [[Cacti: traffic analysis and monitoring network]]&lt;br /&gt;
** [[Zabbix|Zabbix - the professional complete manager]]&lt;br /&gt;
* Kubernetes&lt;br /&gt;
** [[K8s]] Building a K8s Cluster on Alpine Linux&lt;br /&gt;
&lt;br /&gt;
== Security ==&lt;br /&gt;
&lt;br /&gt;
* [[Securing Alpine Linux]] How to Secure Alpine Linux using Security Technical Implementation Guides (STIGs)&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27531</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27531"/>
		<updated>2024-10-12T12:45:57Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Todo|The udev configuration presented here does not work consistently. A recent update and/or reboot has caused the libusb &#039;&#039;insufficient permissions on everything&#039;&#039; message to reappear. Even explicitly setting group ownership and permissions does not fix the problem.}}&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0123456789&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will rename the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
* The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
* The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS, and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
* Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong ownership and permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for giving NUT access to the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from &#039;&#039;&#039;dmesg&#039;&#039;&#039; should tip you off as to which directory and file it is. Look at the line below from &#039;&#039;&#039;dmesg&#039;&#039;&#039; and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of &#039;&#039;/dev/bus/usb/001/003&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do useful things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27530</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27530"/>
		<updated>2024-10-12T12:45:29Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Todo|The udev configuration presented here does not work consistently. A recent update and/or reboot has caused the libusb &#039;&#039;insufficient permissions on everything&#039;&#039; message to reappear. Even explicitly setting group ownership and permissions does fix the problem.}}&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0123456789&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will rename the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
* The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
* The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS, and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
* Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong ownership and permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for giving NUT access to the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from &#039;&#039;&#039;dmesg&#039;&#039;&#039; should tip you off as to which directory and file it is. Look at the line below from &#039;&#039;&#039;dmesg&#039;&#039;&#039; and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of &#039;&#039;/dev/bus/usb/001/003&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do useful things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27514</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27514"/>
		<updated>2024-10-10T13:54:36Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0123456789&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will rename the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
* The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
* The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS, and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
* Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong ownership and permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for giving NUT access to the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from &#039;&#039;&#039;dmesg&#039;&#039;&#039; should tip you off as to which directory and file it is. Look at the line below from &#039;&#039;&#039;dmesg&#039;&#039;&#039; and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of &#039;&#039;/dev/bus/usb/001/003&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do useful things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27513</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27513"/>
		<updated>2024-10-10T13:52:32Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0123456789&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will rename the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS, and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong ownership and permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for giving NUT access to the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from &#039;&#039;&#039;dmesg&#039;&#039;&#039; should tip you off as to which directory and file it is. Look at the line below from &#039;&#039;&#039;dmesg&#039;&#039;&#039; and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of &#039;&#039;/dev/bus/usb/001/003&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do useful things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27503</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27503"/>
		<updated>2024-10-10T02:43:33Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0123456789&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will create a backup copy of the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS, and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong ownership and permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for giving NUT access to the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from &#039;&#039;&#039;dmesg&#039;&#039;&#039; should tip you off as to which directory and file it is. Look at the line below from &#039;&#039;&#039;dmesg&#039;&#039;&#039; and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of &#039;&#039;/dev/bus/usb/001/003&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do useful things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27502</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27502"/>
		<updated>2024-10-10T02:41:44Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0123456789&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will create a backup copy of the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong ownership and permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for giving NUT access to the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from &#039;&#039;&#039;dmesg&#039;&#039;&#039; should tip you off as to which directory and file it is. Look at the line below from &#039;&#039;&#039;dmesg&#039;&#039;&#039; and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of &#039;&#039;/dev/bus/usb/001/003&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do useful things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27501</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27501"/>
		<updated>2024-10-10T01:30:41Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0235210142&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will create a backup copy of the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong ownership and permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for giving NUT access to the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from &#039;&#039;&#039;dmesg&#039;&#039;&#039; should tip you off as to which directory and file it is. Look at the line below from &#039;&#039;&#039;dmesg&#039;&#039;&#039; and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of &#039;&#039;/dev/bus/usb/001/003&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do useful things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27500</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27500"/>
		<updated>2024-10-10T01:28:17Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0235210142&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will create a backup copy of the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong ownership and permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for giving NUT access to the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from &#039;&#039;&#039;dmesg&#039;&#039;&#039; should tip you off as to which directory and file it is. Look at the line below from &#039;&#039;&#039;dmesg&#039;&#039;&#039; and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of &#039;&#039;/dev/bus/usb/001/003&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27499</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27499"/>
		<updated>2024-10-10T01:26:19Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0235210142&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will create a backup copy of the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from &#039;&#039;&#039;dmesg&#039;&#039;&#039; should tip you off as to which directory and file it is. Look at the line below from &#039;&#039;&#039;dmesg&#039;&#039;&#039; and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of &#039;&#039;/dev/bus/usb/001/003&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27498</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27498"/>
		<updated>2024-10-10T01:21:59Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0235210142&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will create a backup copy of the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27497</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27497"/>
		<updated>2024-10-10T01:20:14Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0235210142&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will create a backup copy of the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Thee are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27496</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27496"/>
		<updated>2024-10-10T01:18:40Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0235210142&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will create a backup copy of the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can also enter the network address of a specific interface if 0.0.0.0 (all interfaces) is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Thee are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27495</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27495"/>
		<updated>2024-10-10T01:15:23Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0235210142&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will create a backup copy of the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. All USB attached UPSs should act the same.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can also enter the network address of a specific interface if 0.0.0.0 (all interfaces) is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Thee are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27494</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27494"/>
		<updated>2024-10-10T01:13:59Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. This is done with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0235210142&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will create a backup copy of the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. All USB attached UPSs should act the same.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can also enter the network address of a specific interface if 0.0.0.0 (all interfaces) is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Thee are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27493</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27493"/>
		<updated>2024-10-10T01:12:43Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[WORK IN PROGRESS]&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like Home Assistant.&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. This is done with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0235210142&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will create a backup copy of the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. All USB attached UPSs should act the same.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can also enter the network address of a specific interface if 0.0.0.0 (all interfaces) is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Thee are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27492</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27492"/>
		<updated>2024-10-10T00:46:07Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[WORK IN PROGRESS]&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like Home Assistant.&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. This is done with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0235210142&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will create a backup copy of the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. All USB attached UPSs should act the same.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can also enter the network address of a specific interface if 0.0.0.0 (all interfaces) is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
If you were to try starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Thee are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27491</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27491"/>
		<updated>2024-10-10T00:40:24Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[WORK IN PROGRESS]&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like Home Assistant.&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. This is done with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0235210142&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will create a backup copy of the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. All USB attached UPSs should act the same.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can also enter the network address of a specific interface if 0.0.0.0 (all interfaces) is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
If you were to try starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Thee are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27490</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27490"/>
		<updated>2024-10-09T23:31:48Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[WORK IN PROGRESS]&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. This is done with the `dmesg` command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0235210142&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the /etc/nut subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will create a backup copy of the original configuration file and then write a new file with only the configuration needed.&lt;br /&gt;
&lt;br /&gt;
The line written to nut.conf instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in ups.conf define the name (in square brackets), the driver used to communicate with the UPS and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. All USB attached UPSs should act the same.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in upsd.conf is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can also enter the network address of a specific interface if 0.0.0.0 (all interfaces) is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
If you were to try starting the nut-upsd service at this point, it would complain loudly.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27489</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27489"/>
		<updated>2024-10-09T23:29:54Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[WORK IN PROGRESS]&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. This is done with the `dmesg` command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0235210142&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv upsd.conf upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the /etc/nut subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will create a backup copy of the original configuration file and then write a new file with only the configuration needed.&lt;br /&gt;
&lt;br /&gt;
The line written to nut.conf instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
The lines in ups.conf define the name (in square brackets), the driver used to communicate with the UPS and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. All USB attached UPSs should act the same.&lt;br /&gt;
&lt;br /&gt;
Finally, the line in upsd.conf is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can also enter the network address of a specific interface if 0.0.0.0 (all interfaces) is not appropriate for your situation.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27488</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27488"/>
		<updated>2024-10-09T23:00:32Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[WORK IN PROGRESS]&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. This is done with the `dmesg` command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 dmesg&lt;br /&gt;
 &lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0235210142&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27487</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=27487"/>
		<updated>2024-10-09T22:51:02Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: Created page with &amp;quot;[WORK IN PROGRESS]  == Installing and Configuring Network UPS Tools (NUT) ==  This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[WORK IN PROGRESS]&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Tutorials_and_Howtos&amp;diff=27486</id>
		<title>Tutorials and Howtos</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Tutorials_and_Howtos&amp;diff=27486"/>
		<updated>2024-10-09T22:46:09Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Other Servers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Todo|This material has been re-organized..., but grouping should be checked: &#039;&#039;&#039;Howtos are smaller articles&#039;&#039;&#039; and &#039;&#039;&#039;tutorials are more detailed document&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
[[Image:package_edutainment.svg|right|link=]]&lt;br /&gt;
{{TOC left}}&lt;br /&gt;
&#039;&#039;&#039;Welcome to Tutorials and Howtos, a place of basic and advanced configuration tasks for your Alpine Linux.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The tutorials are hands-on&#039;&#039;&#039; and the reader is expected to try and achieve the goals described in each step, possibly with the help of a good example. The output in one step is the starting point for the following step.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Howtos are smaller articles&#039;&#039;&#039; explaining how to perform a particular task with Alpine Linux, that expects a minimal knowledge from reader to perform actions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; contributions on those pages must be complete articles as well as requesting topics to be covered, don&#039;t override already made contributions. If you want to request a topic, please add your request in this page&#039;s [[Talk:Tutorials_and_Howtos|Discussion]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Clear}}&lt;br /&gt;
&lt;br /&gt;
= Howtos =&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
&lt;br /&gt;
=== Miscellaneous ===&lt;br /&gt;
&lt;br /&gt;
* [[Ansible]] &#039;&#039;(Configuration management)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Monitoring ===&lt;br /&gt;
&lt;br /&gt;
* [[Awstats]] &#039;&#039;(Free log file analyzer)&#039;&#039;&lt;br /&gt;
* [[Cacti: traffic analysis and monitoring network]] &#039;&#039;(Front-end for rrdtool networking monitor)&#039;&#039;&lt;br /&gt;
* [[Cvechecker]] &#039;&#039;(Compare installed packages for Common Vulnerabilities Exposure)&#039;&#039; &amp;lt;!-- Monitoring and Security --&amp;gt;&lt;br /&gt;
* [[Linfo]]&lt;br /&gt;
* [[Obtaining user information via SNMP]] &#039;&#039;(Using squark-auth-snmp as a Squid authentication helper)&#039;&#039; &amp;lt;!-- Networking and Server, &amp;lt;== Using squark-auth-snmp --&amp;gt;&lt;br /&gt;
* [[PhpSysInfo]] &#039;&#039;(A simple application that displays information about the host it&#039;s running on)&#039;&#039;&lt;br /&gt;
* [[Matomo]] &#039;&#039;(A real time web analytics software program)&#039;&#039;&lt;br /&gt;
* [[Setting up A Network Monitoring and Inventory System]] &#039;&#039;(Nagios + OpenAudit and related components)&#039;&#039; &amp;lt;!-- draft, solution, Networking and Monitoring and Server --&amp;gt;&lt;br /&gt;
** [[Setting up NRPE daemon]] &#039;&#039;(Performs remote Nagios checks)&#039;&#039; &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Setting Up Fprobe And Ntop|Ntop]] &#039;&#039;(NetFlow collection and analysis using a remote fprobe instance; for alpine 3.10-3.12 only)&#039;&#039; &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Setting up lm_sensors]]&lt;br /&gt;
* [[SqStat]] &#039;&#039;(Script to look at active squid users connections)&#039;&#039;&lt;br /&gt;
* [[Traffic monitoring]] &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
** [[Setting up monitoring using rrdtool (and rrdcollect)]]&lt;br /&gt;
** [[Setting up traffic monitoring using rrdtool (and snmp)]] &amp;lt;!-- Monitoring --&amp;gt;&lt;br /&gt;
* [[Zabbix|Zabbix - the professional complete manager]] &#039;&#039;(Monitor and track the status of network services and hardware)&#039;&#039;&lt;br /&gt;
* [[ZoneMinder video camera security and surveillance]]&lt;br /&gt;
&lt;br /&gt;
=== Networking ===&lt;br /&gt;
&lt;br /&gt;
* Alpine Wall &#039;&#039;(a new firewall management framework)&#039;&#039;&lt;br /&gt;
** [[Alpine Wall]]&lt;br /&gt;
** [https://git.alpinelinux.org/awall/about/ Alpine Wall User&#039;s Guide]&lt;br /&gt;
** [[How-To Alpine Wall]]&lt;br /&gt;
* [[Freeradius Active Directory Integration]]&lt;br /&gt;
* [[GNUnet]]&lt;br /&gt;
* [[Setting up a OpenVPN server|OpenVPN server]] &#039;&#039;(Allowing single users or devices to remotely connect to your network)&#039;&#039;&lt;br /&gt;
* [[OpenVSwitch]]&lt;br /&gt;
* [[Using Alpine on Windows domain with IPSEC isolation]]&lt;br /&gt;
* [[Configure a Wireguard interface (wg)|Wireguard]]&lt;br /&gt;
&lt;br /&gt;
=== Telephony ===&lt;br /&gt;
&lt;br /&gt;
* [[FreePBX|FreePBX on Alpine Linux]]&lt;br /&gt;
* [[Setting up Zaptel/Asterisk on Alpine]]&lt;br /&gt;
* [[Kamailio]] &#039;&#039;(SIP Server, formerly OpenSER)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Backup and data migration ==&lt;br /&gt;
&lt;br /&gt;
* [[Alpine local backup|Alpine local backup (lbu)]] &#039;&#039;(Permanently store your modifications in case your box needs reboot)&#039;&#039;&lt;br /&gt;
** [[Back Up a Flash Memory Installation]]&lt;br /&gt;
** [[Manually editing a existing apkovl]]&lt;br /&gt;
* [[Migrating data]]&lt;br /&gt;
* [[Rsnapshot]] - setting up periodic backups&lt;br /&gt;
&lt;br /&gt;
== Desktop ==&lt;br /&gt;
* [[Daily driver guide]]&lt;br /&gt;
* [[Alpine and UEFI]]&lt;br /&gt;
* [[Default applications]]&lt;br /&gt;
* Desktop cloud&lt;br /&gt;
** [[Nextcloud]] &#039;&#039;(Self hostable cloud suite - Dropbox Alternative)&#039;&#039;&lt;br /&gt;
* [[Desktop environments and Window managers]] (overall information only)&lt;br /&gt;
* [[Gaming on Alpine]]&lt;br /&gt;
* [[Printer Setup]]&lt;br /&gt;
* [[Remote Desktop Server]]&lt;br /&gt;
* Sound Systems&lt;br /&gt;
** [[ALSA]]&lt;br /&gt;
** [[PipeWire]]&lt;br /&gt;
** [[PulseAudio]]&lt;br /&gt;
&lt;br /&gt;
== Power management ==&lt;br /&gt;
&lt;br /&gt;
* [[Configure action when power-button is pressed]]&lt;br /&gt;
* [[Suspend on LID close]]&lt;br /&gt;
* [[Configure Wake-on-LAN]]&lt;br /&gt;
&lt;br /&gt;
== Networking ==&lt;br /&gt;
&lt;br /&gt;
* [[Bluetooth]] - Instructions for installing and configuring Bluetooth&lt;br /&gt;
* [[Bonding]] - Bond (or aggregate) multiple ethernet interfaces&lt;br /&gt;
* [[Bridge]] - Configuring a network bridge&lt;br /&gt;
** [[Bridge wlan0 to eth0]]&lt;br /&gt;
* [[Configure Networking]]&lt;br /&gt;
* [[How to configure static routes]]&lt;br /&gt;
* Modem&lt;br /&gt;
** [[Using HSDPA modem]]&lt;br /&gt;
** [[Using serial modem]]&lt;br /&gt;
* [[mDNS]] - Howto implement multicast DNS resolution in Alpine. &lt;br /&gt;
* [[Multi ISP]] &#039;&#039;(Dual-ISP setup with load-balancing and automatic failover)&#039;&#039;&lt;br /&gt;
* [[PXE boot]]&lt;br /&gt;
* Wi-Fi&lt;br /&gt;
** [[Wi-Fi|Connecting to a wireless access point]]&lt;br /&gt;
** [[How to setup a wireless access point]] &#039;&#039;(Setting up Secure Wireless AP w/ WPA encryption with bridge to wired network)&#039;&#039;&lt;br /&gt;
* [[VLAN]]&lt;br /&gt;
&lt;br /&gt;
== Other Architectures ==&lt;br /&gt;
&lt;br /&gt;
=== ARM ===&lt;br /&gt;
&lt;br /&gt;
* [[Alpine on ARM]]&lt;br /&gt;
&lt;br /&gt;
==== Raspberry Pi ====&lt;br /&gt;
&lt;br /&gt;
* [[Raspberry Pi Bluetooth Speaker|Raspberry Pi - Bluetooth Speaker]]&lt;br /&gt;
* [[Raspberry Pi|Raspberry Pi - Installation]]&lt;br /&gt;
* [[Linux Router with VPN on a Raspberry Pi|Raspberry Pi - Router with VPN]]&lt;br /&gt;
* [[Linux Router with VPN on a Raspberry Pi (IPv6)|Raspberry Pi - Router with VPN (IPv6)]]&lt;br /&gt;
* [[Classic install or sys mode on Raspberry Pi|Raspberry Pi - Sys mode install]]&lt;br /&gt;
* [[Raspberry Pi LVM on LUKS|Raspberry Pi - Sys mode install - LVM on LUKS]]&lt;br /&gt;
* [[RPI Video Receiver|Raspberry Pi - Video Receiver]] &#039;&#039;(network video decoder using Rasperry Pi and omxplayer)&#039;&#039;&lt;br /&gt;
* [[Raspberry Pi 3 - Browser Client]] - kiosk or digital sign&lt;br /&gt;
* [[Raspberry Pi 3 - Configuring it as wireless access point -AP Mode]]&lt;br /&gt;
* [[Raspberry Pi 3 - Setting Up Bluetooth]]&lt;br /&gt;
* [[Raspberry Pi 4 - Persistent system acting as a NAS and Time Machine]]&lt;br /&gt;
* [[How to set up Alpine as a wireless router|Raspberry Pi Zero W - Wireless router]] &#039;&#039;(Setting up a firewalled, Wireless AP with wired network on a Pi Zero W)&#039;&#039;&lt;br /&gt;
* [[RPI Video Receiver]]&lt;br /&gt;
&lt;br /&gt;
=== IBM Z (IBM z Systems) ===&lt;br /&gt;
&lt;br /&gt;
* [[s390x|s390x - Installation]]&lt;br /&gt;
&lt;br /&gt;
=== PowerPC ===&lt;br /&gt;
&lt;br /&gt;
* [[Ppc64le|Powerpc64le - Installation]]&lt;br /&gt;
&lt;br /&gt;
== Post-Install ==&lt;br /&gt;
&lt;br /&gt;
* [[CPU frequency scaling]]&lt;br /&gt;
* [[Repositories#Enabling_the_community_repository|Enable Community repository]] &#039;&#039;(Providing additional packages)&#039;&#039;&lt;br /&gt;
* [[Enable Serial Console on Boot]]&lt;br /&gt;
* [[Alpine Linux Init System|Init System (OpenRC)]] &#039;&#039;(Configure a service to automatically boot at next reboot)&#039;&#039;&lt;br /&gt;
** [[Multiple Instances of Services|Init System - Multiple Instances of Services]]&lt;br /&gt;
** [[Writing Init Scripts|Init System - Writing Init Scripts]]&lt;br /&gt;
* [[Installing Oracle Java|Oracle Java (installation)]]&lt;br /&gt;
* [[IGMPproxy]]&lt;br /&gt;
* [[Alpine Package Keeper|Package Management (apk)]] &#039;&#039;(How to add/remove packages on your Alpine)&#039;&#039;&lt;br /&gt;
** [[Comparison with other distros|Package Management - Comparison with other distros]]&lt;br /&gt;
* [[Running glibc programs]]&lt;br /&gt;
* [[Setting up a new user]]&lt;br /&gt;
* [[Upgrading Alpine]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Remote Administration ==&lt;br /&gt;
&lt;br /&gt;
* ACF&lt;br /&gt;
** [[Changing passwords for ACF|ACF - changing passwords]]&lt;br /&gt;
** [[Generating SSL certs with ACF]] &amp;lt;!-- Generating SSL certs with ACF 1.9 --&amp;gt;&lt;br /&gt;
** [[setup-acf| ACF - setup]] &#039;&#039;(Configures ACF (webconfiguration/webmin) so you can manage your box through https)&#039;&#039;&lt;br /&gt;
* [[Setting up a SSH server]] &#039;&#039;(Using ssh is a good way to administer your box remotely)&#039;&#039;&lt;br /&gt;
** [[HOWTO OpenSSH 2FA with password and Google Authenticator |OpenSSH 2FA]] &#039;&#039;(A simple two factor setup for OpenSSH)&#039;&#039;&lt;br /&gt;
* [[OpenVCP]] &#039;&#039;(VServer Control Panel)&#039;&#039;&lt;br /&gt;
* [[PhpMyAdmin]] &#039;&#039;(Web-based administration tool for MYSQL)&#039;&#039;&lt;br /&gt;
* [[PhpPgAdmin]] &#039;&#039;(Web-based administration tool for PostgreSQL)&#039;&#039;&lt;br /&gt;
* [[Webmin]] &#039;&#039;(A web-based interface for Linux system)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Server ==&lt;br /&gt;
&lt;br /&gt;
* [[Hosting services on Alpine]] &#039;&#039;(Hosting mail, webservices and other services)&#039;&#039;&lt;br /&gt;
* [[Hosting Web/Email services on Alpine]]&lt;br /&gt;
&lt;br /&gt;
=== DNS ===&lt;br /&gt;
&lt;br /&gt;
* [[DNSCrypt-Proxy]] &#039;&#039;Encrypt and authenticate DNS calls from your system&#039;&#039;&lt;br /&gt;
* [[Setting up nsd DNS server]]&lt;br /&gt;
* [[Setting up unbound DNS server]]&lt;br /&gt;
* [[TinyDNS Format]]&lt;br /&gt;
&lt;br /&gt;
=== HTTP ===&lt;br /&gt;
&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
** [[Apache with php-fpm]]&lt;br /&gt;
** [[Setting Up Apache with PHP]]&lt;br /&gt;
** [[Apache authentication: NTLM Single Signon]]&lt;br /&gt;
* [[Darkhttpd]]&lt;br /&gt;
* [[Lighttpd]]&lt;br /&gt;
** [[Lighttpd Advanced security]]&lt;br /&gt;
** [[Setting Up Lighttpd With FastCGI]]&lt;br /&gt;
* [[Nginx]]&lt;br /&gt;
** [[Nginx as reverse proxy with acme (letsencrypt)]]&lt;br /&gt;
** [[Nginx with PHP]]&lt;br /&gt;
* Squid Proxy&lt;br /&gt;
** [[Obtaining user information via SNMP]] &#039;&#039;(Using squark-auth-snmp as a Squid authentication helper)&#039;&#039; &amp;lt;!-- Networking and Server, &amp;lt;== Using squark-auth-snmp --&amp;gt;&lt;br /&gt;
** [[Setting up Explicit Squid Proxy]]&lt;br /&gt;
** [[Setting up Transparent Squid Proxy]] &#039;&#039;(Covers Squid proxy and URL Filtering system)&#039;&#039;&lt;br /&gt;
** [[SqStat]] &#039;&#039;(Script to look at active squid users connections)&#039;&#039;&lt;br /&gt;
* [[Tomcat]]&lt;br /&gt;
&lt;br /&gt;
==== Hostable Content ====&lt;br /&gt;
&lt;br /&gt;
* [[DokuWiki]]&lt;br /&gt;
* [[Drupal]] &#039;&#039;(Content Management System (CMS) written in PHP)&#039;&#039;&lt;br /&gt;
* [[Kopano]] &#039;&#039;(Microsoft Outlook compatible Groupware)&#039;&#039;&lt;br /&gt;
* [[Mahara]] &#039;&#039;(E-portfolio and social networking system)&#039;&#039;&lt;br /&gt;
* [[MediaWiki]] &#039;&#039;(Free web-based wiki software application)&#039;&#039;&lt;br /&gt;
* [[Pastebin]] &#039;&#039;(Pastebin software application)&#039;&#039;&lt;br /&gt;
* [[WordPress]] &#039;&#039;(Web software to create website or blog)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== IRC ===&lt;br /&gt;
&lt;br /&gt;
* [[NgIRCd]] &#039;&#039;(Server for Internet Relay Chat/IRC)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Mail ===&lt;br /&gt;
&lt;br /&gt;
* Exim/Dovecot&lt;br /&gt;
** [[Small-Time Email with Exim and Dovecot]] &#039;&#039;(A simple configuration for your home network.)&lt;br /&gt;
** [[Setting up dovecot with imap and tls]]&lt;br /&gt;
* [[relay email to gmail (msmtp, mailx, sendmail]]&lt;br /&gt;
* [[Roundcube]] &#039;&#039;(Webmail system)&#039;&#039;&lt;br /&gt;
* [[Setting up postfix with virtual domains]]&lt;br /&gt;
* Server protection&lt;br /&gt;
** [[Setting up clamsmtp]]&lt;br /&gt;
&lt;br /&gt;
=== Other Servers ===&lt;br /&gt;
&lt;br /&gt;
* [[Chrony and GPSD | Chrony, gpsd, and a garmin LVC 18 as a Stratum 1 NTP source ]]&lt;br /&gt;
* [[Glpi]] &#039;&#039;(Manage inventory of technical resources)&#039;&#039;&lt;br /&gt;
* [[How to setup a Alpine Linux mirror]]&lt;br /&gt;
* [[Setting up an NFS server|nfs-server]]&lt;br /&gt;
* [[nut-ups|NUT UPS]] &#039;&#039;(UPS Monitoring with Network UPS Tools)&#039;&#039;&lt;br /&gt;
* [[Odoo]]&lt;br /&gt;
* [[Configure OpenLDAP | OpenLDAP]] &#039;&#039;(Installing and configuring the Alpine package for OpenLDAP)&#039;&#039;&lt;br /&gt;
* [[Setting up a LLDAP server|lldap-server]] &#039;&#039;(Directory Server)&#039;&#039;&lt;br /&gt;
* [[Setting up a samba-ad-dc|samba-ad-dc]] &#039;&#039;(Active Directory compatible domain controller)&#039;&#039;&lt;br /&gt;
* [[Setting up a Samba server|samba-server]] &#039;&#039;(standard file sharing)&#039;&#039;&lt;br /&gt;
* [[Setting up Transmission (bittorrent) with Clutch WebUI]]&lt;br /&gt;
&lt;br /&gt;
=== Software development ===&lt;br /&gt;
&lt;br /&gt;
* [[Cgit]]&lt;br /&gt;
* [[OsTicket]] &#039;&#039;(Ticket system)&#039;&#039;&lt;br /&gt;
* [[Patchwork]] &#039;&#039;(Patch review management system)&#039;&#039;&lt;br /&gt;
* [[Redmine]] &#039;&#039;(Project management system)&#039;&#039;&lt;br /&gt;
* [[Request Tracker]] &#039;&#039;(Ticket system)&#039;&#039;&lt;br /&gt;
* [[Setting up trac wiki|Trac]] &#039;&#039;(Enhanced wiki and issue tracking system for software development projects)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Storage ==&lt;br /&gt;
&lt;br /&gt;
* [[Setting up disks manually|Disk setup (manual)]]&lt;br /&gt;
* [[Filesystems]]&lt;br /&gt;
** [[Burning ISOs]]&lt;br /&gt;
* [[Setting up iSCSI|iSCSI Setup]]&lt;br /&gt;
** [[iSCSI Raid and Clustered File Systems]]&lt;br /&gt;
** [[Linux iSCSI Target (TCM)|iSCSI Target (TCM)/LinuxIO (LIO)]]&lt;br /&gt;
** [[Linux iSCSI Target (tgt)|User space iSCSI Target (tgt)]]&lt;br /&gt;
* [[Setting up Logical Volumes with LVM|LVM Setup]]&lt;br /&gt;
** [[Setting up LVM on GPT-labeled disks|LVM on GPT-labeled disks]]&lt;br /&gt;
** [[Installing on GPT LVM|LVM on GPT-labeled disks (updated)]]&lt;br /&gt;
** [[LVM on LUKS]]&lt;br /&gt;
* RAID&lt;br /&gt;
** [[Raid Administration]]&lt;br /&gt;
** [[Setting up a software RAID array]]&lt;br /&gt;
* ZFS&lt;br /&gt;
** [[Root on ZFS with native encryption]]&lt;br /&gt;
** [[Setting up ZFS on LUKS]]&lt;br /&gt;
** [[Setting up ZFS with native encryption]]&lt;br /&gt;
** [[ZFS scrub and trim]]&lt;br /&gt;
* [[CEPH|CEPH]]&lt;br /&gt;
&lt;br /&gt;
== Virtualization ==&lt;br /&gt;
&lt;br /&gt;
* [[Docker]]&lt;br /&gt;
* [[Installing Alpine in a virtual machine]]&lt;br /&gt;
** [[Install Alpine on VMware ESXi]]&lt;br /&gt;
* [[KVM]] &#039;&#039;(Setting up Alpine as a KVM hypervisor)&#039;&#039;&lt;br /&gt;
* [[LXC]] &#039;&#039;(Setting up a Linux container in Alpine Linux)&#039;&#039;&lt;br /&gt;
* [[QEMU]]&lt;br /&gt;
* Xen&lt;br /&gt;
** [[Xen Dom0]] &#039;&#039;(Setting up Alpine as a dom0 for Xen hypervisor)&#039;&#039;&lt;br /&gt;
** [[Xen Dom0 on USB or SD]]&lt;br /&gt;
** [[Create Alpine Linux PV DomU|Xen DomU (paravirtualized)]]&lt;br /&gt;
** [[Xen LiveCD]]&lt;br /&gt;
** [[Xen PCI Passthrough]]&lt;br /&gt;
&lt;br /&gt;
= Tutorials =&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [[TTY_Autologin|TTY Autologin]]&lt;br /&gt;
* [[Kexec|Faster rebooting with kexec]]&lt;br /&gt;
* [[Dynamic Multipoint VPN (DMVPN)]] combined with [[Small Office Services]]&lt;br /&gt;
* [[DIY Fully working Alpine Linux for Allwinner and Other ARM SOCs]]&lt;br /&gt;
* [[Fault Tolerant Routing with Alpine Linux]]&lt;br /&gt;
* [[High Availability High Performance Web Cache]] &#039;&#039;(uCarp + HAProxy for High Availability Services such as Squid web proxy)&#039;&#039;&lt;br /&gt;
* [[Linux iSCSI Target (TCM)]]&lt;br /&gt;
* [[ISP Mail Server 3.x HowTo]]] &#039;&#039;(Postfix+PostfixAdmin+DoveCot+Roundcube+ClamAV+Spamd - A full-service ISP mail server)&#039;&#039;&lt;br /&gt;
* [[Replacing non-Alpine Linux with Alpine remotely]]&lt;br /&gt;
* [[Setting up A Network Monitoring and Inventory System]] &#039;&#039;(Nagios + OpenAudit and related components)&#039;&#039; &amp;lt;!-- draft --&amp;gt;&lt;br /&gt;
* [[Streaming Security Camera Video with VLC]]&lt;br /&gt;
* [[Install Alpine on a btrfs filesystem with refind as boot manager]]&lt;br /&gt;
&lt;br /&gt;
== Newbie corner ==&lt;br /&gt;
&lt;br /&gt;
* [[How to get regular stuff working]] &#039;&#039;some notes on need-to-know topics&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Servers ==&lt;br /&gt;
&lt;br /&gt;
* [[Alpine production deploy]]&lt;br /&gt;
** [[Production Web server: Lighttpd|Production web server: Lighttpd‎‎]]&lt;br /&gt;
** [[MySQL|Production database: MySQL]]&lt;br /&gt;
** [[Production LAMP system: Lighttpd + PHP + MySQL‎‎]]&lt;br /&gt;
* Alpine production monitoring&lt;br /&gt;
** [[Cacti: traffic analysis and monitoring network]]&lt;br /&gt;
** [[Zabbix|Zabbix - the professional complete manager]]&lt;br /&gt;
* Kubernetes&lt;br /&gt;
** [[K8s]] Building a K8s Cluster on Alpine Linux&lt;br /&gt;
&lt;br /&gt;
== Security ==&lt;br /&gt;
&lt;br /&gt;
* [[Securing Alpine Linux]] How to Secure Alpine Linux using Security Technical Implementation Guides (STIGs)&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=26704</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=26704"/>
		<updated>2024-05-12T00:51:33Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: fixed group name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would anyone do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to &#039;&#039;mail&#039;&#039;, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory or the mailbox files within the directory.&lt;br /&gt;
&lt;br /&gt;
The directory permissions should look like this:&lt;br /&gt;
&lt;br /&gt;
  # ls -ld /var/mail&lt;br /&gt;
  drwxrwsr-x    3 root     mail&lt;br /&gt;
&lt;br /&gt;
The permissions on mailbox files inside should look like this:&lt;br /&gt;
&lt;br /&gt;
  # ls -l&lt;br /&gt;
  -rw-rw----    1 dave     mail&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating Credentials for Dovecot Users ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot will use /etc/passwd for looking up user information, but not authentication. Technically, /etc/passwd authentication can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot credentials and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
The permissions on the Dovecot password file should be such that dovecot can read it, but not write to it. Only root should be able to write it.&lt;br /&gt;
&lt;br /&gt;
  ls -l /etc/dovecot/passwd&lt;br /&gt;
  -rw-r-----    1 root     dovecot&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was the result of a typographical error I made in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
You can further simplify things by commenting out the ssl lines in the dovecot.conf so it looks like this:&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  #ssl=yes&lt;br /&gt;
  #ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  #ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
Now TLS is out of the picture, letting you diagnose other potential problems. However, you may have to do some work to convince your mail client that sending login credentials in cleartext is okay. Only do this on a network where you trust your users!&lt;br /&gt;
&lt;br /&gt;
== Using and Enjoying Your Small-Time Email Setup ==&lt;br /&gt;
&lt;br /&gt;
Now that everything is setup, you can start sending yourself cat pictures or you can configure other programs to use the email system to send notifications. For example, I use [https://mmonit.com/monit/ Monit] to keep an eye on services and file system space. When Monit detects a problem, it sends me an email.&lt;br /&gt;
&lt;br /&gt;
The setup presented in this guide uses port 25 for SMTP and port 143 for IMAP. There are no dedicated TLS ports. Encryption is done using STARTTLS.&lt;br /&gt;
&lt;br /&gt;
== A Word About Aliases ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve ever used /etc/aliases for mail delivery, you should be aware that Exim puts this file in /etc/mail/aliases. The format is the same as Sendmail.&lt;br /&gt;
&lt;br /&gt;
== Scripted Installation and Configuration ==&lt;br /&gt;
&lt;br /&gt;
If you like living dangerously (or if you have a test system you don&#039;t care about) you can do all of the server configuration presented above with a single script, as shown below:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
  &lt;br /&gt;
  apk add exim mailx&lt;br /&gt;
  &lt;br /&gt;
  sed -i~ \&lt;br /&gt;
    -e &#039;s/# group = mail/  group = mail/&#039; \&lt;br /&gt;
    -e &#039;s/# mode = 0660/  mode = 0660/&#039; \&lt;br /&gt;
    /etc/exim/exim.conf&lt;br /&gt;
  &lt;br /&gt;
  ln -s mail/aliases /etc/aliases&lt;br /&gt;
  &lt;br /&gt;
  rc-update add exim&lt;br /&gt;
  service exim start&lt;br /&gt;
  &lt;br /&gt;
  apk add dovecot&lt;br /&gt;
  &lt;br /&gt;
  mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf~&lt;br /&gt;
  &lt;br /&gt;
  cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/dovecot/dovecot.conf&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
  EOF&lt;br /&gt;
  &lt;br /&gt;
  touch /etc/dovecot/passwd&lt;br /&gt;
  chown root:dovecot /etc/dovecot/passwd&lt;br /&gt;
  chmod 640 /etc/dovecot/passwd&lt;br /&gt;
  &lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Create dovecot user passwords with: doveadm pw -s sha512-crypt&amp;quot;&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Configure_OpenLDAP&amp;diff=23326</id>
		<title>Configure OpenLDAP</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Configure_OpenLDAP&amp;diff=23326"/>
		<updated>2023-04-28T16:11:40Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: Removing the link to stackoverflow, but keeping the reference. I didn&amp;#039;t source the script from there. This is the original. I&amp;#039;m the same guy who asked the question on S.O.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Lightweight Directory Access Protocol (LDAP) is often employed as an authentication mechanism, providing a common username and password across many different applications. This tutorial shows how to install and configure the OpenLDAP package on Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
== Installing Packages ==&lt;br /&gt;
&lt;br /&gt;
There is an Alpine package for OpenLDAP. However, simply adding the openldap apk is not enough to get you up and running. You&#039;ll also need to install a backend database and some LDAP command-line tools.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s how:&lt;br /&gt;
&lt;br /&gt;
  apk add openldap openldap-back-mdb openldap-clients&lt;br /&gt;
&lt;br /&gt;
But, before you start up the slapd service and go, there&#039;s a bit of configuration to do.&lt;br /&gt;
&lt;br /&gt;
== Customizing Configuration for OpenLDAP 2.3+ ==&lt;br /&gt;
&lt;br /&gt;
The Alpine OpenLDAP package can use either a configuration directory (slapd.d) or a configuration file (slapd.conf). Since OpenLDAP version 2.3, the preferred method is to use the slapd.d configuration directory. Any official OpenLDAP documentation, including their [https://www.openldap.org/doc/admin26/quickstart.html quickstart guide], will use this configuration method.&lt;br /&gt;
&lt;br /&gt;
First, create the slapd.d directory with the proper ownership and permissions.&lt;br /&gt;
&lt;br /&gt;
  install -m 755 -o ldap -g ldap -d /etc/openldap/slapd.d&lt;br /&gt;
&lt;br /&gt;
Next, edit the slapd startup configuration to use the directory instead of the file.&lt;br /&gt;
&lt;br /&gt;
# Open up /etc/conf.d/slapd in your favorite editor&lt;br /&gt;
# Comment out cfgfile=&amp;quot;/etc/openldap/slapd.conf&amp;quot;&lt;br /&gt;
# Uncomment cfgdir=&amp;quot;/etc/openldap/slapd.d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Finally, get rid of the included slapd.conf file.&lt;br /&gt;
&lt;br /&gt;
  rm /etc/openldap/slapd.conf&lt;br /&gt;
&lt;br /&gt;
== Updating Shared Libraries File Names ==&lt;br /&gt;
&lt;br /&gt;
Open up /etc/openldap/slapd.ldif in your favorite editor. Search for the file names ending with &amp;lt;code&amp;gt;.la&amp;lt;/code&amp;gt; and change the extension to &amp;lt;code&amp;gt;.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Customizing Configuration for Your Domain ==&lt;br /&gt;
&lt;br /&gt;
Your LDAP domain can be the same as your DNS domain or it can be completely different. Whatever you choose, be sure to use the LDAP naming convention of &amp;lt;code&amp;gt;dc=domain,dc=tld&amp;lt;/code&amp;gt; rather than the dot separated DNS style of &amp;lt;code&amp;gt;domain.tld&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Edit slapd.ldif again.&lt;br /&gt;
# Find the &amp;lt;code&amp;gt;olcSuffix:&amp;lt;/code&amp;gt; keyword.&lt;br /&gt;
# Change the value to match your domain&lt;br /&gt;
# Find &amp;lt;code&amp;gt;olcRootDN:&amp;lt;/code&amp;gt;&lt;br /&gt;
# Change the value to match your domain&lt;br /&gt;
&lt;br /&gt;
Later, this document will assume the domain is &amp;lt;code&amp;gt;dc=home&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;dc=contoso,dc=com&amp;lt;/code&amp;gt;, reflecting a domain of &amp;lt;code&amp;gt;home&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;contoso.com&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
&lt;br /&gt;
== Adding Schema for Linux User Accounts ==&lt;br /&gt;
&lt;br /&gt;
The basic OpenLDAP configuration does not include anything other than core schema definitions. To be useful for Linux systems, the inetOrgPerson schema and NIS schema are often included. The schema files are provided with the OpenLDAP package. All that needs to be done is to include them in the slapd.ldif configuration along with the cosine.ldif dependency.&lt;br /&gt;
&lt;br /&gt;
# Edit slapd.ldif again.&lt;br /&gt;
# Find the line &amp;lt;code&amp;gt;include: file:///etc/openldap/schema/core.ldif&amp;lt;/code&amp;gt;&lt;br /&gt;
# Append similar lines referencing &#039;&#039;cosine.ldif&#039;&#039;, &#039;&#039;inetorgperson.ldif&#039;&#039;, and &#039;&#039;nis.ldif&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
It should look like this when you&#039;re done:&lt;br /&gt;
&lt;br /&gt;
  include: file:///etc/openldap/schema/core.ldif&lt;br /&gt;
  include: file:///etc/openldap/schema/cosine.ldif&lt;br /&gt;
  include: file:///etc/openldap/schema/inetorgperson.ldif&lt;br /&gt;
  include: file:///etc/openldap/schema/nis.ldif&lt;br /&gt;
&lt;br /&gt;
== Importing the Configuration ==&lt;br /&gt;
Verify slapd.ldif one last time and use the &amp;lt;code&amp;gt;slapadd&amp;lt;/code&amp;gt; command to import it into the backend database.&lt;br /&gt;
&lt;br /&gt;
  slapadd -n 0 -F /etc/openldap/slapd.d -l /etc/openldap/slapd.ldif&lt;br /&gt;
&lt;br /&gt;
There should be no errors, only a &amp;quot;Closing DB...&amp;quot; message.&lt;br /&gt;
&lt;br /&gt;
Next, change ownership on the resulting files in /etc/openldap/slapd.d&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;If you skip this step, the slapd service will refuse to start.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
  chown -R ldap:ldap /etc/openldap/slapd.d/*&lt;br /&gt;
&lt;br /&gt;
== Configuring the slapd Service ==&lt;br /&gt;
&lt;br /&gt;
The pid directory is missing. We&#039;ll need to create it or the service won&#039;t start, so this needs to be done first.&lt;br /&gt;
&lt;br /&gt;
  install -m 755 -o ldap -g ldap -d /var/lib/openldap/run&lt;br /&gt;
&lt;br /&gt;
Next, you can start the service and enable it at boot.&lt;br /&gt;
&lt;br /&gt;
  service slapd start&lt;br /&gt;
  rc-update add slapd&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
The OpenLDAP quickstart guide uses the &amp;lt;code&amp;gt;ldapsearch&amp;lt;/code&amp;gt; utility to test the configuration.&lt;br /&gt;
&lt;br /&gt;
  ldapsearch -x -b &amp;quot;&amp;quot; -s base &#039;(objectclass=*)&#039; namingContexts&lt;br /&gt;
&lt;br /&gt;
You should see your domain.&lt;br /&gt;
&lt;br /&gt;
You can also test with &amp;lt;code&amp;gt;slapcat&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  slapcat -n 0&lt;br /&gt;
&lt;br /&gt;
This will dump the entire config database in LDIF format. You can also pipe to grep and specify your domain name to verify everything looks correct. When using grep, remember LDAP uses the format dc=domain,dc=com and not the more familiar domain.com.&lt;br /&gt;
&lt;br /&gt;
Later, when you begin populating your LDAP database, you can use &amp;lt;code&amp;gt;slapcat -n 1&amp;lt;/code&amp;gt; to see your information. (Zero is the config database. Numbers above zero are user-defined databases.)&lt;br /&gt;
&lt;br /&gt;
Finally, you can run &amp;lt;code&amp;gt;netstat -tln&amp;lt;/code&amp;gt; and look for LDAP port 389 in the output.&lt;br /&gt;
&lt;br /&gt;
== Scripted Installation ==&lt;br /&gt;
&lt;br /&gt;
If you want to automate the steps above, use the following script. Be sure to adjust the DOMAIN value to fit your needs.&lt;br /&gt;
&lt;br /&gt;
  export DOMAIN=&amp;quot;dc=home&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Installing packages...&amp;quot;&lt;br /&gt;
  apk add openldap openldap-back-mdb openldap-clients&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Configuring for v2.3+ style slapd.d config directory...&amp;quot;&lt;br /&gt;
  install -m 755 -o ldap -g ldap -d /etc/openldap/slapd.d&lt;br /&gt;
  sed -i~ \&lt;br /&gt;
    -e &#039;s/^cfgfile=/#cfgfile=/&#039; \&lt;br /&gt;
    -e &#039;s/^#cfgdir=.*/cfgdir=\&amp;quot;\/etc\/openldap\/slapd.d\&amp;quot;/&#039; \&lt;br /&gt;
    /etc/conf.d/slapd&lt;br /&gt;
  rm /etc/openldap/slapd.conf&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Customizing for domain: ${DOMAIN}...&amp;quot;&lt;br /&gt;
  sed -i~ \&lt;br /&gt;
    -e &#039;s/\.la$/.so/&#039; \&lt;br /&gt;
    -e &amp;quot;s/dc=my-domain,dc=com/${DOMAIN}/&amp;quot; /etc/openldap/slapd.ldif&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Adding schema for Linux user accounts...&amp;quot;&lt;br /&gt;
  cp /etc/openldap/slapd.ldif /etc/openldap/slapd.ldif~1&lt;br /&gt;
  awk &#039;{ print } /^include:/ { sub(&amp;quot;core&amp;quot;, &amp;quot;cosine&amp;quot;, $0); print $0; sub(&amp;quot;cosine&amp;quot;, &amp;quot;inetorgperson&amp;quot;); print $0; sub(&amp;quot;inetorgperson&amp;quot;, &amp;quot;nis&amp;quot;); print  }&#039; /etc/openldap/slapd.ldif~1 &amp;gt;/etc/openldap/slapd.ldif&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Importing configuration...&amp;quot;&lt;br /&gt;
  slapadd -n 0 -F /etc/openldap/slapd.d -l /etc/openldap/slapd.ldif&lt;br /&gt;
  chown -R ldap:ldap /etc/openldap/slapd.d/*&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Configuring slapd service...&amp;quot;&lt;br /&gt;
  install -m 755 -o ldap -g ldap -d /var/lib/openldap/run&lt;br /&gt;
  service slapd start&lt;br /&gt;
  rc-update add slapd&lt;br /&gt;
&lt;br /&gt;
== Creating an Organizational Structure ==&lt;br /&gt;
&lt;br /&gt;
Now that the installation is done, you can start using your LDAP database. At a minimum, you&#039;ll need to create an organization within your LDAP directory. This is covered as step 11 in the OpenLDAP [https://openldap.org/doc/admin26/quickstart.html quickstart] document.&lt;br /&gt;
&lt;br /&gt;
Here is an example using the contoso.com domain as the organization and &amp;lt;code&amp;gt;home&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;dc=home&amp;lt;/code&amp;gt; as the base DN (update the baseDN if yours differs):&lt;br /&gt;
&lt;br /&gt;
  cat &amp;lt;&amp;lt;EOF &amp;gt;org.ldif&lt;br /&gt;
  dn: dc=contoso,dc=com&lt;br /&gt;
  objectclass: dcObject&lt;br /&gt;
  objectclass: organization&lt;br /&gt;
  o: Fictional Company&lt;br /&gt;
  dc: contoso&lt;br /&gt;
  &lt;br /&gt;
  dn: cn=Manager,dc=contoso,dc=com&lt;br /&gt;
  objectclass: organizationalRole&lt;br /&gt;
  cn: Manager&lt;br /&gt;
  EOF&lt;br /&gt;
  &lt;br /&gt;
  ldapadd -x -D &amp;quot;cn=Manager,dc=home&amp;quot; -w secret -f org.ldif&lt;br /&gt;
&lt;br /&gt;
You may also want to create organizational units (OUs) to help keep your directory tidy.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an LDIF to create &#039;&#039;People&#039;&#039; and &#039;&#039;Groups&#039;&#039; as OUs:&lt;br /&gt;
&lt;br /&gt;
  # Organizational unit for users&lt;br /&gt;
  dn: ou=People,dc=home&lt;br /&gt;
  changetype: add&lt;br /&gt;
  objectClass: organizationalUnit&lt;br /&gt;
  ou: People&lt;br /&gt;
  &lt;br /&gt;
  # Organizational unit for groups.&lt;br /&gt;
  dn: ou=Groups,dc=home&lt;br /&gt;
  changetype: add&lt;br /&gt;
  objectClass: organizationalUnit&lt;br /&gt;
  ou: Groups&lt;br /&gt;
&lt;br /&gt;
Import the OUs with an ldapadd command similar to the one used to create the organization.&lt;br /&gt;
&lt;br /&gt;
Now that this is done, you&#039;re ready to connect to the LDAP server with the administration tool of your choice and begin populating users, groups, etc. [http://ldapadmin.org/ LDAPAdmin] is an oldie, but a goodie for Windows users.&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
&lt;br /&gt;
The configuration presented here does not include provisions for TLS (encrypted) communication. It should not be used on an untrusted network. Refer to the official OpenLDAP docs  for instructions on setting up encrypted LDAP connections.&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
https://openldap.org/doc/admin26/quickstart.html&lt;br /&gt;
&lt;br /&gt;
https://stackoverflow.com/questions/72132704/did-i-import-inetorgperson-schema-correctly-for-openldap-on-alpine-linux/&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21884</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21884"/>
		<updated>2022-05-15T13:36:30Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Creating Credentials for Dovecot Users */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would anyone do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory or the mailbox files within the directory.&lt;br /&gt;
&lt;br /&gt;
The directory permissions should look like this:&lt;br /&gt;
&lt;br /&gt;
  # ls -ld /var/mail&lt;br /&gt;
  drwxrwsr-x    3 root     mail&lt;br /&gt;
&lt;br /&gt;
The permissions on mailbox files inside should look like this:&lt;br /&gt;
&lt;br /&gt;
  # ls -l&lt;br /&gt;
  -rw-rw----    1 dave     mail&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating Credentials for Dovecot Users ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot will use /etc/passwd for looking up user information, but not authentication. Technically, /etc/passwd authentication can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot credentials and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
The permissions on the Dovecot password file should be such that dovecot can read it, but not write to it. Only root should be able to write it.&lt;br /&gt;
&lt;br /&gt;
  ls -l /etc/dovecot/passwd&lt;br /&gt;
  -rw-r-----    1 root     dovecot&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was the result of a typographical error I made in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
You can further simplify things by commenting out the ssl lines in the dovecot.conf so it looks like this:&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  #ssl=yes&lt;br /&gt;
  #ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  #ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
Now TLS is out of the picture, letting you diagnose other potential problems. However, you may have to do some work to convince your mail client that sending login credentials in cleartext is okay. Only do this on a network where you trust your users!&lt;br /&gt;
&lt;br /&gt;
== Using and Enjoying Your Small-Time Email Setup ==&lt;br /&gt;
&lt;br /&gt;
Now that everything is setup, you can start sending yourself cat pictures or you can configure other programs to use the email system to send notifications. For example, I use [https://mmonit.com/monit/ Monit] to keep an eye on services and file system space. When Monit detects a problem, it sends me an email.&lt;br /&gt;
&lt;br /&gt;
The setup presented in this guide uses port 25 for SMTP and port 143 for IMAP. There are no dedicated TLS ports. Encryption is done using STARTTLS.&lt;br /&gt;
&lt;br /&gt;
== A Word About Aliases ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve ever used /etc/aliases for mail delivery, you should be aware that Exim puts this file in /etc/mail/aliases. The format is the same as Sendmail.&lt;br /&gt;
&lt;br /&gt;
== Scripted Installation and Configuration ==&lt;br /&gt;
&lt;br /&gt;
If you like living dangerously (or if you have a test system you don&#039;t care about) you can do all of the server configuration presented above with a single script, as shown below:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
  &lt;br /&gt;
  apk add exim mailx&lt;br /&gt;
  &lt;br /&gt;
  sed -i~ \&lt;br /&gt;
    -e &#039;s/# group = mail/  group = mail/&#039; \&lt;br /&gt;
    -e &#039;s/# mode = 0660/  mode = 0660/&#039; \&lt;br /&gt;
    /etc/exim/exim.conf&lt;br /&gt;
  &lt;br /&gt;
  ln -s mail/aliases /etc/aliases&lt;br /&gt;
  &lt;br /&gt;
  rc-update add exim&lt;br /&gt;
  service exim start&lt;br /&gt;
  &lt;br /&gt;
  apk add dovecot&lt;br /&gt;
  &lt;br /&gt;
  mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf~&lt;br /&gt;
  &lt;br /&gt;
  cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/dovecot/dovecot.conf&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
  EOF&lt;br /&gt;
  &lt;br /&gt;
  touch /etc/dovecot/passwd&lt;br /&gt;
  chown root:dovecot /etc/dovecot/passwd&lt;br /&gt;
  chmod 640 /etc/dovecot/passwd&lt;br /&gt;
  &lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Create dovecot user passwords with: doveadm pw -s sha512-crypt&amp;quot;&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21883</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21883"/>
		<updated>2022-05-15T13:31:31Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Creating a Dovecot User and Password */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would anyone do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory or the mailbox files within the directory.&lt;br /&gt;
&lt;br /&gt;
The directory permissions should look like this:&lt;br /&gt;
&lt;br /&gt;
  # ls -ld /var/mail&lt;br /&gt;
  drwxrwsr-x    3 root     mail&lt;br /&gt;
&lt;br /&gt;
The permissions on mailbox files inside should look like this:&lt;br /&gt;
&lt;br /&gt;
  # ls -l&lt;br /&gt;
  -rw-rw----    1 dave     mail&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating Credentials for Dovecot Users ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot will use /etc/passwd for looking up user information, but not authentication. Technically, /etc/passwd authentication can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot credentials and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was the result of a typographical error I made in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
You can further simplify things by commenting out the ssl lines in the dovecot.conf so it looks like this:&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  #ssl=yes&lt;br /&gt;
  #ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  #ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
Now TLS is out of the picture, letting you diagnose other potential problems. However, you may have to do some work to convince your mail client that sending login credentials in cleartext is okay. Only do this on a network where you trust your users!&lt;br /&gt;
&lt;br /&gt;
== Using and Enjoying Your Small-Time Email Setup ==&lt;br /&gt;
&lt;br /&gt;
Now that everything is setup, you can start sending yourself cat pictures or you can configure other programs to use the email system to send notifications. For example, I use [https://mmonit.com/monit/ Monit] to keep an eye on services and file system space. When Monit detects a problem, it sends me an email.&lt;br /&gt;
&lt;br /&gt;
The setup presented in this guide uses port 25 for SMTP and port 143 for IMAP. There are no dedicated TLS ports. Encryption is done using STARTTLS.&lt;br /&gt;
&lt;br /&gt;
== A Word About Aliases ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve ever used /etc/aliases for mail delivery, you should be aware that Exim puts this file in /etc/mail/aliases. The format is the same as Sendmail.&lt;br /&gt;
&lt;br /&gt;
== Scripted Installation and Configuration ==&lt;br /&gt;
&lt;br /&gt;
If you like living dangerously (or if you have a test system you don&#039;t care about) you can do all of the server configuration presented above with a single script, as shown below:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
  &lt;br /&gt;
  apk add exim mailx&lt;br /&gt;
  &lt;br /&gt;
  sed -i~ \&lt;br /&gt;
    -e &#039;s/# group = mail/  group = mail/&#039; \&lt;br /&gt;
    -e &#039;s/# mode = 0660/  mode = 0660/&#039; \&lt;br /&gt;
    /etc/exim/exim.conf&lt;br /&gt;
  &lt;br /&gt;
  ln -s mail/aliases /etc/aliases&lt;br /&gt;
  &lt;br /&gt;
  rc-update add exim&lt;br /&gt;
  service exim start&lt;br /&gt;
  &lt;br /&gt;
  apk add dovecot&lt;br /&gt;
  &lt;br /&gt;
  mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf~&lt;br /&gt;
  &lt;br /&gt;
  cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/dovecot/dovecot.conf&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
  EOF&lt;br /&gt;
  &lt;br /&gt;
  touch /etc/dovecot/passwd&lt;br /&gt;
  chown root:dovecot /etc/dovecot/passwd&lt;br /&gt;
  chmod 640 /etc/dovecot/passwd&lt;br /&gt;
  &lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Create dovecot user passwords with: doveadm pw -s sha512-crypt&amp;quot;&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21877</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21877"/>
		<updated>2022-05-11T23:10:50Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Troubleshooting Mail Delivery */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would anyone do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory or the mailbox files within the directory.&lt;br /&gt;
&lt;br /&gt;
The directory permissions should look like this:&lt;br /&gt;
&lt;br /&gt;
  # ls -ld /var/mail&lt;br /&gt;
  drwxrwsr-x    3 root     mail&lt;br /&gt;
&lt;br /&gt;
The permissions on mailbox files inside should look like this:&lt;br /&gt;
&lt;br /&gt;
  # ls -l&lt;br /&gt;
  -rw-rw----    1 dave     mail&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating a Dovecot User and Password ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot will use /etc/passwd for looking up user information, but not authentication. Technically, /etc/passwd authentication can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot credentials and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was the result of a typographical error I made in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
You can further simplify things by commenting out the ssl lines in the dovecot.conf so it looks like this:&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  #ssl=yes&lt;br /&gt;
  #ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  #ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
Now TLS is out of the picture, letting you diagnose other potential problems. However, you may have to do some work to convince your mail client that sending login credentials in cleartext is okay. Only do this on a network where you trust your users!&lt;br /&gt;
&lt;br /&gt;
== Using and Enjoying Your Small-Time Email Setup ==&lt;br /&gt;
&lt;br /&gt;
Now that everything is setup, you can start sending yourself cat pictures or you can configure other programs to use the email system to send notifications. For example, I use [https://mmonit.com/monit/ Monit] to keep an eye on services and file system space. When Monit detects a problem, it sends me an email.&lt;br /&gt;
&lt;br /&gt;
The setup presented in this guide uses port 25 for SMTP and port 143 for IMAP. There are no dedicated TLS ports. Encryption is done using STARTTLS.&lt;br /&gt;
&lt;br /&gt;
== A Word About Aliases ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve ever used /etc/aliases for mail delivery, you should be aware that Exim puts this file in /etc/mail/aliases. The format is the same as Sendmail.&lt;br /&gt;
&lt;br /&gt;
== Scripted Installation and Configuration ==&lt;br /&gt;
&lt;br /&gt;
If you like living dangerously (or if you have a test system you don&#039;t care about) you can do all of the server configuration presented above with a single script, as shown below:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
  &lt;br /&gt;
  apk add exim mailx&lt;br /&gt;
  &lt;br /&gt;
  sed -i~ \&lt;br /&gt;
    -e &#039;s/# group = mail/  group = mail/&#039; \&lt;br /&gt;
    -e &#039;s/# mode = 0660/  mode = 0660/&#039; \&lt;br /&gt;
    /etc/exim/exim.conf&lt;br /&gt;
  &lt;br /&gt;
  ln -s mail/aliases /etc/aliases&lt;br /&gt;
  &lt;br /&gt;
  rc-update add exim&lt;br /&gt;
  service exim start&lt;br /&gt;
  &lt;br /&gt;
  apk add dovecot&lt;br /&gt;
  &lt;br /&gt;
  mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf~&lt;br /&gt;
  &lt;br /&gt;
  cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/dovecot/dovecot.conf&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
  EOF&lt;br /&gt;
  &lt;br /&gt;
  touch /etc/dovecot/passwd&lt;br /&gt;
  chown root:dovecot /etc/dovecot/passwd&lt;br /&gt;
  chmod 640 /etc/dovecot/passwd&lt;br /&gt;
  &lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Create dovecot user passwords with: doveadm pw -s sha512-crypt&amp;quot;&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21876</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21876"/>
		<updated>2022-05-11T23:09:17Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Troubleshooting Mail Delivery */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would anyone do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory or the mailbox files within the directory.&lt;br /&gt;
&lt;br /&gt;
The directory permissions should look like this:&lt;br /&gt;
&lt;br /&gt;
  # ls -ld /var/mail&lt;br /&gt;
  drwxrwsr-x    3 root     mail&lt;br /&gt;
&lt;br /&gt;
The permissions on mailboxes inside should look like this:&lt;br /&gt;
&lt;br /&gt;
  # ls -l&lt;br /&gt;
  -rw-rw----    1 dave     mail&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating a Dovecot User and Password ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot will use /etc/passwd for looking up user information, but not authentication. Technically, /etc/passwd authentication can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot credentials and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was the result of a typographical error I made in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
You can further simplify things by commenting out the ssl lines in the dovecot.conf so it looks like this:&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  #ssl=yes&lt;br /&gt;
  #ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  #ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
Now TLS is out of the picture, letting you diagnose other potential problems. However, you may have to do some work to convince your mail client that sending login credentials in cleartext is okay. Only do this on a network where you trust your users!&lt;br /&gt;
&lt;br /&gt;
== Using and Enjoying Your Small-Time Email Setup ==&lt;br /&gt;
&lt;br /&gt;
Now that everything is setup, you can start sending yourself cat pictures or you can configure other programs to use the email system to send notifications. For example, I use [https://mmonit.com/monit/ Monit] to keep an eye on services and file system space. When Monit detects a problem, it sends me an email.&lt;br /&gt;
&lt;br /&gt;
The setup presented in this guide uses port 25 for SMTP and port 143 for IMAP. There are no dedicated TLS ports. Encryption is done using STARTTLS.&lt;br /&gt;
&lt;br /&gt;
== A Word About Aliases ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve ever used /etc/aliases for mail delivery, you should be aware that Exim puts this file in /etc/mail/aliases. The format is the same as Sendmail.&lt;br /&gt;
&lt;br /&gt;
== Scripted Installation and Configuration ==&lt;br /&gt;
&lt;br /&gt;
If you like living dangerously (or if you have a test system you don&#039;t care about) you can do all of the server configuration presented above with a single script, as shown below:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
  &lt;br /&gt;
  apk add exim mailx&lt;br /&gt;
  &lt;br /&gt;
  sed -i~ \&lt;br /&gt;
    -e &#039;s/# group = mail/  group = mail/&#039; \&lt;br /&gt;
    -e &#039;s/# mode = 0660/  mode = 0660/&#039; \&lt;br /&gt;
    /etc/exim/exim.conf&lt;br /&gt;
  &lt;br /&gt;
  ln -s mail/aliases /etc/aliases&lt;br /&gt;
  &lt;br /&gt;
  rc-update add exim&lt;br /&gt;
  service exim start&lt;br /&gt;
  &lt;br /&gt;
  apk add dovecot&lt;br /&gt;
  &lt;br /&gt;
  mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf~&lt;br /&gt;
  &lt;br /&gt;
  cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/dovecot/dovecot.conf&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
  EOF&lt;br /&gt;
  &lt;br /&gt;
  touch /etc/dovecot/passwd&lt;br /&gt;
  chown root:dovecot /etc/dovecot/passwd&lt;br /&gt;
  chmod 640 /etc/dovecot/passwd&lt;br /&gt;
  &lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Create dovecot user passwords with: doveadm pw -s sha512-crypt&amp;quot;&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21875</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21875"/>
		<updated>2022-05-11T16:46:52Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Testing the Dovecot Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would anyone do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory.&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating a Dovecot User and Password ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot will use /etc/passwd for looking up user information, but not authentication. Technically, /etc/passwd authentication can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot credentials and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was the result of a typographical error I made in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
You can further simplify things by commenting out the ssl lines in the dovecot.conf so it looks like this:&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  #ssl=yes&lt;br /&gt;
  #ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  #ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
Now TLS is out of the picture, letting you diagnose other potential problems. However, you may have to do some work to convince your mail client that sending login credentials in cleartext is okay. Only do this on a network where you trust your users!&lt;br /&gt;
&lt;br /&gt;
== Using and Enjoying Your Small-Time Email Setup ==&lt;br /&gt;
&lt;br /&gt;
Now that everything is setup, you can start sending yourself cat pictures or you can configure other programs to use the email system to send notifications. For example, I use [https://mmonit.com/monit/ Monit] to keep an eye on services and file system space. When Monit detects a problem, it sends me an email.&lt;br /&gt;
&lt;br /&gt;
The setup presented in this guide uses port 25 for SMTP and port 143 for IMAP. There are no dedicated TLS ports. Encryption is done using STARTTLS.&lt;br /&gt;
&lt;br /&gt;
== A Word About Aliases ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve ever used /etc/aliases for mail delivery, you should be aware that Exim puts this file in /etc/mail/aliases. The format is the same as Sendmail.&lt;br /&gt;
&lt;br /&gt;
== Scripted Installation and Configuration ==&lt;br /&gt;
&lt;br /&gt;
If you like living dangerously (or if you have a test system you don&#039;t care about) you can do all of the server configuration presented above with a single script, as shown below:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
  &lt;br /&gt;
  apk add exim mailx&lt;br /&gt;
  &lt;br /&gt;
  sed -i~ \&lt;br /&gt;
    -e &#039;s/# group = mail/  group = mail/&#039; \&lt;br /&gt;
    -e &#039;s/# mode = 0660/  mode = 0660/&#039; \&lt;br /&gt;
    /etc/exim/exim.conf&lt;br /&gt;
  &lt;br /&gt;
  ln -s mail/aliases /etc/aliases&lt;br /&gt;
  &lt;br /&gt;
  rc-update add exim&lt;br /&gt;
  service exim start&lt;br /&gt;
  &lt;br /&gt;
  apk add dovecot&lt;br /&gt;
  &lt;br /&gt;
  mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf~&lt;br /&gt;
  &lt;br /&gt;
  cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/dovecot/dovecot.conf&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
  EOF&lt;br /&gt;
  &lt;br /&gt;
  touch /etc/dovecot/passwd&lt;br /&gt;
  chown root:dovecot /etc/dovecot/passwd&lt;br /&gt;
  chmod 640 /etc/dovecot/passwd&lt;br /&gt;
  &lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Create dovecot user passwords with: doveadm pw -s sha512-crypt&amp;quot;&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21874</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21874"/>
		<updated>2022-05-11T16:46:27Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Testing the Dovecot Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would anyone do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory.&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating a Dovecot User and Password ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot will use /etc/passwd for looking up user information, but not authentication. Technically, /etc/passwd authentication can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot credentials and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was the result of a typographical error I made in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
You can further simplify things by commenting out the ssl lines in the dovecot.conf so it looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  #ssl=yes&lt;br /&gt;
  #ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  #ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
Now TLS is out of the picture, letting you diagnose other potential problems. However, you may have to do some work to convince your mail client that sending login credentials in cleartext is okay. Only do this on a network where you trust your users!&lt;br /&gt;
&lt;br /&gt;
== Using and Enjoying Your Small-Time Email Setup ==&lt;br /&gt;
&lt;br /&gt;
Now that everything is setup, you can start sending yourself cat pictures or you can configure other programs to use the email system to send notifications. For example, I use [https://mmonit.com/monit/ Monit] to keep an eye on services and file system space. When Monit detects a problem, it sends me an email.&lt;br /&gt;
&lt;br /&gt;
The setup presented in this guide uses port 25 for SMTP and port 143 for IMAP. There are no dedicated TLS ports. Encryption is done using STARTTLS.&lt;br /&gt;
&lt;br /&gt;
== A Word About Aliases ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve ever used /etc/aliases for mail delivery, you should be aware that Exim puts this file in /etc/mail/aliases. The format is the same as Sendmail.&lt;br /&gt;
&lt;br /&gt;
== Scripted Installation and Configuration ==&lt;br /&gt;
&lt;br /&gt;
If you like living dangerously (or if you have a test system you don&#039;t care about) you can do all of the server configuration presented above with a single script, as shown below:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
  &lt;br /&gt;
  apk add exim mailx&lt;br /&gt;
  &lt;br /&gt;
  sed -i~ \&lt;br /&gt;
    -e &#039;s/# group = mail/  group = mail/&#039; \&lt;br /&gt;
    -e &#039;s/# mode = 0660/  mode = 0660/&#039; \&lt;br /&gt;
    /etc/exim/exim.conf&lt;br /&gt;
  &lt;br /&gt;
  ln -s mail/aliases /etc/aliases&lt;br /&gt;
  &lt;br /&gt;
  rc-update add exim&lt;br /&gt;
  service exim start&lt;br /&gt;
  &lt;br /&gt;
  apk add dovecot&lt;br /&gt;
  &lt;br /&gt;
  mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf~&lt;br /&gt;
  &lt;br /&gt;
  cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/dovecot/dovecot.conf&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
  EOF&lt;br /&gt;
  &lt;br /&gt;
  touch /etc/dovecot/passwd&lt;br /&gt;
  chown root:dovecot /etc/dovecot/passwd&lt;br /&gt;
  chmod 640 /etc/dovecot/passwd&lt;br /&gt;
  &lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Create dovecot user passwords with: doveadm pw -s sha512-crypt&amp;quot;&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21873</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21873"/>
		<updated>2022-05-11T16:44:41Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Creating a Dovecot User and Password */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would anyone do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory.&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating a Dovecot User and Password ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot will use /etc/passwd for looking up user information, but not authentication. Technically, /etc/passwd authentication can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot credentials and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was the result of a typo in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
You can further simplify things by commenting out the ssl lines in the dovecot.conf so it looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  #ssl=yes&lt;br /&gt;
  #ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  #ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
Now TLS is out of the picture, letting you diagnose other potential problems. However, you may have to do some work to convince your mail client that sending login credentials in cleartext is okay. Only do this on a network where you trust your users!&lt;br /&gt;
&lt;br /&gt;
== Using and Enjoying Your Small-Time Email Setup ==&lt;br /&gt;
&lt;br /&gt;
Now that everything is setup, you can start sending yourself cat pictures or you can configure other programs to use the email system to send notifications. For example, I use [https://mmonit.com/monit/ Monit] to keep an eye on services and file system space. When Monit detects a problem, it sends me an email.&lt;br /&gt;
&lt;br /&gt;
The setup presented in this guide uses port 25 for SMTP and port 143 for IMAP. There are no dedicated TLS ports. Encryption is done using STARTTLS.&lt;br /&gt;
&lt;br /&gt;
== A Word About Aliases ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve ever used /etc/aliases for mail delivery, you should be aware that Exim puts this file in /etc/mail/aliases. The format is the same as Sendmail.&lt;br /&gt;
&lt;br /&gt;
== Scripted Installation and Configuration ==&lt;br /&gt;
&lt;br /&gt;
If you like living dangerously (or if you have a test system you don&#039;t care about) you can do all of the server configuration presented above with a single script, as shown below:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
  &lt;br /&gt;
  apk add exim mailx&lt;br /&gt;
  &lt;br /&gt;
  sed -i~ \&lt;br /&gt;
    -e &#039;s/# group = mail/  group = mail/&#039; \&lt;br /&gt;
    -e &#039;s/# mode = 0660/  mode = 0660/&#039; \&lt;br /&gt;
    /etc/exim/exim.conf&lt;br /&gt;
  &lt;br /&gt;
  ln -s mail/aliases /etc/aliases&lt;br /&gt;
  &lt;br /&gt;
  rc-update add exim&lt;br /&gt;
  service exim start&lt;br /&gt;
  &lt;br /&gt;
  apk add dovecot&lt;br /&gt;
  &lt;br /&gt;
  mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf~&lt;br /&gt;
  &lt;br /&gt;
  cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/dovecot/dovecot.conf&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
  EOF&lt;br /&gt;
  &lt;br /&gt;
  touch /etc/dovecot/passwd&lt;br /&gt;
  chown root:dovecot /etc/dovecot/passwd&lt;br /&gt;
  chmod 640 /etc/dovecot/passwd&lt;br /&gt;
  &lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Create dovecot user passwords with: doveadm pw -s sha512-crypt&amp;quot;&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21872</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21872"/>
		<updated>2022-05-11T15:40:50Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Using and Enjoying Your Small-Time Email Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would anyone do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory.&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating a Dovecot User and Password ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot does not use /etc/passwd for authentication. Technically, this can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was the result of a typo in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
You can further simplify things by commenting out the ssl lines in the dovecot.conf so it looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  #ssl=yes&lt;br /&gt;
  #ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  #ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
Now TLS is out of the picture, letting you diagnose other potential problems. However, you may have to do some work to convince your mail client that sending login credentials in cleartext is okay. Only do this on a network where you trust your users!&lt;br /&gt;
&lt;br /&gt;
== Using and Enjoying Your Small-Time Email Setup ==&lt;br /&gt;
&lt;br /&gt;
Now that everything is setup, you can start sending yourself cat pictures or you can configure other programs to use the email system to send notifications. For example, I use [https://mmonit.com/monit/ Monit] to keep an eye on services and file system space. When Monit detects a problem, it sends me an email.&lt;br /&gt;
&lt;br /&gt;
The setup presented in this guide uses port 25 for SMTP and port 143 for IMAP. There are no dedicated TLS ports. Encryption is done using STARTTLS.&lt;br /&gt;
&lt;br /&gt;
== A Word About Aliases ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve ever used /etc/aliases for mail delivery, you should be aware that Exim puts this file in /etc/mail/aliases. The format is the same as Sendmail.&lt;br /&gt;
&lt;br /&gt;
== Scripted Installation and Configuration ==&lt;br /&gt;
&lt;br /&gt;
If you like living dangerously (or if you have a test system you don&#039;t care about) you can do all of the server configuration presented above with a single script, as shown below:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
  &lt;br /&gt;
  apk add exim mailx&lt;br /&gt;
  &lt;br /&gt;
  sed -i~ \&lt;br /&gt;
    -e &#039;s/# group = mail/  group = mail/&#039; \&lt;br /&gt;
    -e &#039;s/# mode = 0660/  mode = 0660/&#039; \&lt;br /&gt;
    /etc/exim/exim.conf&lt;br /&gt;
  &lt;br /&gt;
  ln -s mail/aliases /etc/aliases&lt;br /&gt;
  &lt;br /&gt;
  rc-update add exim&lt;br /&gt;
  service exim start&lt;br /&gt;
  &lt;br /&gt;
  apk add dovecot&lt;br /&gt;
  &lt;br /&gt;
  mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf~&lt;br /&gt;
  &lt;br /&gt;
  cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/dovecot/dovecot.conf&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
  EOF&lt;br /&gt;
  &lt;br /&gt;
  touch /etc/dovecot/passwd&lt;br /&gt;
  chown root:dovecot /etc/dovecot/passwd&lt;br /&gt;
  chmod 640 /etc/dovecot/passwd&lt;br /&gt;
  &lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Create dovecot user passwords with: doveadm pw -s sha512-crypt&amp;quot;&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21871</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21871"/>
		<updated>2022-05-11T15:34:40Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Scripted Installation and Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would anyone do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory.&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating a Dovecot User and Password ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot does not use /etc/passwd for authentication. Technically, this can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was the result of a typo in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
You can further simplify things by commenting out the ssl lines in the dovecot.conf so it looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  #ssl=yes&lt;br /&gt;
  #ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  #ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
Now TLS is out of the picture, letting you diagnose other potential problems. However, you may have to do some work to convince your mail client that sending login credentials in cleartext is okay. Only do this on a network where you trust your users!&lt;br /&gt;
&lt;br /&gt;
== Using and Enjoying Your Small-Time Email Setup ==&lt;br /&gt;
&lt;br /&gt;
Now that everything is setup, you can send yourself cat pictures or you can configure other programs to use the email system to send notifications. For example, I use [https://mmonit.com/monit/ Monit] to keep an eye on services and file system space.&lt;br /&gt;
&lt;br /&gt;
The setup presented in this guide uses port 25 for SMTP and port 143 for IMAP. There are no dedicated TLS ports. Encryption is done using STARTTLS.&lt;br /&gt;
&lt;br /&gt;
== A Word About Aliases ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve ever used /etc/aliases for mail delivery, you should be aware that Exim puts this file in /etc/mail/aliases. The format is the same as Sendmail.&lt;br /&gt;
&lt;br /&gt;
== Scripted Installation and Configuration ==&lt;br /&gt;
&lt;br /&gt;
If you like living dangerously (or if you have a test system you don&#039;t care about) you can do all of the server configuration presented above with a single script, as shown below:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
  &lt;br /&gt;
  apk add exim mailx&lt;br /&gt;
  &lt;br /&gt;
  sed -i~ \&lt;br /&gt;
    -e &#039;s/# group = mail/  group = mail/&#039; \&lt;br /&gt;
    -e &#039;s/# mode = 0660/  mode = 0660/&#039; \&lt;br /&gt;
    /etc/exim/exim.conf&lt;br /&gt;
  &lt;br /&gt;
  ln -s mail/aliases /etc/aliases&lt;br /&gt;
  &lt;br /&gt;
  rc-update add exim&lt;br /&gt;
  service exim start&lt;br /&gt;
  &lt;br /&gt;
  apk add dovecot&lt;br /&gt;
  &lt;br /&gt;
  mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf~&lt;br /&gt;
  &lt;br /&gt;
  cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/dovecot/dovecot.conf&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
  EOF&lt;br /&gt;
  &lt;br /&gt;
  touch /etc/dovecot/passwd&lt;br /&gt;
  chown root:dovecot /etc/dovecot/passwd&lt;br /&gt;
  chmod 640 /etc/dovecot/passwd&lt;br /&gt;
  &lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Create dovecot user passwords with: doveadm pw -s sha512-crypt&amp;quot;&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21870</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21870"/>
		<updated>2022-05-11T15:31:29Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would anyone do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory.&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating a Dovecot User and Password ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot does not use /etc/passwd for authentication. Technically, this can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was the result of a typo in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
You can further simplify things by commenting out the ssl lines in the dovecot.conf so it looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  #ssl=yes&lt;br /&gt;
  #ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  #ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
Now TLS is out of the picture, letting you diagnose other potential problems. However, you may have to do some work to convince your mail client that sending login credentials in cleartext is okay. Only do this on a network where you trust your users!&lt;br /&gt;
&lt;br /&gt;
== Using and Enjoying Your Small-Time Email Setup ==&lt;br /&gt;
&lt;br /&gt;
Now that everything is setup, you can send yourself cat pictures or you can configure other programs to use the email system to send notifications. For example, I use [https://mmonit.com/monit/ Monit] to keep an eye on services and file system space.&lt;br /&gt;
&lt;br /&gt;
The setup presented in this guide uses port 25 for SMTP and port 143 for IMAP. There are no dedicated TLS ports. Encryption is done using STARTTLS.&lt;br /&gt;
&lt;br /&gt;
== A Word About Aliases ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve ever used /etc/aliases for mail delivery, you should be aware that Exim puts this file in /etc/mail/aliases. The format is the same as Sendmail.&lt;br /&gt;
&lt;br /&gt;
== Scripted Installation and Configuration ==&lt;br /&gt;
&lt;br /&gt;
If you like living dangerously (or if you have a test system you don&#039;t care about) you can do all of the server configuration presented above with a single script, as shown below:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
  &lt;br /&gt;
  apk add exim mailx&lt;br /&gt;
  &lt;br /&gt;
  sed -i~ \&lt;br /&gt;
    -e &#039;s/# group = mail/  group = mail/&#039; \&lt;br /&gt;
    -e &#039;s/# mode = 0660/  mode = 0660/&#039; \&lt;br /&gt;
    /etc/exim/exim.conf&lt;br /&gt;
  &lt;br /&gt;
  ln -s mail/aliases /etc/aliases&lt;br /&gt;
  &lt;br /&gt;
  rc-update add exim&lt;br /&gt;
  service exim start&lt;br /&gt;
  &lt;br /&gt;
  apk add dovecot&lt;br /&gt;
  &lt;br /&gt;
  mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf~&lt;br /&gt;
  &lt;br /&gt;
  cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/dovecot/dovecot.conf&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
  EOF&lt;br /&gt;
  &lt;br /&gt;
  touch /etc/dovecot/passwd&lt;br /&gt;
  chown root:dovecot /etc/dovecot/passwd&lt;br /&gt;
  chmod 640 /etc/dovecot/passwd&lt;br /&gt;
  &lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
  &lt;br /&gt;
  echo &amp;quot;Create user passwords with: doveadm pw -s sha512-crypt&amp;quot;&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Tutorials_and_Howtos&amp;diff=21869</id>
		<title>Tutorials and Howtos</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Tutorials_and_Howtos&amp;diff=21869"/>
		<updated>2022-05-11T15:25:28Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Mail */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Todo|This material needs to be re-organized .. as &#039;&#039;&#039;Howtos are smaller articles&#039;&#039;&#039; and &#039;&#039;&#039;tutorials are more detailed document&#039;&#039;&#039; both need to be reordered as independent sections }}&lt;br /&gt;
&lt;br /&gt;
[[Image:package_edutainment.svg|right|link=]]&lt;br /&gt;
{{TOC left}}&lt;br /&gt;
&#039;&#039;&#039;Welcome to Tutorials and Howtos, a place of basic and advanced configuration tasks for your Alpine Linux.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The tutorials are hands-on&#039;&#039;&#039; and the reader is expected to try and achieve the goals described in each step, possibly with the help of a good example. The output in one step is the starting point for the following step.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Howtos are smaller articles&#039;&#039;&#039; explaining how to perform a particular task with Alpine Linux, that expects a minimal knowledge from reader to perform actions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; contributions on those pages must be complete articles as well as requesting topics to be covered, don&#039;t override already made contributions. If you want to request a topic, please add your request in this page&#039;s [[Talk:Tutorials_and_Howtos|Discussion]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Clear}}&lt;br /&gt;
&lt;br /&gt;
=== Postinstall ===&lt;br /&gt;
&lt;br /&gt;
* [[Post installation|Post installation notes]]&lt;br /&gt;
&lt;br /&gt;
==== Postinstall: desktops and applications ====&lt;br /&gt;
&lt;br /&gt;
* [[Desktop environments and Window managers]] (overall information only)&lt;br /&gt;
** [[Xfce]]&lt;br /&gt;
** [[LXQt]]&lt;br /&gt;
** [[Openbox]]&lt;br /&gt;
** [[MATE]]&lt;br /&gt;
* [[Alpine and UEFI|Alpine and UEFI Support Status and related topics]]&lt;br /&gt;
&lt;br /&gt;
==== Developers: compilers, IDEs and tools ====&lt;br /&gt;
&lt;br /&gt;
* [[Alpine newbie developer]]&lt;br /&gt;
** [[Alpine newbie developer: gitea|Alpine newbie developer: Git management web frontend gitea]]&lt;br /&gt;
** [[Alpine newbie developer: full stack web]]&lt;br /&gt;
&lt;br /&gt;
==== Servers: deploy in production ====&lt;br /&gt;
&lt;br /&gt;
* [[Alpine production deploy]]&lt;br /&gt;
** [[Production Web server: Lighttpd|Production web server: Lighttpd‎‎]]&lt;br /&gt;
** [[Production DataBases : mysql|Production database: MySql]]&lt;br /&gt;
** [[Production LAMP system: Lighttpd + PHP + MySQL‎‎]]&lt;br /&gt;
* Alpine production monitoring&lt;br /&gt;
** [[Cacti: traffic analysis and monitoring network]]&lt;br /&gt;
** [[Zabbix|Zabbix - the professional complete manager]]&lt;br /&gt;
* Kubernetes&lt;br /&gt;
** [[K8s]] Building a K8s Cluster on Alpine Linux&lt;br /&gt;
&lt;br /&gt;
== Storage ==&lt;br /&gt;
&lt;br /&gt;
* [[Alpine local backup|Alpine local backup (lbu)]] &#039;&#039;(Permanently store your modifications in case your box needs reboot)&#039;&#039; &amp;lt;!-- Installation and Storage --&amp;gt;&lt;br /&gt;
** [[Back Up a Flash Memory Installation]] &amp;lt;!-- Installation and Storage --&amp;gt;&lt;br /&gt;
** [[Manually editing a existing apkovl]]&lt;br /&gt;
&lt;br /&gt;
* [[Setting up disks manually]] &amp;lt;!-- Installation and Storage --&amp;gt;&lt;br /&gt;
* [[Setting up a software RAID array]]&lt;br /&gt;
&amp;lt;!-- ** [[Setting up a /var partition on software IDE raid1]]  Obsolete, Installation and Storage --&amp;gt; &lt;br /&gt;
* [[Raid Administration]]&lt;br /&gt;
* [[Setting up encrypted volumes with LUKS]]&lt;br /&gt;
* [[Setting up LVM on LUKS]]&lt;br /&gt;
* [[Setting up Logical Volumes with LVM]]&lt;br /&gt;
** [[Setting up LVM on GPT-labeled disks]]&lt;br /&gt;
** [[Installing on GPT LVM]]&lt;br /&gt;
* [[Filesystems|Formatting HD/Floppy/Other]] &amp;lt;!-- just a stub --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Setting up iSCSI]]&lt;br /&gt;
** [[iSCSI Raid and Clustered File Systems]]&lt;br /&gt;
* [[Setting up NBD]]&lt;br /&gt;
* [[Setting up ZFS on LUKS]]&lt;br /&gt;
* [[Setting up ZFS with native encryption]]&lt;br /&gt;
* [[High performance SCST iSCSI Target on Linux software Raid]] &#039;&#039;(deprecated)&#039;&#039; &amp;lt;!-- solution --&amp;gt;&lt;br /&gt;
* [[Linux iSCSI Target (TCM)]]&lt;br /&gt;
* [[Disk Replication with DRBD]] &amp;lt;!-- draft --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Burning ISOs]] &amp;lt;!-- just some links now --&amp;gt;&lt;br /&gt;
* [[Partitioning and Bootmanagers]]&lt;br /&gt;
* [[Migrating data]]&lt;br /&gt;
* [[Create a bootable SDHC from a Mac]]&lt;br /&gt;
* [[Alpine on ARM]]&lt;br /&gt;
&lt;br /&gt;
== Networking ==&lt;br /&gt;
&lt;br /&gt;
* [[Configure Networking]]&lt;br /&gt;
* [[Connecting to a wireless access point]]&lt;br /&gt;
* [[Bonding]]&lt;br /&gt;
* [[Vlan]]&lt;br /&gt;
* [[Bridge]]&lt;br /&gt;
* [[Bridge wlan0 to eth0]]&lt;br /&gt;
* [[OpenVSwitch]]&lt;br /&gt;
* [[How to configure static routes]]&lt;br /&gt;
* [[Configure a Wireguard interface (wg)]]&lt;br /&gt;
&lt;br /&gt;
* [[Alpine Wall]] - [[How-To Alpine Wall]] - [[Alpine Wall User&#039;s Guide]] &#039;&#039;(a new firewall management framework)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[PXE boot]]&lt;br /&gt;
&lt;br /&gt;
* [[Using serial modem]]&lt;br /&gt;
* [[Using HSDPA modem]]&lt;br /&gt;
* [[Setting up Satellite Internet Connection]]&lt;br /&gt;
* [[Using Alpine on Windows domain with IPSEC isolation]]&lt;br /&gt;
&lt;br /&gt;
* [[Setting up a SSH server]] &#039;&#039;(Using SSH is the preferred way to administer your box remotely)&#039;&#039; &amp;lt;!-- Server and Networking --&amp;gt;&lt;br /&gt;
** [[HOWTO OpenSSH 2FA with password and Google Authenticator]] &#039;&#039;(A simple two factor setup for OpenSSH)&#039;&#039;&lt;br /&gt;
* [[How to setup a wireless access point]] &#039;&#039;(Setting up Secure Wireless AP w/ WPA encryption with bridge to wired network)&#039;&#039;&lt;br /&gt;
* [[How to set up Alpine as a wireless router]] &#039;&#039;(Setting up a firewalled, Wireless AP with wired network on a Pi Zero W)&#039;&#039;&lt;br /&gt;
* [[Setting up a OpenVPN server with Alpine]] &#039;&#039;(Allowing single users or devices to remotely connect to your network)&#039;&#039;&lt;br /&gt;
&amp;lt;!-- [[Using Racoon for Remote Sites]] is a different VPN tunnelling method, but that article is just a stub --&amp;gt;&lt;br /&gt;
* [[Experiences with OpenVPN-client on ALIX.2D3]]  &amp;lt;!-- solution --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Generating SSL certs with ACF]] &amp;lt;!-- Generating SSL certs with ACF 1.9 --&amp;gt;&lt;br /&gt;
* [[Setting up unbound DNS server]]&lt;br /&gt;
* [[Setting up nsd DNS server]]&lt;br /&gt;
* [[TinyDNS Format]]&lt;br /&gt;
* [[Fault Tolerant Routing with Alpine Linux]] &amp;lt;!-- solution --&amp;gt;&lt;br /&gt;
* [[Freeradius Active Directory Integration]]&lt;br /&gt;
* [[Multi_ISP]] &#039;&#039;(Dual-ISP setup with load-balancing and automatic failover)&#039;&#039;&lt;br /&gt;
* [[OwnCloud]] &#039;&#039;(Installing OwnCloud)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Seafile: setting up your own private cloud]]&lt;br /&gt;
&lt;br /&gt;
* [[GNUnet]]&lt;br /&gt;
&lt;br /&gt;
== Post-Install ==&lt;br /&gt;
&amp;lt;!-- If you edit this, please coordinate with Installation and Developer_Documentation#Package_management.  Note that these three sections are not exact duplicates. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Setting up a new user]]&lt;br /&gt;
* [[Enable Community Repository]] &#039;&#039;(Providing additional packages)&#039;&#039;&lt;br /&gt;
* [[Alpine Linux package management|Package Management (apk)]] &#039;&#039;(How to add/remove packages on your Alpine)&#039;&#039;&lt;br /&gt;
   &amp;lt;!-- [[Alpine Linux package management#Local_Cache|How to enable APK caching]] --&amp;gt;&lt;br /&gt;
** [[Comparison with other distros]]&lt;br /&gt;
* [[Alpine local backup|Alpine local backup (lbu)]] &#039;&#039;(Permanently store your modifications in case your box needs reboot)&#039;&#039;&lt;br /&gt;
** [[Back Up a Flash Memory Installation]] &amp;lt;!-- new --&amp;gt;&lt;br /&gt;
** [[Manually editing a existing apkovl]]&lt;br /&gt;
* [[Alpine Linux Init System|Init System (OpenRC)]] &#039;&#039;(Configure a service to automatically boot at next reboot)&#039;&#039;&lt;br /&gt;
** [[Multiple Instances of Services]]&lt;br /&gt;
   &amp;lt;!-- [[Writing Init Scripts]] --&amp;gt;&lt;br /&gt;
* [[Alpine setup scripts#setup-xorg-base|Setting up Xorg]]&lt;br /&gt;
* [[Upgrading Alpine]]&lt;br /&gt;
&amp;lt;!-- Obsolete&lt;br /&gt;
 [[Upgrading Alpine - v1.9.x]]&lt;br /&gt;
 [[Upgrading Alpine - CD v1.8.x]]&lt;br /&gt;
 [[Upgrading Alpine - HD v1.8.x]]&lt;br /&gt;
 [[Upgrade to repository main|Upgrading to signed repositories]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Setting up a ssh-server]] &#039;&#039;(Using ssh is a good way to administer your box remotely)&#039;&#039;&lt;br /&gt;
** [[HOWTO OpenSSH 2FA with password and Google Authenticator]] &#039;&#039;(A simple two factor setup for OpenSSH)&#039;&#039;&lt;br /&gt;
* [[setup-acf]] &#039;&#039;(Configures ACF (webconfiguration) so you can manage your box through https)&#039;&#039;&lt;br /&gt;
* [[Changing passwords for ACF|Changing passwords]]&lt;br /&gt;
* [[Ansible]] &#039;&#039;(Configuration management)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Enable Serial Console on Boot]]&lt;br /&gt;
&amp;lt;!-- Obsolete?&lt;br /&gt;
* [[Error message on boot: Address space collision: host bridge window conflicts with Adaptor ROM]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
* [[How to get regular stuff working]] &#039;&#039;some notes on need-to-know topics&#039;&#039;&lt;br /&gt;
* [[Installing Oracle Java]]&lt;br /&gt;
* [[Rsnapshot|Setting up periodic backups with &amp;lt;samp&amp;gt;rsnapshot&amp;lt;/samp&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
== Virtualization==&lt;br /&gt;
&lt;br /&gt;
* [[Xen Dom0]] &#039;&#039;(Setting up Alpine as a dom0 for Xen hypervisor)&#039;&#039;&lt;br /&gt;
* [[Xen Dom0 on USB or SD]]&lt;br /&gt;
* [[Create Alpine Linux PV DomU]]&lt;br /&gt;
* [[Xen PCI Passthrough]]&lt;br /&gt;
* [[Xen LiveCD]]&lt;br /&gt;
* [[QEMU]]&lt;br /&gt;
* [[KVM]] &#039;&#039;(Setting up Alpine as a KVM hypervisor)&#039;&#039;&lt;br /&gt;
* [[LXC]] &#039;&#039;(Setting up a Linux container in Alpine Linux)&#039;&#039;&lt;br /&gt;
* [[Docker]]&lt;br /&gt;
* [[Install Alpine on VirtualBox]]&lt;br /&gt;
* [[Install Alpine on VMWare]]&lt;br /&gt;
&lt;br /&gt;
== Desktop Environment ==&lt;br /&gt;
&lt;br /&gt;
* [[AwesomeWM]]&lt;br /&gt;
* [[dwm]]&lt;br /&gt;
* [[EyeOS]] &#039;&#039;(Cloud Computing Desktop)&#039;&#039;&lt;br /&gt;
* [[Gnome]]&lt;br /&gt;
* [[KDE]]&lt;br /&gt;
* [[MATE]]&lt;br /&gt;
* [[Oneye]] &#039;&#039;(Cloud Computing Desktop - Dropbox Alternative)&#039;&#039;&lt;br /&gt;
* [[Nextcloud]] &#039;&#039;(Self hostable cloud suite - Dropbox Alternative)&#039;&#039;&lt;br /&gt;
* [[Remote Desktop Server]]&lt;br /&gt;
* [[River]]&lt;br /&gt;
* [[Suspend on LID close]]&lt;br /&gt;
* [[Sway]]&lt;br /&gt;
* [[Xfce]]&lt;br /&gt;
* [[Sound Setup]]&lt;br /&gt;
* [[PipeWire]]&lt;br /&gt;
* [[Printer Setup]]&lt;br /&gt;
* [[Default applications]]&lt;br /&gt;
&lt;br /&gt;
== Raspberry Pi ==&lt;br /&gt;
&lt;br /&gt;
* [[Raspberry Pi|Raspberry Pi (Installation)]]&lt;br /&gt;
* [[Raspberry Pi - Headless Installation]]&lt;br /&gt;
* [[Classic install or sys mode on Raspberry Pi]]&lt;br /&gt;
* [[RPI Video Receiver]] &#039;&#039;(network video decoder using Rasperry Pi and omxplayer)&#039;&#039;&lt;br /&gt;
* [[Linux Router with VPN on a Raspberry Pi]]&lt;br /&gt;
* [[Linux Router with VPN on a Raspberry Pi (IPv6)]]&lt;br /&gt;
* [[Raspberry Pi 4 - Persistent system acting as a NAS and Time Machine]]&lt;br /&gt;
* [[Raspberry Pi 3 - Configuring it as wireless access point -AP Mode]]&lt;br /&gt;
* [[Raspberry Pi 3 - Setting Up Bluetooth]]&lt;br /&gt;
* [[Raspberry Pi 3 - Browser Client]] - kiosk or digital sign&lt;br /&gt;
* [[Raspberry Pi Zero W - Installation]]&lt;br /&gt;
* [[Raspberry Pi Bluetooth Speaker]]&lt;br /&gt;
&lt;br /&gt;
== PowerPC ==&lt;br /&gt;
&lt;br /&gt;
* [[Ppc64le|Powerpc64le (Installation)]]&lt;br /&gt;
&lt;br /&gt;
== IBM Z (IBM z Systems) ==&lt;br /&gt;
&lt;br /&gt;
* [[s390x|s390x (Installation)]]&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
&lt;br /&gt;
=== Telephony ===&lt;br /&gt;
* [[Setting up Zaptel/Asterisk on Alpine]]&lt;br /&gt;
** [[Setting up Streaming an Asterisk Channel]]&lt;br /&gt;
* [[Freepbx on Alpine Linux]]&lt;br /&gt;
* [[FreePBX_V3]] &#039;&#039;(FreeSWITCH, Asterisk GUI web acces tool)&#039;&#039;&lt;br /&gt;
* [[2600hz]] &#039;&#039;(FreeSWITCH, Asterisk GUI web access tool)&#039;&#039;&lt;br /&gt;
* [[Kamailio]] &#039;&#039;(SIP Server, formerly OpenSER)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Mail ===&lt;br /&gt;
* [[Small-Time Email with Exim and Dovecot]] &#039;&#039;(A simple configuration for your home network.)&lt;br /&gt;
* [[Hosting services on Alpine]] &#039;&#039;(Hosting mail, webservices and other services)&#039;&#039;&lt;br /&gt;
** [[Hosting Web/Email services on Alpine]]&lt;br /&gt;
* [[ISP Mail Server HowTo]] &amp;lt;!-- solution, Mail --&amp;gt;&lt;br /&gt;
** [[ISP Mail Server Upgrade 2.x]]&lt;br /&gt;
** [[ISP Mail Server 2.x HowTo]] &#039;&#039;(Beta, please test)&#039;&#039;&lt;br /&gt;
** [[ISP Mail Server 3.x HowTo]]&lt;br /&gt;
* [[Roundcube]] &#039;&#039;(Webmail system)&#039;&#039;&lt;br /&gt;
* [[Setting up postfix with virtual domains]]&lt;br /&gt;
* [[Protecting your email server with Alpine]]&lt;br /&gt;
* [[Setting up clamsmtp]]&lt;br /&gt;
* [[Setting up dovecot with imap and ssl]]&lt;br /&gt;
* [[relay email to gmail (msmtp, mailx, sendmail]]&lt;br /&gt;
&lt;br /&gt;
=== HTTP ===&lt;br /&gt;
* [[Lighttpd]]&lt;br /&gt;
** [[Lighttpd Https access]]&lt;br /&gt;
** [[Setting Up Lighttpd with PHP]]&lt;br /&gt;
** [[Setting Up Lighttpd With FastCGI]]&lt;br /&gt;
* [[Cherokee]]&lt;br /&gt;
* [[Nginx]]&lt;br /&gt;
** [[Nginx_with_PHP#Nginx_with_PHP|Nginx with PHP]]&lt;br /&gt;
** [[Nginx as reverse proxy with acme (letsencrypt)]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
** [[Apache with php-fpm]]&lt;br /&gt;
** [[Setting Up Apache with PHP]]&lt;br /&gt;
** [[Apache authentication: NTLM Single Signon]]&lt;br /&gt;
&lt;br /&gt;
* [[High Availability High Performance Web Cache]] &#039;&#039;(uCarp + HAProxy for High Availability Services such as Squid web proxy)&#039;&#039; &amp;lt;!-- solution, Server --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Setting up Transparent Squid Proxy]] &amp;lt;!-- draft --&amp;gt;&lt;br /&gt;
** [[SqStat]] &#039;&#039;(Script to look at active squid users connections)&#039;&#039;&lt;br /&gt;
** [[Obtaining user information via SNMP]] &#039;&#039;(Using squark-auth-snmp as a Squid authentication helper)&#039;&#039; &amp;lt;!-- Networking and Server, &amp;lt;== Using squark-auth-snmp --&amp;gt;&lt;br /&gt;
* [[Setting up Explicit Squid Proxy]]&lt;br /&gt;
&lt;br /&gt;
* [[Drupal]] &#039;&#039;(Content Management System (CMS) written in PHP)&#039;&#039;&lt;br /&gt;
* [[WordPress]] &#039;&#039;(Web software to create website or blog)&#039;&#039;&lt;br /&gt;
* [[MediaWiki]] &#039;&#039;(Free web-based wiki software application)&#039;&#039;&lt;br /&gt;
* [[DokuWiki]]&lt;br /&gt;
* [[Darkhttpd]]&lt;br /&gt;
* [[Tomcat]]&lt;br /&gt;
* [[Kopano]] &#039;&#039;(Microsoft Outlook compatible Groupware)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Other Servers ===&lt;br /&gt;
* [[Setting up a ssh-server]] &#039;&#039;(Using ssh is a good way to administer your box remotely)&#039;&#039;&lt;br /&gt;
** [[HOWTO OpenSSH 2FA with password and Google Authenticator]] &#039;&#039;(A simple two factor setup for OpenSSH)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Configure OpenLDAP]] &#039;&#039;(Installing and configuring the Alpine package for OpenLDAP)&#039;&#039;&lt;br /&gt;
* [[Setting up a nfs-server]]&lt;br /&gt;
* [[Setting up a samba-server]] &#039;&#039;(standard file sharing)&#039;&#039;&lt;br /&gt;
* [[Setting up a samba-ad-dc]] &#039;&#039;(Active Directory compatible domain controller)&#039;&#039;&lt;br /&gt;
* [[Phpizabi]] &#039;&#039;(Social Networking Platform)&#039;&#039;&lt;br /&gt;
* [[Statusnet]] &#039;&#039;(Microblogging Platform)&#039;&#039;&lt;br /&gt;
* [[Pastebin]] &#039;&#039;(Pastebin software application)&#039;&#039;&lt;br /&gt;
* [[Setting up Transmission (bittorrent) with Clutch WebUI]]&lt;br /&gt;
&lt;br /&gt;
* [[Patchwork]] &#039;&#039;(Patch review management system)&#039;&#039;&lt;br /&gt;
* [[Redmine]] &#039;&#039;(Project management system)&#039;&#039;&lt;br /&gt;
* [[Request-Tracker]] &#039;&#039;(Ticket system)&#039;&#039;&lt;br /&gt;
* [[OsTicket]] &#039;&#039;(Ticket system)&#039;&#039;&lt;br /&gt;
* [[Setting up trac wiki|Trac]] &#039;&#039;(Enhanced wiki and issue tracking system for software development projects)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Alpine_newbie_developer: gitea|Setting up Git management web frontend gitea]]&lt;br /&gt;
* [[Cgit]]&lt;br /&gt;
** [[Setting up a git repository server with gitolite and cgit]] &amp;lt;!-- doesn&#039;t exist yet --&amp;gt;&lt;br /&gt;
* [[Roundcube]] &#039;&#039;(Webmail system)&#039;&#039;&lt;br /&gt;
* [[Glpi]] &#039;&#039;(Manage inventory of technical resources)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[How to setup a Alpine Linux mirror]]&lt;br /&gt;
* [[Cups]]&lt;br /&gt;
* [[NgIRCd]] &#039;&#039;(Server for Internet Relay Chat/IRC)&#039;&#039;&lt;br /&gt;
* [[How To Setup Your Own IRC Network]] &#039;&#039;(Using {{Pkg|charybdis}} and {{Pkg|atheme-iris}})&#039;&#039;&lt;br /&gt;
* [[OpenVCP]] &#039;&#039;(VServer Control Panel)&#039;&#039;&lt;br /&gt;
* [[Mahara]] &#039;&#039;(E-portfolio and social networking system)&#039;&#039;&lt;br /&gt;
* [[Chrony and GPSD | Using chrony, gpsd, and a garmin LVC 18 as a Stratum 1 NTP source ]]&lt;br /&gt;
* [[Sending SMS using gnokii]]&lt;br /&gt;
* [[IPTV How To|Internet Protocol television (IPTV)]]&lt;br /&gt;
* [[UniFi_Controller]]&lt;br /&gt;
* [[DNSCrypt-Proxy]] &#039;&#039;Encrypt and authenticate DNS calls from your system&#039;&#039;&lt;br /&gt;
* [[Odoo]]&lt;br /&gt;
&lt;br /&gt;
=== Monitoring ===&lt;br /&gt;
* Setting up [[collectd]]&lt;br /&gt;
* [[Traffic monitoring]] &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Setting up traffic monitoring using rrdtool (and snmp)]] &amp;lt;!-- Monitoring --&amp;gt;&lt;br /&gt;
* [[Setting up monitoring using rrdtool (and rrdcollect)]]&lt;br /&gt;
* [[Cacti: traffic analysis and monitoring network]] &#039;&#039;(Front-end for rrdtool networking monitor)&#039;&#039;&lt;br /&gt;
* [[LTTng]] &#039;&#039;(Kernel and userspace tracing)&#039;&#039;&lt;br /&gt;
* [[Zabbix|Zabbix - the professional complete manager]] &#039;&#039;(Monitor and track the status of network services and hardware)&#039;&#039;&lt;br /&gt;
* [[Setting up A Network Monitoring and Inventory System]] &#039;&#039;(Nagios + OpenAudit and related components)&#039;&#039; &amp;lt;!-- draft, solution, Networking and Monitoring and Server --&amp;gt;&lt;br /&gt;
** [[Setting up NRPE daemon]] &#039;&#039;(Performs remote Nagios checks)&#039;&#039; &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Setting up Smokeping|Smokeping]] &#039;&#039;(Network latency monitoring)&#039;&#039; &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
** [[Setting up MRTG and Smokeping to Monitor Bandwidth Usage and Network Latency]]&lt;br /&gt;
* [[Setting Up Fprobe And Ntop|Ntop]] &#039;&#039;(NetFlow collection and analysis using a remote fprobe instance)&#039;&#039; &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Cvechecker]] &#039;&#039;(Compare installed packages for Common Vulnerabilities Exposure)&#039;&#039; &amp;lt;!-- Monitoring and Security --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[IP Accounting]] &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Obtaining user information via SNMP]] &#039;&#039;(Using squark-auth-snmp as a Squid authentication helper)&#039;&#039; &amp;lt;!-- Networking and Server, &amp;lt;== Using squark-auth-snmp --&amp;gt;&lt;br /&gt;
* [[SqStat]] &#039;&#039;(Script to look at active squid users connections)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Piwik]] &#039;&#039;(A real time web analytics software program)&#039;&#039;&lt;br /&gt;
* [[Awstats]] &#039;&#039;(Free log file analyzer)&#039;&#039;&lt;br /&gt;
* [[Intrusion Detection using Snort]]&lt;br /&gt;
** [[Intrusion Detection using Snort, Sguil, Barnyard and more]]&lt;br /&gt;
* [[Dglog]] &#039;&#039;(Log analyzer for the web content filter DansGuardian)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Webmin]] &#039;&#039;(A web-based interface for Linux system)&#039;&#039;&lt;br /&gt;
* [[PhpPgAdmin]] &#039;&#039;(Web-based administration tool for PostgreSQL)&#039;&#039;&lt;br /&gt;
* [[PhpMyAdmin]] &#039;&#039;(Web-based administration tool for MYSQL)&#039;&#039;&lt;br /&gt;
* [[PhpSysInfo]] &#039;&#039;(A simple application that displays information about the host it&#039;s running on)&#039;&#039;&lt;br /&gt;
* [[Linfo]]&lt;br /&gt;
&lt;br /&gt;
* [[Setting up lm_sensors]]&lt;br /&gt;
&lt;br /&gt;
* [[ZoneMinder video camera security and surveillance]]&lt;br /&gt;
&lt;br /&gt;
== Misc ==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Shell]]&lt;br /&gt;
* [[:Category:Programming]]&lt;br /&gt;
* [[Running glibc programs]]&lt;br /&gt;
* [[:Category:Drivers]]&lt;br /&gt;
* [[:Category:Multimedia]]&lt;br /&gt;
* [[Kernel Modesetting]]&lt;br /&gt;
* [[CPU frequency scaling]]&lt;br /&gt;
&lt;br /&gt;
== Complete Solutions ==&lt;br /&gt;
* [[Unattended Boot and Install]]&lt;br /&gt;
* [[DIY Fully working Alpine Linux for Allwinner and Other ARM SOCs]]&lt;br /&gt;
* [https://codeberg.org/AVG7/alpine-sway-x86_64 DIY Live-USB-Stick with Sway] &lt;br /&gt;
* [[Alpine on the Aopen Chromebase or Chromebox Mini with Mainline Kernel]]&lt;br /&gt;
* [[Replacing non-Alpine Linux with Alpine remotely]]&lt;br /&gt;
* [[High performance SCST iSCSI Target on Linux software Raid]]&lt;br /&gt;
* [[Fault Tolerant Routing with Alpine Linux]]&lt;br /&gt;
* [[Experiences with OpenVPN-client on ALIX.2D3]]&lt;br /&gt;
* [[Building a cloud with Alpine Linux]]&lt;br /&gt;
&lt;br /&gt;
* [[ISP Mail Server HowTo]] &#039;&#039;(Postfix+PostfixAdmin+DoveCot+Roundcube+ClamAV+Spamd - A full-serivce ISP mail server)&#039;&#039;&lt;br /&gt;
** [[ISP Mail Server Upgrade 2.x]]&lt;br /&gt;
** [[ISP Mail Server 2.x HowTo]] &#039;&#039;(Beta, please test)&#039;&#039;&lt;br /&gt;
* [[High Availability High Performance Web Cache]] &#039;&#039;(uCarp + HAProxy for High Availability Services such as Squid web proxy)&#039;&#039;&lt;br /&gt;
* [[Setting up A Network Monitoring and Inventory System]] &#039;&#039;(Nagios + OpenAudit and related components)&#039;&#039; &amp;lt;!-- draft --&amp;gt;&lt;br /&gt;
* [[Streaming Security Camera Video with VLC]]&lt;br /&gt;
* [[Dynamic Multipoint VPN (DMVPN)]] combined with [[Small_Office_Services]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
This does not attempt to be complete. Is it useful to have these listed here? I find them more accessible if grouped with their topics; also, an up-to-date list of all Draft or Obsolete pages can be found at [[Project:Wiki maintenance]].&lt;br /&gt;
&lt;br /&gt;
== Drafts ==&lt;br /&gt;
Currently unfinished/works-in-progress.&lt;br /&gt;
* [[Using Racoon for Remote Sites]]&lt;br /&gt;
* [[Setting up Transparent Squid Proxy]] &#039;&#039;(Covers Squid proxy and URL Filtering system)&#039;&#039;&lt;br /&gt;
** [[Obtaining user information via SNMP]] &#039;&#039;(Using the Squark Squid authentication helper)&#039;&#039; [!-- no longer a draft --]&lt;br /&gt;
* [[Setting up Streaming an Asterisk Channel]]&lt;br /&gt;
* [[Setting up A Network Monitoring and Inventory System]] &#039;&#039;(Nagios + OpenAudit and related components)&#039;&#039;&lt;br /&gt;
* [[Intrusion Detection using Snort]] &#039;&#039;(Installing and configuring Snort and related applications on Alpine 2.0.x)&#039;&#039;&lt;br /&gt;
* [[IP Accounting]] &#039;&#039;(Installing and configuring pmacct for IP Accounting, Netflow/sFlow collector)&#039;&#039;&lt;br /&gt;
* [[Disk Replication with DRBD]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Newbies ==&lt;br /&gt;
&lt;br /&gt;
* [[Alpine_newbie]] (for overall information in funny sections)&lt;br /&gt;
&lt;br /&gt;
[[Category:System_Administration]]&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21868</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21868"/>
		<updated>2022-05-11T15:23:05Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would anyone do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory.&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating a Dovecot User and Password ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot does not use /etc/passwd for authentication. Technically, this can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was the result of a typo in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
You can further simplify things by commenting out the ssl lines in the dovecot.conf so it looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  #ssl=yes&lt;br /&gt;
  #ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  #ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
Now TLS is out of the picture, letting you diagnose other potential problems. However, you may have to do some work to convince your mail client that sending login credentials in cleartext is okay. Only do this on a network where you trust your users!&lt;br /&gt;
&lt;br /&gt;
== Using and Enjoying Your Small-Time Email Setup ==&lt;br /&gt;
&lt;br /&gt;
Now that everything is setup, you can send yourself cat pictures or you can configure other programs to use the email system to send notifications. For example, I use [https://mmonit.com/monit/ Monit] to keep an eye on services and file system space.&lt;br /&gt;
&lt;br /&gt;
The setup presented in this guide uses port 25 for SMTP and port 143 for IMAP. There are no dedicated TLS ports. Encryption is done using STARTTLS.&lt;br /&gt;
&lt;br /&gt;
== A Word About Aliases ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve ever used /etc/aliases for mail delivery, you should be aware that Exim puts this file in /etc/mail/aliases. The format is the same as Sendmail.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21867</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21867"/>
		<updated>2022-05-11T15:21:58Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Why would you do this? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ draft }}&lt;br /&gt;
&lt;br /&gt;
If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would anyone do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory.&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating a Dovecot User and Password ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot does not use /etc/passwd for authentication. Technically, this can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was the result of a typo in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
You can further simplify things by commenting out the ssl lines in the dovecot.conf so it looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  #ssl=yes&lt;br /&gt;
  #ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  #ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
Now TLS is out of the picture, letting you diagnose other potential problems. However, you may have to do some work to convince your mail client that sending login credentials in cleartext is okay. Only do this on a network where you trust your users!&lt;br /&gt;
&lt;br /&gt;
== Using and Enjoying Your Small-Time Email Setup ==&lt;br /&gt;
&lt;br /&gt;
Now that everything is setup, you can send yourself cat pictures or you can configure other programs to use the email system to send notifications. For example, I use [https://mmonit.com/monit/ Monit] to keep an eye on services and file system space.&lt;br /&gt;
&lt;br /&gt;
The setup presented in this guide uses port 25 for SMTP and port 143 for IMAP. There are no dedicated TLS ports. Encryption is done using STARTTLS.&lt;br /&gt;
&lt;br /&gt;
== A Word About Aliases ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve ever used /etc/aliases for mail delivery, you should be aware that Exim puts this file in /etc/mail/aliases. The format is the same as Sendmail.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21866</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21866"/>
		<updated>2022-05-11T15:21:07Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ draft }}&lt;br /&gt;
&lt;br /&gt;
If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would you do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory.&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating a Dovecot User and Password ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot does not use /etc/passwd for authentication. Technically, this can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was the result of a typo in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
You can further simplify things by commenting out the ssl lines in the dovecot.conf so it looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  #ssl=yes&lt;br /&gt;
  #ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  #ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
Now TLS is out of the picture, letting you diagnose other potential problems. However, you may have to do some work to convince your mail client that sending login credentials in cleartext is okay. Only do this on a network where you trust your users!&lt;br /&gt;
&lt;br /&gt;
== Using and Enjoying Your Small-Time Email Setup ==&lt;br /&gt;
&lt;br /&gt;
Now that everything is setup, you can send yourself cat pictures or you can configure other programs to use the email system to send notifications. For example, I use [https://mmonit.com/monit/ Monit] to keep an eye on services and file system space.&lt;br /&gt;
&lt;br /&gt;
The setup presented in this guide uses port 25 for SMTP and port 143 for IMAP. There are no dedicated TLS ports. Encryption is done using STARTTLS.&lt;br /&gt;
&lt;br /&gt;
== A Word About Aliases ==&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve ever used /etc/aliases for mail delivery, you should be aware that Exim puts this file in /etc/mail/aliases. The format is the same as Sendmail.&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21865</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21865"/>
		<updated>2022-05-11T15:08:27Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ draft }}&lt;br /&gt;
&lt;br /&gt;
If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would you do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory.&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating a Dovecot User and Password ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot does not use /etc/passwd for authentication. Technically, this can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was the result of a typo in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
You can further simplify things by commenting out the ssl lines in the dovecot.conf so it looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  #ssl=yes&lt;br /&gt;
  #ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  #ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
Now TLS is out of the picture, letting you diagnose other potential problems. However, you may have to do some work to convince your mail client that sending login credentials in cleartext is okay. Only do this on a network where you trust your users!&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21864</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21864"/>
		<updated>2022-05-11T14:58:05Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Configuring Dovecot */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ draft }}&lt;br /&gt;
&lt;br /&gt;
If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would you do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory.&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating a Dovecot User and Password ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot does not use /etc/passwd for authentication. Technically, this can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was from a typo in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Work in progress. More to come.&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21863</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21863"/>
		<updated>2022-05-11T14:57:40Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Configuring Dovecot */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ draft }}&lt;br /&gt;
&lt;br /&gt;
If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would you do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory.&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of sixteen lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # These are self-signed certs generated when the dovecat apk was installed.&lt;br /&gt;
  ssl=yes&lt;br /&gt;
  ssl_cert=&amp;lt;/etc/ssl/dovecot/server.pem&lt;br /&gt;
  ssl_key=&amp;lt;/etc/ssl/dovecot/server.key&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating a Dovecot User and Password ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot does not use /etc/passwd for authentication. Technically, this can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was from a typo in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Work in progress. More to come.&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21862</id>
		<title>Small-Time Email with Exim and Dovecot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Small-Time_Email_with_Exim_and_Dovecot&amp;diff=21862"/>
		<updated>2022-05-11T14:56:36Z</updated>

		<summary type="html">&lt;p&gt;Dhorton: /* Testing the Dovecot Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ draft }}&lt;br /&gt;
&lt;br /&gt;
If you want a super-simple SMTP / IMAP setup for a home server, this is the guide for you. This document covers the minimum steps to get email delivery up and running on a small home network. You&#039;re not going to want to use this for any serious enterprise stuff, but for a small home LAN it works well.&lt;br /&gt;
&lt;br /&gt;
== Why would you do this? ==&lt;br /&gt;
&lt;br /&gt;
My personal motivation for creating this small-time email setup was to deliver alerts from [https://mmonit.com/monit/ Monit] so I would know when my system needed attention. You can use it for this or similar minimalist email needs. Just don&#039;t do anything crazy like exposing it to the internet.&lt;br /&gt;
&lt;br /&gt;
== Why Exim and Dovecot? ==&lt;br /&gt;
&lt;br /&gt;
For an email server, Exim is easy to configure. Dovecot is a little more complex, but not insurmountable. Both are well documented.&lt;br /&gt;
&lt;br /&gt;
== Installing the Packages ==&lt;br /&gt;
The first step is to install Exim, Dovecot, and Mailx. (Mailx is used for testing.)&lt;br /&gt;
&lt;br /&gt;
  apk add exim dovecot mailx&lt;br /&gt;
&lt;br /&gt;
== Configuring Exim ==&lt;br /&gt;
&lt;br /&gt;
The next step is to get Exim working for delivering email to users on the system. This is a pretty simple configuration and there are only a few parameters to change in the delivered exim.conf file.&lt;br /&gt;
&lt;br /&gt;
# Make a backup of /etc/exim/exim.conf&lt;br /&gt;
# Open /etc/exim/exim.conf in your favorite text editor.&lt;br /&gt;
# Make the changes stated below and save.&lt;br /&gt;
&lt;br /&gt;
Find the lines that look like this:&lt;br /&gt;
&lt;br /&gt;
  # group = mail&lt;br /&gt;
  # mode = 0660&lt;br /&gt;
&lt;br /&gt;
They&#039;ll be under the heading of &amp;lt;code&amp;gt;local_delivery:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you find them, remove the comment (hash symbol). The local_delivery section should now look like this:&lt;br /&gt;
&lt;br /&gt;
  local_delivery:&lt;br /&gt;
    driver = appendfile&lt;br /&gt;
    file = /var/mail/$local_part_data&lt;br /&gt;
    delivery_date_add&lt;br /&gt;
    envelope_to_add&lt;br /&gt;
    return_path_add&lt;br /&gt;
    group = mail&lt;br /&gt;
    mode = 0660&lt;br /&gt;
&lt;br /&gt;
The only thing changed is the removal of the hash symbol from the last two lines.&lt;br /&gt;
&lt;br /&gt;
== Fixing Ownership and Permissions on /var/mail ==&lt;br /&gt;
&lt;br /&gt;
As it stands, Exim will not be able to deliver messages to /var/mail, where the user mailboxes are stored. This is due to permissions.&lt;br /&gt;
&lt;br /&gt;
To fix it, run these two commands:&lt;br /&gt;
&lt;br /&gt;
  chgrp mail /var/mail&lt;br /&gt;
  chmod 2775 /var/mail&lt;br /&gt;
&lt;br /&gt;
When you&#039;re done, verify it with &amp;lt;code&amp;gt;ls -ld /var/mail&amp;lt;/code&amp;gt;. It should look something like this:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ld /var/mail/&lt;br /&gt;
  drwxrwsr-x    3 root     mail          4096 May 11 12:58 /var/mail/&lt;br /&gt;
&lt;br /&gt;
Setting the group ownership to exim, lets exim write to users&#039; mailboxes when new mail comes in.&lt;br /&gt;
&lt;br /&gt;
== Starting the Exim Service ==&lt;br /&gt;
&lt;br /&gt;
Start Exim and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service exim start&lt;br /&gt;
  rc-update add exim&lt;br /&gt;
&lt;br /&gt;
== Testing the Exim Setup ==&lt;br /&gt;
&lt;br /&gt;
Log in a a regular user and try sending a test email to yourself. You can do this with the mail command, like this:&lt;br /&gt;
&lt;br /&gt;
  mail -s Testing dave&lt;br /&gt;
  This is a test.&lt;br /&gt;
  .&lt;br /&gt;
&lt;br /&gt;
This sends a test message to the user dave. (Obviously, you&#039;ll want to replace dave with your username.) The final . on the last line is important. It tells the mail command the message is done.&lt;br /&gt;
&lt;br /&gt;
When the message is sent, check that you received it by running &amp;lt;code&amp;gt;mail&amp;lt;/code&amp;gt; with no command-line parameters. If everything went well, it should look like the example below.&lt;br /&gt;
&lt;br /&gt;
  $ mail&lt;br /&gt;
  Mail version 8.1 6/6/93.  Type ? for help.&lt;br /&gt;
  &amp;quot;/var/mail/dave&amp;quot;: 1 messages&lt;br /&gt;
  &amp;gt;   1 dave@myserver.home      Wed May 11 03:51  27/847   &amp;quot;Testing&amp;quot;&lt;br /&gt;
  &amp;amp;&lt;br /&gt;
&lt;br /&gt;
You can type the message number (1) to display the contents of the mail and then type q to quit the mail program.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting Mail Delivery ==&lt;br /&gt;
&lt;br /&gt;
If the mail test fails, look int the directory /var/spool/exim/msglog. If there are files in here, they are stuck messages. The files are plain text. Display the contents to show any error messages. In most cases, the problem will be related to permissions on the /var/mail directory.&lt;br /&gt;
&lt;br /&gt;
== Configuring Dovecot ==&lt;br /&gt;
&lt;br /&gt;
If everything is working with local delivery, it&#039;s time to set up IMAP using Dovecot.&lt;br /&gt;
&lt;br /&gt;
The Dovecot package for Alpine comes with twenty configuration files in /etc/dovecot/conf.d. As a small-time email admin, you may feel overwhelmed. Don&#039;t worry, everything can be condensed down to a single config file of 13 lines.&lt;br /&gt;
&lt;br /&gt;
First, make a backup copy of /etc/dovecot/dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
Next, create a new dovecot.conf that looks like this:&lt;br /&gt;
&lt;br /&gt;
  listen = *&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
  protocols = imap&lt;br /&gt;
  disable_plaintext_auth = no&lt;br /&gt;
  mail_privileged_group = mail&lt;br /&gt;
  mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;br /&gt;
  userdb {&lt;br /&gt;
    driver = passwd&lt;br /&gt;
  }&lt;br /&gt;
  passdb {&lt;br /&gt;
    driver = passwd-file&lt;br /&gt;
    args = scheme=sha512-crypt username_format=%n /etc/dovecot/passwd&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
This config does not have the &amp;lt;code&amp;gt;!include conf.d/*.conf&amp;lt;/code&amp;gt; that was in the original dovecot.conf, so those twenty files in conf.d are going to be ignored. Everything is now in this single dovecot.conf.&lt;br /&gt;
&lt;br /&gt;
== Starting the Dovecot Service ==&lt;br /&gt;
&lt;br /&gt;
Start Dovecot and configure it to start at boot time with the usual commands.&lt;br /&gt;
&lt;br /&gt;
  service dovecot start&lt;br /&gt;
  rc-update add dovecot&lt;br /&gt;
&lt;br /&gt;
== Creating a Dovecot User and Password ==&lt;br /&gt;
&lt;br /&gt;
As it is configured, Dovecot does not use /etc/passwd for authentication. Technically, this can be done using Pluggable Authentication Modules (PAM), but PAM is not part of the base install of Alpine Linux. The next best thing is to use a separate password file for Dovecot and to use the same SHA512-Crypt hashing algorithm used in /etc/passwd.&lt;br /&gt;
&lt;br /&gt;
The Dovecot configuration above specifies a password file of /etc/dovecot/passwd. The Dovecot password file looks like this:&lt;br /&gt;
&lt;br /&gt;
  dave:{SHA512-CRYPT}$6$mQ1rxB0gZHqg8Tg9$nxZ8odJZ6xVpmOVpsnYfAo1i7SuoLDhsvoykieukWF9NyNBq.WwhDA7udcYxP1iEm/IzlBmnwz6/vOO3SX8gA.&lt;br /&gt;
&lt;br /&gt;
There are two fields, username and password, separated by a colon. Notice the {SHA512-CRYPT} prefix to the password. This indicates the hashing algorithm.&lt;br /&gt;
&lt;br /&gt;
You can create passwords with the &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; command, like this:&lt;br /&gt;
&lt;br /&gt;
  # doveadm pw -s sha512-crypt&lt;br /&gt;
  Enter new password:&lt;br /&gt;
  Retype new password:&lt;br /&gt;
&lt;br /&gt;
The command will output the hashed password. You&#039;ll need to edit Dovecot&#039;s password file with a text editor and create the username/password pair by hand.&lt;br /&gt;
&lt;br /&gt;
== Testing the Dovecot Setup ==&lt;br /&gt;
&lt;br /&gt;
To test IMAP, you&#039;ll need an email client. Personally, I&#039;ve used [https://www.thunderbird.net Thunderbird] on Windows and [https://k9mail.app/ K-9 Mail] on Android. The trickiest part is getting the email client to trust the self-signed certificates. Configuring email clients is beyond the scope of this document.&lt;br /&gt;
&lt;br /&gt;
From the server side, the Dovecot log file can help you diagnose errors. The dovecot.conf file specifies the location of the log file.&lt;br /&gt;
&lt;br /&gt;
  log_path = /var/log/dovecot.log&lt;br /&gt;
&lt;br /&gt;
One of the common errors I&#039;ve seen looks like this:&lt;br /&gt;
&lt;br /&gt;
  Disconnected: TLS initialization failed.&lt;br /&gt;
  Error: Failed to initialize SSL server context: Can&#039;t load SSL certificate&lt;br /&gt;
&lt;br /&gt;
This was from a typo in the Dovecot config file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Work in progress. More to come.&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Dhorton</name></author>
	</entry>
</feed>