Browse Source

remove escaped

pull/3051/head
Daniel Gibbs 5 years ago
parent
commit
3b43b7987d
  1. 4
      lgsm/functions/alert.sh
  2. 6
      lgsm/functions/alert_discord.sh
  3. 2
      lgsm/functions/alert_ifttt.sh
  4. 2
      lgsm/functions/alert_pushbullet.sh
  5. 2
      lgsm/functions/alert_pushover.sh
  6. 4
      lgsm/functions/alert_rocketchat.sh
  7. 4
      lgsm/functions/alert_slack.sh
  8. 5
      lgsm/functions/alert_telegram.sh

4
lgsm/functions/alert.sh

@ -79,10 +79,6 @@ info_distro.sh
info_config.sh info_config.sh
info_messages.sh info_messages.sh
# JSON-safe escaping string. - use this is json based alerts
escaped_servername=$(echo -n "${servername}" | jq -sRr "@json")
escaped_alertbody=$(echo -n "${alertbody}" | jq -sRr "@json")
if [ "${alert}" == "permissions" ]; then if [ "${alert}" == "permissions" ]; then
fn_alert_permissions fn_alert_permissions
elif [ "${alert}" == "restart" ]; then elif [ "${alert}" == "restart" ]; then

6
lgsm/functions/alert_discord.sh

@ -22,8 +22,8 @@ json=$(cat <<EOF
"author": { "author": {
"name": "${alertemoji} ${alertsubject} ${alertemoji}", "name": "${alertemoji} ${alertsubject} ${alertemoji}",
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.png"}, "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.png"},
"title": "${escaped_servername}", "title": "${servername}",
"description": ${escaped_alertbody}, "description": "${alertbody}",
"url": "", "url": "",
"type": "content", "type": "content",
"thumbnail": {}, "thumbnail": {},
@ -41,7 +41,7 @@ json=$(cat <<EOF
}, },
{ {
"name": "Server Name", "name": "Server Name",
"value": ${escaped_servername}, "value": "${servername}",
"inline": true "inline": true
} }
] ]

2
lgsm/functions/alert_ifttt.sh

@ -10,7 +10,7 @@ json=$(cat <<EOF
{ {
"value1": "${selfname}", "value1": "${selfname}",
"value2": "${alertemoji} ${alertsubject} ${alertemoji}", "value2": "${alertemoji} ${alertsubject} ${alertemoji}",
"value3": "Message: \n${escaped_alertbody}\n\nGame: \n${gamename}\n\nServer name: \n${escaped_servername}\n\nHostname: \n${HOSTNAME}\n\nServer IP: \n${alertip}:${port}\n\nMore info: \n${alerturl}" "value3": "Message: \n${alertbody}\n\nGame: \n${gamename}\n\nServer name: \n${servername}\n\nHostname: \n${HOSTNAME}\n\nServer IP: \n${alertip}:${port}\n\nMore info: \n${alerturl}"
} }
EOF EOF
) )

2
lgsm/functions/alert_pushbullet.sh

@ -11,7 +11,7 @@ json=$(cat <<EOF
"channel_tag": "${channeltag}", "channel_tag": "${channeltag}",
"type": "note", "type": "note",
"title": "${alertemoji} ${alertsubject} ${alertemoji}", "title": "${alertemoji} ${alertsubject} ${alertemoji}",
"body": "Message\n${escaped_alertbody}\n\nGame\n${gamename}\n\nServer name\n${escaped_servername}\n\nHostname\n${HOSTNAME}\n\nServer IP\n${alertip}:${port}\n\nMore info\n${alerturl}" "body": "Message\n${alertbody}\n\nGame\n${gamename}\n\nServer name\n${servername}\n\nHostname\n${HOSTNAME}\n\nServer IP\n${alertip}:${port}\n\nMore info\n${alerturl}"
} }
EOF EOF
) )

2
lgsm/functions/alert_pushover.sh

