Last active
March 21, 2023 23:44
-
-
Save raspi/45b0c3adea085bbbd25f1375e0ce5580 to your computer and use it in GitHub Desktop.
Dump FreeBSD sysctl descriptions as markdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://gist.github.com/raspi/a93d149b3916f4c12bbb9a52fe575f93