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:
parent
2b58e38907
commit
c5144faf96
16
README.md
16
README.md
@ -9,7 +9,7 @@ machines
|
||||
# SYNOPSIS
|
||||
|
||||
**boxctl**
|
||||
\[**-mnv**]
|
||||
\[**-fmnsv**]
|
||||
\[**-h** *host*]
|
||||
\[**-u** *user*]
|
||||
|
||||
@ -39,6 +39,11 @@ The options are as follows:
|
||||
> Defaults to
|
||||
> *root*.
|
||||
|
||||
**-f**
|
||||
|
||||
> Force installation of all packages.
|
||||
> This skipps the 'intelligent' diff mode.
|
||||
|
||||
**-m**
|
||||
|
||||
> Run maintenance tasks.
|
||||
@ -52,6 +57,15 @@ The options are as follows:
|
||||
> Dry 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**
|
||||
|
||||
> Increase verbosity.
|
||||
|
51
boxctl.sh
51
boxctl.sh
@ -23,31 +23,16 @@ RUN_USER="root"
|
||||
VERBOSITY=0
|
||||
DRY=0
|
||||
MAINTENANCE=0
|
||||
SNAPSHOT=""
|
||||
FORCE=0
|
||||
SSH_CTL_PATH="/tmp/boxctl-%r@%h:%p"
|
||||
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
|
||||
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
|
||||
while getopts "fh:mnu:sv" arg; do
|
||||
case $arg in
|
||||
f)
|
||||
FORCE=1
|
||||
;;
|
||||
h)
|
||||
SERVER=$OPTARG
|
||||
;;
|
||||
@ -60,12 +45,36 @@ while getopts "h:mnu:v" arg; do
|
||||
u)
|
||||
RUN_USER=$OPTARG
|
||||
;;
|
||||
s)
|
||||
SNAPSHOT="-Dsnap"
|
||||
;;
|
||||
v)
|
||||
VERBOSITY=$((VERBOSITY+1))
|
||||
;;
|
||||
esac
|
||||
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() {
|
||||
local _level _msg
|
||||
_level=$1
|
||||
|
12
man/boxctl.8
12
man/boxctl.8
@ -24,7 +24,7 @@
|
||||
machines
|
||||
.Sh SYNOPSIS
|
||||
.Nm boxctl
|
||||
.Op Fl mnv
|
||||
.Op Fl fmnsv
|
||||
.Op Fl h Ar host
|
||||
.Op Fl u Ar user
|
||||
.Sh DESCRIPTION
|
||||
@ -48,6 +48,9 @@ User to connect to
|
||||
with.
|
||||
Defaults to
|
||||
.Pa root .
|
||||
.It Fl f
|
||||
Force installation of all packages.
|
||||
This skipps the 'intelligent' diff mode.
|
||||
.It Fl m
|
||||
Run maintenance tasks.
|
||||
This includes deleting unused dependencies using
|
||||
@ -57,6 +60,13 @@ And installing / updating firmware using
|
||||
.It Fl n
|
||||
Dry 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
|
||||
Increase verbosity.
|
||||
More v's can be specified to increase information output.
|
||||
|
Loading…
Reference in New Issue
Block a user