Full stretch support

This commit is contained in:
Maniack Crudelis 2018-05-02 11:36:26 +02:00
parent 909c5b4acf
commit 151b7a230f
3 changed files with 254 additions and 235 deletions

View file

@ -24,3 +24,5 @@ LXC_BRIDGE=
# Distribution debian # Distribution debian
DISTRIB= DISTRIB=
# Branche à utiliser pour le script d'install de cette distribution (si non standard)
BRANCH=

View file

@ -16,6 +16,7 @@ then
dnsforce=$(cat "$pcheck_config" | grep dnsforce= | cut -d '=' -f2) dnsforce=$(cat "$pcheck_config" | grep dnsforce= | cut -d '=' -f2)
main_iface=$(cat "$pcheck_config" | grep iface= | cut -d '=' -f2) main_iface=$(cat "$pcheck_config" | grep iface= | cut -d '=' -f2)
DISTRIB=$(cat "$pcheck_config" | grep DISTRIB= | cut -d '=' -f2) DISTRIB=$(cat "$pcheck_config" | grep DISTRIB= | cut -d '=' -f2)
branch=$(cat "$pcheck_config" | grep BRANCH= | cut -d '=' -f2)
fi fi
LOG_BUILD_LXC="$script_dir/Build_lxc.log" LOG_BUILD_LXC="$script_dir/Build_lxc.log"
@ -27,6 +28,7 @@ test -n "$LXC_NAME" || LXC_NAME=pchecker_lxc
test -n "$LXC_BRIDGE" || LXC_BRIDGE=lxc-pchecker test -n "$LXC_BRIDGE" || LXC_BRIDGE=lxc-pchecker
test -n "$dnsforce" || dnsforce=1 test -n "$dnsforce" || dnsforce=1
test -n "$DISTRIB" || DISTRIB=jessie test -n "$DISTRIB" || DISTRIB=jessie
test -n "$branch" || branch=""
ARG_SSH="-t" ARG_SSH="-t"
# Tente de définir l'interface réseau principale # Tente de définir l'interface réseau principale
@ -65,7 +67,8 @@ echo -e "# Domaine de test\nDOMAIN=$DOMAIN\n" >> "$pcheck_config"
echo -e "# Mot de passe\nYUNO_PWD=$YUNO_PWD\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 conteneur\nLXC_NAME=$LXC_NAME\n" >> "$pcheck_config"
echo -e "# Nom du bridge\nLXC_BRIDGE=$LXC_BRIDGE\n" >> "$pcheck_config" echo -e "# Nom du bridge\nLXC_BRIDGE=$LXC_BRIDGE\n" >> "$pcheck_config"
echo -e "# Distribution debian\nDISTRIB=$DISTRIB\n" >> "$pcheck_config" echo -e "# Distribution debian\nDISTRIB=$DISTRIB" >> "$pcheck_config"
echo -e "# Branche à utiliser pour le script d'install de cette distribution (si non standard)\nBRANCH=$branch\n" >> "$pcheck_config"
echo -e "\e[1m> Update et install lxc lxctl\e[0m" | tee -a "$LOG_BUILD_LXC" echo -e "\e[1m> Update et install lxc lxctl\e[0m" | tee -a "$LOG_BUILD_LXC"
sudo apt-get update >> "$LOG_BUILD_LXC" 2>&1 sudo apt-get update >> "$LOG_BUILD_LXC" 2>&1
@ -176,11 +179,10 @@ sudo lxc-attach -n $LXC_NAME -- dpkg-reconfigure openssh-server >> "$LOG_BUILD_
sudo lxc-attach -n $LXC_NAME -- locale-gen en_US.UTF-8 >> "$LOG_BUILD_LXC" 2>&1 sudo lxc-attach -n $LXC_NAME -- locale-gen en_US.UTF-8 >> "$LOG_BUILD_LXC" 2>&1
sudo lxc-attach -n $LXC_NAME -- localedef -i en_US -f UTF-8 en_US.UTF-8 >> "$LOG_BUILD_LXC" 2>&1 sudo lxc-attach -n $LXC_NAME -- localedef -i en_US -f UTF-8 en_US.UTF-8 >> "$LOG_BUILD_LXC" 2>&1
if [ "$DISTRIB" == "stretch" ]; then if [ -n "$branch" ]; then
branch="--branch stretch" branch="--branch $branch"
else
branch=""
fi fi
ssh $ARG_SSH $LXC_NAME "git clone https://github.com/YunoHost/install_script $branch /tmp/install_script" >> "$LOG_BUILD_LXC" 2>&1 ssh $ARG_SSH $LXC_NAME "git clone https://github.com/YunoHost/install_script $branch /tmp/install_script" >> "$LOG_BUILD_LXC" 2>&1
echo -e "\e[1m> Installation de Yunohost...\e[0m" | tee -a "$LOG_BUILD_LXC" echo -e "\e[1m> Installation de Yunohost...\e[0m" | tee -a "$LOG_BUILD_LXC"
ssh $ARG_SSH $LXC_NAME "cd /tmp/install_script; sudo ./install_yunohost -a" | tee -a "$LOG_BUILD_LXC" 2>&1 ssh $ARG_SSH $LXC_NAME "cd /tmp/install_script; sudo ./install_yunohost -a" | tee -a "$LOG_BUILD_LXC" 2>&1

