xref: /aosp_15_r20/external/autotest/utils/install_docker_chroot.sh (revision 9c5db1993ded3edbeafc8092d69fe5de2ee02df7)
1#!/bin/bash
2
3# Copyright 2022 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# This script install pip2, pip3, docker library for python2 and python3.
8
9
10function install_docker_library {
11    mkdir /tmp/docker_library_bootstrap
12
13    # Install pip2
14    wget -O /tmp/docker_library_bootstrap/get_pip2.py https://bootstrap.pypa.io/pip/2.7/get-pip.py
15    python2 /tmp/docker_library_bootstrap/get_pip2.py
16
17    # Install pip3
18    wget -O /tmp/docker_library_bootstrap/get_pip3.py https://bootstrap.pypa.io/pip/3.6/get-pip.py
19    python3 /tmp/docker_library_bootstrap/get_pip3.py
20
21    # Install Docker Python SDK
22   pip2 install docker==4.4.4 --upgrade
23   pip3 install docker==4.4.4 --upgrade
24
25    # Cleaning up
26    rm -rf /tmp/docker_library_bootstrap
27}
28
29cat << EOF
30###############################################################################
31IMPORTANT: Please read below information
32###############################################################################
33The script will install the following into your system:
34    - pip2
35    - pip3
36    - python2/3 Docker SDK
37Please run the script using sudo within chroot or container as this might
38permanently changed your environment.
39
40DO NOT RUN THIS ON YOUR WORKSTATION.
41###############################################################################
42EOF
43
44while true; do
45    read -p "Do you wish to proceed? [y/N]: " yn
46    case "$yn" in
47        [Yy]* ) install_docker_library; break;;
48        [Nn]* ) exit;;
49        * ) echo "Please answer yes or no.";;
50    esac
51done