Skip to content

Instantly share code, notes, and snippets.

@icelander
Created August 23, 2019 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icelander/b0f227c6ff7c6a3f3e4f8ac4bda13c42 to your computer and use it in GitHub Desktop.
Save icelander/b0f227c6ff7c6a3f3e4f8ac4bda13c42 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Mattermost File Processor Script
#
# This script allows you to run a Mattermost command against a list of IDs stored in a text file
# How to use it
#
# 1. Get a list of the identifiers for the items you want to process in a text file. More details on the
# 2. Get the mattermost command you want to run from https://docs.mattermost.com/administration/command-line-tools.html
# 3. Run the script like this to process every line in the file:
# $ mattermost_process_file.sh "<Mattermost command>" <path to identifiers file
# Examples
# Remove many users from a specific channel
# - users.txt contains a list of email addresses, usernames, or user IDs
# - Mattermost command is "channel remove teamname:channelname"
#
# $ mattermost_process_file.sh "channel remove teamname:channelname" users.txt
#
# Notes
# If your Mattermost binary is not located at /opt/mattermost/bin/mattermost change the value on line 32
mattermost_cmd=$1
$ids_file=$2
while read id; do
/opt/mattermost/bin/mattermost $mattermost_cmd $id;
done <$ids_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment