linner.org

NUT (Network UPS Tools) on Slackware 15

Posted by in Linux, Slackware

  • Install sbopkg https://sbopkg.org/
  • Create user nut and group nut
  • Use sbopkg to download/build/install system/nut
  • Check device info for your connected UPS:
    root@pn41:/etc/nut# lsusb
    .
    .
    Bus 001 Device 006: ID 0463:ffff MGE UPS Systems UPS
    .
  • Edit /etc/nut/ups.conf and add your device:
    [myups]
    driver = usbhid-ups
    port = auto
    vendorid = 0463
    pollfreq = 30
  • Add an user to /etc/nut/upsd.users:
    [user]
    password = password
    upsmon master
    actions = SET
    instcmds = ALL

    # To be used by monitoring client
    [client]
    password = password2
    upsmon slave
  • Edit and configure /etc/nut/upsmon.conf.sample and save as upsmon.conf:
    MONITOR myups@localhost 1 user password master
    NOTIFYCMD /etc/nut/sendupsmsg
    NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
    NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
    NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
    NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
  • Edit /etc/nut/nut.conf (to allow other clients to connect):
    MODE=netserver
  • Edit /etc/upsd.conf and specify which NIC that should be used for outside connections:
    LISTEN 192.168.1.9 3493
    LISTEN 127.0.0.1 3493
  • Edit script (/etc/nut/sendupsmsg) that will be called if NOTIFYFLAG with flag EXEC kicks in:
    #!/bin/bash
    echo $(date): "$*" >> /var/log/ups.log
    # Replace with your own script for alert.
    sendupsemail "$*"
  • Set correct file permissions:
    chown root:nut /etc/nut/* /var/log/ups.log
    chmod 650 /etc/nut/* /var/log/ups.log
    chmod +x /etc/rc.d/rc.ups
    chmod 750 /etc/nut/sendupsmsg
  • Add rc.ups to /etc/rc.d/rc.local:
    if [ -x /etc/rc.d/rc.ups ]; then
    /etc/rc.d/rc.ups start
    fi
  • Add shutdown cmd to /etc/rc.d/rc.local_shutdown:
    if [ -f /etc/killpower ]; then
    # Stop ups service:
    echo "Stopping ups stuff: upsdrvctl shutdown"
    upsdrvctl shutdown
    fi
  • Start the services:
    /etc/rc.d/rc.usp start
  • Check if it works:
    upsc myups
  • Pull the plug and check syslog and that the notify script is called
0

Let’s git

Posted by in Lagom

cd .../myproject/
nano -w .gitignore (filtered stuff, one on each row, *.old, *.backup etc)
git init
git add .
git commit -m "Initial release or whatever."
---
git status
nano -w changedfile.xxx
git diff changedfile.xxx
git add changedfile.xxx
git commit -m "Fixed a bug or whatever."
git push (if remote repository on gitlab etc.)
0

Docker in Slackware 14.2

Posted by in Slackware

First, install sbopkg: https://sbopkg.org/
Make sure you have the (standard 14.2) gcc-go package installed.
Select preferred editor before starting sbopkg (default is vi):

> export EDITOR=nano
> sbopkg

From sbopkg, download, build and install tini and Go:

tini
google-go-lang

After google-go-lang is installed, quit sbopkg and make sure to add the path to the new go-binary in ~/.bashrc (check the go version):
PATH=$PATH:/usr/lib64/go1.16.3/go/bin
Logout and login from the terminal session or run:

> . ~/.bashrc

Start sbopkg again and build these packages in the given order:

docker-proxy
libseccomp
runc
containerd
docker
docker-cli
docker-compose

You have to edit the .Slackbuilds for all the packages in bold above before building them and add GO111MODULE=auto \” before the row that contains the GOPATH row (Select “Custom/Edit Slackbuild” from the package menu in sbopkg).

Slackbuild:
.
.
.
GO111MODULE=auto \
GOPATH=$TMP/$SRCNAM-$VERSION/build

Good luck! If everything worked as it should, let’s try Docker out and create a minimal Dockerfile:

# Text file named Dockerfile
FROM busybox
ADD https://github.com/just-containers/s6-overlay/releases/download/v1.21.8.0/s6-overlay-amd64.tar.gz /tmp/
RUN gunzip -c /tmp/s6-overlay-amd64.tar.gz | tar -xf - -C /
ENTRYPOINT ["/init"]

> chmod +x /etc/rc.d/rc.docker
> /etc/rc.d/rc.docker start
> docker build -t s6demo .
> docker run -ti s6demo /bin/sh

Or why not try to run Slackware in Docker?
(from http://www.slackware.com/~vbatts/docker/)

docker run -i -t vbatts/slackware bash
0