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,9 +421,24 @@ 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.
|
||||||
|
if [ "$j" -eq 0 ]
|
||||||
|
then # Commence par tester la restauration après suppression de l'application
|
||||||
|
REMOVE_APP # Suppression de l'app
|
||||||
|
ECHO_FORMAT "\nRestauration de l'application après suppression de l'application...\n" "white" "bold"
|
||||||
|
if [ "$no_lxc" -ne 0 ]; then # Si lxc n'est pas utilisé, impossible d'effectuer le 2e test
|
||||||
|
j=1 # Ignore le 2e test
|
||||||
|
echo "LXC n'est pas utilisé, impossible de tester la restauration sur un système vierge...\n"
|
||||||
|
fi
|
||||||
|
elif [ "$j" -eq 1 ]
|
||||||
|
then # Puis la restauration après restauration du conteneur (si LXC est utilisé)
|
||||||
|
sudo cp -a /var/lib/lxc/$LXC_NAME/rootfs/home/yunohost.backup/archives ./ # Récupère le backup sur le conteneur
|
||||||
|
LXC_STOP # Restaure le conteneur.
|
||||||
|
sudo mv -f ./archives /var/lib/lxc/$LXC_NAME/rootfs/home/yunohost.backup/ # Replace le backup sur le conteneur
|
||||||
|
ECHO_FORMAT "\nRestauration de l'application sur un système vierge...\n" "white" "bold"
|
||||||
|
fi
|
||||||
# Restore de l'app
|
# Restore de l'app
|
||||||
COPY_LOG 1
|
COPY_LOG 1
|
||||||
LXC_START "sudo yunohost --debug backup restore Backup_test --force --apps $APPID"
|
LXC_START "sudo yunohost --debug backup restore Backup_test --force --apps $APPID"
|
||||||
|
@ -457,6 +472,7 @@ CHECK_BACKUP_RESTORE () {
|
||||||
YUNOHOST_RESULT=-1
|
YUNOHOST_RESULT=-1
|
||||||
LXC_STOP # Restaure le snapshot du conteneur avant de recommencer le processus de backup
|
LXC_STOP # Restaure le snapshot du conteneur avant de recommencer le processus de backup
|
||||||
done
|
done
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_PUBLIC_PRIVATE () {
|
CHECK_PUBLIC_PRIVATE () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue