This repository has been archived by the owner on Jul 8, 2024. It is now read-only.
forked from CrowdStrike/cloud-tools-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
falcon-node-sensor-build
executable file
·102 lines (86 loc) · 4.08 KB
/
falcon-node-sensor-build
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
#!/bin/bash
: <<'#OutsideUsageExample'
docker run --privileged=true -it --rm \
-e FALCON_CLIENT_ID="$FALCON_CLIENT_ID" \
-e FALCON_CLIENT_SECRET="$FALCON_CLIENT_SECRET" \
-v /var/run/docker.sock:/var/run/docker.sock \
quay.io/crowdstrike/cloud-tools-image \
falcon-node-sensor-build ubuntu20
#OutsideUsageExample
set -e -o pipefail
function die(){
echo "$0: fatal error: $*" >&2
exit 1
}
if [ -z "$FALCON_CLOUD" ]; then
echo "WARNING: FALCON_CLOUD environment variable missing. Assuming FALCON_CLOUD=us-1" >&2
fi
if [ -z "$FALCON_CLIENT_ID" ]; then
die "Missing FALCON_CLIENT_ID environment variable. Please provide your OAuth2 API Client ID for authentication with CrowdStrike Falcon platform. Establishing and retrieving OAuth2 API credentials can be performed at https://falcon.crowdstrike.com/support/api-clients-and-keys."
fi
if [ -z "$FALCON_CLIENT_SECRET" ]; then
die "Missing FALCON_CLIENT_SECRET environment variable. Please provide your OAuth2 API Client Secret for authentication with CrowdStrike Falcon platform. Establishing and retrieving OAuth2 API credentials can be performed at https://falcon.crowdstrike.com/support/api-clients-and-keys."
fi
tempdir=$(mktemp -d)
tempdir_cleanup() { rm -rf "$tempdir"; }; trap tempdir_cleanup EXIT
pushd "$tempdir"
git clone --depth 1 https://github.com/CrowdStrike/Dockerfiles
pushd Dockerfiles
if [ -z "$2" ]; then
sensor_version=latest;
else
sensor_version="$2"
fi
case "$1" in
amazonlinux2)
falcon_sensor_download --os-name='Amazon Linux' --os-version=2 --sensor-version="${sensor_version}"
docker build --no-cache=true \
--build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
--build-arg VCS_REF="$(git rev-parse --short HEAD)" \
--build-arg FALCON_PKG=falcon-sensor-*.x86_64.rpm \
-t falcon-node-sensor:latest \
-f Dockerfile.amazonlinux .
;;
ubuntu18)
sed -i 's/^FROM ubuntu:.*$/FROM ubuntu:18.04/g' Dockerfile.ubuntu
falcon_sensor_download --os-name=Ubuntu --os-version=16/18/20 --sensor-version="${sensor_version}"
docker build --no-cache=true \
--build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
--build-arg VCS_REF="$(git rev-parse --short HEAD)" \
--build-arg FALCON_PKG=falcon-sensor_*_amd64.deb \
-t falcon-node-sensor:latest \
-f Dockerfile.ubuntu .
;;
ubuntu20)
falcon_sensor_download --os-name=Ubuntu --os-version=16/18/20 --sensor-version="${sensor_version}"
docker build --no-cache=true \
--build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
--build-arg VCS_REF="$(git rev-parse --short HEAD)" \
--build-arg FALCON_PKG=falcon-sensor_*_amd64.deb \
-t falcon-node-sensor:latest \
-f Dockerfile.ubuntu .
;;
rhel8)
falcon_sensor_download --os-name=RHEL/CentOS/Oracle --os-version=8 --sensor-version="${sensor_version}"
docker build --no-cache=true \
--build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
--build-arg VCS_REF="$(git rev-parse --short HEAD)" \
--build-arg FALCON_PKG=falcon-sensor-*.x86_64.rpm \
-t falcon-node-sensor:latest \
-f Dockerfile .
;;
sles15)
falcon_sensor_download --os-name=SLES --os-version=15 --sensor-version="${sensor_version}"
docker build --no-cache=true \
--build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
--build-arg VCS_REF="$(git rev-parse --short HEAD)" \
--build-arg FALCON_PKG=falcon-sensor-*.rpm \
-t falcon-node-sensor:latest \
-f Dockerfile.suse .
;;
*)
die "Please provide node operating system as command-line argument. Valid options are: amazonlinux2, ubuntu18, ubuntu20, rhel8, sles15"
;;
esac
docker images falcon-node-sensor
echo "Contaner falcon-node-sensor:latest has been built successfully"