source: install/scripts/upgrade_check.sh @ 411

Revision 411, 1.4 KB checked in by anarcat, 7 years ago (diff)

[project @ alternc: changeset 2004-10-24 03:26:30 by anonymous]
run php4 quietly

Original author: anonymous
Date: 2004-10-24 03:26:30

RevLine 
[352]1#!/bin/sh -e
[334]2
[407]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
[334]15strip_ext() {
16        echo $1 | sed 's/\.[^.]*$//'
17}
18
[407]19# find the version from a filename by stripping everything but the extension
[334]20get_ext() {
21        echo $1 | sed 's/^.*\.\([^.]*\)$/\1/'
22}
23
24oldvers=$1
25
26if [ -z "$oldvers" ] || [ "$oldvers" == '<unknown>' ]; then
27        # this is not an upgrade
[352]28        exit 0
[334]29fi
30
[407]31# the upgrade script we are considering
[334]32extensions="*.sh *.php *.sql"
33cd /usr/share/alternc/install/upgrades
34for file in $extensions
35do
36        if [ -r $file ]; then
[407]37                # the version in the filename
[334]38                upvers=`strip_ext $file`
[407]39                # the extension
[334]40                ext=`get_ext $file`
41                if dpkg --compare-versions $upvers gt $oldvers; then
42                  echo running upgrade script $file
[407]43                  # run the proper program to interpret the upgrade script
[334]44                  case "$ext" in
45                  sql)
[336]46                        mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASS $MYSQL_DATABASE \
[334]47                        < $file
48                        ;;
49                  php)
[411]50                        php4 -q $file
[334]51                        ;;
52                  sh)
53                        sh $file
54                        ;;
55                  esac
56                else
57                  echo "not running script $file, too old u$upvers o$oldvers"
58                fi
59        fi
60done
Note: See TracBrowser for help on using the repository browser.