Ticket #5525: postflight

File postflight, 3.3 KB (added by drernie@…, 19 years ago)

Postflight script (goes in 'files')

Line 
1#!/bin/bash
2#
3# Copyright (c) 2005 Ole Guldberg Jensen <olegb@opendarwin.org>
4# Copyright (c) 2005 Dr. Ernie Prabhakar <drernir@opendarwin.org>
5# Copyright (c) 2005 Matt Anton <matt@opendarwin.org>
6# Copyright (c) 2005 Juan Manuel Palacios <jmpp@opendarwin.org>
7# All rights reserved.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions
11# are met:
12# 1. Redistributions of source code must retain the above copyright
13#    notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright
15#    notice, this list of conditions and the following disclaimer in the
16#    documentation and/or other materials provided with the distribution.
17#
18# THIS SOFTWARE IS PROVIDED BY Eric Melville AND CONTRIBUTORS ``AS IS'' AND
19# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28# SUCH DAMAGE.
29#
30
31echo ""
32echo "Checking the PATH variable for $USER..."
33echo ""
34
35BINPATH=/opt/local/bin
36SBINPATH=/opt/local/sbin
37TMP=`/usr/bin/mktemp /tmp/dp.$$`
38$SHELL -l <<EOF > $TMP
39    /usr/bin/printenv PATH
40    exit
41EOF
42
43if grep $BINPATH $TMP >/dev/null 2>&1; then
44        echo "You already have the right PATH - l337!"
45else
46    USHELL=`basename $SHELL`
47   echo "Setting the PATH of $USHELL for $USER in ${HOME:=/Users/$USER}"
48    case $USHELL in
49      *csh)
50        /bin/cp -fp $HOME/.cshrc $HOME/.cshrc.dpsaved   # we backup the original
51        echo "#" >> $HOME/.cshrc
52        echo "# Your previous .cshrc (if any) is saved as .cshrc.dpsaved" >> $HOME/.cshrc
53        echo "# Setting the path for DarwinPorts." >> $HOME/.cshrc
54        echo "set path=($BINPATH $SBINPATH $path)" >> $HOME/.cshrc
55        chown $USER $HOME/.cshrc
56        ;;
57      *sh)
58        /bin/cp -fp $HOME/.profile $HOME/.profile.dpsaved # we backup the original
59        echo "#" >> $HOME/.profile
60        echo "# Your previous .profile  (if any) is saved as .profile.dpsaved" >> $HOME/.profile
61        echo "# Setting the path for DarwinPorts." >> $HOME/.profile
62        echo "export PATH=$BINPATH:$SBINPATH:$PATH" >> $HOME/.profile
63        chown $USER $HOME/.profile
64        ;;
65      *)
66        echo "Unknown shell! Please set your own PATH manually."
67        ;;
68    esac
69fi
70
71export PATH=$BINPATH:$PATH
72
73# run selfupdate
74
75echo""
76echo "Selfupdating The DarwinPorts system ..."
77echo ""
78
79#port -d selfupdate
80if [ $? != 0 ]; then
81    echo "An attempt to synchronize your recent DarwinPorts installation with OpenDarwin servers failed, please run 'port -d selfupdate' manually to find out the cause of the error."
82    exit
83fi
84
85# done !!
86echo ""
87echo "You have succesfully installed the DarwinPorts system."
88echo ""
89echo "Launch a terminal and try it out !!"
90echo "Read the port manualpage for help."
91echo ""