# Afterboot OpenBSD

### by Joshua Branson — April 28, 2023

# set up doas

Let’s make any user that is in the group “wheel” able to execute privledged commands.

    # cat /etc/examples/doas.conf | sed 's/keepenv/persist keepevn/' > /etc/doas.conf

# install packages

    # pkg_add emacs dino netsurf dino git fish mpv firefox gpg \
      hack-fonts pkg_add isync evince libreoffice xfce4-terminal \
      xfce4-screenshooter xfce4-dict i3

When I installed isync, I got a message that said, the following rcscripts were installed: /etc/rc.d/saslauthd apparently openbsd’s packaged isync, lets you set up a daemon to periodically fetch your email. looking at the file, I’m not sure what it is.

Well I could list all of the packages that I minually installed, it is actually much easier to create a list of packages.

    pkg_info -mz | tee openbsd-pkg-list

Now, when I want to re-install those packages I can just do this:

    # pkg_add -l list

# clone my various repos

    cd ~/
    git clone https://notabug.org/jbranso/prog
    cd prog
    mkdir -p gnu/guix/
    cd gnu/guix
    git clone https://notabug.org/jbranso/guix
    mv guix guix-src
    git clone https://notabug.org/jbranso/guix-config

# update my OpenBSD install

`# doas syspatch`

# enable softupdates

Unless you are using really old ancient hardware, you should enable softupdates.

change

`43434930490.a / ffs rw 1 1`

to

`43434930490.a / ffs rw,softdep 1 1`

# window manager stuff

## modify my ~/.xsession

auto start xfce, prefer utf-8, set up a background color, and lock X after some inactivity.

    cat ~/.xsession

    # prefer UTF-8 whenever possible
    export LC_CTYPE="en_US.UTF-8"

    # use UTF-8 everywhere
    export LANG=en_US.UTF-8

    # specify location of kshrc
    export ENV=$HOME/.kshrc

    # set your background color
    xsetroot -solid dimgray

    xidle -delay 5 -sw -program "/usr/X11R6/bin/xlock -mode flag" \
                       -timeout 300

    exec i3

## set up polybar for i3

https://forum.endeavouros.com/t/tutorial-easy-setup-endeavour-xfce-i3-tiling-window-manager/13171

    # doas pkg_add polybar
    $ mkdir ~/.config/polybar
    $ cp /usr/local/share/examples/polybar/config ~/.config/polybar

This wiki page has a lot of details about setting up fonts.

More information is in my polybar config.

# If this is a laptop with a battery, then install this

https://dataswamp.org/~solene/2022-03-21-openbsd-cool-frequency.html

    # doas pkg_add obsdfreqd
    # rcctl enable obsdfreqd
    # rcctl stop apmd
    # rcctl disable apmd
    # rcctl start obsdfreqd

# set up doom emacs

(I also need to ensure that `~/prog/gnu/guix/` exists because my emacs looks for some guix snippets).

    git clone --depth 1 https://github.com/doomemacsdoomemacs ~/.config/emacs
    ~/.config/emacs/bin/doom install

add doom emacs to path

    cat ~/.profile

    # $OpenBSD: dot.profile,v 1.8 2022/08/10 07:40:37 tb Exp $
    #
    # sh/ksh initialization
    #

    PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/home/joshua/.config/emacs/bin
    export PATH HOME TERM

# copy my ~/ config files

cp .authinfo.gpg, .ssh, .mbsyncrc, .gnupg/

cp documents to ~/

# import my gpg keys from my usb stick.

`gpg --import ./dismail.de.gpg.key.asc`

`git config --global commit.gpgsign true`

## set up pinentry

    pkg_add pinentry-dmenu

There are two things that you need to do to set up pinentry-dmenu, so that when I need to sign commits or decrypt stuff, the pinentry-dmenu popup happens.

- set up gpg agent

      cat ~/.gnupg/gpg-agent.conf

      pinentry-program /usr/local/bin/pinentry-dmenu

      default-cache-ttl 3600

- `man gpg-agent` says to do this:

      You should always add the following lines to your .bashrc or whatever
      initialization file is used for all shell invocations:

      cat ~/.profile | grep GPG_TTY

      GPG_TTY=$(tty)
      export GPG_TTY

- start a dbus session

  This is only needed if you want to use pinentry-gnome3

      cat ~/.xsession | grep dbus

      # start a dbus session, which I believe gpg needs to for graphical pinentry
      # I found this command in /usr/local/share/doc/pkg-readmes/dbus
      if [ -x /usr/local/bin/dbus-launch -a -z "${DBUS_SESSION_BUS_ADDRESS}" ]; then
              eval `dbus-launch --sh-syntax --exit-with-x11`

If you have difficulty getting pinentry to work, here are some steps to manually get pinentry to work:

in a fish terminal a type in:

    gpgconf --kill gpg-agent
    set GPG_TTY $(tty)
    export GPG_TTY
    git commit -m "my commit message"

# change `/etc/motd`

I once set an invalid option up in /etc/fstab that threw me in a root shell with only root mounted. All of a sudden vi would not work. That below command is how to fix it: `export TERM=vt200`

    cat /etc/motd

    OpenBSD 7.2 (GENERIC.MP) #7: Sat Feb 25 14:07:58 MST 2023

    Welcome to OpenBSD: The proactively secure Unix-like operating system.

    Please use the sendbug(1) utility to report bugs in the system.
    Before reporting a bug, please try to reproduce it with the latest
    version of the code.  With bug reports, please try to ensure that
    enough information to reproduce the problem is enclosed, and if a
    known fix for it exists, include that as well.

    If you are having trouble using vi in the console try this:

    export TERM=vt200;

# install haunt on OpenBSD

`doas pkg_add guile info`

First install guile-commonmark:

    $ cd ~/prog/guile
    $ git clone git clone https://github.com/OrangeShark/guile-commonmark
    $ cd guile-commonmark
    # export AUTOCONF_VERSION=2.71
    # export export AUTOMAKE_VERSION=1.16.5
    # doas pkg_add autoconf automake

Why am I seeing 2 aclocal binaries? No idea.

    ls /usr/local/bin/aclocal*
    ls /usr/local/bin/automake*

    /usr/local/bin/aclocal
    /usr/local/bin/aclocal-1.16
    /usr/local/bin/automake
    /usr/local/bin/automake-1.16

Arsen on irc helped me figure out the next incantation.

    AUTOMAKE=automake-1.16 ACLOCAL=aclocal-1.16 ./bootstrap
    ./configure
    make
    make check
    # make install

Now let’s install haunt

    git clone https://git.dthompson.us/haunt.git
    cd haunt
    AUTOMAKE=automake-1.16 ACLOCAL=aclocal-1.16 ./bootstrap
    ./configure
    make
    make check
    # make install