You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.1 KiB
Bash
53 lines
1.1 KiB
Bash
#!/bin/bash
|
|
|
|
dir=$(pwd)
|
|
dirname=$(basename ${dir})
|
|
|
|
# Nous sommes dans "bin" directement => cherche un exécutable "console" (le fameux "bin/console")
|
|
if [ "$dirname" = "bin" ] ; then
|
|
script="${dir}/console"
|
|
if [ ! -e "$script" -o ! -x "$script" ] ; then
|
|
script=""
|
|
fi
|
|
fi
|
|
|
|
# Un sous-répertoire "bin" existe => cherche l'exécutable "bin/console"
|
|
if [ -z "$script" -a -d "bin" ] ; then
|
|
script="${dir}/bin/console"
|
|
if [ ! -e "$script" -o ! -x "$script" ] ; then
|
|
script=""
|
|
fi
|
|
fi
|
|
|
|
# Cherche "programs.php"
|
|
if [ -z "$script" ] ; then
|
|
script="${dir}/programs.php"
|
|
if [ ! -e "$script" -o ! -r "$script" ] ; then
|
|
script=""
|
|
else
|
|
script="php $script"
|
|
fi
|
|
fi
|
|
|
|
# Nous sommes dans un sous-répertoire de "public_html" => ré-invoque "console", mais dans le répertoire "public_html"
|
|
if [ -z "$script" ] ; then
|
|
if [[ "$dir" == *"/public_html/"* ]] ; then
|
|
while [ -n "$dir" -a ! "$dirname" = "public_html" ] ; do
|
|
dir=$(dirname ${dir})
|
|
dirname=$(basename $dir)
|
|
done
|
|
|
|
cd $dir
|
|
script="console"
|
|
fi
|
|
fi
|
|
|
|
#
|
|
# Exécute le script si trouvé, sinon erreur
|
|
#
|
|
if [ -n "$script" ] ; then
|
|
$script "$@"
|
|
else
|
|
echo -e "\033[0;31mAucune console trouvée\033[0m" >&2
|
|
fi
|