root/alternc/tags/0.9.6.3/install/upgrade_check.sh

Revision 1798, 1.4 kB (checked in by nahuel, 2 years ago)

Comme php5 peut etre installé, nous utilisons le lien php qui pointe soit vers php5 soit vers php4 ( soit php6 ? ).
close: #1042

  • Property svn:executable set to *
Line 
1 #!/bin/sh -e
2
3 # this script will look for upgrade scripts in
4 # /usr/share/alternc/install/upgrades and execute them based on the
5 # extension
6 #
7 # usage:
8 # $0 oldvers, where oldvers is the version of the package previously
9 # installed
10 #
11 # an upgrade file is considered only if its basename is a version
12 # number greater than the $oldvers argument
13
14 # remove version from filename by stripping the extension
15 strip_ext() {
16         echo $1 | sed 's/\.[^.]*$//'
17 }
18
19 # find the version from a filename by stripping everything but the extension
20 get_ext() {
21         echo $1 | sed 's/^.*\.\([^.]*\)$/\1/'
22 }
23
24 oldvers=$1
25
26 if [ -z "$oldvers" -o "$oldvers" = '<unknown>' ]; then
27         # this is not an upgrade
28         exit 0
29 fi
30
31 . /etc/alternc/local.sh
32
33 # the upgrade script we are considering
34 extensions="*.sql *.sh *.php"
35 cd /usr/share/alternc/install/upgrades
36 for file in $extensions
37 do
38         if [ -r $file ]; then
39                 # the version in the filename
40                 upvers=`strip_ext $file`
41                 # the extension
42                 ext=`get_ext $file`
43                 if dpkg --compare-versions $upvers gt $oldvers; then
44                   echo running upgrade script $file
45                   # run the proper program to interpret the upgrade script
46                   case "$ext" in
47                   sql)
48                         mysql -f -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASS $MYSQL_DATABASE \
49                         < $file || true
50                         ;;
51                   php)
52                         php -q $file || true
53                         ;;
54                   sh)
55                         sh $file || true
56                         ;;
57                   esac
58                 fi
59         fi
60 done
Note: See TracBrowser for help on using the browser.