View file

@ -166,61 +166,74 @@ RESTORE_CONTAINER () {
LXC_NETWORK_CONFIG () { LXC_NETWORK_CONFIG () {
lxc_network=0 lxc_network=0
if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.type = veth"; then if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.type = veth"
then
lxc_network=1 # Si la ligne de la config réseau est absente, c'est une erreur. lxc_network=1 # Si la ligne de la config réseau est absente, c'est une erreur.
check_repair=1 check_repair=1
if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.type"; then # Si la ligne est incorrecte, elle est corrigée. if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.type"
then # Si la ligne est incorrecte, elle est corrigée.
sudo sed -i "s/.*lxc.network.type.*/lxc.network.type = veth/g" /var/lib/lxc/$LXC_NAME/config sudo sed -i "s/.*lxc.network.type.*/lxc.network.type = veth/g" /var/lib/lxc/$LXC_NAME/config
else # Sinon elle est ajoutée. else # Sinon elle est ajoutée.
echo "lxc.network.type = veth" | sudo tee -a /var/lib/lxc/$LXC_NAME/config echo "lxc.network.type = veth" | sudo tee -a /var/lib/lxc/$LXC_NAME/config
fi fi
fi fi
if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.flags = up"; then if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.flags = up"
then
lxc_network=1 lxc_network=1
check_repair=1 check_repair=1
if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.flags"; then if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.flags"
then
sudo sed -i "s/.*lxc.network.flags.*/lxc.network.flags = up/g" /var/lib/lxc/$LXC_NAME/config sudo sed -i "s/.*lxc.network.flags.*/lxc.network.flags = up/g" /var/lib/lxc/$LXC_NAME/config
else else
echo "lxc.network.flags = up" | sudo tee -a /var/lib/lxc/$LXC_NAME/config echo "lxc.network.flags = up" | sudo tee -a /var/lib/lxc/$LXC_NAME/config
fi fi
fi fi
if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.link = $LXC_BRIDGE"; then if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.link = $LXC_BRIDGE"
then
lxc_network=1 lxc_network=1
check_repair=1 check_repair=1
if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.link"; then if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.link"
then
sudo sed -i "s/.*lxc.network.link.*/lxc.network.link = $LXC_BRIDGE" /var/lib/lxc/$LXC_NAME/config sudo sed -i "s/.*lxc.network.link.*/lxc.network.link = $LXC_BRIDGE" /var/lib/lxc/$LXC_NAME/config
else else
echo "lxc.network.link = $LXC_BRIDGE" | sudo tee -a /var/lib/lxc/$LXC_NAME/config echo "lxc.network.link = $LXC_BRIDGE" | sudo tee -a /var/lib/lxc/$LXC_NAME/config
fi fi
fi fi
if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.name = eth0"; then if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.name = eth0"
then
lxc_network=1 lxc_network=1
check_repair=1 check_repair=1
if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.name"; then if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.name"
then
sudo sed -i "s/.*lxc.network.name.*/lxc.network.name = eth0/g" /var/lib/lxc/$LXC_NAME/config sudo sed -i "s/.*lxc.network.name.*/lxc.network.name = eth0/g" /var/lib/lxc/$LXC_NAME/config
else else
echo "lxc.network.name = eth0" | sudo tee -a /var/lib/lxc/$LXC_NAME/config echo "lxc.network.name = eth0" | sudo tee -a /var/lib/lxc/$LXC_NAME/config
fi fi
fi fi
if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.veth.pair = $LXC_NAME"; then if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.veth.pair = $LXC_NAME"
then
lxc_network=1 lxc_network=1
check_repair=1 check_repair=1
if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.veth.pair"; then if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.veth.pair"
then
sudo sed -i "s/.*lxc.network.veth.pair.*/lxc.network.veth.pair = $LXC_NAME/g" /var/lib/lxc/$LXC_NAME/config sudo sed -i "s/.*lxc.network.veth.pair.*/lxc.network.veth.pair = $LXC_NAME/g" /var/lib/lxc/$LXC_NAME/config
else else
echo "lxc.network.veth.pair = $LXC_NAME" | sudo tee -a /var/lib/lxc/$LXC_NAME/config echo "lxc.network.veth.pair = $LXC_NAME" | sudo tee -a /var/lib/lxc/$LXC_NAME/config
fi fi
fi fi
if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.hwaddr = 00:FF:AA:00:00:01"; then if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.hwaddr = 00:FF:AA:00:00:01"
then
lxc_network=1 lxc_network=1
check_repair=1 check_repair=1
if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.hwaddr"; then if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.hwaddr"
then
sudo sed -i "s/.*lxc.network.hwaddr.*/lxc.network.hwaddr = 00:FF:AA:00:00:01/g" /var/lib/lxc/$LXC_NAME/config sudo sed -i "s/.*lxc.network.hwaddr.*/lxc.network.hwaddr = 00:FF:AA:00:00:01/g" /var/lib/lxc/$LXC_NAME/config
else else
echo "lxc.network.hwaddr = 00:FF:AA:00:00:01" | sudo tee -a /var/lib/lxc/$LXC_NAME/config echo "lxc.network.hwaddr = 00:FF:AA:00:00:01" | sudo tee -a /var/lib/lxc/$LXC_NAME/config
fi fi
fi fi
if [ $lxc_network -eq 1 ]; then if [ $lxc_network -eq 1 ]
then
echo -e "\e[91mLa configuration réseau LXC du conteneur est incorrecte et a été corrigée.\e[0m" echo -e "\e[91mLa configuration réseau LXC du conteneur est incorrecte et a été corrigée.\e[0m"
else else
echo -e "\e[92mLa configuration réseau LXC du conteneur est correcte.\e[0m" echo -e "\e[92mLa configuration réseau LXC du conteneur est correcte.\e[0m"
@ -245,6 +258,7 @@ CREATE_BRIDGE () {
bridge_maxwait 0 bridge_maxwait 0
EOF EOF
} }
# Test la présence du fichier de config du bridge lxc-pchecher # Test la présence du fichier de config du bridge lxc-pchecher
if ! test -e /etc/network/interfaces.d/$LXC_BRIDGE if ! test -e /etc/network/interfaces.d/$LXC_BRIDGE
then then
@ -254,16 +268,17 @@ then
else else
echo -e "\e[92mLe fichier de config du bridge est présent.\e[0m" echo -e "\e[92mLe fichier de config du bridge est présent.\e[0m"
fi fi
# Test le démarrage du bridge # Test le démarrage du bridge
bridge=0 bridge=0
while test "$bridge" -ne 1 while test "$bridge" -ne 1
do do
sudo ifup $LXC_BRIDGE --interfaces=/etc/network/interfaces.d/$LXC_BRIDGE sudo ifup $LXC_BRIDGE --interfaces=/etc/network/interfaces.d/$LXC_BRIDGE
if sudo ifconfig | grep -q $LXC_BRIDGE if sudo ip address | grep -q $LXC_BRIDGE
then then
echo -e "\e[92mLe bridge démarre correctement.\e[0m" echo -e "\e[92mLe bridge démarre correctement.\e[0m"
# Vérifie que le bridge obtient une adresse IP # Vérifie que le bridge obtient une adresse IP
if LC_ALL=C sudo ifconfig | grep -A 10 $LXC_BRIDGE | grep "inet addr" | grep -q -F "$PLAGE_IP.1 " if LC_ALL=C sudo ip address | grep -A 10 $LXC_BRIDGE | grep "inet " | grep -q -F "$PLAGE_IP.1"
then then
echo -e "\e[92mLe bridge obtient correctement son adresse IP.\e[0m" echo -e "\e[92mLe bridge obtient correctement son adresse IP.\e[0m"
else else
@ -275,7 +290,7 @@ do
bridge=-1 # Bridge à -1 pour indiquer que cette erreur s'est déjà présentée. bridge=-1 # Bridge à -1 pour indiquer que cette erreur s'est déjà présentée.
continue # Retourne au début de la boucle pour réessayer continue # Retourne au début de la boucle pour réessayer
else else
sudo ifconfig sudo ip address
echo -e "\e[91mLe bridge n'obtient pas la bonne adresse IP après réparation. Tenter une réinstallation complète de Package_checker...\e[0m" echo -e "\e[91mLe bridge n'obtient pas la bonne adresse IP après réparation. Tenter une réinstallation complète de Package_checker...\e[0m"
sudo rm "$script_dir/../pcheck.lock" # Retire le lock sudo rm "$script_dir/../pcheck.lock" # Retire le lock
exit 1 exit 1
@ -290,7 +305,7 @@ do
bridge=-2 # Bridge à -1 pour indiquer que cette erreur s'est déjà présentée. bridge=-2 # Bridge à -1 pour indiquer que cette erreur s'est déjà présentée.
continue # Retourne au début de la boucle pour réessayer continue # Retourne au début de la boucle pour réessayer
else else
sudo ifconfig sudo ip address
echo -e "\e[91mLe bridge ne démarre pas après réparation. Tenter une réinstallation complète de Package_checker...\e[0m" echo -e "\e[91mLe bridge ne démarre pas après réparation. Tenter une réinstallation complète de Package_checker...\e[0m"
sudo rm "$script_dir/../pcheck.lock" # Retire le lock sudo rm "$script_dir/../pcheck.lock" # Retire le lock
exit 1 exit 1
@ -355,6 +370,7 @@ CHECK_LXC_NET () {
fi fi
return 0 return 0
} }
lxc_net=1 lxc_net=1
lxc_net_check=0 # Passe sur les différents tests lxc_net_check=0 # Passe sur les différents tests
while test "$lxc_net" -eq 1 # Boucle tant que la connexion internet du conteneur n'est pas réparée. while test "$lxc_net" -eq 1 # Boucle tant que la connexion internet du conteneur n'est pas réparée.
@ -484,7 +500,6 @@ if [ "$?" -ne 0 ]; then # Si la commande échoue, il y a un problème avec Yunoh
exit 1 exit 1
else else
echo -e "\e[92mYunohost est installé correctement.\e[0m" echo -e "\e[92mYunohost est installé correctement.\e[0m"
fi fi
STOP_CONTAINER STOP_CONTAINER