commit 0db681124baffa207d87dd2b36f2f4014ff135c5
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Sat, 25 Oct 2025 14:03:19 -0500
Add functional project
Diffstat:
| A | Makefile | | | 17 | +++++++++++++++++ |
| A | README | | | 5 | +++++ |
| A | ptlab | | | 74 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | ptlab.1 | | | 62 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
4 files changed, 158 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
@@ -0,0 +1,17 @@
+SCRIPTS = ptlab
+
+PREFIX = /usr/local/
+MANPREFIX = ${PREFIX}/man
+
+install:
+.for s in ${SCRIPTS}
+ install -o root -g bin -m 755 $s ${PREFIX}/bin/$s
+.endfor
+ install -o root -g bin -m 644 ptlab.1 ${MANPREFIX}/man1/ptlab.1
+ makewhatis -d ${MANPREFIX} ${MANPREFIX}/man1/ptlab.1
+
+uninstall:
+.for s in ${SCRIPTS}
+ rm -f /usr/local/bin/$s
+.endfor
+ rm -f ${MANPREFIX}/man1/ptlab.1
diff --git a/README b/README
@@ -0,0 +1,5 @@
+ptlab
+=====
+
+Script for working with packet tracer, specifically in combination
+with Wendell Odom's config labs.
diff --git a/ptlab b/ptlab
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+set -e
+
+log() {
+ echo "ptlab: $*" 1>&2
+}
+
+err() {
+ log "$@"
+ exit 1
+}
+
+usage() {
+ echo 'usage: ptlab [-lnkux] [lab]' 1>&2
+ exit 1
+}
+
+pt() {
+ packettracer "$@"
+}
+
+baseurl=https://files.certskills.com/virl
+labs="$HOME"/ptlabs
+
+update=false
+fetchonly=false
+local=false
+keep=false
+while test $# -gt 0
+do
+ case "$1" in
+ (-l) local=true ;;
+ (-n) fetchonly=true ;;
+ (-k) keep=true ;;
+ (-u) update=true ;;
+ (-x) set -x ;;
+ (--) shift; break ;;
+ (-*) usage ;;
+ (*) break ;;
+ esac
+ shift
+done
+
+if $local || test $# -eq 0; then
+ pt "$@"
+ exit
+fi
+
+lab="$(basename "$1")"
+file=clab"${lab#clab}".pkt
+
+path="$labs"/init/"$file"
+if $update || ! test -f "$path"
+then
+ url="$baseurl"/"$file"
+ mkdir -p "$(dirname "$path")"
+ curl -SsLo "$path".tmp "$url" ||
+ err "Unable to fetch $url"
+ chmod a-w "$path".tmp
+ mv -f "$path".tmp "$path"
+fi
+
+$fetchonly &&
+ exit
+
+runpath="$labs"/run/"$file"
+mkdir -p "$labs"/run
+if ! $keep || ! test -e "$runpath"
+then
+ cp "$path" "$runpath"
+ chmod ug+w "$runpath"
+fi
+pt "$runpath"
diff --git a/ptlab.1 b/ptlab.1
@@ -0,0 +1,62 @@
+.Dd October 19, 2025
+.Dt PTLAB 1
+.Os
+.Sh NAME
+.Nm ptlab
+.Nd Packet tracer wrapper script
+.Sh SYNOPSIS
+.Nm
+.Op -lnkux
+.Op Ar lab
+.Sh DESCRIPTION
+The
+.Nm
+utility handles fetching Wendell Odom's config labs and executing
+packet tracer on them.
+.Nm
+By default, the
+.Ar lab
+provided is treated as a config lab from Wendell's website. It can
+be provided as the full url to the lab or just the lab number.
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl l
+Treat
+the provided
+.Ar lab
+as a .pkt file instead of a config lab identifier.
+.It Fl n
+Don't run packet tracer, only fetch the config lab.
+.It Fl k
+Keep lab from last run instead of overwriting it with the initial
+config lab.
+.It Fl u
+Update the config lab with the newest version from the server.
+.It Fl x
+Turn on debugging
+.Xr ( sh 1
+Xtrace option).
+.Pp
+.Sh FILES
+.Bl -tag -width Ds
+.It Pa ~/ptlabs/
+Directory for config labs and temporary files.
+.El
+.Sh EXIT STATUS
+.Ex -std
+.Sh EXAMPLES
+.Pp
+Run the
+.Qq ROAS Basics 1
+lab:
+.Pp
+.Dl $ ptlab https://www.certskills.com/clab120/
+.Pp
+Update the same lab, but don't run it:
+.Pp
+.Dl $ ptlab -u -n 120
+.Pp
+.\.Sh SEE ALSO
+.Sh AUTHORS
+.An Jacob R. Edwards Aq Mt jacob@jacobedwards.org