build_hue_common.sh 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. #!/usr/bin/env bash
  2. big_console_header() {
  3. set +x
  4. local text="$*"
  5. local spacing=$(( (75+${#text}) /2 ))
  6. printf "\n\n============================================================================\n"
  7. printf "%*s\n" ${spacing} "${text}"
  8. printf "============================================================================\n\n\n"
  9. set -x
  10. }
  11. is_supported_os() {
  12. local _arrayname=$1
  13. local _os=$2
  14. local _array=()
  15. eval "_array=(\"\${${_arrayname}[@]}\")"
  16. for item in "${_array[@]}"; do
  17. if [[ "$item" == "$_os" ]]; then
  18. return 0
  19. fi
  20. done
  21. return 1
  22. }
  23. is_supported_python_version() {
  24. local PYBIN="$1"
  25. local version="$2"
  26. IFS='.' read -r major minor patch <<< "$version"
  27. "$PYBIN" -c "import sys; exit(0) if sys.version_info >= ($major, $minor, $patch) else exit(1)"
  28. return $?
  29. }
  30. function install_python311() {
  31. local DOCKEROS=${1:-"ubuntu22"}
  32. local PYTHON_VERSION=${2:-"3.11.12"}
  33. pushd .
  34. cd $HOME
  35. local INSTALL_PREFIX="/opt/python/${PYTHON_VERSION}"
  36. local PYTHON_TGZ="Python-${PYTHON_VERSION}.tgz"
  37. local PYTHON_SRC_DIR="Python-${PYTHON_VERSION}"
  38. export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/mit/bin:$PATH
  39. export LD_LIBRARY_PATH=${INSTALL_PREFIX}/lib:/opt/sqlite3/lib:${LD_LIBRARY_PATH}
  40. export CPPFLAGS="-I/opt/sqlite3/include"
  41. export LDFLAGS="-L/opt/sqlite3/lib"
  42. echo "Installing build dependencies..."
  43. case "${DOCKEROS}" in
  44. ubuntu22)
  45. sudo -- sh -c 'apt update && \
  46. apt install -y \
  47. build-essential \
  48. libbz2-dev libncurses5-dev libgdbm-dev libreadline-dev libkrb5-dev \
  49. liblzma-dev uuid-dev libldap2-dev libffi-dev zlib1g-dev libssl-dev wget curl'
  50. ;;
  51. redhat9|redhat8|redhat8-arm64)
  52. sudo -- sh -c 'yum groupinstall -y "Development Tools" && \
  53. yum install -y \
  54. bzip2-devel ncurses-devel gdbm-devel readline-devel krb5-devel \
  55. xz-devel libuuid-devel openldap-devel libffi-devel zlib-devel openssl-devel wget curl'
  56. ;;
  57. sles15)
  58. sudo -- sh -c 'zypper refresh'
  59. sudo -- sh -c 'zypper install -y \
  60. gcc gcc-c++ make \
  61. ncurses-devel gdbm-devel readline-devel krb5-devel \
  62. xz-devel libuuid-devel openldap2-devel libffi-devel zlib-devel libopenssl-devel wget curl'
  63. ;;
  64. *)
  65. echo "Unsupported OS: ${DOCKEROS}. Exiting."
  66. exit 1
  67. ;;
  68. esac
  69. echo "Installing sqlite3..."
  70. sudo LD_LIBRARY_PATH=${LD_LIBRARY_PATH} PATH=${PATH} \
  71. -- sh -c 'cd /tmp && \
  72. mkdir -p /opt/sqlite3 && \
  73. curl -o sqlite-autoconf-3350500.tar.gz https://www.sqlite.org/2021/sqlite-autoconf-3350500.tar.gz && \
  74. tar zxvf sqlite-autoconf-3350500.tar.gz && \
  75. cd sqlite-autoconf-3350500 && \
  76. ./configure --prefix=/opt/sqlite3 && make && make install && \
  77. libtool --finish /opt/sqlite3/lib'
  78. echo "Installing Python ${PYTHON_VERSION}..."
  79. sudo DOCKEROS=${DOCKEROS} PYTHON_VERSION=${PYTHON_VERSION} INSTALL_PREFIX=${INSTALL_PREFIX} \
  80. PYTHON_TGZ=${PYTHON_TGZ} PYTHON_SRC_DIR=${PYTHON_SRC_DIR} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} \
  81. CPPFLAGS=${CPPFLAGS} LDFLAGS=${LDFLAGS} PATH=${PATH} \
  82. -- sh -c 'cd /tmp && mkdir -p "${INSTALL_PREFIX}" && \
  83. curl -o "${PYTHON_TGZ}" "https://www.python.org/ftp/python/${PYTHON_VERSION}/${PYTHON_TGZ}" && \
  84. tar zxf "${PYTHON_TGZ}" && \
  85. cd "${PYTHON_SRC_DIR}" && \
  86. ./configure --prefix="${INSTALL_PREFIX}" --enable-shared --enable-optimizations --with-lto && \
  87. make altinstall'
  88. # echo "Stripping debug symbols to reduce size..."
  89. # sudo -- sh -c '/usr/bin/strip "${INSTALL_PREFIX}/bin/python3.11" && \
  90. # /usr/bin/strip "${INSTALL_PREFIX}/lib/libpython3.11.so.1.0"'
  91. sudo DOCKEROS=${DOCKEROS} PYTHON_VERSION=${PYTHON_VERSION} INSTALL_PREFIX=${INSTALL_PREFIX} \
  92. PYTHON_TGZ=${PYTHON_TGZ} PYTHON_SRC_DIR=${PYTHON_SRC_DIR} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} \
  93. CPPFLAGS=${CPPFLAGS} LDFLAGS=${LDFLAGS} PATH=${PATH} \
  94. -- sh -c 'cd /tmp && curl -sS https://bootstrap.pypa.io/get-pip.py | "${INSTALL_PREFIX}/bin/python3.11"'
  95. export SQLITE3_PATH=/opt/sqlite3/bin/sqlite3
  96. export PYTHON311_PATH=${INSTALL_PREFIX}
  97. export PATH=${INSTALL_PREFIX}/bin:$PATH
  98. export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
  99. popd
  100. }
  101. function centos7_install() {
  102. if [[ $FORCEINSTALL -eq 1 ]]; then
  103. # pre-req install
  104. sudo -- sh -c 'yum install -y cyrus-sasl-gssapi \
  105. cyrus-sasl-plain \
  106. java-11-openjdk \
  107. java-11-openjdk-devel \
  108. java-11-openjdk-headless \
  109. krb5-workstation \
  110. libpcap \
  111. ncurses-devel \
  112. nmap-ncat \
  113. xmlsec1 \
  114. xmlsec1-openssl \
  115. unzip \
  116. python3-devel \
  117. postgresql-devel'
  118. # Ensure pg_config is available
  119. export PG_CONFIG=$(which pg_config)
  120. if [ -z "$PG_CONFIG" ]; then
  121. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  122. exit 1
  123. fi
  124. echo "PG_CONFIG is set to $PG_CONFIG"
  125. # MySQLdb install
  126. sudo -- sh -c 'cd /tmp && curl -sSLO https://cloudera-build-us-west-1.vpc.cloudera.com/s3/ARTIFACTS/mysql80-community-release-el7-11.noarch.rpm && \
  127. rpm -ivh mysql80-community-release-el7-11.noarch.rpm && \
  128. yum install -y mysql-community-libs mysql-community-client-plugins mysql-community-common'
  129. # NODEJS 16 install
  130. # Upgrading to node-v16 because of the following CVE's in node-v14 "CVE-2021-3450, CVE-2021-44531, CVE-2023-32004, CVE-2023-32006"
  131. # Node-v20-LTS is not supported by old OS'es - Redhat7_ppc, Centos7, Ubuntu18, Sles12. So upgrading to node-v16
  132. sudo -- sh -c 'cd /tmp && curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash - && \
  133. yum install -y nodejs npm'
  134. # sqlite3 install
  135. sudo -- sh -c 'cd /tmp && curl -o sqlite-autoconf-3350500.tar.gz https://sqlite.org/2021/sqlite-autoconf-3350500.tar.gz && \
  136. tar zxvf sqlite-autoconf-3350500.tar.gz && \
  137. cd sqlite-autoconf-3350500 && \
  138. ./configure --prefix=/opt/sqlite3 && make && make install'
  139. # python3.8 re install for sqlite3 3.35.5 or higher version
  140. sudo LD_LIBRARY_PATH=/opt/sqlite3/lib:$ORACLE_INSTANTCLIENT19_PATH:$LD_LIBRARY_PATH \
  141. LD_RUN_PATH=/opt/sqlite3/lib:$ORACLE_INSTANTCLIENT19_PATH:$LD_RUN_PATH \
  142. -- sh -c 'cd /tmp && curl -o Python-3.8.13.tgz https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tgz && \
  143. tar zxvf Python-3.8.13.tgz && \
  144. cd Python-3.8.13 && \
  145. ./configure --enable-shared --prefix=/opt/cloudera/cm-agent && \
  146. make altinstall'
  147. export SQLITE3_PATH=/opt/sqlite3/bin/sqlite3
  148. export PYTHON38_PATH="/opt/cloudera/cm-agent"
  149. pip_bin="${PYTHON38_PATH}/bin/pip3.8"
  150. export VIRTUAL_ENV_VERSION="20.19.0"
  151. # Pip modules install
  152. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  153. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  154. sudo pip_bin=${pip_bin} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  155. fi
  156. }
  157. function redhat8_install() {
  158. if [[ $FORCEINSTALL -eq 1 ]]; then
  159. # pre-req install
  160. sudo -- sh -c 'yum install -y \
  161. java-11-openjdk \
  162. java-11-openjdk-devel \
  163. java-11-openjdk-headless \
  164. krb5-workstation \
  165. ncurses-devel \
  166. nmap-ncat \
  167. xmlsec1 \
  168. xmlsec1-openssl \
  169. libss \
  170. ncurses-c++-libs \
  171. python3-devel \
  172. postgresql-devel'
  173. # Ensure pg_config is available
  174. export PG_CONFIG=$(which pg_config)
  175. if [ -z "$PG_CONFIG" ]; then
  176. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  177. exit 1
  178. fi
  179. echo "PG_CONFIG is set to $PG_CONFIG"
  180. # MySQLdb install
  181. sudo -- sh -c 'yum install -y python3-mysqlclient'
  182. # NODEJS 20 install
  183. sudo -- sh -c 'cd /tmp && curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash - && \
  184. yum install -y nodejs'
  185. if ! is_supported_python_version "$PYTHON311_PATH/bin/python3.11" $REQ_PYTHON311; then
  186. install_python311 "redhat8" "$REQ_PYTHON311"
  187. fi
  188. export pip_bin=${PYTHON311_PATH}/bin/pip3.11
  189. export VIRTUAL_ENV_VERSION="20.30.0"
  190. # Pip modules install
  191. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  192. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  193. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  194. fi
  195. }
  196. function redhat8_arm64_install() {
  197. if [[ $FORCEINSTALL -eq 1 ]]; then
  198. # pre-req install
  199. sudo -- sh -c 'yum install -y \
  200. java-11-openjdk \
  201. java-11-openjdk-devel \
  202. java-11-openjdk-headless \
  203. krb5-workstation \
  204. ncurses-devel \
  205. nmap-ncat \
  206. xmlsec1 \
  207. xmlsec1-openssl \
  208. libss \
  209. ncurses-c++-libs'
  210. # MySQLdb install
  211. sudo -- sh -c 'yum install -y python3-mysqlclient'
  212. # NODEJS 20 install
  213. sudo -- sh -c 'cd /tmp && curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash - && \
  214. yum install -y nodejs'
  215. # Pip modules install
  216. if ! is_supported_python_version "$PYTHON311_PATH/bin/python3.11" $REQ_PYTHON311; then
  217. install_python311 "redhat8-arm64" "$REQ_PYTHON311"
  218. fi
  219. export pip_bin=${PYTHON311_PATH}/bin/pip3.11
  220. export VIRTUAL_ENV_VERSION="20.30.0"
  221. # Pip modules install
  222. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  223. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install psycopg2-binary==2.9.6'
  224. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  225. fi
  226. }
  227. function redhat9_install() {
  228. if [[ $FORCEINSTALL -eq 1 ]]; then
  229. # pre-req install
  230. sudo -- sh -c 'yum install -y \
  231. java-11-openjdk \
  232. java-11-openjdk-devel \
  233. java-11-openjdk-headless \
  234. krb5-workstation \
  235. ncurses-devel \
  236. nmap-ncat \
  237. xmlsec1 \
  238. xmlsec1-openssl \
  239. libss \
  240. ncurses-c++-libs \
  241. postgresql-devel'
  242. # Ensure pg_config is available
  243. export PG_CONFIG=$(which pg_config)
  244. if [ -z "$PG_CONFIG" ]; then
  245. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  246. exit 1
  247. fi
  248. echo "PG_CONFIG is set to $PG_CONFIG"
  249. # MySQLdb install
  250. sudo -- sh -c 'yum install -y python3-mysqlclient'
  251. # NODEJS 20 install
  252. sudo -- sh -c 'cd /tmp && curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash - && \
  253. yum install -y nodejs'
  254. if ! is_supported_python_version "$PYTHON311_PATH/bin/python3.11" $REQ_PYTHON311; then
  255. install_python311 "redhat9" "$REQ_PYTHON311"
  256. fi
  257. export pip_bin=${PYTHON311_PATH}/bin/pip3.11
  258. export VIRTUAL_ENV_VERSION="20.30.0"
  259. # Pip modules install
  260. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  261. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  262. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  263. fi
  264. }
  265. function sles12_install() {
  266. if [[ $FORCEINSTALL -eq 1 ]]; then
  267. # pre-req install
  268. sudo -- sh -c 'zypper refresh'
  269. sudo -- sh -c 'zypper install -y cyrus-sasl-gssapi \
  270. cyrus-sasl-plain \
  271. java-11-openjdk \
  272. java-11-openjdk-devel \
  273. java-11-openjdk-headless \
  274. krb5-client pam_krb5 krb5-appl-clients krb5-plugin-kdb-ldap \
  275. libpcap \
  276. ncurses-devel \
  277. nmap \
  278. python3-devel \
  279. postgresql-server-devel \
  280. xmlsec1 xmlsec1-devel xmlsec1-openssl-devel'
  281. # Ensure pg_config is available
  282. export PG_CONFIG=$(which pg_config)
  283. if [ -z "$PG_CONFIG" ]; then
  284. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  285. exit 1
  286. fi
  287. echo "PG_CONFIG is set to $PG_CONFIG"
  288. # MySQLdb install
  289. sudo -- sh -c 'zypper install -y libmysqlclient-devel libmysqlclient18 libmysqld18 libmysqld-devel'
  290. # NODEJS 16 install
  291. # Upgrading to node-v16 because of the following CVE's in node-v14 "CVE-2021-3450, CVE-2021-44531, CVE-2023-32004, CVE-2023-32006"
  292. # Node-v20-LTS is not supported by old OS'es - Redhat7_ppc, Centos7, Ubuntu18, Sles12. So upgrading to node-v16
  293. sudo -- sh -c 'zypper install -y npm14 nodejs14'
  294. pip_bin="${PYTHON38_PATH}/bin/pip3.8"
  295. VIRTUAL_ENV_VERSION="20.19.0"
  296. # Pip modules install
  297. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  298. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  299. sudo pip_bin=${pip_bin} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  300. # sqlite3 install
  301. sudo -- sh -c 'cd /tmp && curl --insecure -o sqlite-autoconf-3350500.tar.gz https://sqlite.org/2021/sqlite-autoconf-3350500.tar.gz && \
  302. tar zxvf sqlite-autoconf-3350500.tar.gz && \
  303. cd sqlite-autoconf-3350500 && \
  304. ./configure --prefix=/opt/sqlite3 && make && make install'
  305. export LD_LIBRARY_PATH=/opt/sqlite3/lib:$LD_LIBRARY_PATH
  306. export SQLITE3_PATH=/opt/sqlite3/bin/sqlite3
  307. fi
  308. }
  309. function sles15_install() {
  310. if [[ $FORCEINSTALL -eq 1 ]]; then
  311. # pre-req install
  312. sudo -- sh -c 'zypper refresh'
  313. sudo -- sh -c 'zypper install -y cyrus-sasl-gssapi \
  314. cyrus-sasl-plain \
  315. java-11-openjdk \
  316. java-11-openjdk-devel \
  317. java-11-openjdk-headless \
  318. krb5-client pam_krb5 krb5-plugin-kdb-ldap \
  319. libpcap1 \
  320. ncurses-devel \
  321. nmap \
  322. postgresql-server-devel \
  323. xmlsec1 xmlsec1-devel xmlsec1-openssl-devel'
  324. # Ensure pg_config is available
  325. export PG_CONFIG=$(which pg_config)
  326. if [ -z "$PG_CONFIG" ]; then
  327. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  328. exit 1
  329. fi
  330. echo "PG_CONFIG is set to $PG_CONFIG"
  331. # MySQLdb install
  332. sudo -- sh -c 'zypper install -y libmariadb-devel mariadb-client python3-mysqlclient'
  333. # NODEJS 18 install
  334. sudo -- sh -c 'zypper install -y nodejs18 npm20'
  335. sudo -- sh -c 'rm -f /usr/local/bin/node && ln -s /usr/bin/node18 /usr/local/bin/node'
  336. sudo -- sh -c 'rm -f /usr/local/bin/npm && ln -s /usr/bin/npm20 /usr/local/bin/npm'
  337. if ! is_supported_python_version "$PYTHON311_PATH/bin/python3.11" $REQ_PYTHON311; then
  338. install_python311 "sles15" "$REQ_PYTHON311"
  339. fi
  340. export pip_bin=${PYTHON311_PATH}/bin/pip3.11
  341. export VIRTUAL_ENV_VERSION="20.30.0"
  342. # Pip modules install
  343. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  344. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  345. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  346. fi
  347. }
  348. function ubuntu18_install() {
  349. if [[ $FORCEINSTALL -eq 1 ]]; then
  350. # pre-req install
  351. sudo -- sh -c 'apt-get update'
  352. sudo -- sh -c 'DEBIAN_FRONTEND=noninteractive apt -qq -y install \
  353. krb5-user \
  354. krb5-kdc \
  355. krb5-config \
  356. libkrb5-dev'
  357. sudo -- sh -c 'apt -y install \
  358. ldap-utils \
  359. libpython3.8-dev \
  360. libpython3.8-minimal \
  361. libpython3.8-stdlib \
  362. libxmlsec1 \
  363. libxmlsec1-openssl \
  364. netcat \
  365. nmap \
  366. python3-asn1crypto \
  367. python3-cffi-backend \
  368. python3-crypto \
  369. python3-cryptography \
  370. python3-keyring \
  371. python3-psycopg2 \
  372. python3-setuptools \
  373. python3-wheel \
  374. python3.8-venv \
  375. python3-dev \
  376. libpq-dev \
  377. zlibc'
  378. # Ensure pg_config is available
  379. export PG_CONFIG=$(which pg_config)
  380. if [ -z "$PG_CONFIG" ]; then
  381. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  382. exit 1
  383. fi
  384. echo "PG_CONFIG is set to $PG_CONFIG"
  385. # MySQLdb install
  386. # It is pre-installed
  387. # NODEJS 16 install
  388. # Upgrading to node-v16 because of the following CVE's in node-v14 "CVE-2021-3450, CVE-2021-44531, CVE-2023-32004, CVE-2023-32006"
  389. # Node-v20-LTS is not supported by old OS'es - Redhat7_ppc, Centos7, Ubuntu18, Sles12. So upgrading to node-v16
  390. sudo -- sh -c 'cd /tmp && curl -sL https://deb.nodesource.com/setup_16.x | sudo bash - && \
  391. apt -y install nodejs'
  392. pip_bin="${PYTHON38_PATH}/bin/pip3.8"
  393. VIRTUAL_ENV_VERSION="20.19.0"
  394. # Pip modules install
  395. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  396. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  397. sudo pip_bin=${pip_bin} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  398. # sqlite3 install
  399. sudo -- sh -c 'cd /tmp && curl -o sqlite-autoconf-3350500.tar.gz https://sqlite.org/2021/sqlite-autoconf-3350500.tar.gz && \
  400. tar zxvf sqlite-autoconf-3350500.tar.gz && \
  401. cd sqlite-autoconf-3350500 && \
  402. ./configure --prefix=/opt/sqlite3 && make && make install'
  403. export LD_LIBRARY_PATH=/opt/sqlite3/lib:$LD_LIBRARY_PATH
  404. export SQLITE3_PATH=/opt/sqlite3/bin/sqlite3
  405. fi
  406. }
  407. function ubuntu20_install() {
  408. if [[ $FORCEINSTALL -eq 1 ]]; then
  409. # pre-req install
  410. sudo -- sh -c 'DEBIAN_FRONTEND=noninteractive apt -qq -y install \
  411. krb5-user \
  412. krb5-kdc \
  413. krb5-config \
  414. libkrb5-dev'
  415. sudo -- sh -c 'apt -y install \
  416. ldap-utils \
  417. libpython3.8-dev \
  418. libpython3.8-minimal \
  419. libpython3.8-stdlib \
  420. libxmlsec1 \
  421. libxmlsec1-openssl \
  422. libpq-dev \
  423. netcat \
  424. nmap \
  425. python-asn1crypto \
  426. python3-crypto \
  427. python3-cryptography \
  428. python3-keyring \
  429. python3-psycopg2 \
  430. python3-setuptools \
  431. python3-wheel \
  432. python3.8-venv \
  433. zlibc \
  434. openssl \
  435. sudo \
  436. tar \
  437. util-linux'
  438. # Ensure pg_config is available
  439. export PG_CONFIG=$(which pg_config)
  440. if [ -z "$PG_CONFIG" ]; then
  441. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  442. exit 1
  443. fi
  444. echo "PG_CONFIG is set to $PG_CONFIG"
  445. # MySQLdb install
  446. # It is pre-installed
  447. # NODEJS 20 install
  448. sudo -- sh -c 'apt-get install -y curl && \
  449. cd /tmp && curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && \
  450. apt-get install -y nodejs'
  451. # sqlite3 install
  452. sudo -- sh -c 'cd /tmp && curl -o sqlite-autoconf-3350500.tar.gz https://sqlite.org/2021/sqlite-autoconf-3350500.tar.gz && \
  453. tar zxvf sqlite-autoconf-3350500.tar.gz && \
  454. cd sqlite-autoconf-3350500 && \
  455. ./configure --prefix=/opt/sqlite3 && make && make install'
  456. # python3.8 re install for sqlite3 3.35.5 or higher version
  457. sudo LD_LIBRARY_PATH=/opt/sqlite3/lib:$ORACLE_INSTANTCLIENT19_PATH:$LD_LIBRARY_PATH \
  458. LD_RUN_PATH=/opt/sqlite3/lib:$ORACLE_INSTANTCLIENT19_PATH:$LD_RUN_PATH \
  459. -- sh -c 'cd /tmp && curl -o Python-3.8.13.tgz https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tgz && \
  460. tar zxvf Python-3.8.13.tgz && \
  461. cd Python-3.8.13 && \
  462. ./configure --enable-shared --prefix=/opt/cloudera/cm-agent && \
  463. make altinstall'
  464. export SQLITE3_PATH=/opt/sqlite3/bin/sqlite3
  465. export PYTHON38_PATH="/opt/cloudera/cm-agent"
  466. export pip_bin="${PYTHON38_PATH}/bin/pip3.8"
  467. VIRTUAL_ENV_VERSION="20.19.0"
  468. # Pip modules install
  469. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  470. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  471. sudo pip_bin=${pip_bin} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  472. # sqlite3 install
  473. sudo -- sh -c 'cd /tmp && curl -o sqlite-autoconf-3350500.tar.gz https://sqlite.org/2021/sqlite-autoconf-3350500.tar.gz && \
  474. tar zxvf sqlite-autoconf-3350500.tar.gz && \
  475. cd sqlite-autoconf-3350500 && \
  476. ./configure --prefix=/opt/sqlite3 && make && make install'
  477. export LD_LIBRARY_PATH=/opt/sqlite3/lib:$LD_LIBRARY_PATH
  478. export SQLITE3_PATH=/opt/sqlite3/bin/sqlite3
  479. fi
  480. }
  481. function ubuntu22_install() {
  482. local PYTHON_VERSION=${1:-"python3.11"} # Default to Python 3.11 if not provided
  483. if [[ $FORCEINSTALL -eq 1 ]]; then
  484. sudo -- sh -c 'apt update'
  485. # Add deadsnakes PPA for Python 3.8
  486. sudo -- sh -c 'add-apt-repository ppa:deadsnakes/ppa -y'
  487. sudo -- sh -c 'apt update'
  488. # pre-req install
  489. sudo -- sh -c 'DEBIAN_FRONTEND=noninteractive apt -qq -y install \
  490. krb5-user \
  491. krb5-kdc \
  492. krb5-config \
  493. libkrb5-dev'
  494. sudo -- sh -c "apt -y install \
  495. ldap-utils \
  496. libxmlsec1 \
  497. libxmlsec1-openssl \
  498. libpq-dev \
  499. netcat \
  500. nmap \
  501. openssl \
  502. sudo \
  503. tar \
  504. util-linux"
  505. # Ensure pg_config is available
  506. export PG_CONFIG=$(which pg_config)
  507. if [ -z "$PG_CONFIG" ]; then
  508. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  509. exit 1
  510. fi
  511. echo "PG_CONFIG is set to $PG_CONFIG"
  512. # MySQLdb install
  513. # It is pre-installed
  514. # NODEJS 20 install
  515. sudo -- sh -c 'apt-get install -y curl && \
  516. cd /tmp && curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && \
  517. apt-get install -y nodejs'
  518. if ! is_supported_python_version "$PYTHON311_PATH/bin/python3.11" $REQ_PYTHON311; then
  519. install_python311 "ubuntu22" "$REQ_PYTHON311"
  520. fi
  521. export pip_bin=${PYTHON311_PATH}/bin/pip3.11
  522. export VIRTUAL_ENV_VERSION="20.30.0"
  523. # Pip modules install
  524. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  525. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  526. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  527. fi
  528. }