mirror of
https://github.com/openappsec/openappsec.git
synced 2025-11-16 01:12:18 +03:00
Fix agent token argument issue
This commit is contained in:
@@ -20,9 +20,9 @@ active_watchdog_pid=
|
|||||||
cleanup() {
|
cleanup() {
|
||||||
local signal="$1"
|
local signal="$1"
|
||||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Signal ${signal} was received, exiting gracefully..." >&2
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Signal ${signal} was received, exiting gracefully..." >&2
|
||||||
if [ -n "${active_watchdog_pid}" ] && ps -p ${active_watchdog_pid} > /dev/null 2>&1; then
|
if [ -n "${active_watchdog_pid}" ] && ps -p "${active_watchdog_pid}" > /dev/null 2>&1; then
|
||||||
kill -TERM ${active_watchdog_pid} 2>/dev/null || true
|
kill -TERM "${active_watchdog_pid}" 2>/dev/null || true
|
||||||
wait ${active_watchdog_pid} 2>/dev/null || true
|
wait "${active_watchdog_pid}" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
echo "Cleanup completed. Exiting now." >&2
|
echo "Cleanup completed. Exiting now." >&2
|
||||||
exit 0
|
exit 0
|
||||||
@@ -31,12 +31,12 @@ cleanup() {
|
|||||||
trap 'cleanup SIGTERM' SIGTERM
|
trap 'cleanup SIGTERM' SIGTERM
|
||||||
trap 'cleanup SIGINT' SIGINT
|
trap 'cleanup SIGINT' SIGINT
|
||||||
|
|
||||||
if [ ! -f /nano-service-installers/$ORCHESTRATION_INSTALLATION_SCRIPT ]; then
|
if [ ! -f "/nano-service-installers/$ORCHESTRATION_INSTALLATION_SCRIPT" ]; then
|
||||||
echo "Error: agent installation package doesn't exist."
|
echo "Error: agent installation package doesn't exist."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $1 ]; then
|
if [ -z "$1" ]; then
|
||||||
var_mode="--hybrid_mode"
|
var_mode="--hybrid_mode"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -60,72 +60,72 @@ while true; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z $var_token ] && [ $var_mode != "--hybrid_mode" ]; then
|
if [ -z "$var_token" ] && [ "$var_mode" != "--hybrid_mode" ]; then
|
||||||
var_token=$(env | grep 'AGENT_TOKEN=' | cut -d'=' -f2-)
|
var_token=$(env | grep 'AGENT_TOKEN=' | cut -d'=' -f2-)
|
||||||
if [ -z $var_token ]; then
|
if [ -z "$var_token" ]; then
|
||||||
echo "Error: Token was not provided as input argument."
|
echo "Error: Token was not provided as input argument."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
orchestration_service_installation_flags="--container_mode --skip_registration"
|
orchestration_service_installation_flags="--container_mode --skip_registration"
|
||||||
if [ ! -z $var_token ]; then
|
if [ -n "$var_token" ]; then
|
||||||
export AGENT_TOKEN="$var_token"
|
export AGENT_TOKEN="$var_token"
|
||||||
orchestration_service_installation_flags="$orchestration_service_installation_flags --token $var_token"
|
orchestration_service_installation_flags="$orchestration_service_installation_flags --token $var_token"
|
||||||
fi
|
fi
|
||||||
if [ ! -z $var_fog_address ]; then
|
if [ -n "$var_fog_address" ]; then
|
||||||
orchestration_service_installation_flags="$orchestration_service_installation_flags --fog $var_fog_address"
|
orchestration_service_installation_flags="$orchestration_service_installation_flags --fog $var_fog_address"
|
||||||
fi
|
fi
|
||||||
if [ ! -z $var_proxy ]; then
|
if [ -n "$var_proxy" ]; then
|
||||||
orchestration_service_installation_flags="$orchestration_service_installation_flags --proxy $var_proxy"
|
orchestration_service_installation_flags="$orchestration_service_installation_flags --proxy $var_proxy"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z $var_mode ]; then
|
if [ -n "$var_mode" ]; then
|
||||||
orchestration_service_installation_flags="$orchestration_service_installation_flags $var_mode"
|
orchestration_service_installation_flags="$orchestration_service_installation_flags $var_mode"
|
||||||
fi
|
fi
|
||||||
if [ ! -z "$var_ignore" ]; then
|
if [ -n "$var_ignore" ]; then
|
||||||
orchestration_service_installation_flags="$orchestration_service_installation_flags $var_ignore"
|
orchestration_service_installation_flags="$orchestration_service_installation_flags $var_ignore"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
/nano-service-installers/$ORCHESTRATION_INSTALLATION_SCRIPT --install $orchestration_service_installation_flags
|
"/nano-service-installers/$ORCHESTRATION_INSTALLATION_SCRIPT" --install $orchestration_service_installation_flags
|
||||||
|
|
||||||
if [ -f /var/run/secrets/kubernetes.io/serviceaccount/token ]; then
|
if [ -f "/var/run/secrets/kubernetes.io/serviceaccount/token" ]; then
|
||||||
/etc/cp/orchestration/k8s-check-update-listener.sh &
|
/etc/cp/orchestration/k8s-check-update-listener.sh &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/nano-service-installers/$ATTACHMENT_REGISTRATION_SERVICE --install
|
"/nano-service-installers/$ATTACHMENT_REGISTRATION_SERVICE" --install
|
||||||
/nano-service-installers/$CACHE_INSTALLATION_SCRIPT --install
|
"/nano-service-installers/$CACHE_INSTALLATION_SCRIPT" --install
|
||||||
/nano-service-installers/$HTTP_TRANSACTION_HANDLER_SERVICE --install
|
"/nano-service-installers/$HTTP_TRANSACTION_HANDLER_SERVICE" --install
|
||||||
|
|
||||||
if [ "$PROMETHEUS" == "true" ]; then
|
if [ "$PROMETHEUS" == "true" ]; then
|
||||||
/nano-service-installers/$PROMETHEUS_INSTALLATION_SCRIPT --install
|
"/nano-service-installers/$PROMETHEUS_INSTALLATION_SCRIPT" --install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$CENTRAL_NGINX_MANAGER" == "true" ]; then
|
if [ "$CENTRAL_NGINX_MANAGER" == "true" ]; then
|
||||||
/nano-service-installers/$NGINX_CENTRAL_MANAGER_INSTALLATION_SCRIPT --install
|
"/nano-service-installers/$NGINX_CENTRAL_MANAGER_INSTALLATION_SCRIPT" --install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$CROWDSEC_ENABLED" == "true" ]; then
|
if [ "$CROWDSEC_ENABLED" == "true" ]; then
|
||||||
/nano-service-installers/$INTELLIGENCE_INSTALLATION_SCRIPT --install
|
"/nano-service-installers/$INTELLIGENCE_INSTALLATION_SCRIPT" --install
|
||||||
/nano-service-installers/$CROWDSEC_INSTALLATION_SCRIPT --install
|
"/nano-service-installers/$CROWDSEC_INSTALLATION_SCRIPT" --install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# use advanced model if exist as data for agent
|
# use advanced model if exist as data for agent
|
||||||
FILE=/advanced-model/open-appsec-advanced-model.tgz
|
FILE="/advanced-model/open-appsec-advanced-model.tgz"
|
||||||
if [ -f "$FILE" ]; then
|
if [ -f "$FILE" ]; then
|
||||||
tar -xzvf $FILE -C /etc/cp/conf/waap
|
tar -xzvf "$FILE" -C /etc/cp/conf/waap
|
||||||
fi
|
fi
|
||||||
|
|
||||||
touch /etc/cp/watchdog/wd.startup
|
touch /etc/cp/watchdog/wd.startup
|
||||||
/etc/cp/watchdog/cp-nano-watchdog >/dev/null 2>&1 &
|
/etc/cp/watchdog/cp-nano-watchdog >/dev/null 2>&1 &
|
||||||
active_watchdog_pid=$!
|
active_watchdog_pid=$!
|
||||||
while true; do
|
while true; do
|
||||||
if [ -f /tmp/restart_watchdog ]; then
|
if [ -f "/tmp/restart_watchdog" ]; then
|
||||||
rm -f /tmp/restart_watchdog
|
rm -f /tmp/restart_watchdog
|
||||||
kill -9 ${active_watchdog_pid}
|
kill -9 "${active_watchdog_pid}"
|
||||||
fi
|
fi
|
||||||
if [ ! "$(ps -f | grep cp-nano-watchdog | grep ${active_watchdog_pid})" ]; then
|
if [ ! "$(ps -f | grep cp-nano-watchdog | grep "${active_watchdog_pid}")" ]; then
|
||||||
/etc/cp/watchdog/cp-nano-watchdog >/dev/null 2>&1 &
|
/etc/cp/watchdog/cp-nano-watchdog >/dev/null 2>&1 &
|
||||||
active_watchdog_pid=$!
|
active_watchdog_pid=$!
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user