mirror of
https://github.com/cytopia/devilbox.git
synced 2025-01-18 18:56:25 +00:00
Fix autostart script for blackfire to only configure client
This commit is contained in:
parent
e09d6a06b8
commit
a4c05d34e9
82
autostart/configure-blackfire-cli.sh-example
Executable file
82
autostart/configure-blackfire-cli.sh-example
Executable file
@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
|
||||
###
|
||||
### Blackfire Client (cli) Variables
|
||||
###
|
||||
# Blackfire Client ID via env: BLACKFIRE_SERVER_ID
|
||||
BF_CLIENT_ID=
|
||||
# Blackfire Client Token via env: BLACKFIRE_SERVER_TOKEN
|
||||
BF_CLIENT_TOKEN=
|
||||
|
||||
|
||||
###
|
||||
### Get Client ID and Client Token
|
||||
###
|
||||
if BF_CLIENT_ID="$( env | grep -Eo '^BLACKFIRE_CLIENT_ID=.*$' )"; then
|
||||
BF_CLIENT_ID="${BF_CLIENT_ID#*=}"
|
||||
fi
|
||||
|
||||
if BF_CLIENT_TOKEN="$( env | grep -Eo '^BLACKFIRE_CLIENT_TOKEN=.*$' )"; then
|
||||
BF_CLIENT_TOKEN="${BF_CLIENT_TOKEN#*=}"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Create Client (cli) Config
|
||||
###
|
||||
{
|
||||
echo "[blackfire]";
|
||||
echo ";";
|
||||
echo "; This is a configuration file for Blackfire.";
|
||||
echo ";";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: ca-cert";
|
||||
echo "; desc : Sets the PEM encoded certificates to use";
|
||||
echo "; default:";
|
||||
echo "ca-cert=";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: client-id";
|
||||
echo "; desc : Sets the Client ID used for API authentication";
|
||||
echo "; default:";
|
||||
echo "client-id=${BF_CLIENT_ID}";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: client-token";
|
||||
echo "; desc : Sets the Client Token used for API authentication";
|
||||
echo "; default:";
|
||||
echo "client-token=${BF_CLIENT_TOKEN}";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: endpoint";
|
||||
echo "; desc : Sets the API endpoint";
|
||||
echo "; default: https://blackfire.io";
|
||||
echo "endpoint=https://blackfire.io";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: http-proxy";
|
||||
echo "; desc : Sets the HTTP proxy to use";
|
||||
echo "; default:";
|
||||
echo "http-proxy=";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: https-proxy";
|
||||
echo "; desc : Sets the HTTPS proxy to use";
|
||||
echo "; default:";
|
||||
echo "https-proxy=";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: timeout";
|
||||
echo "; desc : Sets the Blackfire API connection timeout";
|
||||
echo "; default: 15s";
|
||||
echo "timeout=15s";
|
||||
} > /home/devilbox/.blackfire.ini
|
||||
|
||||
chown devilbox:devilbox /home/devilbox/.blackfire.ini
|
||||
chmod 0600 /home/devilbox/.blackfire.ini
|
@ -1,191 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
|
||||
###
|
||||
### Pre-flight check
|
||||
###
|
||||
if ! command -v blackfire-agent >/dev/null 2>&1; then
|
||||
echo "No blackfire-agent binary available, skipping initialization"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Blackfire Server (Agent) Variables
|
||||
###
|
||||
# Blackfire Server ID via env: BLACKFIRE_SERVER_ID
|
||||
BF_SERVER_ID=
|
||||
# Blackfire Server Token via env: BLACKFIRE_SERVER_TOKEN
|
||||
BF_SERVER_TOKEN=
|
||||
# Blackfire Server Loglevel (4: debug, 3: info, 2: warning, 1: error)
|
||||
BF_SERVER_LOGLEVEL=2
|
||||
|
||||
|
||||
###
|
||||
### Blackfire Client (cli) Variables
|
||||
###
|
||||
# Blackfire Client ID via env: BLACKFIRE_SERVER_ID
|
||||
BF_CLIENT_ID=
|
||||
# Blackfire Client Token via env: BLACKFIRE_SERVER_TOKEN
|
||||
BF_CLIENT_TOKEN=
|
||||
|
||||
|
||||
###
|
||||
### Get Server ID and Server Token
|
||||
###
|
||||
if BF_SERVER_ID="$( env | grep -Eo '^BLACKFIRE_SERVER_ID=.*$' )"; then
|
||||
BF_SERVER_ID="${BF_SERVER_ID#*=}"
|
||||
fi
|
||||
|
||||
if BF_SERVER_TOKEN="$( env | grep -Eo '^BLACKFIRE_SERVER_TOKEN=.*$' )"; then
|
||||
BF_SERVER_TOKEN="${BF_SERVER_TOKEN#*=}"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Get Client ID and Client Token
|
||||
###
|
||||
if BF_CLIENT_ID="$( env | grep -Eo '^BLACKFIRE_CLIENT_ID=.*$' )"; then
|
||||
BF_CLIENT_ID="${BF_CLIENT_ID#*=}"
|
||||
fi
|
||||
|
||||
if BF_CLIENT_TOKEN="$( env | grep -Eo '^BLACKFIRE_CLIENT_TOKEN=.*$' )"; then
|
||||
BF_CLIENT_TOKEN="${BF_CLIENT_TOKEN#*=}"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Create Server (Agent) Config
|
||||
###
|
||||
{
|
||||
echo "[blackfire]";
|
||||
echo ";";
|
||||
echo "; This is a configuration file for Blackfire's Agent.";
|
||||
echo ";";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: ca-cert";
|
||||
echo "; desc : Sets the PEM encoded certificates";
|
||||
echo "; default:";
|
||||
echo "ca-cert=";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: collector";
|
||||
echo "; desc : Sets the URL of Blackfire's data collector";
|
||||
echo "; default: https://blackfire.io";
|
||||
echo "collector=https://blackfire.io";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: http-proxy";
|
||||
echo "; desc : Sets the HTTP proxy to use";
|
||||
echo "; default:";
|
||||
echo "http-proxy=";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: https-proxy";
|
||||
echo "; desc : Sets the HTTPS proxy to use";
|
||||
echo "; default:";
|
||||
echo "https-proxy=";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: log-file";
|
||||
echo "; desc : Sets the path of the log file. Use stderr to log to stderr";
|
||||
echo "; default: stderr";
|
||||
echo "log-file=stderr";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: log-level";
|
||||
echo "; desc : log verbosity level (4: debug, 3: info, 2: warning, 1: error)";
|
||||
echo "; default: 1";
|
||||
echo "log-level=${BF_SERVER_LOGLEVEL}";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: server-id";
|
||||
echo "; desc : Sets the server id used to authenticate with Blackfire API";
|
||||
echo "; default:";
|
||||
echo "server-id=${BF_SERVER_ID}";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: server-token";
|
||||
echo "; desc : Sets the server token used to authenticate with Blackfire API. It is unsafe to set this from the command line";
|
||||
echo "; default:";
|
||||
echo "server-token=${BF_SERVER_TOKEN}";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: socket";
|
||||
echo "; desc : Sets the socket the agent should read traces from. Possible value can be a unix socket or a TCP address. ie: unix:///var/run/blackfire/agent.sock or tcp://127.0.0.1:8307";
|
||||
echo "; default: unix:///var/run/blackfire/agent.sock";
|
||||
echo "socket=unix:///var/run/blackfire/agent.sock";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: spec";
|
||||
echo "; desc : Sets the path to the JSON specifications file";
|
||||
echo "; default:";
|
||||
echo "spec=";
|
||||
} > /etc/blackfire/agent
|
||||
|
||||
|
||||
###
|
||||
### Create Client (cli) Config
|
||||
###
|
||||
{
|
||||
echo "[blackfire]";
|
||||
echo ";";
|
||||
echo "; This is a configuration file for Blackfire.";
|
||||
echo ";";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: ca-cert";
|
||||
echo "; desc : Sets the PEM encoded certificates to use";
|
||||
echo "; default:";
|
||||
echo "ca-cert=";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: client-id";
|
||||
echo "; desc : Sets the Client ID used for API authentication";
|
||||
echo "; default:";
|
||||
echo "client-id=${BF_CLIENT_ID}";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: client-token";
|
||||
echo "; desc : Sets the Client Token used for API authentication";
|
||||
echo "; default:";
|
||||
echo "client-token=${BF_CLIENT_TOKEN}";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: endpoint";
|
||||
echo "; desc : Sets the API endpoint";
|
||||
echo "; default: https://blackfire.io";
|
||||
echo "endpoint=https://blackfire.io";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: http-proxy";
|
||||
echo "; desc : Sets the HTTP proxy to use";
|
||||
echo "; default:";
|
||||
echo "http-proxy=";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: https-proxy";
|
||||
echo "; desc : Sets the HTTPS proxy to use";
|
||||
echo "; default:";
|
||||
echo "https-proxy=";
|
||||
echo "";
|
||||
echo ";";
|
||||
echo "; setting: timeout";
|
||||
echo "; desc : Sets the Blackfire API connection timeout";
|
||||
echo "; default: 15s";
|
||||
echo "timeout=15s";
|
||||
} > /home/devilbox/.blackfire.ini
|
||||
|
||||
chown devilbox:devilbox /home/devilbox/.blackfire.ini
|
||||
chmod 0600 /home/devilbox/.blackfire.ini
|
||||
|
||||
|
||||
###
|
||||
### Start agent
|
||||
###
|
||||
/etc/init.d/blackfire-agent restart || true
|
Loading…
Reference in New Issue
Block a user