Date Tags freebsd

So, there are things I want to do on a FreeBSD after the installation. A few things I want to make sure is exactly as I want it to make the place feel more like home.

First of all, I want a few packages that I want installed to make my life both with less surprices as I work on various platforms, and some of it just because it makes my life feel a bit easier.

First of all, since this is the freebsd ports tree I'll be using for software, I'll start with getting it up to date quickly followed by the installation of a few packages that covers my basic needs ;-)

First getting it up to date, I start with the classic su - to get to root because I want a few things underway before I mostly do things through sudo.

pkg update -f
pkg upgrade -y

Then a single starter

pkg install -y tmux sudo

I've put together a tiny snippet that seems to work across at least theese three platforms, and it's fairly easy to adjust for new "fun" platforms. My current version requires a switch to sh as shell.

sh -
case `uname -s` in
        FreeBSD)
                SUDOPATH=/usr/local/etc/sudoers.d/
                ;;
        NetBSD)
                SUDOPATH=/usr/pkg/etc/sudoers.d/
                ;;
        Linux)
                SUDOPATH=/etc/sudoers.d/
                ;;
esac

After that I do this, with the export USER=myusername with myusername being replaced with my actual login name.

export USER=myusername
tee $SUDOPATH$USER<<EOF
$USER ALL=(ALL:ALL) NOPASSWD: ALL
EOF

To allow me to stop being root and fix a few more bits on the machine in the comfort of my own shell and environment.

Next step is to started tmux so I can run the rest in there. It's really nice and you're on a primitive console like a serial, or working remotely and suffer bad net.

Then it's time to install the extra bits.

sudo pkg install -y zsh git py27-virtualenv htop

And if it's a physical box, I'll most likely want bhyve for some extra stuff.

sudo pkg install -y vm-bhyve

Periodics

Quite often I prefer to have periodic scripts deliver their ourput in a local log rather than have then send a mail off, there's plenty of stuff in my mailbox allready, so I setup this periodic.conf file.

sudo tee /etc/periodic.conf<<EOF
daily_output=/var/log/daily.log
weekly_output=/var/log/weekly.log
monthly_output=/var/log/monthly.log
daily_backup_pf_tables="YES"
EOF

If there's a chance the machine is running pf and might have some tables I like to have then automatically syncronized during the daily job with a script like.

sudo tee /etc/periodic/daily/600.backup-pf-tables<<EOF
#!/bin/sh

# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
    . /etc/defaults/periodic.conf
    source_periodic_confs
fi

case "\$daily_backup_pf_tables" in
    [Yy][Ee][Ss])
        rc=0
        if [ -d /etc/pf.d ]; then
          echo "Checking known pf lists"
          for list in \`/sbin/pfctl -q -sT\`
          do
            OF="/etc/pf.d/\$list.yesterday"
            NF="/etc/pf.d/\$list"
            REP="\$list"
            if [ -r \$NF ]; then
              /sbin/pfctl -q -t \$list -T show >/etc/pf.d/\$list 2>/dev/null
              if ! /usr/bin/diff -qN \$OF \$NF >/dev/null; then
                echo "Changes in \$REP list----"
                diff -uN \$OF \$NF
                cp \$NF \$OF
              fi
            fi
          done
        fi
        ;;
    *)  rc=0;;
esac

exit \$rc
EOF
sudo chmod 755 /etc/periodic/daily/600.backup-pf-tables

And a tiny note here that needs to be written down somewhere. On one of my machines the console display is horribly broken with the bottom of the text actually appearing on top of the screen, something makes it really not like the tty. All that's needed is a single line in /boot/loader.conf

kern.vty=sc

And then everything looks better, even vidcontrol suddenly works!

There's probably more to come :-)


Comments

comments powered by Disqus