Skip to content

Instantly share code, notes, and snippets.

@raspi
Last active March 21, 2023 23:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raspi/45b0c3adea085bbbd25f1375e0ce5580 to your computer and use it in GitHub Desktop.
Save raspi/45b0c3adea085bbbd25f1375e0ce5580 to your computer and use it in GitHub Desktop.
Dump FreeBSD sysctl descriptions as markdown
#!/bin/sh
# Function for printing
p()
{
KEY=$1
TYPE=$2
DESCR=$3
# last character is '.'
if [ $(echo "$KEY" | egrep -c '\.$') -ge 1 ]; then
return
fi
# No description
if [ -z "$DESCR" ]; then
return
fi
# key has something.1.something
if [ $(echo "$KEY" | egrep -c '\.[0-9]+\.') -ge 1 ]; then
return
fi
echo "## $TYPE \`$item\`"
echo "$DESCR"
echo ""
}
echo "# Settable via \`/etc/sysctl.conf\`:"
echo ""
VARIABLES=$(sysctl -aNW)
for item in $VARIABLES
do
p "$item" "$(sysctl -tn $item)" "$(sysctl -dn $item)"
done
echo "# Settable via \`/boot/loader.conf\`:"
echo ""
VARIABLES=$(sysctl -aNT)
for item in $VARIABLES
do
p "$item" "$(sysctl -tn $item)" "$(sysctl -dn $item)"
done
@raspi
Copy link
Author

raspi commented Sep 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment