1
1
#! /bin/bash
2
- # Copyright 2018 Splunk
2
+ # Copyright 2018-2021 Splunk
3
3
#
4
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
5
# you may not use this file except in compliance with the License.
14
14
# limitations under the License.
15
15
16
16
set -e
17
- apt-get update
18
- apt-get install -y locales wget gnupg apt-utils
17
+
18
+ # Generate UTF-8 char map and locale
19
+ apt-get update -y
20
+ apt-get install -y --no-install-recommends locales wget gnupg apt-utils
19
21
echo " en_US.UTF-8 UTF-8" > /etc/locale.gen
20
22
rm -f /usr/share/locale/locale.alias
21
23
ln -s /etc/locale.alias /usr/share/locale/locale.alias
@@ -27,37 +29,59 @@ export LANG=en_US.utf8
27
29
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
28
30
/usr/sbin/dpkg-reconfigure -f noninteractive tzdata
29
31
30
- # Install additional dependencies
31
- echo " deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" >> /etc/apt/sources.list
32
- apt-key adv --keyserver https://keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
33
- apt-get update
32
+ # Install utility packages
33
+ apt-get install -y --no-install-recommends curl sudo libgssapi-krb5-2 busybox procps acl gcc make \
34
+ libffi-dev libssl-dev make build-essential libbz2-dev \
35
+ wget xz-utils ca-certificates zlib1g-dev
36
+
37
+ # Install Python and necessary packages
38
+ PY_SHORT=${PYTHON_VERSION% .* }
39
+ wget -O /tmp/python.tgz https://www.python.org/ftp/python/${PYTHON_VERSION} /Python-${PYTHON_VERSION} .tgz
40
+ mkdir -p /tmp/pyinstall
41
+ tar -xzC /tmp/pyinstall/ --strip-components=1 -f /tmp/python.tgz
42
+ rm /tmp/python.tgz
43
+ cd /tmp/pyinstall
44
+ ./configure --enable-optimizations --prefix=/usr --with-ensurepip=install
45
+ make altinstall LDFLAGS=" -Wl,--strip-all"
46
+ rm -rf /tmp/pyinstall
47
+ ln -sf /usr/bin/python${PY_SHORT} /usr/bin/python
48
+ ln -sf /usr/bin/pip${PY_SHORT} /usr/bin/pip
49
+ # For ansible apt module
50
+ cd /tmp
51
+ apt-get download python3-apt=1.4.2
52
+ dpkg -x python3-apt_1.4.2_amd64.deb python3-apt
53
+ rm python3-apt_1.4.2_amd64.deb
54
+ cp -r /tmp/python3-apt/usr/lib/python3/dist-packages/* /usr/lib/python${PY_SHORT} /site-packages/
55
+ cd /usr/lib/python${PY_SHORT} /site-packages/
56
+ cp apt_pkg.cpython-35m-x86_64-linux-gnu.so apt_pkg.so
57
+ cp apt_inst.cpython-35m-x86_64-linux-gnu.so apt_inst.so
58
+ rm -rf /tmp/python3-apt
59
+ # Install splunk-ansible dependencies
60
+ cd /
61
+ pip -q --no-cache-dir install wheel requests ansible jmespath --upgrade
62
+ # Remove tests packaged in python libs
63
+ find /usr/lib/ -depth \( -type d -a -not -wholename ' */ansible/plugins/test' -a \( -name test -o -name tests -o -name idle_test \) \) -exec rm -rf ' {}' \;
64
+ find /usr/lib/ -depth \( -type f -a -name ' *.pyc' -o -name ' *.pyo' -o -name ' *.a' \) -exec rm -rf ' {}' \;
65
+ find /usr/lib/ -depth \( -type f -a -name ' wininst-*.exe' \) -exec rm -rf ' {}' \;
66
+ ldconfig
34
67
35
- # put back tools for customer support
36
- apt-cache show ansible
37
- apt-get install -y --no-install-recommends ansible curl sudo libgssapi-krb5-2 busybox procps acl
38
- apt-get install -y --no-install-recommends python-requests python-jmespath
68
+ apt-get remove -y --allow-remove-essential gcc libffi-dev libssl-dev make build-essential libbz2-dev xz-utils zlib1g-dev
69
+ apt-get autoremove -y --allow-remove-essential
39
70
40
71
# Install scloud
41
72
wget -O /usr/bin/scloud.tar.gz ${SCLOUD_URL}
42
73
tar -xf /usr/bin/scloud.tar.gz -C /usr/bin/
43
74
rm /usr/bin/scloud.tar.gz
44
75
76
+ # Enable busybox symlinks
45
77
cd /bin
46
- ln -s busybox clear
47
- ln -s busybox find
48
- ln -s busybox diff
49
- ln -s busybox killall
50
- ln -s busybox netstat
51
- ln -s busybox nslookup
52
- ln -s busybox ping
53
- ln -s busybox ping6
54
- ln -s busybox readline
55
- ln -s busybox route
56
- ln -s busybox syslogd
57
- ln -s busybox tail
58
- ln -s busybox traceroute
59
- ln -s busybox vi
78
+ BBOX_LINKS=( clear find diff hostname killall netstat nslookup ping ping6 readline route syslogd tail traceroute vi )
79
+ for item in " ${BBOX_LINKS[@]} "
80
+ do
81
+ ln -s busybox $item || true
82
+ done
60
83
chmod u+s /bin/ping
61
84
62
- apt-get clean autoclean
85
+ # Clean
86
+ apt clean autoclean
63
87
rm -rf /var/lib/apt/lists/*
0 commit comments