FreeBSD and UTF-8

I want to have all the locales set to en_US.UTF-8, but I don’t want 12h time (AM/PM).

Modify /etc/login.conf as follows:

--- /etc/login.conf.orig	2016-05-17 20:19:47.189836683 +0200
+++ /etc/login.conf	2016-05-17 20:04:48.151898313 +0200
@@ -26,7 +26,7 @@
-	:setenv=MAIL=/var/mail/$,BLOCKSIZE=K:\
+	:setenv=MAIL=/var/mail/$,BLOCKSIZE=K,LC_COLLATE=C:\
 	:path=/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin ~/bin:\
@@ -44,7 +44,9 @@
-	:umask=022:
+	:umask=022:\
+    :charset=UTF-8:\
+    :lang=en_US.UTF-8:
 # A collection of common class names - forward them all to 'default'

After changing execute sudo cap_mkdb /etc/login.conf.

To change to 24h clock in uptime, w etc. Change /usr/share/locale/en_US.UTF-8/LC_TIME as follows:

--- LC_TIME.orig	2016-05-17 20:14:40.018856258 +0200
+++ LC_TIME	2016-05-17 20:15:36.835860995 +0200
@@ -39,8 +39,8 @@
 %a %b %e %X %Y
 %a %b %e %X %Z %Y
@@ -55,4 +55,4 @@
-%I:%M:%S %p

Note: Don’t remove the lines, only all characters on the lines.


Update a port to a newer version

So, you know a new version of a software has been released, but the port maintainer isn’t fast enough to satisfy your bleeding edge need; here’s how you’d do it:

  1. Update Makefile, variables like PORTVERSION and any other variables used to identify the package to download.
  2. Make sure that it is possible to download the new package and generate distinfo:
    make makesum
  3. Generate the pkg-plist file so that all the new files is correctly pointed out:
    make makeplist > pkg-plist
    awk '/etc\/rc.d\/plexmediaserver/,/^$/' pkg-plist > tmp && mv tmp pkg-plist
  4. Then it’s just a matter of re-installing the ports:
    make distclean && make && make reinstall clean

Courtesy of mikec_pt on the Plex Forums [].

Installing splunk on FreeBSD 10

Acquire software
First, register an account [] on the splunk website to get access to the downloads. When logged in with your freshly verified account, go to the download page [] for the enterprise version.

Download the package named “FreeBSD<n>” (at the time writing these instructions, <n> = 7). Easiest is to cancel the “Save file…” dialogue and instead go with the “Got wget? Get this URL” approach.

Use the URL to download the software package on your FreeBSD 10 server.

Configure FreeBSD
Add some configuration to the boot loader:

sysctl -a | egrep "kern.maxdsiz|kern.dfldsiz" | sed 's/: /="/' | awk '{print $0"\""}' >> /boot/loader.conf
echo "machdep.hlt_cpus=0" >> /boot/loader.conf

Reboot server for changes to take affect.

Install and start software
Uncompress the package contents in /opt:

mkdir /opt
tar zxvf splunk-*.tgz -C /opt
/opt/splunk/bin/splunk enable boot-start
service splunk start

Configure syslog
The standard syslog daemon in FreeBSD listens on UDP port 514 by default. We want splunk to take care of that, so to disable lets disable it by adding the syslogd flag -ss in /etc/rc.conf and restart the daemon.

echo 'syslogd_flags="-ss"' >> /etc/rc.conf
service syslogd restart

Let’s configure splunk to listen for remote logging on UDP port 514 instead for remote clients.

/opt/splunk/bin/splunk add udp -source 514 -sourcetype syslog -resolvehost true

Locally on the server, we should monitor /var/log.

/opt/splunk/bin/splunk add monitor /var/log

Now you have a working instance of Splunk! What is left todo is configure your clients to use it as a remote logging server… that is however out of the scope of these instructions.

Change to free license
With the free enterprise download (needed for the FreeBSD version), you received a trial license for 60 days. For home usage, you can just remove the trial license straight away and save you the hassle down the road in 60 days.

/opt/splunk/bin/splunk edit licenser-groups Free -is_active 1
service splunk restart