From 7f2481ea121f2fd93a482ef39dce22779d4ad5b1 Mon Sep 17 00:00:00 2001 From: Kaedon Cleland-Host <24703977+Dracentis@users.noreply.github.com> Date: Thu, 30 Jan 2025 05:34:27 -0500 Subject: [PATCH] New Script: Mattermost (#1856) * Create mattermost.sh, mattermost-install.sh, and mattermost.json * Change paths in build.func install.func and mattermost.sh This commit is for testing purposes and will be reverted before creating the pull request. * Fixed OS in mattermost.sh and mattermost.json * Change paths in all files Points all files to my fork for testing. * Added tags and fixed missing variable definition * Fixed mattermost-install.sh * Fixed sed command in mattermost-install.sh * Fixed sed command in mattermost-install.sh * Fixed broken config in mattermost-install.sh * Revert "Change paths in all files" This reverts commit 2f93e39233a8dc27c5f4f77d5b84eba9fea34b61. * Revert "Change paths in build.func install.func and mattermost.sh" This reverts commit 084c71fbdc4ae6abed09f6858b852967286bb092. * Fixed date in mattermost.json * Update install/mattermost-install.sh Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com> * Update mattermost.json --------- Co-authored-by: CanbiZ <47820557+MickLesk@users.noreply.github.com> Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com> --- ct/mattermost.sh | 49 ++++++++++++++++++++++++++++ install/mattermost-install.sh | 60 +++++++++++++++++++++++++++++++++++ json/mattermost.json | 34 ++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 ct/mattermost.sh create mode 100644 install/mattermost-install.sh create mode 100644 json/mattermost.json diff --git a/ct/mattermost.sh b/ct/mattermost.sh new file mode 100644 index 00000000..9b9a32c2 --- /dev/null +++ b/ct/mattermost.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: Kaedon Cleland-Host (dracentis) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://mattermost.com/ + +# App Default Values +APP="Mattermost" +var_tags="collaboration" +var_cpu="1" +var_ram="2048" +var_disk="8" +var_os="ubuntu" +var_version="24.04" +var_unprivileged="1" + +# App Output & Base Settings +header_info "$APP" +base_settings + +# Core +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + if [[ ! -f /etc/apt/sources.list.d/mattermost.list ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + msg_info "Updating ${APP} LXC" + apt-get update &>/dev/null + apt-get -y upgrade &>/dev/null + msg_ok "Updated Successfully" + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8065${CL}" diff --git a/install/mattermost-install.sh b/install/mattermost-install.sh new file mode 100644 index 00000000..b1a5a374 --- /dev/null +++ b/install/mattermost-install.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: Kaedon Cleland-Host (dracentis) +# License: MIT +# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y \ + curl \ + sudo \ + mc \ + gpg \ + postgresql +msg_ok "Installed Dependencies" + +msg_info "Setting up PostgreSQL" +DB_NAME=mattermost +DB_USER=mmuser +DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) +$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME;" +$STD sudo -u postgres psql -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS';" +$STD sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME to $DB_USER;" +$STD sudo -u postgres psql -c "ALTER DATABASE $DB_NAME OWNER TO $DB_USER;" +$STD sudo -u postgres psql -c "GRANT USAGE, CREATE ON SCHEMA PUBLIC TO $DB_USER;" +{ + echo "Mattermost Credentials" + echo "Database User: $DB_USER" + echo "Database Password: $DB_PASS" + echo "Database Name: $DB_NAME" +} >> ~/mattermost.creds +msg_ok "Set up PostgreSQL" + +msg_info "Installing Mattermost" +IPADDRESS=$(hostname -I | awk '{print $1}') +curl -sL -o- /usr/share/keyrings/mattermost-archive-keyring.gpg https://deb.packages.mattermost.com/pubkey.gpg +sh -c 'curl -o- https://deb.packages.mattermost.com/repo-setup.sh | sudo bash -s mattermost' +$STD apt-get update +$STD apt-get install -y mattermost +$STD install -C -m 600 -o mattermost -g mattermost /opt/mattermost/config/config.defaults.json /opt/mattermost/config/config.json +sed -i -e "/DataSource/c\ \"DataSource\": \"postgres://$DB_USER:$DB_PASS@localhost:5432/$DB_NAME?sslmode=disable&connect_timeout=10\"," \ + -e "/SiteURL/c\ \"SiteURL\": \"http://$IPADDRESS:8065\"," /opt/mattermost/config/config.json +systemctl enable -q --now mattermost.service +msg_ok "Installed Mattermost" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/json/mattermost.json b/json/mattermost.json new file mode 100644 index 00000000..b4b27945 --- /dev/null +++ b/json/mattermost.json @@ -0,0 +1,34 @@ +{ + "name": "Mattermost", + "slug": "mattermost", + "categories": [ + 25 + ], + "date_created": "2025-01-30", + "type": "ct", + "updateable": false, + "privileged": false, + "interface_port": 8065, + "documentation": null, + "website": "https://mattermost.com/", + "logo": "https://avatars.githubusercontent.com/u/9828093?s=200&v=4", + "description": "Mattermost is an open source platform for secure collaboration across the entire software development lifecycle. It's written in Go and React and runs as a single Linux binary with MySQL or PostgreSQL. It has a slimilar interface and features to Slack or Discord.", + "install_methods": [ + { + "type": "default", + "script": "ct/mattermost.sh", + "resources": { + "cpu": 1, + "ram": 2048, + "hdd": 8, + "os": "ubuntu", + "version": "24.04" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] +}