This is the build script and notes for the raspberry pi that monitors my Rack and UPS.
Download the rpi2-musl image of void linux from reputable sources, currently here
Burn image to MicroSD card using either dd
or whatever windows tool is the popular thing and preferably doesn’t use electron.
Use cfdisk
to expand main partition from 2GB to remaining size of MicroSD card.
Login as root with default password of void-linux
Need to get correct time and network set up in order to update system and install packages (as root) Remember that the only available text editor is vi
!
1. Configure static IP address by editing `/etc/dhcpcd.conf` with the
following lines at the bottom of the file. Actual IP addresses are
found in the network documentation. We use DHCP rather than manual
`ip` commands in `/etc/rc.local` to take advantage of other aspects of
DHCP including auto DNS server population and domain name.
also uncomment `ntp_servers` option
dns server is usually pfsense default gateway
```conf
interface eth0
inform ip_address=$IPaddress
static ip_address=$IPaddress
static routers=$defaultgateway
static domain_name_servers=$dnsserver
```
2. edit `/etc/rc.conf` and change the following lines to set keymap and
timezone:
```conf
TIMEZONE="America/Denver" # or appropriate timezone
KEYMAP="us"
```
3. Enable NTP and DHCP services:
```bash
ln -s /etc/sv/ntpd /var/service
ln -s /etc/sv/dhcpcd /var/service
```
4. Check `/etc/ntpd.conf` for constraints line, and comment out. This
doesn't work on Raspi due to lack of HWCLK
5. Add `server $gateway` to `/etc/ntpd.conf` since it doesn't seem to pick
it up from DHCP. NTP server will usually be the pfsense gateway, but
use whatever machine is actually the NTP server
6. Create new non-root user, replacing $newusername with the actual name
of the user. This command adds the user to the wheel group, which
allows `sudo` access
```bash
useradd -m -s /bin/bash -U -G wheel,users,audio,video,cdrom,input $newusername
```
7. Set system hostname by editing `/etc/hostname`
Reboot the system using reboot
command. This should allow DHCP and NTP to do their thing and allow us to update the system and install new packages.
Log in as the new user you created
Update the system by running the following command until there is no output.
```bash
sudo xbps-install -Svu
```
```bash
sudo xbps-install nano network-ups-tools rng-tools thefuck vim htop
```
```bash
sudo xbps-install st-terminfo
```
```bash
sudo xbps-install socklog-void
sudo ln -s /etc/sv/socklog-unix /var/service
sudo ln -s /etc/sv/nanoklogd /var/service
# so normal user can access logs
sudo usermod -a -G socklog $USER
```
Config files for Network UPS Tool (NUT) are found at /etc/ups/
nut.conf
has a few global config options, which are not important on void.
ups.conf
is where you configure what UPSes the system will be interacting with
upsd.conf
is the configuration for the UPS data server
Configuration steps as follows:
Edit /etc/ups/nut.conf
and set MODE=netserver
. This is not strictly required on void, but still better to set.
Run nut-scanner
to generate config options for attached UPSes
Edit /etc/ups/ups.conf
and add the results of nut-scanner
to the begining of the file, except the vendor line. Add [cyberpower]
before. See syntax examples in config file.
Edit /etc/ups/upsd.conf
and update listen directive to the IP address of the local system.
Edit /etc/ups/upsd.users
and add an admin
user, upsmonMaster
and upsmonSlave
users with passwords from password safe.
- `admin` user has set actions and all instcmds
- `upsmonMaster` user is set up per example in config file with master
attributes for local monitoring by the raspi.
- `upsmonSlave` user is set up per example in config file with slave
attributes for remote monitoring by other clients.
/etc/ups/upsmon.conf
to set up local UPS monitoring. Add the following lines to the config file.```conf
# raspi has 1 power supply connected to this UPS. It is master
# because it is the monitoring system for the ups.
# other systems will be listed as slaves
MONITOR cyberpower@localhost 1 upsmonMaster $password master
# all other values can be left as defaults for now
```
Need to change ownership of config files on void linux as the default is set up incorrectly:
sudo chown root:nut /etc/ups/*
sudo chmod 640 /etc/ups/*
start the following services:
sudo ln -s /etc/sv/upsdrvctl/ /var/service
sudo ln -s /etc/sv/upsd/ /var/service
sudo ln -s /etc/sv/upsmon/ /var/service
check status of ups with the following command to make sure it is detected properly
upsc cyberpower
build-script, rack-monitor, notes