forked from mirrors/openup
Rename some functions.
This commit is contained in:
parent
94ed4cae6c
commit
b27db2f296
1 changed files with 27 additions and 27 deletions
54
openup
54
openup
|
|
@ -36,7 +36,7 @@ usage() {
|
|||
exit 1
|
||||
}
|
||||
|
||||
error() {
|
||||
pr_error() {
|
||||
echo "!!! ${@}"
|
||||
}
|
||||
|
||||
|
|
@ -50,18 +50,18 @@ set -A REL -- $(sysctl -n kern.version | sed 's/^OpenBSD \([0-9]\.[0-9]\)\([^ ]*
|
|||
REL_INT="$(echo ${REL[0]} | tr -d '.')"
|
||||
|
||||
if [ "${REL[1]}" == -!(stable) -o "${REL_INT}" -lt "${OPENUP_MINREL}" ]; then
|
||||
error "${REL[0]}${REL[1]} is not a supported release"
|
||||
pr_error "${REL[0]}${REL[1]} is not a supported release"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q installpath /etc/pkg.conf 2>/dev/null; then
|
||||
if [ -z "${PKG_PATH}" ]; then
|
||||
error "No package repository defined in pkg.conf(5) nor PKG_PATH"
|
||||
error
|
||||
error "The \${PKG_PATH} environment variable can be set as follow:"
|
||||
error "PKG_PATH=http://ftp.openbsd.org/pub/OpenBSD/\$(uname -r)/packages/\$(arch -s)"
|
||||
error "PKG_PATH=https://stable.mtier.org/updates/\$(uname -r)/\$(arch -s):\${PKG_PATH}"
|
||||
error "export PKG_PATH"
|
||||
pr_error "No package repository defined in pkg.conf(5) nor PKG_PATH"
|
||||
pr_error
|
||||
pr_error "The \${PKG_PATH} environment variable can be set as follow:"
|
||||
pr_error "PKG_PATH=http://ftp.openbsd.org/pub/OpenBSD/\$(uname -r)/packages/\$(arch -s)"
|
||||
pr_error "PKG_PATH=https://stable.mtier.org/updates/\$(uname -r)/\$(arch -s):\${PKG_PATH}"
|
||||
pr_error "export PKG_PATH"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
|
@ -72,7 +72,7 @@ if [ -n "${_BPLIST}" ]; then
|
|||
_i=$(echo ${_BPLIST} | wc -w)
|
||||
_v=$(echo ${_BPLIST} | grep "^binpatch${REL_INT}" | wc -w)
|
||||
if [ "${_i}" -ne "${_v}" ]; then
|
||||
error "Binpatch(es) from a previous release installed"
|
||||
pr_error "Binpatch(es) from a previous release installed"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
|
@ -88,11 +88,11 @@ TMPSPLITCERT=$(mktemp -p ${TMPDIR} openup-split_cert.XXXXXX) || exit 1
|
|||
|
||||
trap "rm -f ${TMPDIR}/openup-*" 1 2 3 13 15
|
||||
|
||||
print3() {
|
||||
pr_bigarrow() {
|
||||
echo "===> ${@}${DRYRUN}"
|
||||
}
|
||||
|
||||
print_arrow() {
|
||||
pr_smallarrow() {
|
||||
echo "-> ${@}"
|
||||
}
|
||||
|
||||
|
|
@ -107,16 +107,16 @@ get_cert() {
|
|||
grep -q "${PKG_CERT_FPRINT}" && return
|
||||
done
|
||||
|
||||
print3 "Downloading certificate"
|
||||
pr_bigarrow "Downloading certificate"
|
||||
_CMD="ftp -Vo ${TMPCERT} ${PKG_CERT_URL}"
|
||||
print_arrow "${_CMD}"
|
||||
pr_smallarrow "${_CMD}"
|
||||
if [ -z "${DRYRUN}" ]; then
|
||||
eval ${_CMD} || exit 1
|
||||
fi
|
||||
|
||||
print3 "Installing certificate"
|
||||
pr_bigarrow "Installing certificate"
|
||||
_CMD="cat ${TMPCERT} >>/etc/ssl/pkgca.pem"
|
||||
print_arrow "${_CMD}"
|
||||
pr_smallarrow "${_CMD}"
|
||||
if [ -z "${DRYRUN}" ]; then
|
||||
eval ${_CMD} || exit 1
|
||||
fi
|
||||
|
|
@ -125,9 +125,9 @@ get_cert() {
|
|||
update_self() {
|
||||
local _CMD _N
|
||||
|
||||
print3 "Checking for openup update"
|
||||
pr_bigarrow "Checking for openup update"
|
||||
_CMD="ftp -Vo ${TMPUPD} ${OPENUP_URL}"
|
||||
print_arrow "${_CMD}"
|
||||
pr_smallarrow "${_CMD}"
|
||||
if [ -z "${DRYRUN}" ]; then
|
||||
eval ${_CMD} || exit 1
|
||||
fi
|
||||
|
|
@ -135,16 +135,16 @@ update_self() {
|
|||
_N=$(grep -Eo '^OPENUP_VERSION=.*' ${TMPUPD} | awk -F '=' '{ print $2 }')
|
||||
if [ -n "${_N}" -o -n "${DRYRUN}" ]; then
|
||||
if [ "${OPENUP_VERSION}" -lt "${_N}" -o -n "${DRYRUN}" ]; then
|
||||
print3 "Updating openup to the latest release"
|
||||
pr_bigarrow "Updating openup to the latest release"
|
||||
_CMD="cat ${TMPUPD} >${MEESA}"
|
||||
print_arrow "${_CMD}"
|
||||
pr_smallarrow "${_CMD}"
|
||||
if [ -z "${DRYRUN}" ]; then
|
||||
eval ${_CMD} || exit 1
|
||||
rtn=$?
|
||||
fi
|
||||
print3 "openup has been updated, restarting"
|
||||
pr_bigarrow "openup has been updated, restarting"
|
||||
_CMD="${MEESA} -U $@"
|
||||
print_arrow "${_CMD}"
|
||||
pr_smallarrow "${_CMD}"
|
||||
if [ -z "${DRYRUN}" ]; then
|
||||
eval ${_CMD}
|
||||
exit $rtn
|
||||
|
|
@ -159,9 +159,9 @@ update_binpatches() {
|
|||
_BP=$(pkg_info -Q binpatch${REL_INT}-$(arch -s) | sed 's/.[^-]*$//' | sort -u | tr '\n' ' ')
|
||||
|
||||
if [ -n "$_BP" ]; then
|
||||
print3 "Updating binpatch(es)"
|
||||
pr_bigarrow "Updating binpatch(es)"
|
||||
_CMD="pkg_add ${pkg_opt} ${_BP}"
|
||||
print_arrow "${_CMD}"
|
||||
pr_smallarrow "${_CMD}"
|
||||
eval ${_CMD}
|
||||
fi
|
||||
}
|
||||
|
|
@ -169,18 +169,18 @@ update_binpatches() {
|
|||
update_pkg() {
|
||||
local _CMD
|
||||
|
||||
print3 "Updating package(s)"
|
||||
pr_bigarrow "Updating package(s)"
|
||||
_CMD="pkg_add -u ${pkg_opt}"
|
||||
print_arrow "${_CMD}"
|
||||
pr_smallarrow "${_CMD}"
|
||||
eval ${_CMD}
|
||||
}
|
||||
|
||||
update_fw() {
|
||||
local _CMD
|
||||
|
||||
print3 "Updating firmware(s)"
|
||||
pr_bigarrow "Updating firmware(s)"
|
||||
_CMD="fw_update ${fw_opt}"
|
||||
print_arrow "${_CMD}"
|
||||
pr_smallarrow "${_CMD}"
|
||||
eval ${_CMD}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue