Bash script works in Debian not in OpenSuse
I have written a few bash-scripts to automate the installation of various applications from source.
It works fine in Debian Lenny with bash version 3.2 (GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu) )
In OpenSuse 11.4 with bash version 4.1 (GNU bash, version 4.1.10(1)-release (x86_64-suse-linux-gnu) ) it doesn't work.
Details:
All variables are stored in one file "variabler", sourced by installation scripts.
The start script uses command "dialog" for easy selection, then simply calls appropriate installation script. There is one separate file for each application.
The dialog is displayed, I can select & deselect - but once I hit <enter> script simply stops. There is no output at all, no error no nothing.
However, I can run each installation script directly so obviously problem is that the install scripts are not called correctly in Suse.
The scripts are all in /usr/local/src/ which is in $PATH
I have tried calling the install scripts with full path as well, no difference.
All variabes are correct - remember I can succesfully install everything by executing the install scripts one by one.
List of files:
cert_install - start script
variabler - contains all variables such as application version, where source is etc
inst_apa, inst_openssl etc - executable scripts that installs one application each.
The start script:
Code:
#!/bin/bash
# Kontrollera att filen 'variabler' finns, avsluta annars
if [ ! -f variabler ]; then
echo "Filen 'variabler' saknas"
exit
fi
# Läs in variablerna
source variabler
# Skapa logg-katalog om den inte finns
if [ -f logs ]; then
echo "Kan inte skapa katalog 'logs' - finns en fil med det namnet."
echo "Radera den först, eller kör vidare utan att loggar sparas."
fi
if [ ! -d logs ]; then
mkdir logs <---------- This works fine!
export LOGGDIR=logs
fi
# Val av program att installera
# Kommandot 'dialog': sista 3 värdena är Totalhöjd Totalbredd Boxhöjd
cmd=(dialog --separate-output --checklist "Val av program att installera: \n
OBS! Openssl & PCRE are required for Apache, Php & Modsec" 18 76 7)
options=(1 "Openssl" on
2 "PCRE" on
3 "Apache" off
4 "MySQL" off
5 "Php" off
6 "ModSecurity - experimental!" off
7 "ModSec Core Ruleset - experimental!" off)
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear
for choice in $choices
do
case $choice in
1)
echo "Installerar OpenSSL"
inst_openssl 2> >(tee $LOGGDIR/openssl_error)
;;
2)
echo "Installerar PCRE"
inst_pcre 2> >(tee $LOGGDIR/pcre_error)
;;
3)
# Kontrollera beroenden (pcre & openssl)
echo "Installerar Apache"
inst_apa 2> >(tee $LOGGDIR/apache_error)
;;
4)
echo "Installerar MySQL"
inst_mysql 2> >(tee $LOGGDIR/mysql_error)
;;
5)
echo "Installerar Php"
inst_php 2> >(tee $LOGGDIR/php_error)
;;
6)
echo "Installerar ModSecurity"
inst_modsec 2> >(tee $LOGGDIR/modsec_error)
;;
7)
echo "Installerar ModSecurity Core Ruleset"
inst_crs 2> >(tee $LOGGDIR/crs_error)
;;
esac
done
Example installation script - "inst_openssl":
Code:
#!/bin/bash
# Skapat 2011-11-01
# Detta script kompilerar Openssl från källkod
# Variabler för installationsscriptet läses in från filen "variabler"
source variabler
# Ladda hem & packa upp källkoden
cd $SRC_DIR
wget $REPO_OPTIONS $REPO_PROTOKOLL/$REPO/openssl-$OPENSSL_APPVERSION.tar.gz
tar -zxf openssl-$OPENSSL_APPVERSION.tar.gz
cd openssl-$OPENSSL_APPVERSION
./config --prefix=/nih/openssl-$OPENSSL_APPVERSION/ --openssldir=/od/openssl-$OPENSSL_APPVERSION
make && make install
# Ta bort gamla bin-filen, länka in nya
KAT=/usr/bin/
IDAG=`date +%d%m%y`
if [ -h $KAT/openssl ] ; then
unlink $KAT/openssl
else
if [ -f $KAT/openssl ] ; then
mv $KAT/openssl $KAT/openssl.$IDAG
ln -s /nih/openssl-$OPENSSL_APPVERSION/openssl $KAT/openssl
fi
fi
My first guess is there is a difference between bash 3.2 & 4.1 that causes the problem.
I'm currently investigating this line in cert_install :
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
Any ideas?