Add -f and -s options.

-f forces reinstallation of packages (if they are missing)
-s forces pkg_add to use '-Dsnap'
This commit is contained in:
Aaron Bieber 2019-10-10 07:27:20 -06:00
parent 2b58e38907
commit c5144faf96
Signed by: qbit
GPG Key ID: 279160AB1BE1236B
3 changed files with 56 additions and 23 deletions

View File

@ -9,7 +9,7 @@ machines
# SYNOPSIS # SYNOPSIS
**boxctl** **boxctl**
\[**-mnv**] \[**-fmnsv**]
\[**-h** *host*] \[**-h** *host*]
\[**-u** *user*] \[**-u** *user*]
@ -39,6 +39,11 @@ The options are as follows:
> Defaults to > Defaults to
> *root*. > *root*.
**-f**
> Force installation of all packages.
> This skipps the 'intelligent' diff mode.
**-m** **-m**
> Run maintenance tasks. > Run maintenance tasks.
@ -52,6 +57,15 @@ The options are as follows:
> Dry run. > Dry run.
> This will only print the commands that will be run. > This will only print the commands that will be run.
**-s**
> Force
> pkg\_add(1)
> to run with '-Dsnap'.
> This is useful when
> OpenBSD
> is in -beta.
**-v** **-v**
> Increase verbosity. > Increase verbosity.

View File

@ -23,31 +23,16 @@ RUN_USER="root"
VERBOSITY=0 VERBOSITY=0
DRY=0 DRY=0
MAINTENANCE=0 MAINTENANCE=0
SNAPSHOT=""
FORCE=0
SSH_CTL_PATH="/tmp/boxctl-%r@%h:%p" SSH_CTL_PATH="/tmp/boxctl-%r@%h:%p"
SSH_OPTS="-o ControlMaster=auto -o ControlPersist=60s -o ControlPath=${SSH_CTL_PATH}" SSH_OPTS="-o ControlMaster=auto -o ControlPersist=60s -o ControlPath=${SSH_CTL_PATH}"
SERVICE_START_RESTART=$(cat <<EOF
/usr/sbin/rcctl enable %s; \
/usr/sbin/rcctl check %s && \
/usr/sbin/rcctl restart %s || \
/usr/sbin/rcctl start %s
EOF
)
PKG_DIFF_INSTALL=$(cat <<EOF while getopts "fh:mnu:sv" arg; do
if [ -f /etc/packages ]; then
# Already ran a full install, so only install new packages
diff -u /etc/packages /etc/packages.tmp | grep -e ^+[a-z0-9] | \
sed 's/^+//' > /tmp/new_packages
/usr/sbin/pkg_add %s -z -l /tmp/new_packages
else
/usr/sbin/pkg_add %s -z -l /etc/packages.tmp
fi
mv /etc/packages.tmp /etc/packages
EOF
)
while getopts "h:mnu:v" arg; do
case $arg in case $arg in
f)
FORCE=1
;;
h) h)
SERVER=$OPTARG SERVER=$OPTARG
;; ;;
@ -60,12 +45,36 @@ while getopts "h:mnu:v" arg; do
u) u)
RUN_USER=$OPTARG RUN_USER=$OPTARG
;; ;;
s)
SNAPSHOT="-Dsnap"
;;
v) v)
VERBOSITY=$((VERBOSITY+1)) VERBOSITY=$((VERBOSITY+1))
;; ;;
esac esac
done done
PKG_DIFF_INSTALL=$(cat <<EOF
if [ -f /etc/packages ] && [ "${FORCE}" == "0" ]; then
# Already ran a full install, so only install new packages
diff -u /etc/packages /etc/packages.tmp | grep -e ^+[a-z0-9] | \
sed 's/^+//' > /tmp/new_packages
/usr/sbin/pkg_add %s ${SNAPSHOT} -z -l /tmp/new_packages
else
/usr/sbin/pkg_add %s ${SNAPSHOT} -z -l /etc/packages.tmp
fi
mv /etc/packages.tmp /etc/packages
EOF
)
SERVICE_START_RESTART=$(cat <<EOF
/usr/sbin/rcctl enable %s; \
/usr/sbin/rcctl check %s && \
/usr/sbin/rcctl restart %s || \
/usr/sbin/rcctl start %s
EOF
)
msg() { msg() {
local _level _msg local _level _msg
_level=$1 _level=$1

View File

@ -24,7 +24,7 @@
machines machines
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm boxctl .Nm boxctl
.Op Fl mnv .Op Fl fmnsv
.Op Fl h Ar host .Op Fl h Ar host
.Op Fl u Ar user .Op Fl u Ar user
.Sh DESCRIPTION .Sh DESCRIPTION
@ -48,6 +48,9 @@ User to connect to
with. with.
Defaults to Defaults to
.Pa root . .Pa root .
.It Fl f
Force installation of all packages.
This skipps the 'intelligent' diff mode.
.It Fl m .It Fl m
Run maintenance tasks. Run maintenance tasks.
This includes deleting unused dependencies using This includes deleting unused dependencies using
@ -57,6 +60,13 @@ And installing / updating firmware using
.It Fl n .It Fl n
Dry run. Dry run.
This will only print the commands that will be run. This will only print the commands that will be run.
.It Fl s
Force
.Xr pkg_add 1
to run with '-Dsnap'.
This is useful when
.Ox
is in -beta.
.It Fl v .It Fl v
Increase verbosity. Increase verbosity.
More v's can be specified to increase information output. More v's can be specified to increase information output.