@ -21,7 +21,7 @@ else
alertpriority="0" alertpriority="0"
fi fi
pushoversend=$(curl -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alertemoji} ${alertsubject} ${alertemoji}" -F message=" <b>Message</b><br>${escaped_alertbody}<br><br><b>Game</b><br>${escaped_gamename}<br><br><b>Server name</b><br>${servername}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>Server IP</b><br><a href='https://www.gametracker.com/server_info/${alertip}:${port}'>${alertip}:${port}</a><br><br><b>More info</b><br><a href='${alerturl}'>${alerturl}</a>" "https://api.pushover.net/1/messages.json" | grep errors) pushoversend=$(curl -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alertemoji} ${alertsubject} ${alertemoji}" -F message=" <b>Message</b><br>${alertbody}<br><br><b>Game</b><br>${gamename}<br><br><b>Server name</b><br>${servername}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>Server IP</b><br><a href='https://www.gametracker.com/server_info/${alertip}:${port}'>${alertip}:${port}</a><br><br><b>More info</b><br><a href='${alerturl}'>${alerturl}</a>" "https://api.pushover.net/1/messages.json" | grep errors)
if [ "${pushoversend}" ]; then if [ "${pushoversend}" ]; then
fn_print_fail_nl "Sending Pushover alert: ${pushoversend}" fn_print_fail_nl "Sending Pushover alert: ${pushoversend}"

4
lgsm/functions/alert_rocketchat.sh

@ -14,7 +14,7 @@ fi
json=$(cat <<EOF json=$(cat <<EOF
{ {
"alias": "LinuxGSM", "alias": "LinuxGSM",
"text": "*${alertemoji} ${alertsubject} ${alertemoji}* + \n ${escaped_alertbody}", "text": "*${alertemoji} ${alertsubject} ${alertemoji}* + \n ${alertbody}",
"attachments": [ "attachments": [
{ {
"title": "Linuxgsm Alert", "title": "Linuxgsm Alert",
@ -34,7 +34,7 @@ json=$(cat <<EOF
{ {
"short": true, "short": true,
"title": "Server Name:", "title": "Server Name:",
"value": "${escaped_servername}" "value": "${servername}"
} }
] ]
} }

4
lgsm/functions/alert_slack.sh

@ -28,7 +28,7 @@ json=$(cat <<EOF
"type": "section", "type": "section",
"text": { "text": {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*${alertemoji} ${alertsubject} ${alertemoji}* \n ${escaped_alertbody}" "text": "*${alertemoji} ${alertsubject} ${alertemoji}* \n ${alertbody}"
} }
}, },
{ {
@ -47,7 +47,7 @@ json=$(cat <<EOF
}, },
{ {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*Server Name:* \n ${escaped_servername}" "text": "*Server Name:* \n ${servername}"
} }
] ]
}, },

5
lgsm/functions/alert_telegram.sh

@ -6,14 +6,11 @@
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
escaped_servername=$(echo -n "${servername}" | jq -sRr "@json")
escaped_alertbody=$(echo -n "${alertbody}" | jq -sRr "@json")
json=$(cat <<EOF json=$(cat <<EOF
{ {
"chat_id": "${telegramchatid}", "chat_id": "${telegramchatid}",
"parse_mode": "HTML", "parse_mode": "HTML",
"text": "<b>${alertemoji} ${alertsubject} ${alertemoji}</b>\n\n<b>Message</b>\n${escaped_alertbody}\n\n<b>Game</b>\n${gamename}\n\n<b>Server name</b>\n${escaped_servername}\n\n<b>Hostname</b>\n${HOSTNAME}\n\n<b>Server IP</b>\n<a href='https://www.gametracker.com/server_info/${alertip}:${port}'>${alertip}:${port}</a>\n\n<b>More info</b>\n<a href='${alerturl}'>${alerturl}</a>", "text": "<b>${alertemoji} ${alertsubject} ${alertemoji}</b>\n\n<b>Message</b>\n${alertbody}\n\n<b>Game</b>\n${gamename}\n\n<b>Server name</b>\n${servername}\n\n<b>Hostname</b>\n${HOSTNAME}\n\n<b>Server IP</b>\n<a href='https://www.gametracker.com/server_info/${alertip}:${port}'>${alertip}:${port}</a>\n\n<b>More info</b>\n<a href='${alerturl}'>${alerturl}</a>",
"disable_web_page_preview": "yes", "disable_web_page_preview": "yes",
EOF EOF
) )

Loading…
Cancel
Save