generated from nginx/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathfetch-external-devportal-dependencies.sh
127 lines (107 loc) · 5.92 KB
/
fetch-external-devportal-dependencies.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env bash
# This script is used to fetch external packages that are not available in standard Linux distribution
# Example: ./fetch-external-dependencies ubuntu18.04 nginx-repo.crt nginx-repo.key
# Script will create devportal-dependencies-ubuntu18.04.tar.gz in local directory which can be copied
# into target machine and packages inside can be installed manually
set -eo pipefail
PACKAGE_PATH="."
mkdir -p $PACKAGE_PATH
declare -A NGINXPLUS_REPO
NGINXPLUS_REPO['ubuntu18.04']="https://pkgs.nginx.com/plus/ubuntu/pool/nginx-plus/n/nginx-plus"
NGINXPLUS_REPO['ubuntu20.04']="https://pkgs.nginx.com/plus/ubuntu/pool/nginx-plus/n/nginx-plus"
NGINXPLUS_REPO['ubuntu22.04']="https://pkgs.nginx.com/plus/ubuntu/pool/nginx-plus/n/nginx-plus"
NGINXPLUS_REPO['debian10']="https://pkgs.nginx.com/plus/debian/pool/nginx-plus/n/nginx-plus"
NGINXPLUS_REPO['debian11']="https://pkgs.nginx.com/plus/debian/pool/nginx-plus/n/nginx-plus"
NGINXPLUS_REPO['centos7']="https://pkgs.nginx.com/plus/centos/7/x86_64/RPMS"
NGINXPLUS_REPO['rhel7']="https://pkgs.nginx.com/plus/rhel/7/x86_64/RPMS"
NGINXPLUS_REPO['rhel8']="https://pkgs.nginx.com/plus/rhel/8/x86_64/RPMS"
NGINXPLUS_REPO['rhel9']="https://pkgs.nginx.com/plus/rhel/9/x86_64/RPMS"
NGINXPLUS_REPO['amzn2']="https://pkgs.nginx.com/plus/amzn2/2/x86_64/RPMS"
declare -A NJS_REPO
NJS_REPO['ubuntu18.04']="https://pkgs.nginx.com/plus/ubuntu/pool/nginx-plus/n/nginx-plus-module-njs"
NJS_REPO['ubuntu20.04']="https://pkgs.nginx.com/plus/ubuntu/pool/nginx-plus/n/nginx-plus-module-njs"
NJS_REPO['ubuntu22.04']="https://pkgs.nginx.com/plus/ubuntu/pool/nginx-plus/n/nginx-plus-module-njs"
NJS_REPO['debian10']="https://pkgs.nginx.com/plus/debian/pool/nginx-plus/n/nginx-plus-module-njs"
NJS_REPO['debian11']="https://pkgs.nginx.com/plus/debian/pool/nginx-plus/n/nginx-plus-module-njs"
NJS_REPO['centos7']="https://pkgs.nginx.com/plus/centos/7/x86_64/RPMS"
NJS_REPO['rhel7']="https://pkgs.nginx.com/plus/rhel/7/x86_64/RPMS"
NJS_REPO['rhel8']="https://pkgs.nginx.com/plus/rhel/8/x86_64/RPMS"
NJS_REPO['rhel9']="https://pkgs.nginx.com/plus/rhel/9/x86_64/RPMS"
NJS_REPO['amzn2']="https://pkgs.nginx.com/plus/amzn2/2/x86_64/RPMS"
declare -A NGINXPLUS_PACKAGES
NGINXPLUS_PACKAGES['ubuntu18.04']="nginx-plus_29-1~bionic_amd64.deb"
NGINXPLUS_PACKAGES['ubuntu20.04']="nginx-plus_29-1~focal_amd64.deb"
NGINXPLUS_PACKAGES['ubuntu22.04']="nginx-plus_29-1~jammy_amd64.deb"
NGINXPLUS_PACKAGES['debian10']="nginx-plus_29-1~buster_amd64.deb"
NGINXPLUS_PACKAGES['debian11']="nginx-plus_29-1~bullseye_amd64.deb"
NGINXPLUS_PACKAGES['centos7']="nginx-plus-29-1.el7.ngx.x86_64.rpm"
NGINXPLUS_PACKAGES['rhel7']="nginx-plus-29-1.el7.ngx.x86_64.rpm"
NGINXPLUS_PACKAGES['rhel8']="nginx-plus-29-1.el8.ngx.x86_64.rpm"
NGINXPLUS_PACKAGES['rhel9']="nginx-plus-29-1.el9.ngx.x86_64.rpm"
NGINXPLUS_PACKAGES['amzn2']="nginx-plus-29-1.amzn2.ngx.x86_64.rpm"
declare -A NJS_PACKAGES
NJS_PACKAGES['ubuntu18.04']="nginx-plus-module-njs_29+0.7.12-1~bionic_amd64.deb"
NJS_PACKAGES['ubuntu20.04']="nginx-plus-module-njs_29+0.7.12-1~focal_amd64.deb"
NJS_PACKAGES['ubuntu22.04']="nginx-plus-module-njs_29+0.7.12-1~jammy_amd64.deb"
NJS_PACKAGES['debian10']="nginx-plus-module-njs_29+0.7.12-1~buster_amd64.deb"
NJS_PACKAGES['debian11']="nginx-plus-module-njs_29+0.7.12-1~bullseye_amd64.deb"
NJS_PACKAGES['centos7']="nginx-plus-module-njs-29+0.7.12-1.el7.ngx.x86_64.rpm"
NJS_PACKAGES['rhel7']="nginx-plus-module-njs-29+0.7.12-1.el7.ngx.x86_64.rpm"
NJS_PACKAGES['rhel8']="nginx-plus-module-njs-29+0.7.12-1.el8.ngx.x86_64.rpm"
NJS_PACKAGES['rhel9']="nginx-plus-module-njs-29+0.7.12-1.el9.ngx.x86_64.rpm"
NJS_PACKAGES['amzn2']="nginx-plus-module-njs-29+0.7.12-1.amzn2.ngx.x86_64.rpm"
download_packages() {
local target_distribution=$1
local nginx_repo_cert=$2
local nginx_repo_key=$3
if [ -z $target_distribution ] || [ -z $nginx_repo_cert ] || [ -z $nginx_repo_key ]; then
echo "$0 - missing parameter"
exit 1
fi
mkdir -p "${PACKAGE_PATH}/${target_distribution}"
# just in case delete all files in target dir
rm -f "${PACKAGE_PATH}/${target_distribution}/*"
readarray -t nginxplus_files <<<"${NGINXPLUS_PACKAGES[${target_distribution}]}"
readarray -t njs_files <<<"${NJS_PACKAGES[${target_distribution}]}"
for package_file in "${nginxplus_files[@]}"; do
if [ -z $package_file ]; then
continue
fi
file_url="${NGINXPLUS_REPO[$target_distribution]}/$package_file"
save_file="${PACKAGE_PATH}/${target_distribution}/$package_file"
echo "Fetching $file_url"
curl --cert ${nginx_repo_cert} --key ${nginx_repo_key} -fs $file_url --output $save_file
done
for package_file in "${njs_files[@]}"; do
if [ -z $package_file ]; then
continue
fi
file_url="${NJS_REPO[$target_distribution]}/$package_file"
save_file="${PACKAGE_PATH}/${target_distribution}/$package_file"
echo "Fetching $file_url"
curl --cert ${nginx_repo_cert} --key ${nginx_repo_key} -fs $file_url --output $save_file
done
bundle_file="${PACKAGE_PATH}/devportal-dependencies-${target_distribution}.tar.gz"
tar -zcf $bundle_file -C "${PACKAGE_PATH}/${target_distribution}" .
echo "Bundle file saved as $bundle_file"
}
target_distribution=$1
nginx_repo_cert=$2
nginx_repo_key=$3
if [ -z $target_distribution ]; then
echo "Usage: $0 target_distribution nginxrepo_cert nginxrepo_key"
echo "Supported target distributions: ${!NGINXPLUS_REPO[@]}"
exit 1
fi
if [ -z $nginx_repo_cert ] || [ -z $nginx_repo_key ]; then
echo "Usage: $0 target_distribution nginxrepo_cert nginxrepo_key"
echo "Missing nginxrepo_cert or nginxrepo_key parameters"
exit 1
fi
# check if target distribution is supported
if [ -z ${NGINXPLUS_REPO[$target_distribution]} ]; then
echo "Target distribution $target_distribution is not supported."
echo "Supported distributions: ${!NGINXPLUS_REPO[@]}"
exit 1
fi
download_packages "${target_distribution}" "${nginx_repo_cert}" "${nginx_repo_key}"