From b49a2d87517802e6d92049f92a9a4b5d487597ea Mon Sep 17 00:00:00 2001 From: Benedikt Böhm Date: Fri, 31 Oct 2008 08:58:55 +0100 Subject: gentoo bug #244873 - config file support * add SYNC_CMD option * add DIFF_CMD option * add UPGRADE_OPTS option * add RCPT option * add license & copyright --- bin/porticron | 69 +++++++++++++++++++++++++++++++++++++----------------- etc/porticron.conf | 17 ++++++++++++++ 2 files changed, 65 insertions(+), 21 deletions(-) create mode 100644 etc/porticron.conf diff --git a/bin/porticron b/bin/porticron index f6552e9..f83749a 100755 --- a/bin/porticron +++ b/bin/porticron @@ -27,47 +27,56 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# load config +: ${PORTICRON_CONF:-/etc/porticron.conf} + +if [[ -r ${PORTICRON_CONF} ]]; then + source ${PORTICRON_CONF} +fi + + +# detect some common variables SCRIPT_NAME=$(basename $0) FQDN=$(hostname --fqdn) IP=$(dig +short ${FQDN}) DATE=$(date -R) PORTDIR=$(portageq portdir) -# only sync portage if PORTDIR is mounted read-write -if touch "${PORTDIR}"/.read_only_check &>/dev/null; then - rm -f "${PORTDIR}"/.read_only_check - /usr/bin/emerge --sync --quiet &>/dev/null -fi -PACKAGES=$(/usr/bin/emerge --pretend --changelog --update --deep --newuse --quiet --usepkg world 2>/dev/null) +# sync if desired +${SYNC_CMD:-/usr/bin/emerge --sync} &>/dev/null -if [[ -z ${PACKAGES} ]]; then - exit 0 + +# build a list of changed ebuilds +if [[ -n ${DIFF_CMD} ]]; then + DIFF=$(${DIFF_CMD} 2>/dev/null) fi -cat </dev/null) -The following packages are currently pending an upgrade: +if [[ -n ${UPGRADE} ]]; then + UPGRADE_MSG=" +${SCRIPT_NAME} has detected that some packages need upgrading: -$(echo "${PACKAGES}" | sed 's/^\[/ [/') +$(echo "${UPGRADE}" | sed 's/^\[/ [/') ======================================================================== You can perform the upgrade by issuing the command: - emerge -NDuk world + emerge ${UPGRADE_OPTS} world as root on ${FQDN} @@ -75,8 +84,26 @@ It is recommended that you pretend the upgrade first to confirm that the actions that would be taken are reasonable. The upgrade may be pretended by issuing the command: - emerge -NDuvpk world + emerge ${UPGRADE_OPTS} --pretend world +" +fi + + +# send mail +if [[ -z ${UPGRADE_MSG} && -z ${DIFF_MSG} ]]; then + exit 0 +fi + +cat <