#!/bin/bash
-# $Id$
-# $URL$
#
# priority: 900
#
function extend_db()
{
shopt -s nullglob
- for file in /usr/share/plc_api/extensions/*-up; do
- script=${file#*/}
- name=${script%-up}
- extension=${script##*}
+ for file in /usr/share/plc_api/extensions/*-up*; do
+ script=${file##*/}
+ name=${script%-up*}
+ extension=${script##*.}
version=$(psql -U $PLC_DB_USER --quiet --tuples-only --no-align -c \
"SELECT version FROM plc_db_extensions WHERE name='$name' LIMIT 1" \
- $PLC_DB_NAME 2>/dev/null | awk '/^[0-9]+$/ { ver=$1 } END { print ver }')
+ $PLC_DB_NAME 2>/dev/null | awk 'BEGIN { ver=0 } /^[0-9]+$/ { ver=$1 } END { print ver }')
if [ $version -eq 0 ]; then
if [ "$extension" = "sql" ] ; then
dialog " - $script (dbdumped)"
check
fi
for file in /usr/share/plc_api/extensions/$name/migrations/[0-9]*-up-*; do
- script=${file#*/}
+ script=${file##*/}
index=${script%-up-*}
extension=${script##*.}
if [ $index -gt $version ] ; then