forked from mirrors/openup
Drop '-n' -- it is useless in its current form.
This commit is contained in:
parent
f61deb1586
commit
8286862c28
1 changed files with 43 additions and 77 deletions
118
openup
118
openup
|
|
@ -60,25 +60,24 @@ usage() {
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -K do not check for kernel binpatches (when running non GENERIC)"
|
echo " -K do not check for kernel binpatches (when running non GENERIC)"
|
||||||
echo " -S do not check for package signatures"
|
echo " -S do not check for package signatures"
|
||||||
echo " -c check/cron mode, report only (cannot be used with -S and/or -n)"
|
echo " -c check/cron mode, report only (cannot be used with -S)"
|
||||||
echo " -n dry-run mode, only report what would be done"
|
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_error() {
|
pr_err() {
|
||||||
echo "!!! ${@}"
|
echo "!!! ${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
pr_error "Need root privileges to run this script"
|
pr_err "Need root privileges to run this script"
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /etc/openup.conf ]; then
|
if [ -f /etc/openup.conf ]; then
|
||||||
if [ $(stat -f "%SMp%SLp" /etc/openup.conf) != "------" ]; then
|
if [ $(stat -f "%SMp%SLp" /etc/openup.conf) != "------" ]; then
|
||||||
pr_error "Unsecure permissions on /etc/openup.conf; please run:"
|
pr_err "Unsecure permissions on /etc/openup.conf; please run:"
|
||||||
pr_error "chmod 0600 /etc/openup.conf"
|
pr_err "chmod 0600 /etc/openup.conf"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
. /etc/openup.conf
|
. /etc/openup.conf
|
||||||
|
|
@ -88,7 +87,7 @@ if [ -n "${_REL[1]}" -a "${_REL[1]}" != "-stable" ]; then _badrel=1; fi
|
||||||
if [ "${_REL_INT}" -lt "${_OPENUP_MINREL}" ]; then _badrel=1; fi
|
if [ "${_REL_INT}" -lt "${_OPENUP_MINREL}" ]; then _badrel=1; fi
|
||||||
|
|
||||||
if [ -n "${_badrel}" ]; then
|
if [ -n "${_badrel}" ]; then
|
||||||
pr_error "${_REL[0]}${_REL[1]} is not a supported release"
|
pr_err "${_REL[0]}${_REL[1]} is not a supported release"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -109,27 +108,13 @@ bye_bye() {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_bigarrow() {
|
pr() {
|
||||||
if [ -z "${checkmode}" ]; then
|
if [ -z "${checkmode}" ]; then
|
||||||
echo "===> ${@}${dryrun}"
|
echo "===> ${@}"
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
pr_smallarrow() {
|
|
||||||
if [ -z "${checkmode}" -a -n "${dryrun}" ]; then
|
|
||||||
echo "-> ${@}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.exe() {
|
|
||||||
if [ -z "${dryrun}" ]; then
|
|
||||||
eval "${@}" || bye_bye
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_cert() {
|
get_cert() {
|
||||||
local _CMD
|
|
||||||
|
|
||||||
if [ -r /etc/ssl/pkgca.pem ]; then
|
if [ -r /etc/ssl/pkgca.pem ]; then
|
||||||
split -p '^-----BEGIN CERTIFICATE-----$' /etc/ssl/pkgca.pem ${_TMPSPLITCERT}
|
split -p '^-----BEGIN CERTIFICATE-----$' /etc/ssl/pkgca.pem ${_TMPSPLITCERT}
|
||||||
fi
|
fi
|
||||||
|
|
@ -139,48 +124,38 @@ get_cert() {
|
||||||
grep -q "${PKG_CERT_FPRINT}" && return
|
grep -q "${PKG_CERT_FPRINT}" && return
|
||||||
done
|
done
|
||||||
|
|
||||||
pr_bigarrow "Downloading certificate"
|
pr "Downloading certificate"
|
||||||
_CMD="ftp -Vo ${_TMPKEY} ${PKG_CERT_URL}"
|
ftp -Vo ${_TMPKEY} ${PKG_CERT_URL} || bye_bye
|
||||||
pr_smallarrow "${_CMD}"
|
|
||||||
cmd.exe ${_CMD}
|
|
||||||
|
|
||||||
pr_bigarrow "Installing certificate"
|
pr "Installing certificate"
|
||||||
_CMD="cat ${_TMPKEY} >>/etc/ssl/pkgca.pem"
|
_cat ${_TMPKEY} >>/etc/ssl/pkgca.pem || bye_bye
|
||||||
pr_smallarrow "${_CMD}"
|
|
||||||
cmd.exe ${_CMD}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_pubkey() {
|
get_pubkey() {
|
||||||
[ -r /etc/signify/mtier-${_REL_INT}-pkg.pub ] && return
|
[ -r /etc/signify/mtier-${_REL_INT}-pkg.pub ] && return
|
||||||
local _CMD
|
|
||||||
|
|
||||||
pr_bigarrow "Downloading public key"
|
pr "Downloading public key"
|
||||||
_CMD="ftp -Vo ${_TMPKEY} ${PKG_PUBKEY_URL}"
|
ftp -Vo ${_TMPKEY} ${PKG_PUBKEY_URL} || bye_bye
|
||||||
pr_smallarrow "${_CMD}"
|
|
||||||
cmd.exe ${_CMD}
|
|
||||||
|
|
||||||
pr_bigarrow "Installing public key"
|
pr "Installing public key"
|
||||||
_CMD="install -m0644 ${_TMPKEY} /etc/signify/mtier-${_REL_INT}-pkg.pub"
|
install -m0644 ${_TMPKEY} /etc/signify/mtier-${_REL_INT}-pkg.pub || bye_bye
|
||||||
pr_smallarrow "${_CMD}"
|
|
||||||
cmd.exe ${_CMD}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_openupd() {
|
check_openupd() {
|
||||||
local _CMD _N
|
local _U
|
||||||
|
|
||||||
pr_bigarrow "Checking for openup update"
|
pr "Checking for openup update"
|
||||||
_CMD="ftp -Vo - ${OPENUP_URL} | awk -F '=' '/^_OPENUP_VERSION/ { print \$2 }'"
|
_U="ftp -Vo - ${OPENUP_URL} | awk -F '=' '/^_OPENUP_VERSION/ { print \$2 }'"
|
||||||
pr_smallarrow "${_CMD}"
|
_U=$(eval $_U)
|
||||||
_N=$(cmd.exe ${_CMD})
|
if [ -z "${_U}" ]; then
|
||||||
if [ -z "${_N}" -a -z "${dryrun}" ]; then
|
pr_err "Cannot retrieve ${OPENUP_URL}"
|
||||||
pr_error "Cannot retrieve ${OPENUP_URL}"
|
pr_err "Please verify your Internet connection, proxy settings and firewall."
|
||||||
pr_error "Please verify your Internet connection, proxy settings and firewall."
|
|
||||||
bye_bye
|
bye_bye
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${_OPENUP_VERSION}" -lt "${_N}" ]; then
|
if [ "${_OPENUP_VERSION}" -lt "${_U}" ]; then
|
||||||
pr_error "New openup release (version ${_N}) available; please update with:"
|
pr_err "New openup release (version ${_U}) available; please update with:"
|
||||||
pr_error "ftp -Vo $(readlink -f $0) ${OPENUP_URL}"
|
pr_err "ftp -Vo $(readlink -f $0) ${OPENUP_URL}"
|
||||||
bye_bye
|
bye_bye
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -193,17 +168,15 @@ rm_old_bp() {
|
||||||
local _BPDB=$(ls -d /var/db/binpatch/{binpatch-,}[0-9]* 2>/dev/null |grep -v ${_REL})
|
local _BPDB=$(ls -d /var/db/binpatch/{binpatch-,}[0-9]* 2>/dev/null |grep -v ${_REL})
|
||||||
local _BPPKG=$(ls -d /var/db/pkg/binpatch* 2>/dev/null |grep -v binpatch${_REL_INT})
|
local _BPPKG=$(ls -d /var/db/pkg/binpatch* 2>/dev/null |grep -v binpatch${_REL_INT})
|
||||||
if [ -n "${_BPPKG}" -o -n "${_BPDB}" ]; then
|
if [ -n "${_BPPKG}" -o -n "${_BPDB}" ]; then
|
||||||
pr_bigarrow "Removing old release binpatch entries"
|
pr "Removing old release binpatch entries"
|
||||||
fi
|
fi
|
||||||
for _bp in ${_BPPKG} ${_BPDB}; do
|
for _bp in ${_BPPKG} ${_BPDB}; do
|
||||||
_CMD="rm -rf ${_bp}"
|
rm -rf ${_bp}
|
||||||
pr_smallarrow "${_CMD}"
|
|
||||||
cmd.exe ${_CMD}
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
update_binpatches() {
|
update_binpatches() {
|
||||||
local _BP _CMD _b _e
|
local _BP _b _e
|
||||||
|
|
||||||
# binpatches can only be found in PKG_PATH_UPDATE{,_LTS) and we
|
# binpatches can only be found in PKG_PATH_UPDATE{,_LTS) and we
|
||||||
# want to make sure we search in all paths and don't stop at the
|
# want to make sure we search in all paths and don't stop at the
|
||||||
|
|
@ -219,15 +192,13 @@ update_binpatches() {
|
||||||
done
|
done
|
||||||
_BP=$(echo "${_BP}" | tr '\n' ' ')
|
_BP=$(echo "${_BP}" | tr '\n' ' ')
|
||||||
|
|
||||||
pr_bigarrow "Installing/updating binpatch(es)"
|
pr "Installing/updating binpatch(es)"
|
||||||
_CMD="pkg_add ${pkg_opt} ${_BP}"
|
pkg_add ${pkg_opt} ${_BP} || bye_bye
|
||||||
pr_smallarrow "${_CMD}"
|
|
||||||
cmd.exe ${_CMD}
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
update_pkg() {
|
update_pkg() {
|
||||||
local _CMD _PKG _e _p
|
local _PKG _e _p
|
||||||
|
|
||||||
_PKG=$(pkg_info -q | grep -v binpatch${_REL_INT}-${_ARCH})
|
_PKG=$(pkg_info -q | grep -v binpatch${_REL_INT}-${_ARCH})
|
||||||
|
|
||||||
|
|
@ -238,12 +209,8 @@ update_pkg() {
|
||||||
done
|
done
|
||||||
_PKG=$(echo "${_PKG}" | tr '\n' ' ')
|
_PKG=$(echo "${_PKG}" | tr '\n' ' ')
|
||||||
|
|
||||||
pr_bigarrow "Updating package(s)"
|
pr "Updating package(s)"
|
||||||
_CMD="pkg_add -quz ${pkg_opt}"
|
pkg_add -quz ${pkg_opt} ${_PKG} || bye_bye
|
||||||
# we don't want to display ${_PKG}, there could be hundreds
|
|
||||||
pr_smallarrow "${_CMD} ..."
|
|
||||||
_CMD="${_CMD} ${_PKG}"
|
|
||||||
cmd.exe ${_CMD}
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -299,32 +266,31 @@ do_i_need_to_reboot() {
|
||||||
local wake_up=$(sysctl -n kern.boottime)
|
local wake_up=$(sysctl -n kern.boottime)
|
||||||
|
|
||||||
if [ "${wake_up}" -lt "${kern_bp_time}" ]; then
|
if [ "${wake_up}" -lt "${kern_bp_time}" ]; then
|
||||||
pr_error
|
pr_err
|
||||||
pr_error "System must be rebooted after the last kernel update"
|
pr_err "System must be rebooted after the last kernel update"
|
||||||
pr_error
|
pr_err
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts 'KScn' arg; do
|
while getopts 'KSc' arg; do
|
||||||
case ${arg} in
|
case ${arg} in
|
||||||
K) exclude_kernel=1 ;;
|
K) exclude_kernel=1 ;;
|
||||||
S) nosig=1; pkg_opt="${pkg_opt} -Dnosig -Dunsigned" ;;
|
S) nosig=1; pkg_opt="${pkg_opt} -Dnosig -Dunsigned" ;;
|
||||||
c) checkmode=1 ;;
|
c) checkmode=1 ;;
|
||||||
n) dryrun=" (dry run)"; pkg_opt="${pkg_opt} -n -Dnosig -Dunsigned" ;;
|
|
||||||
*) usage ;;
|
*) usage ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
[ $# = $(($OPTIND-1)) ] || usage
|
[ $# = $(($OPTIND-1)) ] || usage
|
||||||
|
|
||||||
if [ "${checkmode}" ]; then
|
if [ "${checkmode}" ]; then
|
||||||
if [ -n "${nosig}" -o -n "${dryrun}" ]; then
|
if [ -n "${nosig}" ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f ${_PID} ]; then
|
if [ -f ${_PID} ]; then
|
||||||
pr_error "openup is already running ($(cat ${_PID})):"
|
pr_err "openup is already running ($(cat ${_PID})):"
|
||||||
pr_error "${_PID}"
|
pr_err "${_PID}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo $$ >${_PID}
|
echo $$ >${_PID}
|
||||||
|
|
@ -335,7 +301,7 @@ if [ -n "${exclude_kernel}" ]; then
|
||||||
EXCLUDE_PKG="binpatch${_REL_INT}-${_ARCH}-kernel ${EXCLUDE_PKG}"
|
EXCLUDE_PKG="binpatch${_REL_INT}-${_ARCH}-kernel ${EXCLUDE_PKG}"
|
||||||
fi
|
fi
|
||||||
if [ -n "${EXCLUDE_PKG}" ]; then
|
if [ -n "${EXCLUDE_PKG}" ]; then
|
||||||
pr_bigarrow "Excluded package(s)/binpatch(es): ${EXCLUDE_PKG}"
|
pr "Excluded package(s)/binpatch(es): ${EXCLUDE_PKG}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${checkmode}" ]; then
|
if [ "${checkmode}" ]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue