mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Test backup sans installation
This commit is contained in:
parent
6b8f3a075d
commit
794161a190
3 changed files with 62 additions and 36 deletions
|
@ -15,7 +15,9 @@ Le script est capable d'effectuer les tests suivant:
|
||||||
- Installation en privé
|
- Installation en privé
|
||||||
- Installation en public
|
- Installation en public
|
||||||
- Upgrade sur la même version du package
|
- Upgrade sur la même version du package
|
||||||
- Backup puis restore
|
- Backup
|
||||||
|
- Restore après suppression de l'application
|
||||||
|
- Restore sans installation préalable
|
||||||
- Installation multi-instance
|
- Installation multi-instance
|
||||||
- Test d'utilisateur incorrect
|
- Test d'utilisateur incorrect
|
||||||
- Test de domaine incorrect
|
- Test de domaine incorrect
|
||||||
|
@ -155,7 +157,9 @@ The script is able to perform following tests:
|
||||||
- Private installation.
|
- Private installation.
|
||||||
- Public installation
|
- Public installation
|
||||||
- Upgrade on same package version
|
- Upgrade on same package version
|
||||||
- Backup then restore
|
- Backup
|
||||||
|
- Restore after application uninstall
|
||||||
|
- Restore without installation before
|
||||||
- Multi-instances installation
|
- Multi-instances installation
|
||||||
- Test with wrong user
|
- Test with wrong user
|
||||||
- Test with wrong domain
|
- Test with wrong domain
|
||||||
|
|
|
@ -112,6 +112,7 @@ 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
|
||||||
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.
|
||||||
|
@ -120,6 +121,7 @@ LXC_NETWORK_CONFIG () {
|
||||||
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
|
||||||
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
|
||||||
|
@ -128,6 +130,7 @@ LXC_NETWORK_CONFIG () {
|
||||||
fi
|
fi
|
||||||
if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.link = lxc-pchecker"; then
|
if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.link = lxc-pchecker"; then
|
||||||
lxc_network=1
|
lxc_network=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-pchecker/g" /var/lib/lxc/$LXC_NAME/config
|
sudo sed -i "s/.*lxc.network.link.*/lxc.network.link = lxc-pchecker/g" /var/lib/lxc/$LXC_NAME/config
|
||||||
else
|
else
|
||||||
|
@ -136,6 +139,7 @@ LXC_NETWORK_CONFIG () {
|
||||||
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
|
||||||
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
|
||||||
|
@ -144,6 +148,7 @@ LXC_NETWORK_CONFIG () {
|
||||||
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
|
||||||
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
|
||||||
|
@ -152,13 +157,14 @@ LXC_NETWORK_CONFIG () {
|
||||||
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
|
||||||
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"
|
||||||
|
|
|
@ -421,41 +421,57 @@ CHECK_BACKUP_RESTORE () {
|
||||||
ECHO_FORMAT "--- FAIL ---\n" "lred" "bold"
|
ECHO_FORMAT "--- FAIL ---\n" "lred" "bold"
|
||||||
GLOBAL_CHECK_BACKUP=-1 # Backup échoué
|
GLOBAL_CHECK_BACKUP=-1 # Backup échoué
|
||||||
fi
|
fi
|
||||||
# Suppression de l'app
|
sudo cp -a /var/lib/lxc/$LXC_NAME/rootfs/home/yunohost.backup/archives ./ # Récupère le backup sur le conteneur
|
||||||
REMOVE_APP
|
for j in 0 1
|
||||||
ECHO_FORMAT "\nRestauration de l'application...\n" "white" "bold"
|
do # 2 passes, pour tester la restauration après suppression de l'app ET après restauration du conteneur.
|
||||||
# Restore de l'app
|
if [ "$j" -eq 0 ]
|
||||||
COPY_LOG 1
|
then # Commence par tester la restauration après suppression de l'application
|
||||||
LXC_START "sudo yunohost --debug backup restore Backup_test --force --apps $APPID"
|
REMOVE_APP # Suppression de l'app
|
||||||
YUNOHOST_RESULT=$?
|
ECHO_FORMAT "\nRestauration de l'application après suppression de l'application...\n" "white" "bold"
|
||||||
COPY_LOG 2
|
if [ "$no_lxc" -ne 0 ]; then # Si lxc n'est pas utilisé, impossible d'effectuer le 2e test
|
||||||
LOG_EXTRACTOR
|
j=1 # Ignore le 2e test
|
||||||
# Test l'accès à l'app
|
echo "LXC n'est pas utilisé, impossible de tester la restauration sur un système vierge...\n"
|
||||||
CHECK_URL
|
fi
|
||||||
tnote=$((tnote+1))
|
elif [ "$j" -eq 1 ]
|
||||||
if [ "$YUNOHOST_RESULT" -eq 0 ] && [ "$curl_error" -eq 0 ]; then
|
then # Puis la restauration après restauration du conteneur (si LXC est utilisé)
|
||||||
ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold"
|
sudo cp -a /var/lib/lxc/$LXC_NAME/rootfs/home/yunohost.backup/archives ./ # Récupère le backup sur le conteneur
|
||||||
note=$((note+1))
|
LXC_STOP # Restaure le conteneur.
|
||||||
if [ $GLOBAL_CHECK_RESTORE -ne -1 ]; then # La restauration ne peux pas être réussie si elle a échouée précédemment...
|
sudo mv -f ./archives /var/lib/lxc/$LXC_NAME/rootfs/home/yunohost.backup/ # Replace le backup sur le conteneur
|
||||||
GLOBAL_CHECK_RESTORE=1 # Restore réussi
|
ECHO_FORMAT "\nRestauration de l'application sur un système vierge...\n" "white" "bold"
|
||||||
fi
|
fi
|
||||||
else
|
# Restore de l'app
|
||||||
ECHO_FORMAT "--- FAIL ---\n" "lred" "bold"
|
COPY_LOG 1
|
||||||
GLOBAL_CHECK_RESTORE=-1 # Restore échoué
|
LXC_START "sudo yunohost --debug backup restore Backup_test --force --apps $APPID"
|
||||||
fi
|
YUNOHOST_RESULT=$?
|
||||||
if [ "$no_lxc" -ne 0 ]; then
|
COPY_LOG 2
|
||||||
# Suppression de l'app si lxc n'est pas utilisé.
|
LOG_EXTRACTOR
|
||||||
REMOVE_APP
|
# Test l'accès à l'app
|
||||||
# Suppression de l'archive
|
CHECK_URL
|
||||||
sudo yunohost backup delete Backup_test > /dev/null
|
tnote=$((tnote+1))
|
||||||
elif [ "$auto_remove" -eq 0 ] && [ "$bash_mode" -ne 1 ]; then # Si l'auto_remove est désactivée. Marque une pause avant de continuer.
|
if [ "$YUNOHOST_RESULT" -eq 0 ] && [ "$curl_error" -eq 0 ]; then
|
||||||
if [ "$no_lxc" -eq 0 ]; then
|
ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold"
|
||||||
echo "Utilisez ssh pour vous connecter au conteneur LXC. 'ssh $ARG_SSH $LXC_NAME'"
|
note=$((note+1))
|
||||||
|
if [ $GLOBAL_CHECK_RESTORE -ne -1 ]; then # La restauration ne peux pas être réussie si elle a échouée précédemment...
|
||||||
|
GLOBAL_CHECK_RESTORE=1 # Restore réussi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
ECHO_FORMAT "--- FAIL ---\n" "lred" "bold"
|
||||||
|
GLOBAL_CHECK_RESTORE=-1 # Restore échoué
|
||||||
fi
|
fi
|
||||||
read -p "Appuyer sur une touche pour continuer les tests..." < /dev/tty
|
if [ "$no_lxc" -ne 0 ]; then
|
||||||
fi
|
# Suppression de l'app si lxc n'est pas utilisé.
|
||||||
YUNOHOST_RESULT=-1
|
REMOVE_APP
|
||||||
LXC_STOP # Restaure le snapshot du conteneur avant de recommencer le processus de backup
|
# Suppression de l'archive
|
||||||
|
sudo yunohost backup delete Backup_test > /dev/null
|
||||||
|
elif [ "$auto_remove" -eq 0 ] && [ "$bash_mode" -ne 1 ]; then # Si l'auto_remove est désactivée. Marque une pause avant de continuer.
|
||||||
|
if [ "$no_lxc" -eq 0 ]; then
|
||||||
|
echo "Utilisez ssh pour vous connecter au conteneur LXC. 'ssh $ARG_SSH $LXC_NAME'"
|
||||||
|
fi
|
||||||
|
read -p "Appuyer sur une touche pour continuer les tests..." < /dev/tty
|
||||||
|
fi
|
||||||
|
YUNOHOST_RESULT=-1
|
||||||
|
LXC_STOP # Restaure le snapshot du conteneur avant de recommencer le processus de backup
|
||||||
|
done
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue