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