mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Use lxc_remove in lxc_build
This commit is contained in:
parent
9a4d284332
commit
6a4a2e4a95
2 changed files with 30 additions and 15 deletions
|
@ -67,11 +67,11 @@ 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 "# Distribution debian\nDISTRIB=$DISTRIB\n" >> "$pcheck_config"
|
||||
|
||||
echo -e "\e[1m> Update et install lxc lxctl\e[0m" | tee "$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 install -y lxc lxctl >> "$LOG_BUILD_LXC" 2>&1
|
||||
|
||||
echo -e "\e[1m> Install git, curl and lynx\e[0m" | tee "$LOG_BUILD_LXC"
|
||||
echo -e "\e[1m> Install git, curl and lynx\e[0m" | tee -a "$LOG_BUILD_LXC"
|
||||
sudo apt-get install -y git curl lynx >> "$LOG_BUILD_LXC" 2>&1
|
||||
|
||||
sudo mkdir -p /var/lib/lxcsnaps # Créer le dossier lxcsnaps, pour s'assurer que lxc utilisera ce dossier, même avec lxc 2.
|
||||
|
@ -79,11 +79,7 @@ sudo mkdir -p /var/lib/lxcsnaps # Créer le dossier lxcsnaps, pour s'assurer que
|
|||
if sudo lxc-info -n $LXC_NAME > /dev/null 2>&1
|
||||
then # Si le conteneur existe déjà
|
||||
echo -e "\e[1m> Suppression du conteneur existant.\e[0m" | tee -a "$LOG_BUILD_LXC"
|
||||
sudo lxc-snapshot -n $LXC_NAME -d snap0 | tee -a "$LOG_BUILD_LXC"
|
||||
sudo lxc-snapshot -n $LXC_NAME -d snap1 | tee -a "$LOG_BUILD_LXC"
|
||||
sudo lxc-snapshot -n $LXC_NAME -d snap2 | tee -a "$LOG_BUILD_LXC"
|
||||
sudo rm -f /var/lib/lxcsnaps/$LXC_NAME/snap0.tar.gz | tee -a "$LOG_BUILD_LXC"
|
||||
sudo lxc-destroy -n $LXC_NAME -f | tee -a "$LOG_BUILD_LXC"
|
||||
"$script_dir/lxc_remove.sh" quiet | tee -a "$LOG_BUILD_LXC"
|
||||
fi
|
||||
|
||||
echo -e "\e[1m> Création d'une machine debian $DISTRIB minimaliste.\e[0m" | tee -a "$LOG_BUILD_LXC"
|
||||
|
|
|
@ -14,26 +14,45 @@ if [ "$(whoami)" != "$(cat "$script_dir/setup_user")" ] && test -e "$script_dir/
|
|||
exit 0
|
||||
fi
|
||||
|
||||
echo_bold () {
|
||||
if [ $quiet_remove -eq 0 ]
|
||||
then
|
||||
echo -e "\e[1m> $1\e[0m"
|
||||
fi
|
||||
}
|
||||
|
||||
quiet_remove=0
|
||||
# Check argument "quiet"
|
||||
if [ "$1" = "quiet" ]
|
||||
then
|
||||
quiet_remove=1
|
||||
fi
|
||||
|
||||
touch "$script_dir/../pcheck.lock" # Met en place le lock de Package check
|
||||
|
||||
echo -e "\e[1m> Retire l'ip forwarding.\e[0m"
|
||||
echo_bold "Retire l'ip forwarding."
|
||||
sudo rm /etc/sysctl.d/lxc_pchecker.conf
|
||||
sudo sysctl -p
|
||||
|
||||
echo -e "\e[1m> Désactive le bridge réseau\e[0m"
|
||||
echo_bold "Désactive le bridge réseau"
|
||||
sudo ifdown --force $LXC_BRIDGE
|
||||
|
||||
echo -e "\e[1m> Supprime le brige réseau\e[0m"
|
||||
echo_bold "Supprime le brige réseau"
|
||||
sudo rm /etc/network/interfaces.d/$LXC_BRIDGE
|
||||
|
||||
echo -e "\e[1m> Suppression de la machine et de son snapshots\e[0m"
|
||||
echo_bold "Suppression de la machine et de son snapshots"
|
||||
sudo lxc-snapshot -n $LXC_NAME -d snap0
|
||||
sudo lxc-snapshot -n $LXC_NAME -d snap1
|
||||
sudo lxc-snapshot -n $LXC_NAME -d snap2
|
||||
sudo rm -f /var/lib/lxcsnaps/$LXC_NAME/snap0.tar.gz
|
||||
sudo lxc-destroy -n $LXC_NAME -f
|
||||
|
||||
echo -e "\e[1m> Remove lxc lxctl\e[0m"
|
||||
sudo apt-get remove lxc lxctl
|
||||
if [ $quiet_remove -eq 0 ]
|
||||
then
|
||||
echo_bold "Remove lxc lxctl"
|
||||
sudo apt-get remove lxc lxctl
|
||||
fi
|
||||
|
||||
echo -e "\e[1m> Suppression des lignes de pchecker_lxc dans .ssh/config\e[0m"
|
||||
BEGIN_LINE=$(cat $HOME/.ssh/config | grep -n "^# ssh pchecker_lxc$" | cut -d':' -f 1)
|
||||
echo_bold "Suppression des lignes de pchecker_lxc dans $HOME/.ssh/config"
|
||||
BEGIN_LINE=$(cat $HOME/.ssh/config | grep -n "^# ssh pchecker_lxc$" | cut -d':' -f 1 | tail -n1)
|
||||
sed -i "$BEGIN_LINE,/^IdentityFile/d" $HOME/.ssh/config
|
||||
|
|
Loading…
Add table
Reference in a new issue