source: freebsd-mgnt/update-via-portmaster.sh@ 382

Last change on this file since 382 was 375, checked in by Rick van der Zwet, 13 years ago

Make the logical flow somehow more ... ehm... logical :-)

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1#!/bin/sh
2#
3# Unattended FreeBSD Ports upgrade cycle, please note that starting and stopping
4# of services is taken care of in the pkgtools.conf
5#
6# Rick van der Zwet <info@rickvanderzwet.nl>
7#
8PATH=$PATH:/usr/local/sbin:/usr/local/bin
9WC=`cd $(dirname $0); pwd -P`
10
11if [ `id -u` -ne 0 ]; then
12 echo "Root only!" 1>&2
13 exit 1
14fi
15
16# Make sure we always using the latest version
17svn up --non-interactive `dirname $0` | grep '^[A-Z] ' && {
18 sh $0
19 exit 0
20}
21
22portmaster --version 1>/dev/null 2>/dev/null || make -C /usr/ports/ports-mgmt/portmaster BATCH=yes install clean
23
24# Fetch the latest details and provide listing of packages to be updated
25portsnap fetch update || exit 1
26
27echo "# Find out which packages to update"
28update_list=`pkg_version -o -L= | xargs -n1 pkg_info -qO`
29
30if [ -z "$update_list" ]; then
31 echo "Everything is up2date"
32 exit 0
33fi
34
35echo "# Find the rc.d/* entries affected"
36for pkg in $update_list; do
37 rc_d="$rc_d `pkg_info -qL $pkg $(pkg_info -qR $pkg) | grep -F '/rc.d/'`"
38done
39rc_d="`echo $rc_d | xargs -n1 | sort -u`"
40
41echo "# Going to update the following packages:"
42echo $update_list | xargs -n1 echo "# - "
43echo "# The following daemons will not be available:"
44for rc in $rc_d; do
45 echo "# - $rc (`$rc status 2>&1 | grep -v -e '^Usage:' -e 'directive' -e '^Cannot'`)"
46done
47echo -n "# Do you like to update the packages: (y|n) [y]: "; read INPUT
48case $INPUT in
49 ''|y) ;;
50 [yY][eE][sS]) ;;
51 *)
52 echo "Canceled by user!"; exit 1
53 ;;
54esac
55
56# Stop the daemons affected
57for rc in $rc_d; do
58 $rc stop
59done
60
61# Install via portmaster
62portmaster --no-confirm -yadG
63
64# Just to be sure try to start all port daemons again (this will make sure the
65# already updated ones are also started nicely again).
66for rc in `rcorder /usr/local/etc/rc.d/* 2>/dev/null`; do
67 $rc restart
68done
Note: See TracBrowser for help on using the repository browser.