aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenedikt Böhm <bb@xnull.de>2008-10-31 08:58:55 +0100
committerBenedikt Böhm <bb@xnull.de>2008-10-31 08:58:55 +0100
commitb49a2d87517802e6d92049f92a9a4b5d487597ea (patch)
tree687e5c890a447eb1f58d4b7986e60d18bd1975bc
parentadd copyright and license (diff)
downloadporticron-b49a2d87517802e6d92049f92a9a4b5d487597ea.tar.gz
porticron-b49a2d87517802e6d92049f92a9a4b5d487597ea.tar.bz2
porticron-b49a2d87517802e6d92049f92a9a4b5d487597ea.zip
gentoo bug #244873 - config file support
* add SYNC_CMD option * add DIFF_CMD option * add UPGRADE_OPTS option * add RCPT option * add license & copyright
-rwxr-xr-xbin/porticron69
-rw-r--r--etc/porticron.conf17
2 files changed, 65 insertions, 21 deletions
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 <<EOF | sendmail -t
-To: root@${FQDN}
-From: root@${FQDN}
-Subject: Gentoo package updates on ${FQDN}
-Date: ${DATE}
+if [[ -n ${DIFF} ]]; then
+ DIFF_MSG="${SCRIPT_NAME} has detected the following changes to ${PORTDIR}:
+
+${DIFF}
-porticron report [${DATE}]
========================================================================
+"
+fi
-${SCRIPT_NAME} has detected that some packages need upgrading on:
- ${FQDN}
- [ ${IP} ]
+# build list of upgrades
+: ${UPGRADE_OPTS:=--deep --update}
+UPGRADE=$(/usr/bin/emerge ${UPGRADE_OPTS} --quiet --pretend world 2>/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 <<EOF | sendmail -t
+To: ${RCPT:-root@${FQDN}}
+From: root@${FQDN}
+Subject: Gentoo package updates on ${FQDN} [ ${IP} ]
+Date: ${DATE}
+
+porticron report [${DATE}]
+========================================================================
+${DIFF_MSG}${UPGRADE_MSG}
--
${SCRIPT_NAME}
EOF
diff --git a/etc/porticron.conf b/etc/porticron.conf
new file mode 100644
index 0000000..8c87883
--- /dev/null
+++ b/etc/porticron.conf
@@ -0,0 +1,17 @@
+# use emerge for synchronisation
+SYNC_CMD="/usr/bin/emerge --sync"
+
+# use eix-sync instead of emerge --sync
+#SYNC_CMD="/usr/bin/eix-sync"
+
+# do not synchronize (e.g. if PORTDIR is mounted read-only)
+#SYNC_CMD="/bin/true"
+
+# include a report of changed ebuilds
+#DIFF_CMD="/usr/bin/eix-sync -d"
+
+# emerge upgrade options
+UPGRADE_OPTS="--deep --update"
+
+# recipient for reports
+#RCPT=root@$(hostname -f)