Skip to content

Instantly share code, notes, and snippets.

@icelander
Created November 3, 2021 21:01
Show Gist options
  • Save icelander/045b5033f3603f65393998c5521eb5fe to your computer and use it in GitHub Desktop.
Save icelander/045b5033f3603f65393998c5521eb5fe to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Update & Upgrade
apt-get update
apt-get upgrade -y
## Install Golang
golang_file='go1.17.2.linux-amd64.tar.gz'
golang_url="https://golang.org/dl/$golang_file"
checksum="f242a9db6a0ad1846de7b6d94d507915d14062660616a61ef7c808a76e4f1676 $golang_file"
cd /tmp
wget $golang_url
check=`sha256sum $golang_file`
if [[ $check != $checksum ]]; then
echo "Invalid checksum:"
echo $check
exit 1
fi
tar -C /usr/local -xvzf $golang_file
# Add to the PATH
echo 'export PATH=$PATH:/usr/local/go/bin' > /etc/profile.d/go.sh
# Install Load Test in /opt/mattermost-load-test-ng
if [[ ! -d /opt/mattermost-load-test-ng ]]; then
if [[ ! -d /opt ]]; then
mkdir -p /opt
fi
cd /opt
git clone https://github.com/mattermost/mattermost-load-test-ng
fi
useradd --system --user-group -m -d /opt/mmstagent mmstagent
chown -R mmstagent:mmstagent /opt/mattermost-load-test-ng
# Create the ltapi service
cat << EOF > /etc/systemd/system/mmst-ltagent.service
[Unit]
Description=Mattermost Load Test
Wants=network.target
After=network.target
[Service]
Type=notify
ExecStart=/usr/local/go/bin/go run ./cmd/ltapi &
TimeoutStartSec=3600
KillMode=mixed
Restart=always
RestartSec=10
WorkingDirectory=/opt/mattermost-load-test-ng
User=mmstagent
Group=mmstagent
LimitNOFILE=49152
[Install]
WantedBy=multi-user.target
EOF
# Start the service
systemctl daemon-reload
service mmst-ltagent start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment