X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=env%2Fubuntu%2Fbootloader-env%2F02_clean_bootloader_package_req.sh;h=1f6c474e69fb5ba38f5af2f61be2a37d3025b65f;hb=d97c70768d15571872233922caf17c4a4c34065b;hp=60fe2eaa10b73550e74c2d86833686b56c3d0fb5;hpb=2d1ee64f68cd36284bd180559e91b84a8c10dd3c;p=icn.git diff --git a/env/ubuntu/bootloader-env/02_clean_bootloader_package_req.sh b/env/ubuntu/bootloader-env/02_clean_bootloader_package_req.sh index 60fe2ea..1f6c474 100755 --- a/env/ubuntu/bootloader-env/02_clean_bootloader_package_req.sh +++ b/env/ubuntu/bootloader-env/02_clean_bootloader_package_req.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -ex +set -eux -o pipefail source $(dirname $PWD)/../lib/common.sh source $(dirname $PWD)/../lib/logging.sh @@ -9,26 +9,29 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi -if [[ $(lsb_release -d | cut -f2) != $UBUNTU_BIONIC ]]; then - echo "Currently Ubuntu 18.04.2 LTS is only supported" - exit 1 -fi +function autoremove { + #apt-get autoremove -y + rm -rf /etc/apt/sources.list.d/* +} function clean_essential_packages { apt-get update for package in crudini curl dnsmasq figlet golang nmap patch psmisc \ - python-pip python-requests python-setuptools vim wget; do + python3-pip python3-requests python3-setuptools vim wget; do apt-get remove $package -y done + update-alternatives --remove python /usr/bin/python3 + update-alternatives --remove pip /usr/bin/pip3 - apt-get autoremove -y - rm -rf /etc/apt/sources.list.d/* + autoremove } function check_prerequisite { if !(which pip); then - apt-get install python-pip -y + apt-get install python3-pip -y fi + update-alternatives --install /usr/bin/python python /usr/bin/python3 1 + update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 if !(which curl); then apt-get install curl -y @@ -40,9 +43,9 @@ function check_prerequisite { } function clean_ironic_packages { - for package in jq nodejs python-ironicclient \ - python-ironic-inspector-client python-lxml python-netaddr \ - python-openstackclient unzip genisoimage; do + for package in python3-ironicclient \ + python3-ironic-inspector-client \ + python3-openstackclient genisoimage; do apt-get remove $package -y done } @@ -54,19 +57,15 @@ function clean_docker_packages { $(lsb_release -cs) \ stable" apt-get update + docker rmi -f $(docker image ls -a -q) apt-get remove docker-ce -y - for package in apt-transport-https ca-certificates gnupg-agent \ - software-properties-common; do - apt-get remove $package -y - done - apt-get remove -y docker \ docker-engine \ docker.io \ containerd \ runc \ docker-ce - + apt-get purge docker-* -y --allow-change-held-packages apt-get update } @@ -86,6 +85,28 @@ EOF' apt-get remove kubelet kubeadm kubectl -y } +function clean_all { + apt-get remove -y openvswitch-switch openvswitch-common ovn-central \ + ovn-common ovn-host + rm -rf /var/run/openvswitch + rm -rf /var/lib/openvswitch + rm -rf /var/log/openvswitch + rm -rf /var/lib/libvirt + rm -rf /etc/libvirt + rm -rf /var/lib/virtlet + rm -rf /var/run/libvirt + rm -rf virtlet.sock + rm -rf virtlet-diag.sock + rm -rf criproxy.sock + systemctl stop dockershim + systemctl stop criproxy + systemctl disable kubelet + systemctl disable dockershim + systemctl disable criproxy + if ip link show | grep virbr0-nic > /dev/null; then ip link delete virbr0-nic; fi + if ip link show | grep virbr0 > /dev/null; then ip link delete virbr0; fi +} + function clean_apt_cache { shopt -s extglob pushd /var/cache/apt/archives @@ -123,6 +144,20 @@ function clean_dir { popd } +if [ "$1" == "--only-packages" ]; then + check_prerequisite + clean_docker_packages || true + #clean_ironic_packages + autoremove + exit 0 +fi + +if [ "$1" == "--bm-cleanall" ]; then + clean_all || true + autoremove + exit 0 +fi + check_prerequisite clean_apt_cache check_dir $LOCAL_APT_REPO