80 lines
2.2 KiB
Bash
80 lines
2.2 KiB
Bash
|
#!/bin/bash
|
||
|
#
|
||
|
# Script d'installation du socle bash Tetalab
|
||
|
#
|
||
|
# 21/07/2017 - Doug Le Tough
|
||
|
#
|
||
|
|
||
|
|
||
|
|
||
|
PROFILE_DIR=/etc/profile.d
|
||
|
PROFILE_FILE=tetalab.sh
|
||
|
INSTALL_DIR=$(dirname $0)
|
||
|
NC_EXPL_ROOT=/opt/tetalab
|
||
|
export NC_EXPL_ROOT
|
||
|
|
||
|
NC_EXPL_LIB=${NC_EXPL_ROOT}/lib
|
||
|
NC_EXPL_BIN=${NC_EXPL_ROOT}/bin
|
||
|
NC_EXPL_LOG=${NC_EXPL_ROOT}/log
|
||
|
NC_EXPL_HST=${NC_EXPL_ROOT}/hist
|
||
|
NC_EXPL_CPT=${NC_EXPL_ROOT}/cpt
|
||
|
NC_EXPL_TMP=${NC_EXPL_ROOT}/tmp
|
||
|
NC_EXPL_DAT=${NC_EXPL_ROOT}/dat
|
||
|
NC_EXPL_MOD=${NC_EXPL_ROOT}/mod
|
||
|
NC_EXPL_CFG=${NC_EXPL_ROOT}/conf
|
||
|
NC_EXPL_MSG=${NC_EXPL_ROOT}/msg
|
||
|
NC_EXPL_MAN=${NC_EXPL_ROOT}/man
|
||
|
|
||
|
function exit_on_error
|
||
|
{
|
||
|
ERROR="$@"
|
||
|
echo -e "\033[91m*** ${ERROR} ***\033[0m"
|
||
|
exit 1
|
||
|
}
|
||
|
|
||
|
if [ ! $(id -u) -eq 0 ]; then
|
||
|
exit_on_error "Ce script doit être exécuté par l'utilisateur root"
|
||
|
fi
|
||
|
|
||
|
echo -e "\033[93mInstallation du socle bash Tetalab:\033[0m"
|
||
|
echo -e "\033[93m * Création du répertoire racine: ${NC_EXPL_ROOT}\033[0m"
|
||
|
echo -e "\033[93m * Création des répertoires:\033[0m"
|
||
|
|
||
|
for DIR in $NC_EXPL_LIB $NC_EXPL_BIN $NC_EXPL_LOG $NC_EXPL_HST $NC_EXPL_CPT $NC_EXPL_TMP $NC_EXPL_DAT $NC_EXPL_MOD $NC_EXPL_CFG $NC_EXPL_MSG $NC_EXPL_MAN;
|
||
|
do
|
||
|
echo -e " * ${DIR}"
|
||
|
sudo mkdir -p ${DIR};
|
||
|
RET_VAL=$?
|
||
|
if [ ! ${RET_VAL} -eq 0 ]; then
|
||
|
exit_on_error "Erreur lors de la création des répertoires"
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
echo -e "\033[93m * Copie des fichiers de profile dans ${PROFILE_DIR}\033[0m"
|
||
|
cp ${INSTALL_DIR}/${PROFILE_FILE} ${PROFILE_DIR}
|
||
|
RET_VAL=$?
|
||
|
if [ ! ${RET_VAL} -eq 0 ]; then
|
||
|
exit_on_error "Erreur lors de la copie des fichiers de profile"
|
||
|
fi
|
||
|
|
||
|
echo -e "\033[93m * Copie des fichiers de configuration dans ${NC_EXPL_CFG}\033[0m"
|
||
|
cp -R ${INSTALL_DIR}/conf/* ${NC_EXPL_CFG}
|
||
|
RET_VAL=$?
|
||
|
if [ ! ${RET_VAL} -eq 0 ]; then
|
||
|
exit_on_error "Erreur lors de la copie des fichiers de configuration"
|
||
|
fi
|
||
|
|
||
|
echo -e "\033[93m * Copie des bibliothèques dans ${NC_EXPL_LIB}\033[0m"
|
||
|
cp -R ${INSTALL_DIR}/lib/* ${NC_EXPL_LIB}
|
||
|
RET_VAL=$?
|
||
|
if [ ! ${RET_VAL} -eq 0 ]; then
|
||
|
exit_on_error "Erreur lors de la copie des bibliothèques"
|
||
|
fi
|
||
|
|
||
|
echo -e "\033[93m * Copie des scripts dans ${NC_EXPL_BIN}\033[0m"
|
||
|
cp -R ${INSTALL_DIR}/bin/* ${NC_EXPL_BIN}
|
||
|
RET_VAL=$?
|
||
|
if [ ! ${RET_VAL} -eq 0 ]; then
|
||
|
exit_on_error "Erreur lors de la copie des scripts"
|
||
|
fi
|