-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for command line arguments
- Loading branch information
1 parent
8ea817d
commit 80e5bbe
Showing
2 changed files
with
35 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,26 @@ | ||
#!/bin/bash | ||
|
||
CONFIG="cs.falconhoseclient.cfg" | ||
|
||
# Some conditional echoes for sanity | ||
if [ -n "$API_BASE_URL" ]; then | ||
echo "[*] Using arguments." | ||
echo "[+] API Base URL: ${API_BASE_URL}" | ||
else | ||
echo "[*] Using .env file." | ||
URL="$(grep API_BASE_URL .env | cut -d'=' -f2)" | ||
echo "[+] API Base URL: ${URL}" | ||
fi | ||
|
||
# Output to the .env file | ||
if [ -n "$CLIENT_ID" ]; then sed -i "s|CLIENT_ID=.*|CLIENT_ID=$CLIENT_ID|" .env; fi | ||
if [ -n "$CLIENT_SECRET" ]; then sed -i "s|CLIENT_SECRET=.*|CLIENT_SECRET=$CLIENT_SECRET|" .env; fi | ||
if [ -n "$API_BASE_URL" ]; then sed -i "s|API_BASE_URL=.*|API_BASE_URL=$API_BASE_URL|" .env; fi | ||
|
||
# Substitute things properly | ||
export $(grep -v '^#' .env | xargs) && envsubst < "./${CONFIG}.template" > "./${CONFIG}" | ||
|
||
# Copy the final config file to the proper location | ||
mv "./${CONFIG}" /opt/crowdstrike/etc | ||
|
||
/opt/crowdstrike/bin/cs.falconhoseclient -nodaemon -config=/opt/crowdstrike/etc/cs.falconhoseclient.cfg 2>&1 |