Skip to content

Commit

Permalink
Merge branch 'release/3.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sabinus52 committed Apr 7, 2018
2 parents a1b85da + 82f4b89 commit 33c647a
Show file tree
Hide file tree
Showing 19 changed files with 492 additions and 114 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/conf/*
!/conf/modules.lst
!/conf/modules-develop.lst
!/conf/*.conf
/completion/*
!/completion/olixmain
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
3.4.0
10 changes: 10 additions & 0 deletions conf/modules-develop.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
###
# DON'T TOUCH
##
olixsh|https://github.com/sabinus52/olixsh/archive/develop.tar.gz|
debian|https://github.com/sabinus52/olixshmodule-debian/archive/develop.tar.gz|Installation et gestion des packages Debian
mysql|https://github.com/sabinus52/olixshmodule-mysql/archive/develop.tar.gz|Utilitaires pour les bases mysql
postgres|https://github.com/sabinus52/olixshmodule-postgres/archive/develop.tar.gz|Utilitaires pour les bases postgres
webapp|https://github.com/sabinus52/olixshmodule-webapp/archive/develop.tar.gz|Gestion des applications web
monitor|https://github.com/sabinus52/olixshmodule-monitor/archive/develop.tar.gz|Check pour le monitoring des systèmes
backup|https://github.com/sabinus52/olixshmodule-backup/archive/develop.tar.gz|Sauvegarde des bases et dossiers
1 change: 1 addition & 0 deletions conf/modules.lst
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ mysql|https://github.com/sabinus52/olixshmodule-mysql/archive/master.tar.gz|Util
postgres|https://github.com/sabinus52/olixshmodule-postgres/archive/master.tar.gz|Utilitaires pour les bases postgres
webapp|https://github.com/sabinus52/olixshmodule-webapp/archive/master.tar.gz|Gestion des applications web
monitor|https://github.com/sabinus52/olixshmodule-monitor/archive/master.tar.gz|Check pour le monitoring des systèmes
backup|https://github.com/sabinus52/olixshmodule-backup/archive/master.tar.gz|Sauvegarde des bases et dossiers
18 changes: 18 additions & 0 deletions lib/array.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ function Array.index()
}


###
# Retourne le premier le liste
##
function Array.first()
{
eval echo \${${1}[0]}
}


###
# Retourne le dernier de la liste
##
function Array.last()
{
eval echo \${${1}[*]: -1}
}


###
# Retourne un élément par son index
##
Expand Down
49 changes: 46 additions & 3 deletions lib/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,39 @@ function Config.param.set()
# Gestion des slash "/"
local REPLACE=$(echo $3 | sed 's/\//\\\//g')

sed -i "s/^\($PARAM\s*=\s*\).*\$/\1$REPLACE/" $FILECONF 2> ${OLIX_LOGGER_FILE_ERR}
sed -i "s/^\($PARAM\s*=\s*\).*\$/\1\"$REPLACE\"/" $FILECONF 2> ${OLIX_LOGGER_FILE_ERR}
return $?
}


###
# Récupère la valeur du paramètre de configuration dans le fichier de conf
# @param $2 : Nom du paramètre
##
function Config.param.get()
{
debug "Config.param.get ($1, $2)"

local FILECONF=$(Config.fileName $1)
[[ ! -r $FILECONF ]] && return 101
[[ ! -w $FILECONF ]] && return 102

local REALNAME=$(Config.param.system $1 $2)
#set -x
eval String.explode.value $(grep "^$REALNAME=" $FILECONF)
#set +x
return 0
}


###
# Retourne une méta donnée associés au paramètre d'un fichier de configuration
# @param $2 : Nom du paramètre
# @param $3 : Nom de la métadonnée
##
function Config.param.metadata()
{
local FILECONF=$(Config.fileName $1)
local FILECONF=$(Config.template $1)
[[ ! -r $FILECONF ]] && return 1

grep "^# @$3 $2=" $FILECONF | sed "s/^# @$3 $2=//"
Expand Down Expand Up @@ -147,7 +167,7 @@ function Config.param.values()
##
function Config.param.default()
{
local FILECONF=$(Config.fileName $1)
local FILECONF=$(Config.template $1)
[[ ! -r $FILECONF ]] && return 1

local REALNAME=$(Config.param.system $1 $2)
Expand All @@ -156,3 +176,26 @@ function Config.param.default()
#grep "^$2=" ${FILECONF} | sed "s/^$REALNAME=//"
#return ${PIPESTATUS}
}


###
# Récupère dynamiquement la valeur d'un paramètre
# @param $2 : Nom du paramètre
##
function Config.dynamic.get()
{
local REALNAME=$(Config.param.system $1 $2)
eval echo -n \$$(String.upcase "$REALNAME")
}


###
# Affecte une valeur dans un paramètre dynamiquement
# @param $2 : Nom du paramètre
# @param $3 : Valeur du paramètre
##
function Config.dynamic.set()
{
local REALNAME=$(Config.param.system $1 $2)
eval "$(String.upcase "$REALNAME")=\"$3\""
}
20 changes: 20 additions & 0 deletions lib/directory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@ function Directory.exists()
}


###
# Si le dossier est en lecture
##
function Directory.readable()
{
[[ -z $1 ]] && return 1
[[ -r $1 ]] && return 0 || return 1
}


###
# Si le dossier est en ecriture
##
function Directory.writable()
{
[[ -z $1 ]] && return 1
[[ -w $1 ]] && return 0 || return 1
}


###
# Propriétaire et groupe d'appartenance du fichier
##
Expand Down
10 changes: 10 additions & 0 deletions lib/file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ function File.exists()
}


###
# Si le fichier peut être lu
##
function File.readable()
{
[[ -z $1 ]] && return 1
[[ -r $1 ]] && return 0 || return 1
}


###
# Vérifie si un fichier peut être créé
##
Expand Down
2 changes: 1 addition & 1 deletion lib/module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function Module.url()
##
function Module.all.installed()
{
find $OLIX_MODULE_PATH -maxdepth 1 -mindepth 1 -type d -exec basename {} \; | sort
find -L $OLIX_MODULE_PATH -maxdepth 1 -mindepth 1 -type d -exec basename {} \; | sort
}


Expand Down
36 changes: 36 additions & 0 deletions lib/print.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,42 @@ function Print.result()
}


###
# Affiche le message d'information de retour d'un check
# @param $1 : Valeur de retour
# @param $2 : Message
##
function Print.check()
{
debug "Print.check ($1, $2)"
echo -en $2; String.pad "$2" 64 " "; echo -n " :"
if [[ $1 -gt 100 ]]; then
echo -e " ${CROUGE}ERROR${CVOID}"
elif [[ $1 -eq 0 ]]; then
echo -e " ${CVERT}OK${CVOID}"
else
echo -e " ${CJAUNE}WARNING${CVOID}"
fi
Function.exists "Report.print.result" && Report.print.result "$1" "$2"
return $1
}


###
# Affiche une liste d'élément
# @param $1 : Message à afficher
##
function Print.list()
{
debug "Print.list ($1, $2)"
local I
for I in $1; do
echo $I
done
Function.exists "Report.print.list" && Report.print.list "$1" $2
}


###
# Affiche le contenu d'un fichier
# @param $1 : Nom du fichier
Expand Down
4 changes: 2 additions & 2 deletions lib/string.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function String.explode.value()
{
local DELIMITER="="
[[ -n $2 ]] && DELIMITER=$2
echo $(String.explode $1 2 "$DELIMITER")
echo $(String.explode "$1" 2 "$DELIMITER")
#IFS='=' read -ra PARAM <<< "$1"
#echo ${PARAM[1]}
}
Expand All @@ -141,7 +141,7 @@ function String.explode.param()
{
local DELIMITER="="
[[ -n $2 ]] && DELIMITER=$2
echo $(String.explode $1 1 "$DELIMITER")
echo $(String.explode "$1" 1 "$DELIMITER")
}


Expand Down
33 changes: 30 additions & 3 deletions utils/compression.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,43 @@



###
# Retourne l'extension du compression
# @param $1 : Mode de compression
##
function Compression.extension()
{
case $(String.lower $1) in
bz|bz2) echo -n "bz2";;
gz) echo -n "gz";;
*) echo -n "";;
esac
}


###
# Retourne le binaire de compression
# @param $1 : Mode de compression
##
function Compression.binary()
{
case $(String.lower $1) in
bz|bz2) echo -n "bzip2";;
gz) echo -n "gzip";;
esac
}


###
# Retourne l'extension du compression d'un TAR
# @param $1 : Mode de compression
##
function Compression.tar.extension()
{
case $(String.lower $1) in
bz|bz2) echo -n ".tbz";;
gz) echo -n ".tgz";;
*) echo -n ".tar";;
bz|bz2) echo -n "tbz";;
gz) echo -n "tgz";;
*) echo -n "tar";;
esac
}

Expand Down
12 changes: 6 additions & 6 deletions utils/fileconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ function Fileconfig.update()
cp $TEMPLATE $FILECONF 2> ${OLIX_LOGGER_FILE_ERR} || return 1

# Remet les valeurs personnalisés
for I in $(grep '^OLIX_.*' $FILEDIFF); do
PARAM=$(String.explode.param $I)
debug "Param updated --> $I"
REPLACE=$(echo $I | sed 's/\//\\\//g')
while IFS='\n' read LINE; do
PARAM=$(String.explode.param "$LINE")
REPLACE=$(echo $LINE | sed 's/\//\\\//g')
debug "Param updated --> $PARAM=$REPLACE"
sed -i "s/^\($PARAM\s*=\s*.*\)\$/$REPLACE/" $FILECONF 2> ${OLIX_LOGGER_FILE_ERR}
[[ $? -ne 0 ]] && ERROR=1
done
done < <(grep '^OLIX_.*' $FILEDIFF)
return $ERROR
}

Expand Down Expand Up @@ -132,7 +132,7 @@ function Fileconfig.param.read()
debug "Fileconfig.param.read ($1, $2)"

# Valeur par défaut dans le fichier de conf
local DEFAULT=$(Config.param.default $1 $2)
local DEFAULT=$(Config.param.get $1 $2)
local TYPE=$(Config.param.type $1 $2)

case $TYPE in
Expand Down
Loading

0 comments on commit 33c647a

Please sign in to comment.