Adding platform independent RPM download
[oom/offline-installer.git] / build / create_repo.sh
1 #!/usr/bin/env bash
2
3 container_name="centos_repo"
4 # Path to folder with clonned offline-installer build directory with docker_entrypoint script
5 volume_directory="."
6 # Path inside container
7 container_volume="/mnt/"
8 # Docker image name and version
9 docker_image="centos:centos7.6.1810"
10
11 # Getting input parametters
12 POSITIONAL=()
13 while [[ $# -gt 0 ]]
14 do
15     key="$1"
16     case $key in
17         -h|--help)
18             # Help parametter
19             echo -e "Script for run docker container with RPM repository\n"
20             echo "-h --help: Show this help"
21             echo -e "-d --directory: set root path with offline-installer directory and repository directory for RPM packages\n"
22             echo "If build folder from offline repository is not specified will be used default path of current folder."
23             shift # past argument
24             shift # past value
25             exit
26             ;;
27         -d|--directory)
28             # Directory parametter
29             # Sets path where is clonned offline-installer build directory
30             volume_directory="$2"
31             shift # past argument
32             shift # past value
33             ;;
34         --default)
35             DEFAULT=YES
36             shift # past argument
37             ;;
38         *)  
39             # unknown option
40             POSITIONAL+=("$1") # save it in an array for later
41             shift # past argument
42             ;;
43     esac
44 done
45
46
47 #Check if container "centos-repo" is running
48 if [ ! "$(docker ps -q -f name=$container_name)" ]; then
49     if [ "$(docker ps -aq -f status=exited -f name=$container_name)" ]; then
50         # cleanup
51         docker rm $container_name
52     fi
53     # run repo container
54     # name of container $container_name
55     # docker entrypoint script from mounted volume
56     #
57     docker run -d \
58                --name $container_name \
59                -v ${volume_directory}:${container_volume} \
60                --entrypoint="${container_volume}offline-installer/build/docker-entrypoint.sh" \
61                -it ${docker_image} \
62                --rm \
63                --directory ${container_volume}resources/pkg/rhel/ \
64                --list ${container_volume}offline-installer/build/data_lists/
65 fi