Skip to content

Instantly share code, notes, and snippets.

@libcrack
Created May 12, 2024 14:05
Show Gist options
  • Save libcrack/6b9ab9ccd08284d6d8eded1edef25ddd to your computer and use it in GitHub Desktop.
Save libcrack/6b9ab9ccd08284d6d8eded1edef25ddd to your computer and use it in GitHub Desktop.
Install FreeBSD manpages in pfSense boxes
#!/bin/sh
# devnull@libcrack.so
# Thu Mar 2 19:48:14 CET 2023
#
# From http://ftp.freebsd.org/pub/FreeBSD/README.TXT
#
# releases/${MACHINE}/${MACHINE_ARCH}/*-RELEASE/
# The official FreeBSD releases as individual tarballs to download; useful
# for jail hosting, updating machines in situ, etc. Make sure to look in
# the ${MACHINE_ARCH} sub-directory for the most recent releases (e.g.,
# releases/amd64/amd64); this is a change from the earlier ${ARCH} naming
# scheme (e.g., releases/amd64).
#
# snapshots/${MACHINE}/${MACHINE_ARCH}/*-{STABLE,CURRENT}/
# Intermittently updated snapshots of -CURRENT and selected -STABLE
# branches. A good way to seed a development machine or test in-progress
# FreeBSD features.
#
# Thu Mar 2 19:48:14 CET 2023
# 13.1-RELEASE
# 14.0-CURRENT
#
# Mon Oct 30 01:25:05 CET 2023
# 13.2-RELEASE
# 15.0-CURRENT
#
BRANCH="$(uname -r | cut -f2 -d'-')"
RELEASE="$(uname -r | cut -f1 -d'-')"
echo "-----------------------------------------------------"
echo "Installing manpages on pfSense $RELEASE-$BRANCH"
echo "RELEASE: $RELEASE"
echo "BRANCH: $BRANCH"
echo "-----------------------------------------------------"
echo
cd /tmp || exit 1
if [ "$BRANCH" == "CURRENT" ]; then
curl -JLO "http://ftp.freebsd.org/pub/FreeBSD/snapshots/$(uname -m)/$(uname -r)/base.txz"
elif [ "$BRANCH" == "RELEASE" ]; then
curl -JLO "http://ftp.freebsd.org/pub/FreeBSD/releases/$(uname -m)/$(uname -r)/base.txz"
else
echo "ERROR: Cannot identify FreeBSD branch \"$BRANCH\""
exit 2
fi
if [ ! -f base.txz ]; then
echo "ERROR: failed to download base.txz"
exit 3
fi
file base.txz | grep "XZ compressed data" || exit 4
echo "Deflating base tarball"
mkdir base
xz -d base.txz
tar xvf base.tar -C base
echo "Coping manpages files"
cp base/usr/bin/apropos /usr/bin
cp base/usr/bin/man /usr/bin
cp -r base/usr/share/man /usr/share
echo "Changing file permissions"
chflags -R noschg base/
echo "Deleting base files"
rm -rf base base.tar
cd - || exit 5
echo "MANPAGES INSTALLED"
exit 0
#EOF#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment