sqlmig: mode dépendant du profil
This commit is contained in:
parent
174c08759e
commit
4c43b01739
|
@ -5,3 +5,7 @@
|
|||
|
||||
# Répertoire des profils
|
||||
#PROFILEDIR=/etc/sqlmig
|
||||
|
||||
# Mapping profil/mode
|
||||
#prod_PROFILE_MODE=prod
|
||||
#test_PROFILE_MODE=devel
|
||||
|
|
61
sqlmig
61
sqlmig
|
@ -80,7 +80,9 @@ OPTIONS
|
|||
Quand un profil est activé, les fichiers de configuration par défaut
|
||||
deviennent respectivement \$PROFILE-my.cnf et \$PROFILE-ora.conf au lieu
|
||||
de my.cnf et ora.conf. De plus, ces fichiers sont aussi recherchés dans
|
||||
le répertoire /etc/sqlmig
|
||||
le répertoire /etc/sqlmig, en fonction du mode: en mode production, on
|
||||
cherche d'abord dans /etc/sqlmig. En mode développement, on cherche
|
||||
d'abord dans le répertoire local.
|
||||
|
||||
--mysql
|
||||
--oracle
|
||||
|
@ -221,7 +223,14 @@ function ensure_dbtype() {
|
|||
function ensure_dbmode() {
|
||||
local dbtype="$1" mode="$2"
|
||||
if [ "$mode" == auto ]; then
|
||||
if [ "$dbtype" == mysql ]; then
|
||||
local profile_mode
|
||||
if [ -n "$profile" ]; then
|
||||
profile_mode="${profile}_PROFILE_MODE"
|
||||
profile_mode="${!profile_mode}"
|
||||
fi
|
||||
if [ -n "$profile_mode" ]; then
|
||||
dbmode="$profile_mode"
|
||||
elif [ "$dbtype" == mysql ]; then
|
||||
is_root && dbmode=prod || dbmode=devel
|
||||
else
|
||||
dbmode=prod
|
||||
|
@ -333,15 +342,22 @@ function mysql_after_update() {
|
|||
|
||||
function mysql_get_defaults() {
|
||||
local dir="$1"
|
||||
if [ -z "$profile" ]; then
|
||||
echo "$dir/my.cnf"
|
||||
elif [ -f "$dir/${profile}-my.cnf" ]; then
|
||||
echo "$dir/${profile}-my.cnf"
|
||||
elif [ -f "$PROFILEDIR/${profile}-my.cnf" ]; then
|
||||
echo "$PROFILEDIR/${profile}-my.cnf"
|
||||
else
|
||||
echo "$dir/my.cnf"
|
||||
if [ -n "$profile" ]; then
|
||||
if [ "$dbmode" == devel ]; then
|
||||
if [ -f "$dir/${profile}-my.cnf" ]; then
|
||||
echo "$dir/${profile}-my.cnf"; return
|
||||
elif [ -f "$PROFILEDIR/${profile}-my.cnf" ]; then
|
||||
echo "$PROFILEDIR/${profile}-my.cnf"; return
|
||||
fi
|
||||
else
|
||||
if [ -f "$PROFILEDIR/${profile}-my.cnf" ]; then
|
||||
echo "$PROFILEDIR/${profile}-my.cnf"; return
|
||||
elif [ -f "$dir/${profile}-my.cnf" ]; then
|
||||
echo "$dir/${profile}-my.cnf"; return
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
echo "$dir/my.cnf"
|
||||
}
|
||||
function mysql_set_adminargs() {
|
||||
local dir="$1" defaults
|
||||
|
@ -632,15 +648,22 @@ function oracle_ensure_opdir() {
|
|||
}
|
||||
function oracle_get_defaults() {
|
||||
local dir="$1"
|
||||
if [ -z "$profile" ]; then
|
||||
echo "$dir/ora.conf"
|
||||
elif [ -f "$dir/${profile}-ora.conf" ]; then
|
||||
echo "$dir/${profile}-ora.conf"
|
||||
elif [ -f "$PROFILEDIR/${profile}-ora.conf" ]; then
|
||||
echo "$PROFILEDIR/${profile}-ora.conf"
|
||||
else
|
||||
echo "$dir/ora.conf"
|
||||
if [ -n "$profile" ]; then
|
||||
if [ "$dbmode" == devel ]; then
|
||||
if [ -f "$dir/${profile}-ora.conf" ]; then
|
||||
echo "$dir/${profile}-ora.conf"; return
|
||||
elif [ -f "$PROFILEDIR/${profile}-ora.conf" ]; then
|
||||
echo "$PROFILEDIR/${profile}-ora.conf"; return
|
||||
fi
|
||||
else
|
||||
if [ -f "$PROFILEDIR/${profile}-ora.conf" ]; then
|
||||
echo "$PROFILEDIR/${profile}-ora.conf"; return
|
||||
elif [ -f "$dir/${profile}-ora.conf" ]; then
|
||||
echo "$dir/${profile}-ora.conf"; return
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
echo "$dir/ora.conf"
|
||||
}
|
||||
function oracle_source_adminconf() {
|
||||
local dir="$1"
|
||||
|
@ -717,6 +740,8 @@ function oracle_user_update() {
|
|||
|
||||
MODE=auto
|
||||
PROFILEDIR=/etc/sqlmig
|
||||
prod_PROFILE_MODE=prod
|
||||
test_PROFILE_MODE=devel
|
||||
set_defaults sqlmig
|
||||
|
||||
admindefaults=
|
||||
|
|
Loading…
Reference in New Issue