From 430321acbb0b79f38270e7f28d016948ac352ffd Mon Sep 17 00:00:00 2001 From: Ales Trunda Date: Wed, 16 Jun 2021 17:16:21 +0200 Subject: [PATCH 1/5] fix parsing token --- Linux Script/configure-linux.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Linux Script/configure-linux.sh b/Linux Script/configure-linux.sh index 89018cf..3c01cf1 100644 --- a/Linux Script/configure-linux.sh +++ b/Linux Script/configure-linux.sh @@ -384,10 +384,7 @@ getAuthToken() { if [ "$LOGGLY_AUTH_TOKEN" = "" ]; then logMsgToConfigSysLog "INFO" "INFO: Authentication token not provided. Trying to retrieve it from $LOGGLY_ACCOUNT_URL account." #get authentication token if user has not provided one - tokenstr=$(curl -s -u $LOGGLY_USERNAME:$LOGGLY_PASSWORD $LOGGLY_ACCOUNT_URL/apiv2/customer | grep -v "token") - - #get the string from index 0 to first occurence of , - tokenstr=${tokenstr%%,*} + tokenstr=$(curl -s -u $LOGGLY_USERNAME:$LOGGLY_PASSWORD $LOGGLY_ACCOUNT_URL/apiv2/customer | grep -A1 "token" | grep -v "token") #get the string from index 0 to last occurence of " tokenstr=${tokenstr%\"*} From 6ee7467f43e4fb3356f1356407e7314ffd047e44 Mon Sep 17 00:00:00 2001 From: Ales Trunda Date: Thu, 17 Jun 2021 09:11:18 +0200 Subject: [PATCH 2/5] update readme --- Linux Script/README.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Linux Script/README.md b/Linux Script/README.md index 62f8faa..ac19b71 100644 --- a/Linux Script/README.md +++ b/Linux Script/README.md @@ -1,11 +1,19 @@ -Linux Script -============ +# Linux Script + +## Configure Configure your Linux system to send syslogs to Loggly using the following command - sudo bash configure-linux.sh -a SUBDOMAIN -u USERNAME - +```bash +sudo bash configure-linux.sh -a SUBDOMAIN -u USERNAME +``` + +You can also pass your *customer token* as `-t TOKEN`. If it's omitted, the token will be loaded automatically. + +## Stop Stop sending your Linux System logs to Loggly - sudo bash configure-linux.sh -a SUBDOMAIN -r +```bash +sudo bash configure-linux.sh -a SUBDOMAIN -r +``` From a2778059d56b8c419a4c8082bec30e43d01368a6 Mon Sep 17 00:00:00 2001 From: Ales Trunda Date: Thu, 17 Jun 2021 11:40:05 +0200 Subject: [PATCH 3/5] ehnance token parsing --- Linux Script/configure-linux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Linux Script/configure-linux.sh b/Linux Script/configure-linux.sh index 3c01cf1..3acfe63 100644 --- a/Linux Script/configure-linux.sh +++ b/Linux Script/configure-linux.sh @@ -384,7 +384,7 @@ getAuthToken() { if [ "$LOGGLY_AUTH_TOKEN" = "" ]; then logMsgToConfigSysLog "INFO" "INFO: Authentication token not provided. Trying to retrieve it from $LOGGLY_ACCOUNT_URL account." #get authentication token if user has not provided one - tokenstr=$(curl -s -u $LOGGLY_USERNAME:$LOGGLY_PASSWORD $LOGGLY_ACCOUNT_URL/apiv2/customer | grep -A1 "token" | grep -v "token") + tokenstr=$(curl -s -u $LOGGLY_USERNAME:$LOGGLY_PASSWORD $LOGGLY_ACCOUNT_URL/apiv2/customer | grep -A1 "\"tokens\"" | grep -v "tokens") #get the string from index 0 to last occurence of " tokenstr=${tokenstr%\"*} From 16ed60415fed5b5dee89a4bc74ec450ca1c93b03 Mon Sep 17 00:00:00 2001 From: Ales Trunda Date: Thu, 17 Jun 2021 11:49:28 +0200 Subject: [PATCH 4/5] enhance token parsing --- Linux Script/configure-linux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Linux Script/configure-linux.sh b/Linux Script/configure-linux.sh index 3acfe63..176e7e2 100644 --- a/Linux Script/configure-linux.sh +++ b/Linux Script/configure-linux.sh @@ -384,7 +384,7 @@ getAuthToken() { if [ "$LOGGLY_AUTH_TOKEN" = "" ]; then logMsgToConfigSysLog "INFO" "INFO: Authentication token not provided. Trying to retrieve it from $LOGGLY_ACCOUNT_URL account." #get authentication token if user has not provided one - tokenstr=$(curl -s -u $LOGGLY_USERNAME:$LOGGLY_PASSWORD $LOGGLY_ACCOUNT_URL/apiv2/customer | grep -A1 "\"tokens\"" | grep -v "tokens") + tokenstr=$(curl -s -u $LOGGLY_USERNAME:$LOGGLY_PASSWORD $LOGGLY_ACCOUNT_URL/apiv2/customer | grep -A1 "\"tokens\":" | grep -v "tokens") #get the string from index 0 to last occurence of " tokenstr=${tokenstr%\"*} From 77f763044136b7784af5b68d9f814dcd231501ce Mon Sep 17 00:00:00 2001 From: Vojta Kuban Date: Fri, 18 Jun 2021 12:47:21 +0200 Subject: [PATCH 5/5] Fix typos in messages. --- Linux Script/configure-linux.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Linux Script/configure-linux.sh b/Linux Script/configure-linux.sh index 176e7e2..2928482 100644 --- a/Linux Script/configure-linux.sh +++ b/Linux Script/configure-linux.sh @@ -495,7 +495,7 @@ checkAuthTokenAndWriteContents() { writeContents $LOGGLY_ACCOUNT $LOGGLY_AUTH_TOKEN $LOGGLY_DISTRIBUTION_ID $LOGS_01_HOST $LOGGLY_SYSLOG_PORT restartRsyslog else - logMsgToConfigSysLog "ERROR" "ERROR: Loggly auth token is required to configure rsyslog. Please pass -a while running script." + logMsgToConfigSysLog "ERROR" "ERROR: Loggly auth token is required to configure rsyslog. Please pass -t while running script." exit 1 fi } @@ -509,7 +509,7 @@ setPathToCABundle () { CA_FILE_PATH="/etc/ssl/certs/ca-bundle.crt" ;; *) - logMsgToConfigSysLog "WARN" "WARN: The linux distribution '$LINUX_DIST' has not been previously tested with Loggly. Verify path to the file with root CA certificates (usually stored in OS trust store) in '$RSYSLOG_ETCDIR_CONF' -> '\$DefaultNetstreamDriverCAFile' and restart rsyslog service or re-run script with '--inssecure' attribute. Default path to CA file is '$CA_FILE_PATH'." + logMsgToConfigSysLog "WARN" "WARN: The linux distribution '$LINUX_DIST' has not been previously tested with Loggly. Verify path to the file with root CA certificates (usually stored in OS trust store) in '$RSYSLOG_ETCDIR_CONF' -> '\$DefaultNetstreamDriverCAFile' and restart rsyslog service or re-run script with '--insecure' attribute. Default path to CA file is '$CA_FILE_PATH'." ;; esac }