Skip to content

Instantly share code, notes, and snippets.

View icelander's full-sized avatar

Paul Rothrock icelander

View GitHub Profile
@icelander
icelander / webhook-update-status.json
Created September 2, 2021 14:02
This is what is posted to the webhook URL when a Mattermost Playbook Run has its status updated
{
"id": "q67iw187djnoimfcz4t9xk3ibe",
"name": "Run Name",
"description": "Status update description",
"owner_user_id": "9pjzm4kit7gp7mwadmcs697dyo",
"reporter_user_id": "9pjzm4kit7gp7mwadmcs697dyo",
"team_id": "7wx1ybtjebgyfp7b77r1x3pp7c",
"channel_id": "fhma9oci8jgqiy5em1s4k6gypy",
"create_at": 1630591134576,
"end_at": 0,
@icelander
icelander / webhook_run_start.json
Last active August 16, 2022 15:05
This is what is posted to the webhook URL when a Mattermost Playbook is started
{
"id": "q67iw187djnoimfcz4t9xk3ibe",
"name": "Run Name",
"description": "",
"owner_user_id": "9pjzm4kit7gp7mwadmcs697dyo",
"reporter_user_id": "9pjzm4kit7gp7mwadmcs697dyo",
"team_id": "7wx1ybtjebgyfp7b77r1x3pp7c",
"channel_id": "fhma9oci8jgqiy5em1s4k6gypy",
"create_at": 1630591134576,
"end_at": 0,
@icelander
icelander / system-stats.sql
Created August 25, 2021 18:40
The queries Mattermost 5.37.0 uses to genreate the System Statistics page in the System Console
-- Total Active Users (non-bots)
SELECT COUNT(DISTINCT u.Id)
FROM Users AS u
LEFT JOIN Bots ON u.Id = Bots.UserId
WHERE u.DeleteAt = 0
AND Bots.UserId IS NULL;
-- Total Teams
SELECT COUNT(*) FROM Teams
WHERE DeleteAt = 0;
@icelander
icelander / mmctl-export-downloader.sh
Created August 13, 2021 00:14
Automates the process of resuming mmctl export downloads
#!/bin/bash
# mmctl-export-downloader.sh
## ABOUT
#
# This script automates the process of downloading a very large Mattermost bulk
# exports using mmctl.
#
## USAGE
@icelander
icelander / manual_ldap_search.sh
Created May 12, 2021 19:36
Queries an LDAP server like Mattermost. Be sure to set the configuration values to match your Mattermost config
#!/bin/bash
LdapServer="LdapServer"
LdapPort="LdapPort"
BindUsername="BindUsername"
BindPassword="BindPassword"
BaseDN="BaseDN"
UserFilter="UserFilter"
GroupFilter="GroupFilter"
@icelander
icelander / improved-ldap-check.sh
Created May 11, 2021 22:08
And improved script to check Mattermost LDAP config
#!/bin/bash
jq_cmd=jq
[[ $(type -P "$jq_cmd") ]] || {
echo "'$jq_cmd' command line JSON processor not found";
echo "Please install on linux with 'sudo apt-get install jq'"
echo "Please install on mac with 'brew install jq'"
exit 1;
}
@icelander
icelander / mm_fix_compliance_reports.rb
Last active January 14, 2021 04:30
Replaces the random channel name with usernames in Mattermost compliance reports
#!/usr/bin/env ruby
# frozen_string_literal: true
## mm_fix_compliance_reports.rb
#
## ABOUT
#
# This script takes a Mattermost Compliance Monitoring export CSV and replaces
# the direct message channel names with the corresponding usernames. For
# example:
@icelander
icelander / migrate_custom_emoji.rb
Last active May 27, 2022 22:04
Migrates custom emoji from one Mattermost server to another
#!/usr/bin/env ruby
# frozen_string_literal: true
## migrate_custom_emoji.rb
#
## ABOUT
#
# This script migrates custom emoji from one Mattermost instance to another.
# While it can be run on the source, any machine that can access both
# servers via HTTP that has a copy of the `/opt/mattermost/data/emoji`
@icelander
icelander / get_info.sh
Created November 6, 2020 21:47
Gets diagnostic information for Mattermost application servers
#!/bin/bash
timestamp_string=`date -Iseconds`
parent_dir=`pwd`
dirname="$HOSTNAME-$timestamp_string"
dirpath="$parent_dir/$dirname"
tarname="$dirname.tgz"
tarpath="$parent_dir/$tarname"
if [[ $1 == "--help" || $1 == "-h" ]]; then
@icelander
icelander / make_ldap_users.rb
Last active November 4, 2020 15:02
Imports Mattermost users into an LDAP server from a bulk export file
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'net-ldap'
###
## make_ldap_users.rb
#
# This script automates the process of importing users from a Mattermost bulk