90 lines
3.9 KiB
Bash
90 lines
3.9 KiB
Bash
echo 'Acquire::http::Proxy "http://repo.manturovo-it.ru:3142";' | tee /etc/apt/apt.conf.d/000aptproxy > /dev/null
|
|
sudo apt update && sudo apt upgrade -y
|
|
sudo apt install -y postgresql postgresql-contrib curl gpg jq
|
|
|
|
sudo -u postgres psql <<EOF
|
|
CREATE DATABASE mattermost;
|
|
CREATE USER mmuser WITH PASSWORD 'Q123456q';
|
|
GRANT ALL PRIVILEGES ON DATABASE mattermost TO mmuser;
|
|
\q
|
|
EOF
|
|
|
|
sudo -u postgres psql -d mattermost <<EOF
|
|
GRANT ALL ON SCHEMA public TO mmuser;
|
|
EOF
|
|
|
|
|
|
curl -o- https://deb.packages.mattermost.com/repo-setup.sh | sudo bash -s mattermost
|
|
sudo apt update
|
|
sudo apt install -y mattermost
|
|
|
|
|
|
#cd /tmp
|
|
#MATTERMOST_VERSION=$(/opt/mattermost/bin/mattermost version 2>/dev/null | grep -oP 'Version: \K[\d\.]+')
|
|
#MOSTLY_DOWNLOAD_URL=https://packages.framasoft.org/projects/mostlymatter/mostlymatter-amd64-v${MATTERMOST_VERSION}
|
|
#MOSTLY_DOWNLOAD_URL=http://85.113.221.90:8000/mostlymatter-amd64-v11.3.0
|
|
#curl -L -o mostlymatter $MOSTLY_DOWNLOAD_URL && chmod +x mostlymatter && mv mostlymatter /opt/mattermost/bin/
|
|
#sudo sed -i '/^ExecStart=/s|/opt/mattermost/bin/mattermost|/opt/mattermost/bin/mostlymatter|' /lib/systemd/system/mattermost.service
|
|
|
|
|
|
sudo cp /opt/mattermost/config/config.defaults.json /opt/mattermost/config/config.json
|
|
cd /opt/mattermost/config/
|
|
jq '
|
|
if has("ServiceSettings") then .ServiceSettings.SiteURL = "http://mm.manturovo-it.ru" else . end |
|
|
if has("LocalizationSettings") then .LocalizationSettings.DefaultServerLocale = "ru" else . end |
|
|
if has("LocalizationSettings") then .LocalizationSettings.DefaultClientLocale = "ru" else . end |
|
|
if has("SqlSettings") then .SqlSettings.DataSource = "postgres://mmuser:Q123456q@localhost:5432/mattermost?sslmode=disable&connect_timeout=10&binary_parameters=yes" else . end
|
|
' config.json > config.tmp && mv config.tmp config.json
|
|
sudo chown mattermost:mattermost /opt/mattermost/config/config.json
|
|
sudo chmod 640 /opt/mattermost/config/config.json
|
|
cd ~
|
|
|
|
#sudo systemctl daemon-reload
|
|
# -----------------------------
|
|
#patch mattermost
|
|
BINARY_FILE="/opt/mattermost/bin/mattermost"
|
|
PATTERN="48 89 C1 48 8B 84 24 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 85 C0 74 53"
|
|
REPLACEMENT="75"
|
|
OFFSET=19
|
|
SEARCH_PATTERN=$(echo "$PATTERN" | tr -d ' ' | tr '?' '.' | tr 'A-Z' 'a-z')
|
|
echo "Dumping hexcode of original binary"
|
|
hexdump -ve '1/1 "%.2x"' "$BINARY_FILE" > temp_hex_dump
|
|
echo "Searching for rsa.VerifyPKCS1v15 call inside LicenseValidatorImpl.ValidateLicense()"
|
|
FOUND_OFFSET=$(grep -Eo -b "$SEARCH_PATTERN" temp_hex_dump | awk -F: '{print $1}' | head -n 1)
|
|
if [ -z "$FOUND_OFFSET" ]; then
|
|
echo "Call not found!"
|
|
rm temp_hex_dump
|
|
exit 1
|
|
fi
|
|
BYTE_OFFSET=$((FOUND_OFFSET / 2 + OFFSET))
|
|
BYTE_OFFSET_HEX=$(printf "%x" "$BYTE_OFFSET")
|
|
if [ "$BYTE_OFFSET" -lt 0 ]; then
|
|
echo "Error: Calculated offset is before the start of the file!"
|
|
rm temp_hex_dump
|
|
exit 1
|
|
fi
|
|
echo "Call found, patching jz at offset 0x$BYTE_OFFSET_HEX with jnz"
|
|
printf "$REPLACEMENT" | xxd -r -p | dd of="$BINARY_FILE" bs=1 seek="$BYTE_OFFSET" conv=notrunc > /dev/null 2>&1
|
|
rm temp_hex_dump
|
|
echo "Licensing code patched!"
|
|
# -----------------------------
|
|
|
|
# -----------------------------
|
|
#install elasticsearch
|
|
# *install docker
|
|
sudo apt update
|
|
sudo apt dist-upgrade -y
|
|
sudo apt install -y apt-transport-https ca-certificates curl gnupg lsb-release
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
|
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] http://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
sudo apt update
|
|
sudo apt install -y docker-ce docker-ce-cli containerd.io
|
|
# *
|
|
docker network create elastic
|
|
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.17.0
|
|
docker run -d --name es01 --net elastic -p 9200:9200 -it -m 2GB -e "discovery.type=single-node" -e "action.destructive_requires_name=false" docker.elastic.co/elasticsearch/elasticsearch:7.17.0
|
|
# -----------------------------
|
|
|
|
sudo systemctl start mattermost
|
|
|