mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Fichier de config
This commit is contained in:
parent
1a1c5a82c3
commit
d774587076
5 changed files with 107 additions and 27 deletions
|
@ -64,10 +64,6 @@ if [ "$(whoami)" != "$(cat "$script_dir/sub_scripts/setup_user")" ] && test -e "
|
|||
exit 0
|
||||
fi
|
||||
|
||||
source "$script_dir/sub_scripts/lxc_launcher.sh"
|
||||
source "$script_dir/sub_scripts/testing_process.sh"
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Vérifie la connexion internet.
|
||||
ping -q -c 2 yunohost.org > /dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then # En cas d'échec de connexion, tente de pinger un autre domaine pour être sûr
|
||||
|
@ -133,10 +129,42 @@ echo "$version_plinter" > "$script_dir/plinter_version"
|
|||
USER_TEST=package_checker
|
||||
PASSWORD_TEST=checker_pwd
|
||||
PATH_TEST=/check
|
||||
LXC_NAME=$(cat "$script_dir/sub_scripts/lxc_build.sh" | grep LXC_NAME= | cut -d '=' -f2)
|
||||
if [ -e "$script_dir/config" ]; then
|
||||
main_iface=$(cat "$script_dir/config" | grep iface= | cut -d '=' -f2)
|
||||
else # Si le fichier de config n'existe pas
|
||||
|
||||
# Récupère les informations depuis le fichier de conf (Ou le complète le cas échéant)
|
||||
pcheck_config="$script_dir/config"
|
||||
# Tente de lire les informations depuis le fichier de config si il existe
|
||||
if [ -e "$pcheck_config" ]
|
||||
then
|
||||
PLAGE_IP=$(cat "$pcheck_config" | grep PLAGE_IP= | cut -d '=' -f2)
|
||||
DOMAIN=$(cat "$pcheck_config" | grep DOMAIN= | cut -d '=' -f2)
|
||||
YUNO_PWD=$(cat "$pcheck_config" | grep YUNO_PWD= | cut -d '=' -f2)
|
||||
LXC_NAME=$(cat "$pcheck_config" | grep LXC_NAME= | cut -d '=' -f2)
|
||||
LXC_BRIDGE=$(cat "$pcheck_config" | grep LXC_BRIDGE= | cut -d '=' -f2)
|
||||
main_iface=$(cat "$pcheck_config" | grep iface= | cut -d '=' -f2)
|
||||
fi
|
||||
echo "PLAGE_IP1=$PLAGE_IP"
|
||||
# Utilise des valeurs par défaut si les variables sont vides, et génère le fichier de config
|
||||
if [ -z "$PLAGE_IP" ]; then
|
||||
PLAGE_IP=$(cat "$script_dir/sub_scripts/lxc_build.sh" | grep "|| PLAGE_IP=" | cut -d '"' -f4)
|
||||
echo -e "# Plage IP du conteneur\nPLAGE_IP=$PLAGE_IP\n" >> "$pcheck_config"
|
||||
fi
|
||||
if [ -z "$DOMAIN" ]; then
|
||||
DOMAIN=$(cat "$script_dir/sub_scripts/lxc_build.sh" | grep "|| DOMAIN=" | cut -d '=' -f2)
|
||||
echo -e "# Domaine de test\nDOMAIN=$DOMAIN\n" >> "$pcheck_config"
|
||||
fi
|
||||
if [ -z "$YUNO_PWD" ]; then
|
||||
YUNO_PWD=$(cat "$script_dir/sub_scripts/lxc_build.sh" | grep "|| YUNO_PWD=" | cut -d '=' -f2)
|
||||
echo -e "# Mot de passe\nYUNO_PWD=$YUNO_PWD\n" >> "$pcheck_config"
|
||||
fi
|
||||
if [ -z "$LXC_NAME" ]; then
|
||||
LXC_NAME=$(cat "$script_dir/sub_scripts/lxc_build.sh" | grep "|| LXC_NAME=" | cut -d '=' -f2)
|
||||
echo -e "# Nom du conteneur\nLXC_NAME=$LXC_NAME\n" >> "$pcheck_config"
|
||||
fi
|
||||
if [ -z "$LXC_BRIDGE" ]; then
|
||||
LXC_BRIDGE=$(cat "$script_dir/sub_scripts/lxc_build.sh" | grep "|| LXC_BRIDGE=" | cut -d '=' -f2)
|
||||
echo -e "# Nom du bridge\nLXC_BRIDGE=$LXC_BRIDGE\n" >> "$pcheck_config"
|
||||
fi
|
||||
if [ -z "$main_iface" ]; then
|
||||
# Tente de définir l'interface réseau principale
|
||||
main_iface=$(sudo route | grep default | awk '{print $8;}') # Prend l'interface réseau défini par default
|
||||
if [ -z $main_iface ]; then
|
||||
|
@ -144,9 +172,13 @@ else # Si le fichier de config n'existe pas
|
|||
exit 1
|
||||
fi
|
||||
# Enregistre le nom de l'interface réseau de l'hôte dans un fichier de config
|
||||
echo -e "# interface réseau principale de l'hôte\niface=$main_iface\n" > "$script_dir/config"
|
||||
echo -e "# Interface réseau principale de l'hôte\niface=$main_iface\n" >> "$pcheck_config"
|
||||
fi
|
||||
|
||||
source "$script_dir/sub_scripts/lxc_launcher.sh"
|
||||
source "$script_dir/sub_scripts/testing_process.sh"
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
if [ "$no_lxc" -eq 0 ]
|
||||
then
|
||||
DOMAIN=$(sudo cat /var/lib/lxc/$LXC_NAME/rootfs/etc/yunohost/current_host)
|
||||
|
|
|
@ -3,13 +3,24 @@
|
|||
# Récupère le dossier du script
|
||||
if [ "${0:0:1}" == "/" ]; then script_dir="$(dirname "$0")"; else script_dir="$(echo $PWD/$(dirname "$0" | cut -d '.' -f2) | sed 's@/$@@')"; fi
|
||||
|
||||
pcheck_config="$script_dir/../config"
|
||||
# Tente de lire les informations depuis le fichier de config si il existe
|
||||
if [ -e "$pcheck_config" ]
|
||||
then
|
||||
PLAGE_IP=$(cat "$pcheck_config" | grep PLAGE_IP= | cut -d '=' -f2)
|
||||
DOMAIN=$(cat "$pcheck_config" | grep DOMAIN= | cut -d '=' -f2)
|
||||
YUNO_PWD=$(cat "$pcheck_config" | grep YUNO_PWD= | cut -d '=' -f2)
|
||||
LXC_NAME=$(cat "$pcheck_config" | grep LXC_NAME= | cut -d '=' -f2)
|
||||
LXC_BRIDGE=$(cat "$pcheck_config" | grep LXC_BRIDGE= | cut -d '=' -f2)
|
||||
fi
|
||||
|
||||
LOG_BUILD_LXC="$script_dir/Build_lxc.log"
|
||||
PLAGE_IP="10.1.4"
|
||||
test -n "$PLAGE_IP" || PLAGE_IP="10.1.4" # Utilise des valeurs par défaut si les variables sont vides.
|
||||
test -n "$DOMAIN" || DOMAIN=domain.tld
|
||||
test -n "$YUNO_PWD" || YUNO_PWD=admin
|
||||
test -n "$LXC_NAME" || LXC_NAME=pchecker_lxc
|
||||
test -n "$LXC_BRIDGE" || LXC_BRIDGE=lxc-pchecker
|
||||
ARG_SSH="-t"
|
||||
DOMAIN=domain.tld
|
||||
YUNO_PWD=admin
|
||||
LXC_NAME=pchecker_lxc
|
||||
LXC_BRIDGE=lxc-pchecker
|
||||
|
||||
# Tente de définir l'interface réseau principale
|
||||
main_iface=$(sudo route | grep default | awk '{print $8;}') # Prend l'interface réseau défini par default
|
||||
|
@ -24,7 +35,14 @@ touch "$script_dir/../pcheck.lock" # Met en place le lock de Package check, le t
|
|||
echo $(whoami) > "$script_dir/setup_user"
|
||||
|
||||
# Enregistre le nom de l'interface réseau de l'hôte dans un fichier de config
|
||||
echo -e "# interface réseau principale de l'hôte\niface=$main_iface\n" > "$script_dir/../config"
|
||||
echo -e "# interface réseau principale de l'hôte\niface=$main_iface\n" > "$pcheck_config"
|
||||
# Enregistre les infos dans le fichier de config.
|
||||
echo -e "# Plage IP du conteneur\nPLAGE_IP=$PLAGE_IP\n" >> "$pcheck_config"
|
||||
echo -e "# Domaine de test\nDOMAIN=$DOMAIN\n" >> "$pcheck_config"
|
||||
echo -e "# Mot de passe\nYUNO_PWD=$YUNO_PWD\n" >> "$pcheck_config"
|
||||
echo -e "# Nom du conteneur\nLXC_NAME=$LXC_NAME\n" >> "$pcheck_config"
|
||||
echo -e "# Nom du bridge\nLXC_BRIDGE=$LXC_BRIDGE\n" >> "$pcheck_config"
|
||||
|
||||
|
||||
echo -e "\e[1m> Update et install lxc lxctl\e[0m" | tee "$LOG_BUILD_LXC"
|
||||
sudo apt-get update >> "$LOG_BUILD_LXC" 2>&1
|
||||
|
|
|
@ -6,13 +6,40 @@
|
|||
# Récupère le dossier du script
|
||||
if [ "${0:0:1}" == "/" ]; then script_dir="$(dirname "$0")"; else script_dir="$(echo $PWD/$(dirname "$0" | cut -d '.' -f2) | sed 's@/$@@')"; fi
|
||||
|
||||
PLAGE_IP=$(cat "$script_dir/lxc_build.sh" | grep PLAGE_IP= | cut -d '"' -f2)
|
||||
ARG_SSH="-t"
|
||||
LXC_NAME=$(cat "$script_dir/lxc_build.sh" | grep LXC_NAME= | cut -d '=' -f2)
|
||||
LXC_BRIDGE=$(cat "$script_dir/lxc_build.sh" | grep LXC_BRIDGE= | cut -d '=' -f2)
|
||||
if [ -e "$script_dir/../config" ]; then
|
||||
main_iface=$(cat "$script_dir/../config" | grep iface= | cut -d '=' -f2)
|
||||
else # Si le fichier de config n'existe pas
|
||||
# Récupère les informations depuis le fichier de conf (Ou le complète le cas échéant)
|
||||
pcheck_config="$script_dir/../config"
|
||||
# Tente de lire les informations depuis le fichier de config si il existe
|
||||
if [ -e "$pcheck_config" ]
|
||||
then
|
||||
PLAGE_IP=$(cat "$pcheck_config" | grep PLAGE_IP= | cut -d '=' -f2)
|
||||
DOMAIN=$(cat "$pcheck_config" | grep DOMAIN= | cut -d '=' -f2)
|
||||
YUNO_PWD=$(cat "$pcheck_config" | grep YUNO_PWD= | cut -d '=' -f2)
|
||||
LXC_NAME=$(cat "$pcheck_config" | grep LXC_NAME= | cut -d '=' -f2)
|
||||
LXC_BRIDGE=$(cat "$pcheck_config" | grep LXC_BRIDGE= | cut -d '=' -f2)
|
||||
fi
|
||||
# Utilise des valeurs par défaut si les variables sont vides, et génère le fichier de config
|
||||
if [ -z "$PLAGE_IP" ]; then
|
||||
PLAGE_IP=$(cat "$script_dir/sub_scripts/lxc_build.sh" | grep "|| PLAGE_IP=" | cut -d '"' -f4)
|
||||
echo -e "# Plage IP du conteneur\nPLAGE_IP=$PLAGE_IP\n" >> "$pcheck_config"
|
||||
fi
|
||||
if [ -z "$DOMAIN" ]; then
|
||||
DOMAIN=$(cat "$script_dir/sub_scripts/lxc_build.sh" | grep "|| DOMAIN=" | cut -d '=' -f2)
|
||||
echo -e "# Domaine de test\nDOMAIN=$DOMAIN\n" >> "$pcheck_config"
|
||||
fi
|
||||
if [ -z "$YUNO_PWD" ]; then
|
||||
YUNO_PWD=$(cat "$script_dir/sub_scripts/lxc_build.sh" | grep "|| YUNO_PWD=" | cut -d '=' -f2)
|
||||
echo -e "# Mot de passe\nYUNO_PWD=$YUNO_PWD\n" >> "$pcheck_config"
|
||||
fi
|
||||
if [ -z "$LXC_NAME" ]; then
|
||||
LXC_NAME=$(cat "$script_dir/sub_scripts/lxc_build.sh" | grep "|| LXC_NAME=" | cut -d '=' -f2)
|
||||
echo -e "# Nom du conteneur\nLXC_NAME=$LXC_NAME\n" >> "$pcheck_config"
|
||||
fi
|
||||
if [ -z "$LXC_BRIDGE" ]; then
|
||||
LXC_BRIDGE=$(cat "$script_dir/sub_scripts/lxc_build.sh" | grep "|| LXC_BRIDGE=" | cut -d '=' -f2)
|
||||
echo -e "# Nom du bridge\nLXC_BRIDGE=$LXC_BRIDGE\n" >> "$pcheck_config"
|
||||
fi
|
||||
if [ -z "$main_iface" ]; then
|
||||
# Tente de définir l'interface réseau principale
|
||||
main_iface=$(sudo route | grep default | awk '{print $8;}') # Prend l'interface réseau défini par default
|
||||
if [ -z $main_iface ]; then
|
||||
|
@ -20,7 +47,7 @@ else # Si le fichier de config n'existe pas
|
|||
exit 1
|
||||
fi
|
||||
# Enregistre le nom de l'interface réseau de l'hôte dans un fichier de config
|
||||
echo -e "# interface réseau principale de l'hôte\niface=$main_iface\n" > "$script_dir/../config"
|
||||
echo -e "# Interface réseau principale de l'hôte\niface=$main_iface\n" >> "$pcheck_config"
|
||||
fi
|
||||
|
||||
STOP_CONTAINER () {
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
# Récupère le dossier du script
|
||||
if [ "${0:0:1}" == "/" ]; then script_dir="$(dirname "$0")"; else script_dir="$(echo $PWD/$(dirname "$0" | cut -d '.' -f2) | sed 's@/$@@')"; fi
|
||||
|
||||
LXC_NAME=$(cat "$script_dir/lxc_build.sh" | grep LXC_NAME= | cut -d '=' -f2)
|
||||
LXC_BRIDGE=$(cat "$script_dir/lxc_build.sh" | grep LXC_BRIDGE= | cut -d '=' -f2)
|
||||
pcheck_config="$script_dir/../config"
|
||||
LXC_NAME=$(cat "$pcheck_config" | grep LXC_NAME= | cut -d '=' -f2)
|
||||
LXC_BRIDGE=$(cat "$pcheck_config" | grep LXC_BRIDGE= | cut -d '=' -f2)
|
||||
|
||||
# Check user
|
||||
if [ "$(whoami)" != "$(cat "$script_dir/setup_user")" ] && test -e "$script_dir/setup_user"; then
|
||||
|
|
|
@ -10,9 +10,11 @@ then # L'upgrade est annulé
|
|||
fi
|
||||
touch "$script_dir/../pcheck.lock" # Met en place le lock de Package check
|
||||
|
||||
PLAGE_IP=$(cat "$script_dir/lxc_build.sh" | grep PLAGE_IP= | cut -d '"' -f2)
|
||||
LXC_NAME=$(cat "$script_dir/lxc_build.sh" | grep LXC_NAME= | cut -d '=' -f2)
|
||||
LXC_BRIDGE=$(cat "$script_dir/lxc_build.sh" | grep LXC_BRIDGE= | cut -d '=' -f2)
|
||||
pcheck_config="$script_dir/../config"
|
||||
PLAGE_IP=$(cat "$pcheck_config" | grep PLAGE_IP= | cut -d '=' -f2)
|
||||
LXC_NAME=$(cat "$pcheck_config" | grep LXC_NAME= | cut -d '=' -f2)
|
||||
LXC_BRIDGE=$(cat "$pcheck_config" | grep LXC_BRIDGE= | cut -d '=' -f2)
|
||||
|
||||
if [ -e "$script_dir/../config" ]; then
|
||||
main_iface=$(cat "$script_dir/../config" | grep iface= | cut -d '=' -f2)
|
||||
else # Si le fichier de config n'existe pas
|
||||
|
|
Loading…
Add table
Reference in a new issue