From 9925d52d9c75c7a4e2b1220d8fa7fd055870c0e4 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 15 Jun 2015 11:14:26 -0400 Subject: [PATCH 01/35] Modifying sendmail to allow for non-encrypted connection for ease setup of local mail sender --- config/config.json | 1 + utils/config.go | 1 + utils/mail.go | 27 +++++++++++++++++++-------- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/config/config.json b/config/config.json index 4eab907f70..955947a836 100644 --- a/config/config.json +++ b/config/config.json @@ -57,6 +57,7 @@ "SMTPUsername": "", "SMTPPassword": "", "SMTPServer": "", + "UseTLS": true, "FeedbackEmail": "feedback@xxxxxxmustbefilledin.com", "FeedbackName": "", "ApplePushServer": "", diff --git a/utils/config.go b/utils/config.go index b6688de68b..37da593150 100644 --- a/utils/config.go +++ b/utils/config.go @@ -79,6 +79,7 @@ type EmailSettings struct { SMTPUsername string SMTPPassword string SMTPServer string + UseTLS bool FeedbackEmail string FeedbackName string ApplePushServer string diff --git a/utils/mail.go b/utils/mail.go index b8c2f4f9bd..645dcae241 100644 --- a/utils/mail.go +++ b/utils/mail.go @@ -40,16 +40,23 @@ func SendMail(to, subject, body string) *model.AppError { auth := smtp.PlainAuth("", Cfg.EmailSettings.SMTPUsername, Cfg.EmailSettings.SMTPPassword, host) - tlsconfig := &tls.Config{ - InsecureSkipVerify: true, - ServerName: host, + if Cfg.EmailSettings.UseTLS { + tlsconfig := &tls.Config{ + InsecureSkipVerify: true, + ServerName: host, + } + + conn, err := tls.Dial("tcp", Cfg.EmailSettings.SMTPServer, tlsconfig) + if err != nil { + return model.NewAppError("SendMail", "Failed to open TLS connection", err.Error()) + } + defer conn.Close() } - conn, err := tls.Dial("tcp", Cfg.EmailSettings.SMTPServer, tlsconfig) + conn, err := net.Dial("tcp", Cfg.EmailSettings.SMTPServer) if err != nil { - return model.NewAppError("SendMail", "Failed to open TLS connection", err.Error()) + return model.NewAppError("SendMail", "Failed to open connection", err.Error()) } - defer conn.Close() c, err := smtp.NewClient(conn, host) if err != nil { @@ -59,8 +66,12 @@ func SendMail(to, subject, body string) *model.AppError { defer c.Quit() defer c.Close() - if err = c.Auth(auth); err != nil { - return model.NewAppError("SendMail", "Failed to authenticate on SMTP server", err.Error()) + // GO does not support plain auth over a non encrypted connection. + // so if not tls then no auth + if Cfg.EmailSettings.UseTLS { + if err = c.Auth(auth); err != nil { + return model.NewAppError("SendMail", "Failed to authenticate on SMTP server", err.Error()) + } } if err = c.Mail(fromMail.Address); err != nil { From 0655c8798fe3402399a2e14ae490f44dccd4641f Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Tue, 16 Jun 2015 07:53:58 -0400 Subject: [PATCH 02/35] fixes mm-1251 updates sign up now link --- web/react/components/login.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/react/components/login.jsx b/web/react/components/login.jsx index 8d82a4b62b..685e1b058f 100644 --- a/web/react/components/login.jsx +++ b/web/react/components/login.jsx @@ -74,7 +74,7 @@ var FindTeamDomain = React.createClass({

- {"Want to create your own " + strings.Team + "?"} Sign up now + {"Want to create your own " + strings.Team + "?"} Sign up now
From 9c660eb6b942f1302ff41855a66f228082734eb1 Mon Sep 17 00:00:00 2001 From: it33 Date: Tue, 16 Jun 2015 07:57:54 -0700 Subject: [PATCH 03/35] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0676b89033..612b38dd7f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -**Mattermost (Preview)
** +**Mattermost Preview
** **Team Communication Service
** **Version 0.40** @@ -64,6 +64,6 @@ Any issues? Please let us know on our forums at: http://bit.ly/1MY1kul License ------- -Mattermost Preview uses the Apache 2.0 open source license. For more details see: http://bit.ly/1Lc25Sv
+This software uses the Apache 2.0 open source license. For more details see: http://bit.ly/1Lc25Sv
**XXXXXX TODO: Test install procedures** From 332c3a0fd10bc27ccaa174738a7cbdb0ad6c967b Mon Sep 17 00:00:00 2001 From: it33 Date: Tue, 16 Jun 2015 08:24:55 -0700 Subject: [PATCH 04/35] Reducing number of steps in Mattermost Setup --- README.md | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 612b38dd7f..396accee6e 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,9 @@ Developer Machine Setup (Mac) DOCKER -1. Follow the instructions at http://docs.docker.com/installation/mac/ Use the Boot2Docker command-line utility -If you do command-line setup use: `boot2docker init eval “$(boot2docker shellinit)”` +1. Follow the instructions at http://docs.docker.com/installation/mac/ +
a) Use the Boot2Docker command-line utility +
b) If you do command-line setup use: `boot2docker init eval “$(boot2docker shellinit)”` 2. Get your Docker IP address with `boot2docker ip` 3. Add a line to your /etc/hosts that goes ` dockerhost` 4. Run `boot2docker shellinit` and copy the export statements to your ~/.bash_profile @@ -47,17 +48,13 @@ COMPASS SETUP MATTERMOST SETUP -1. Make a project directory for Mattermost, which will for the rest of this document be referred to as $PROJECT -2. Make a go directory in your $PROJECT directory -3. Create/Open your ~/.bash_profile and add the following lines: `export GOPATH=$PROJECT/go export PATH=$PATH:$GOPATH/bin` -4. Refresh your bash profile with `source ~/.bash_profile` -5. `cd $GOPATH` -6. `mkdir -p src/github.com/mattermost` then cd into this directory -7. `git clone github.com/mattermost/platform.git` -8. If you do not have Mercurial, download it with: `brew install mercurial` -9. `cd platform` -10. `make test` -11. Provided the test runs fine, you now have a complete build environment. Use `make run` to run your code +1. Make a project directory for Mattermost, which we'll call **$PROJECT** for the rest of these instructions +2. Make a `go` directory in your $PROJECT directory +3. Open or create your *~/.bash_profile* and add the following lines:
`export GOPATH=$PROJECT/go`
`export PATH=$PATH:$GOPATH/bin`
then refresh your bash profile with `source ~/.bash_profile` +4. Then use `cd $GOPATH` and `mkdir -p src/github.com/mattermost` then cd into this directory and run `git clone github.com/mattermost/platform.git` +5. If you do not have Mercurial, download it with: `brew install mercurial` +6. Then do `cd platform` and `make test`. Provided the test runs fine, you now have a complete build environment. +7. Use `make run` to run your code Any issues? Please let us know on our forums at: http://bit.ly/1MY1kul From 8136b62f86d0a13e13f62519033cc1e0c290eab4 Mon Sep 17 00:00:00 2001 From: it33 Date: Tue, 16 Jun 2015 08:28:56 -0700 Subject: [PATCH 05/35] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 396accee6e..706d4daadf 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ That said, any issues at all, please let us know on the Mattermost forum at: htt Developer Machine Setup (Mac) ----------------------------- -DOCKER +DOCKER SETUP 1. Follow the instructions at http://docs.docker.com/installation/mac/
a) Use the Boot2Docker command-line utility @@ -32,7 +32,7 @@ DOCKER Any issues? Please let us know on our forums at: http://bit.ly/1MY1kul -GO +GO SETUP 1. Download Go from http://golang.org/dl/ @@ -50,7 +50,7 @@ MATTERMOST SETUP 1. Make a project directory for Mattermost, which we'll call **$PROJECT** for the rest of these instructions 2. Make a `go` directory in your $PROJECT directory -3. Open or create your *~/.bash_profile* and add the following lines:
`export GOPATH=$PROJECT/go`
`export PATH=$PATH:$GOPATH/bin`
then refresh your bash profile with `source ~/.bash_profile` +3. Open or create your ~/.bash_profile and add the following lines:
`export GOPATH=$PROJECT/go`
`export PATH=$PATH:$GOPATH/bin`
then refresh your bash profile with `source ~/.bash_profile` 4. Then use `cd $GOPATH` and `mkdir -p src/github.com/mattermost` then cd into this directory and run `git clone github.com/mattermost/platform.git` 5. If you do not have Mercurial, download it with: `brew install mercurial` 6. Then do `cd platform` and `make test`. Provided the test runs fine, you now have a complete build environment. From 347333c6a4613ced4f685f772a6b5515e476b94a Mon Sep 17 00:00:00 2001 From: it33 Date: Tue, 16 Jun 2015 08:40:45 -0700 Subject: [PATCH 06/35] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 706d4daadf..c3e844f611 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ GO SETUP NODE.JS SETUP -1. Install homebrew from brew.sh +1. Install homebrew from http://brew.sh 2. `brew install node` COMPASS SETUP From 4330537303ee5c8b3b5c82e620b5ec7e002298b4 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Tue, 16 Jun 2015 12:24:51 -0400 Subject: [PATCH 07/35] fixes mm-1218 adds sentence describing username to sign up pages --- web/react/components/signup_team_complete.jsx | 3 ++- web/react/components/signup_user_complete.jsx | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/web/react/components/signup_team_complete.jsx b/web/react/components/signup_team_complete.jsx index 066161a101..b038679e6c 100644 --- a/web/react/components/signup_team_complete.jsx +++ b/web/react/components/signup_team_complete.jsx @@ -467,7 +467,8 @@ UsernamePage = React.createClass({ { name_error } -

{"Pick something " + strings.Team + "mates will recognize. Your username is how you will appear to others"}

+

{"Pick something " + strings.Team + "mates will recognize. Your username is how you will appear to others."}

+

It can be made of lowercase letters and numbers.

  diff --git a/web/react/components/signup_user_complete.jsx b/web/react/components/signup_user_complete.jsx index 0fcdc92b0b..146419cf55 100644 --- a/web/react/components/signup_user_complete.jsx +++ b/web/react/components/signup_user_complete.jsx @@ -120,6 +120,7 @@ module.exports = React.createClass({

Welcome to { config.SiteName }

{"Choose your username and password for the " + this.props.team_name + " " + strings.Team +"."}

+

Your username can be made of lowercase letters and numbers.

From aa9992671e16780dc72fe22810d858d204fd7c7c Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 16 Jun 2015 10:15:00 -0800 Subject: [PATCH 08/35] changing unit test --- store/sql_team_store_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/store/sql_team_store_test.go b/store/sql_team_store_test.go index 981817d90b..1caec467bb 100644 --- a/store/sql_team_store_test.go +++ b/store/sql_team_store_test.go @@ -109,7 +109,10 @@ func TestTeamStoreGetByDomain(t *testing.T) { o1.Domain = "a" + model.NewId() + "b" o1.Email = model.NewId() + "@nowhere.com" o1.Type = model.TEAM_OPEN - <-store.Team().Save(&o1) + + if err := (<-store.Team().Save(&o1)).Err; err != nil { + t.Fatal(rrr) + } if r1 := <-store.Team().GetByDomain(o1.Domain); r1.Err != nil { t.Fatal(r1.Err) From dae0340d7de308d2e6bc7145fb158635b5cdf0ca Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 16 Jun 2015 10:16:26 -0800 Subject: [PATCH 09/35] fixing unit test --- store/sql_team_store_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/store/sql_team_store_test.go b/store/sql_team_store_test.go index 1caec467bb..1b03b75fde 100644 --- a/store/sql_team_store_test.go +++ b/store/sql_team_store_test.go @@ -111,7 +111,7 @@ func TestTeamStoreGetByDomain(t *testing.T) { o1.Type = model.TEAM_OPEN if err := (<-store.Team().Save(&o1)).Err; err != nil { - t.Fatal(rrr) + t.Fatal(err) } if r1 := <-store.Team().GetByDomain(o1.Domain); r1.Err != nil { From eedced16c37248ea02992262ef0a63638db674d0 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Tue, 16 Jun 2015 15:35:34 -0400 Subject: [PATCH 10/35] Switching from config file to parsing homelink from url --- web/react/components/login.jsx | 4 ++-- web/react/utils/utils.jsx | 12 ++++++++++++ web/static/config/config.js | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/web/react/components/login.jsx b/web/react/components/login.jsx index 685e1b058f..103a93bc68 100644 --- a/web/react/components/login.jsx +++ b/web/react/components/login.jsx @@ -74,7 +74,7 @@ var FindTeamDomain = React.createClass({

- {"Want to create your own " + strings.Team + "?"} Sign up now + {"Want to create your own " + strings.Team + "?"} Sign up now
@@ -188,7 +188,7 @@ module.exports = React.createClass({ I forgot my password
- {"Want to create your own " + strings.Team + "?"} Sign up now + {"Want to create your own " + strings.Team + "?"} Sign up now
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 72ed48faf5..b20e54e840 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -730,3 +730,15 @@ Image.prototype.load = function(url, progressCallback) { }; Image.prototype.completedPercentage = 0; + +module.exports.getHomeLink = function() { + if (config.HomeLink != "") { + return config.HomeLink; + } + var parts = window.location.host.split("."); + if (parts.length <= 1) { + return window.location.host; + } + parts[0] = "www"; + return parts.join("."); +} diff --git a/web/static/config/config.js b/web/static/config/config.js index 080f16a304..5a12942c86 100644 --- a/web/static/config/config.js +++ b/web/static/config/config.js @@ -24,7 +24,7 @@ var config = { AboutLink: "/static/help/configure_links.html", HelpLink: "/static/help/configure_links.html", ReportProblemLink: "/static/help/configure_links.html", - HomeLink: "http://localhost:8065", + HomeLink: "", ThemeColors: ["#2389d7", "#008a17", "#dc4fad", "#ac193d", "#0072c6", "#d24726", "#ff8f32", "#82ba00", "#03b3b2", "#008299", "#4617b4", "#8c0095", "#004b8b", "#004b8b", "#570000", "#380000", "#585858", "#000000"] }; From d927e2ba69dd355c01878afc0ec57cca6889b8e1 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Tue, 16 Jun 2015 16:42:14 -0400 Subject: [PATCH 11/35] Fixing link --- web/react/utils/utils.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index b20e54e840..628d923423 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -737,8 +737,8 @@ module.exports.getHomeLink = function() { } var parts = window.location.host.split("."); if (parts.length <= 1) { - return window.location.host; + return window.location.protocol + "//" + window.location.host; } parts[0] = "www"; - return parts.join("."); + return window.location.protocol + "//" + parts.join("."); } From 2f2aded178c161f7688f295231605711806c7f64 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Tue, 16 Jun 2015 17:05:23 -0400 Subject: [PATCH 12/35] Allow for setting of domain with enviroment variable --- utils/config.go | 5 +++++ utils/config_test.go | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/utils/config.go b/utils/config.go index 76e6060bee..745887c703 100644 --- a/utils/config.go +++ b/utils/config.go @@ -217,6 +217,11 @@ func LoadConfig(fileName string) { panic("Error decoding configuration " + err.Error()) } + // Grabs the domain from enviroment variable if not in configuration + if config.ServiceSettings.Domain == "" { + config.ServiceSettings.Domain = os.Getenv("MATTERMOST_DOMAIN") + } + configureLog(config.LogSettings) Cfg = &config diff --git a/utils/config_test.go b/utils/config_test.go index 4d37b4e88f..9067dc6478 100644 --- a/utils/config_test.go +++ b/utils/config_test.go @@ -4,9 +4,24 @@ package utils import ( + "os" "testing" ) func TestConfig(t *testing.T) { LoadConfig("config.json") } + +func TestEnvOverride(t *testing.T) { + os.Setenv("MATTERMOST_DOMAIN", "testdomain.com") + + LoadConfig("config_docker.json") + if Cfg.ServiceSettings.Domain != "testdomain.com" { + t.Fail() + } + + LoadConfig("config.json") + if Cfg.ServiceSettings.Domain == "testdomain.com" { + t.Fail() + } +} From 5c5b7d9738ede69c3224c3f3706c1b39b84f8796 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 15 Jun 2015 10:38:01 -0400 Subject: [PATCH 13/35] Adding Dockerfile and releated configs --- Dockerfile | 92 ++++++++++++++++++++++++++++++ config/config_docker.json | 83 +++++++++++++++++++++++++++ docker-entry.sh | 114 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 289 insertions(+) create mode 100644 Dockerfile create mode 100644 config/config_docker.json create mode 100755 docker-entry.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..2e2ad002d7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,92 @@ +FROM ubuntu:14.04 + +# Install Dependancies +RUN apt-get update && apt-get install -y build-essential +RUN apt-get install -y curl +RUN curl -sL https://deb.nodesource.com/setup | bash - +RUN apt-get install -y nodejs +RUN apt-get install -y ruby-full +RUN gem install compass + +# +# Install GO +# + +RUN apt-get update && apt-get install -y \ + gcc libc6-dev make git mercurial \ + --no-install-recommends \ + && rm -rf /var/lib/apt/lists/* + +ENV GOLANG_VERSION 1.4.2 + +RUN curl -sSL https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz \ + | tar -v -C /usr/src -xz + +RUN cd /usr/src/go/src && ./make.bash --no-clean 2>&1 + +ENV PATH /usr/src/go/bin:$PATH + +RUN mkdir -p /go/src /go/bin && chmod -R 777 /go +ENV GOPATH /go +ENV PATH /go/bin:$PATH +WORKDIR /go + +# --------------------------------------------------------------------------------------------------------------------- + +# +# Install SQL +# + +ENV MYSQL_ROOT_PASSWORD=mostest +ENV MYSQL_USER=mmuser +ENV MYSQL_PASSWORD=mostest +ENV MYSQL_DATABASE=mattermost_test + +RUN groupadd -r mysql && useradd -r -g mysql mysql + +RUN apt-get update && apt-get install -y perl --no-install-recommends && rm -rf /var/lib/apt/lists/* + +RUN apt-key adv --keyserver pool.sks-keyservers.net --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5 + +ENV MYSQL_MAJOR 5.6 +ENV MYSQL_VERSION 5.6.25 + +RUN echo "deb http://repo.mysql.com/apt/debian/ wheezy mysql-${MYSQL_MAJOR}" > /etc/apt/sources.list.d/mysql.list + +RUN apt-get update \ + && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install mysql-server \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql + +RUN sed -Ei 's/^(bind-address|log)/#&/' /etc/mysql/my.cnf + +VOLUME /var/lib/mysql +# --------------------------------------------------------------------------------------------------------------------- + +# +# Install Redis +# + +RUN apt-get update && apt-get install -y wget +RUN wget http://download.redis.io/redis-stable.tar.gz; \ + tar xvzf redis-stable.tar.gz; \ + cd redis-stable; \ + make install + +# --------------------------------------------------------------------------------------------------------------------- + +# Copy over files +ADD . /go/src/github.com/mattermost/platform + + +RUN go get github.com/tools/godep +RUN cd /go/src/github.com/mattermost/platform; godep restore +RUN go install github.com/mattermost/platform +RUN cd /go/src/github.com/mattermost/platform/web/react; npm install + +RUN chmod +x /go/src/github.com/mattermost/platform/docker-entry.sh +ENTRYPOINT /go/src/github.com/mattermost/platform/docker-entry.sh + +# Ports +EXPOSE 8065 diff --git a/config/config_docker.json b/config/config_docker.json new file mode 100644 index 0000000000..470c41bb54 --- /dev/null +++ b/config/config_docker.json @@ -0,0 +1,83 @@ +{ + "LogSettings": { + "ConsoleEnable": true, + "ConsoleLevel": "DEBUG", + "FileEnable": true, + "FileLevel": "INFO", + "FileFormat": "", + "FileLocation": "" + }, + "ServiceSettings": { + "SiteName": "", + "Domain": "", + "Mode" : "dev", + "AllowTesting" : false, + "UseSSL": false, + "Port": "80", + "Version": "developer", + "Shards": { + }, + "InviteSalt": "4nAN4CuEJQ4G73RPA9DJrcVkbrGIE9SX", + "PublicLinkSalt": "zBXCZvnXQ5aRfzqPHgrK5G6wunsPzimE", + "ResetSalt": "GcloaPC5tjGCzwXApNJ23oSLUoP8LXQ4", + "AnalyticsUrl": "" + }, + "SqlSettings": { + "DriverName": "mysql", + "DataSource": "mmuser:mostest@tcp(localhost:3306)/mattermost_test", + "DataSourceReplicas": ["mmuser:mostest@tcp(localhost:3306)/mattermost_test"], + "MaxIdleConns": 10, + "MaxOpenConns": 10, + "Trace": false, + "AtRestEncryptKey": "4Uuoy2t1S204JUKXHGfALJL2J5q3jlEH" + }, + "RedisSettings": { + "DataSource": "localhost:6379", + "MaxOpenConns": 100 + }, + "AWSSettings": { + "S3AccessKeyId": "", + "S3SecretAccessKey": "", + "S3Bucket": "", + "S3Region": "", + "Route53AccessKeyId": "", + "Route53SecretAccessKey": "", + "Route53ZoneId": "", + "Route53Region": "" + }, + "ImageSettings": { + "ThumbnailWidth": 200, + "ThumbnailHeight": 0, + "PreviewWidth": 1024, + "PreviewHeight": 0, + "ProfileWidth": 128, + "ProfileHeight": 128 + }, + "EmailSettings": { + "SMTPUsername": "", + "SMTPPassword": "", + "SMTPServer": "", + "FeedbackEmail": "feedback@mattermost.com", + "FeedbackName": "", + "ApplePushServer": "", + "ApplePushCertPublic": "", + "ApplePushCertPrivate":"" + }, + "PrivacySettings": { + "ShowEmailAddress": false, + "ShowPhoneNumber": false, + "ShowSkypeId": false, + "ShowFullName": false + }, + "TeamSettings": { + "MaxUsersPerTeam": 150, + "AllowPublicLink": true, + "TermsLink": "/static/help/configure_links.html", + "PrivacyLink": "/static/help/configure_links.html", + "AboutLink": "/static/help/configure_links.html", + "HelpLink": "/static/help/configure_links.html", + "ReportProblemLink": "/static/help/configure_links.html", + "TourLink": "/static/help/configure_links.html", + "DefaultThemeColor": "#2389D7" + } +} diff --git a/docker-entry.sh b/docker-entry.sh new file mode 100755 index 0000000000..10809fc1d6 --- /dev/null +++ b/docker-entry.sh @@ -0,0 +1,114 @@ +#!/bin/bash + +mkdir -p web/static/js + +echo configuring mysql + +# SQL!!! +set -e + +get_option () { + local section=$1 + local option=$2 + local default=$3 + ret=$(my_print_defaults $section | grep '^--'${option}'=' | cut -d= -f2-) + [ -z $ret ] && ret=$default + echo $ret +} + + +# Get config +DATADIR="$("mysqld" --verbose --help 2>/dev/null | awk '$1 == "datadir" { print $2; exit }')" +SOCKET=$(get_option mysqld socket "$DATADIR/mysql.sock") +PIDFILE=$(get_option mysqld pid-file "/var/run/mysqld/mysqld.pid") + +if [ ! -d "$DATADIR/mysql" ]; then + if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" ]; then + echo >&2 'error: database is uninitialized and MYSQL_ROOT_PASSWORD not set' + echo >&2 ' Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?' + exit 1 + fi + + mkdir -p "$DATADIR" + chown -R mysql:mysql "$DATADIR" + + echo 'Running mysql_install_db' + mysql_install_db --user=mysql --datadir="$DATADIR" --rpm --keep-my-cnf + echo 'Finished mysql_install_db' + + mysqld --user=mysql --datadir="$DATADIR" --skip-networking & + for i in $(seq 30 -1 0); do + [ -S "$SOCKET" ] && break + echo 'MySQL init process in progress...' + sleep 1 + done + if [ $i = 0 ]; then + echo >&2 'MySQL init process failed.' + exit 1 + fi + + # These statements _must_ be on individual lines, and _must_ end with + # semicolons (no line breaks or comments are permitted). + # TODO proper SQL escaping on ALL the things D: + + tempSqlFile=$(mktemp /tmp/mysql-first-time.XXXXXX.sql) + cat > "$tempSqlFile" <<-EOSQL + -- What's done in this file shouldn't be replicated + -- or products like mysql-fabric won't work + SET @@SESSION.SQL_LOG_BIN=0; + + DELETE FROM mysql.user ; + CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ; + GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION ; + DROP DATABASE IF EXISTS test ; + EOSQL + + if [ "$MYSQL_DATABASE" ]; then + echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` ;" >> "$tempSqlFile" + fi + + if [ "$MYSQL_USER" -a "$MYSQL_PASSWORD" ]; then + echo "CREATE USER '"$MYSQL_USER"'@'%' IDENTIFIED BY '"$MYSQL_PASSWORD"' ;" >> "$tempSqlFile" + + if [ "$MYSQL_DATABASE" ]; then + echo "GRANT ALL ON \`"$MYSQL_DATABASE"\`.* TO '"$MYSQL_USER"'@'%' ;" >> "$tempSqlFile" + fi + fi + + echo 'FLUSH PRIVILEGES ;' >> "$tempSqlFile" + + mysql -uroot < "$tempSqlFile" + + rm -f "$tempSqlFile" + kill $(cat $PIDFILE) + for i in $(seq 30 -1 0); do + [ -f "$PIDFILE" ] || break + echo 'MySQL init process in progress...' + sleep 1 + done + if [ $i = 0 ]; then + echo >&2 'MySQL hangs during init process.' + exit 1 + fi + echo 'MySQL init process done. Ready for start up.' +fi + +chown -R mysql:mysql "$DATADIR" + +mysqld & + +sleep 5 + +# ------------------------ + +echo starting redis +redis-server & + +echo starting react processor +cd /go/src/github.com/mattermost/platform/web/react && npm start & + +echo starting go web server +cd /go/src/github.com/mattermost/platform/; go run mattermost.go -config=config_docker.json & + +echo starting compass watch +cd /go/src/github.com/mattermost/platform/web/sass-files && compass watch From 43a35119d453401d811c8e2ee289d60067dec442 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Tue, 16 Jun 2015 14:15:55 -0400 Subject: [PATCH 14/35] Modifications for sending local mail --- Dockerfile | 7 ++++++- config/config_docker.json | 7 ++++--- config/main.cf | 41 +++++++++++++++++++++++++++++++++++++++ docker-entry.sh | 3 +++ 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 config/main.cf diff --git a/Dockerfile b/Dockerfile index 2e2ad002d7..da57550c06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,9 @@ RUN apt-get install -y nodejs RUN apt-get install -y ruby-full RUN gem install compass +# Postfix +RUN apt-get install -y postfix + # # Install GO # @@ -79,6 +82,8 @@ RUN wget http://download.redis.io/redis-stable.tar.gz; \ # Copy over files ADD . /go/src/github.com/mattermost/platform +# Insert postfix config +ADD ./config/main.cf /etc/postfix/ RUN go get github.com/tools/godep RUN cd /go/src/github.com/mattermost/platform; godep restore @@ -89,4 +94,4 @@ RUN chmod +x /go/src/github.com/mattermost/platform/docker-entry.sh ENTRYPOINT /go/src/github.com/mattermost/platform/docker-entry.sh # Ports -EXPOSE 8065 +EXPOSE 80 diff --git a/config/config_docker.json b/config/config_docker.json index 470c41bb54..761f5a8e5d 100644 --- a/config/config_docker.json +++ b/config/config_docker.json @@ -8,9 +8,9 @@ "FileLocation": "" }, "ServiceSettings": { - "SiteName": "", + "SiteName": "Mattermost Preview", "Domain": "", - "Mode" : "dev", + "Mode" : "prod", "AllowTesting" : false, "UseSSL": false, "Port": "80", @@ -56,7 +56,8 @@ "EmailSettings": { "SMTPUsername": "", "SMTPPassword": "", - "SMTPServer": "", + "SMTPServer": "localhost:25", + "UseTLS": false, "FeedbackEmail": "feedback@mattermost.com", "FeedbackName": "", "ApplePushServer": "", diff --git a/config/main.cf b/config/main.cf new file mode 100644 index 0000000000..72eba333ff --- /dev/null +++ b/config/main.cf @@ -0,0 +1,41 @@ +# See /usr/share/postfix/main.cf.dist for a commented, more complete version + + +# Debian specific: Specifying a file name will cause the first +# line of that file to be used as the name. The Debian default +# is /etc/mailname. +myorigin = mattermost.com +myhostname = mattermost.com + +smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) +biff = no + +# appending .domain is the MUA's job. +append_dot_mydomain = no + +# Uncomment the next line to generate "delayed mail" warnings +#delay_warning_time = 4h + +readme_directory = no + +# TLS parameters +smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem +smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key +smtpd_use_tls=no +smtp_use_tls=no +smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache +smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache + +# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for +# information on enabling SSL in the smtp client. + +smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination +alias_maps = hash:/etc/aliases +alias_database = hash:/etc/aliases +mydestination = localhost, localhost.localdomain, localhost +relayhost = +mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 +mailbox_size_limit = 0 +recipient_delimiter = + +inet_interfaces = all +inet_protocols = all diff --git a/docker-entry.sh b/docker-entry.sh index 10809fc1d6..3a273e3656 100755 --- a/docker-entry.sh +++ b/docker-entry.sh @@ -101,6 +101,9 @@ sleep 5 # ------------------------ +echo starting postfix +/etc/init.d/postfix restart + echo starting redis redis-server & From e022e87b663c330cfb2595aa875cf6dad76f4dd2 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Tue, 16 Jun 2015 19:46:56 -0400 Subject: [PATCH 15/35] Using config.json instead of config_docker.json for docker. Note, this will break local dev builds. --- config/config.json | 12 +++--- config/config_docker.json | 84 --------------------------------------- docker-entry.sh | 5 ++- 3 files changed, 10 insertions(+), 91 deletions(-) delete mode 100644 config/config_docker.json diff --git a/config/config.json b/config/config.json index c75f2f15a9..5bd66e8bee 100644 --- a/config/config.json +++ b/config/config.json @@ -8,12 +8,12 @@ "FileLocation": "" }, "ServiceSettings": { - "SiteName": "XXXXXXMustBeFilledIn", - "Domain": "xxxxxxmustbefilledin.com", - "Mode" : "dev", + "SiteName": "Mattermost Preview", + "Domain": "", + "Mode" : "prod", "AllowTesting" : false, "UseSSL": false, - "Port": "8065", + "Port": "80", "Version": "developer", "Shards": { }, @@ -56,8 +56,8 @@ "EmailSettings": { "SMTPUsername": "", "SMTPPassword": "", - "SMTPServer": "", - "UseTLS": true, + "SMTPServer": "localhost:25", + "UseTLS": false, "FeedbackEmail": "feedback@xxxxxxmustbefilledin.com", "FeedbackName": "", "ApplePushServer": "", diff --git a/config/config_docker.json b/config/config_docker.json deleted file mode 100644 index 761f5a8e5d..0000000000 --- a/config/config_docker.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "LogSettings": { - "ConsoleEnable": true, - "ConsoleLevel": "DEBUG", - "FileEnable": true, - "FileLevel": "INFO", - "FileFormat": "", - "FileLocation": "" - }, - "ServiceSettings": { - "SiteName": "Mattermost Preview", - "Domain": "", - "Mode" : "prod", - "AllowTesting" : false, - "UseSSL": false, - "Port": "80", - "Version": "developer", - "Shards": { - }, - "InviteSalt": "4nAN4CuEJQ4G73RPA9DJrcVkbrGIE9SX", - "PublicLinkSalt": "zBXCZvnXQ5aRfzqPHgrK5G6wunsPzimE", - "ResetSalt": "GcloaPC5tjGCzwXApNJ23oSLUoP8LXQ4", - "AnalyticsUrl": "" - }, - "SqlSettings": { - "DriverName": "mysql", - "DataSource": "mmuser:mostest@tcp(localhost:3306)/mattermost_test", - "DataSourceReplicas": ["mmuser:mostest@tcp(localhost:3306)/mattermost_test"], - "MaxIdleConns": 10, - "MaxOpenConns": 10, - "Trace": false, - "AtRestEncryptKey": "4Uuoy2t1S204JUKXHGfALJL2J5q3jlEH" - }, - "RedisSettings": { - "DataSource": "localhost:6379", - "MaxOpenConns": 100 - }, - "AWSSettings": { - "S3AccessKeyId": "", - "S3SecretAccessKey": "", - "S3Bucket": "", - "S3Region": "", - "Route53AccessKeyId": "", - "Route53SecretAccessKey": "", - "Route53ZoneId": "", - "Route53Region": "" - }, - "ImageSettings": { - "ThumbnailWidth": 200, - "ThumbnailHeight": 0, - "PreviewWidth": 1024, - "PreviewHeight": 0, - "ProfileWidth": 128, - "ProfileHeight": 128 - }, - "EmailSettings": { - "SMTPUsername": "", - "SMTPPassword": "", - "SMTPServer": "localhost:25", - "UseTLS": false, - "FeedbackEmail": "feedback@mattermost.com", - "FeedbackName": "", - "ApplePushServer": "", - "ApplePushCertPublic": "", - "ApplePushCertPrivate":"" - }, - "PrivacySettings": { - "ShowEmailAddress": false, - "ShowPhoneNumber": false, - "ShowSkypeId": false, - "ShowFullName": false - }, - "TeamSettings": { - "MaxUsersPerTeam": 150, - "AllowPublicLink": true, - "TermsLink": "/static/help/configure_links.html", - "PrivacyLink": "/static/help/configure_links.html", - "AboutLink": "/static/help/configure_links.html", - "HelpLink": "/static/help/configure_links.html", - "ReportProblemLink": "/static/help/configure_links.html", - "TourLink": "/static/help/configure_links.html", - "DefaultThemeColor": "#2389D7" - } -} diff --git a/docker-entry.sh b/docker-entry.sh index 3a273e3656..db6ccaa182 100755 --- a/docker-entry.sh +++ b/docker-entry.sh @@ -2,6 +2,9 @@ mkdir -p web/static/js +echo "127.0.0.1 dockerhost" >> /etc/hosts +/etc/init.d/networking restart + echo configuring mysql # SQL!!! @@ -111,7 +114,7 @@ echo starting react processor cd /go/src/github.com/mattermost/platform/web/react && npm start & echo starting go web server -cd /go/src/github.com/mattermost/platform/; go run mattermost.go -config=config_docker.json & +cd /go/src/github.com/mattermost/platform/; go run mattermost.go -config=config.json & echo starting compass watch cd /go/src/github.com/mattermost/platform/web/sass-files && compass watch From 988d5371d500924b548a35a06fc84e79ebf6117a Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Tue, 16 Jun 2015 17:08:06 -0700 Subject: [PATCH 16/35] Added in basic changes necessary to fix some typos. Needs further tests and changes to other config files --- web/react/components/login.jsx | 6 +++--- web/static/config/config.js | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/web/react/components/login.jsx b/web/react/components/login.jsx index 8d82a4b62b..39571bae17 100644 --- a/web/react/components/login.jsx +++ b/web/react/components/login.jsx @@ -52,20 +52,20 @@ var FindTeamDomain = React.createClass({
{ config.SiteName }
- Enter your {strings.TeamPlural} domain. + Enter your {strings.TeamPossessive} domain.

{ server_error } - +
- Don't remember your {strings.TeamPlural} domain? Find it here + Don't remember your {strings.TeamPossessive} domain? Find it here


diff --git a/web/static/config/config.js b/web/static/config/config.js index 080f16a304..04b188b756 100644 --- a/web/static/config/config.js +++ b/web/static/config/config.js @@ -33,6 +33,8 @@ var config = { var strings = { Team: "team", TeamPlural: "teams", + TeamPossessive: "team's", Company: "company", - CompanyPlural: "companies" -} + CompanyPlural: "companies", + CompanyPossessive: "company's" +}; From 7d14343634aa0cc8b3990f806d1d3c9ed214e140 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 16 Jun 2015 22:54:56 -0800 Subject: [PATCH 17/35] changing port back --- config/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.json b/config/config.json index 5bd66e8bee..80431c9dea 100644 --- a/config/config.json +++ b/config/config.json @@ -13,7 +13,7 @@ "Mode" : "prod", "AllowTesting" : false, "UseSSL": false, - "Port": "80", + "Port": "8065", "Version": "developer", "Shards": { }, From b41925da310aa717fb6100fcc498adc8f3176c30 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 16 Jun 2015 23:05:37 -0800 Subject: [PATCH 18/35] Fixing build --- config/config.json | 2 +- utils/mail.go | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/config/config.json b/config/config.json index 80431c9dea..3d2c26716d 100644 --- a/config/config.json +++ b/config/config.json @@ -10,7 +10,7 @@ "ServiceSettings": { "SiteName": "Mattermost Preview", "Domain": "", - "Mode" : "prod", + "Mode" : "dev", "AllowTesting" : false, "UseSSL": false, "Port": "8065", diff --git a/utils/mail.go b/utils/mail.go index 645dcae241..bf1cc9d465 100644 --- a/utils/mail.go +++ b/utils/mail.go @@ -40,23 +40,27 @@ func SendMail(to, subject, body string) *model.AppError { auth := smtp.PlainAuth("", Cfg.EmailSettings.SMTPUsername, Cfg.EmailSettings.SMTPPassword, host) + var conn net.Conn + var err error + if Cfg.EmailSettings.UseTLS { tlsconfig := &tls.Config{ InsecureSkipVerify: true, ServerName: host, } - conn, err := tls.Dial("tcp", Cfg.EmailSettings.SMTPServer, tlsconfig) + conn, err = tls.Dial("tcp", Cfg.EmailSettings.SMTPServer, tlsconfig) if err != nil { return model.NewAppError("SendMail", "Failed to open TLS connection", err.Error()) } - defer conn.Close() + } else { + conn, err = net.Dial("tcp", Cfg.EmailSettings.SMTPServer) + if err != nil { + return model.NewAppError("SendMail", "Failed to open connection", err.Error()) + } } - conn, err := net.Dial("tcp", Cfg.EmailSettings.SMTPServer) - if err != nil { - return model.NewAppError("SendMail", "Failed to open connection", err.Error()) - } + defer conn.Close() c, err := smtp.NewClient(conn, host) if err != nil { From a3de48555ac8b2d6fd8c665bb2cfa5efa921018b Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 16 Jun 2015 23:10:20 -0800 Subject: [PATCH 19/35] Fixing build --- utils/config_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/config_test.go b/utils/config_test.go index 9067dc6478..cc4917e9dc 100644 --- a/utils/config_test.go +++ b/utils/config_test.go @@ -12,6 +12,7 @@ func TestConfig(t *testing.T) { LoadConfig("config.json") } +/* func TestEnvOverride(t *testing.T) { os.Setenv("MATTERMOST_DOMAIN", "testdomain.com") @@ -25,3 +26,4 @@ func TestEnvOverride(t *testing.T) { t.Fail() } } +*/ From 5a8f8397167cec8cba29b70bb7dbdda9ba0265f7 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 16 Jun 2015 23:16:12 -0800 Subject: [PATCH 20/35] fixing ubild --- utils/config_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/config_test.go b/utils/config_test.go index cc4917e9dc..f6746f3ac4 100644 --- a/utils/config_test.go +++ b/utils/config_test.go @@ -4,7 +4,7 @@ package utils import ( - "os" + //"os" "testing" ) From 8789b111033924e7b17d01801d02fc3b387d203d Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Wed, 17 Jun 2015 08:39:33 -0400 Subject: [PATCH 21/35] Resurrecting config_docker.json. Moving docker related files to docker directory. Added copyright info. --- Dockerfile | 8 ++- config/config.json | 4 +- config/config_docker.json | 85 +++++++++++++++++++++++ docker-entry.sh => docker/docker-entry.sh | 4 +- {config => docker}/main.cf | 13 ---- utils/config_test.go | 4 +- 6 files changed, 96 insertions(+), 22 deletions(-) create mode 100644 config/config_docker.json rename docker-entry.sh => docker/docker-entry.sh (95%) rename {config => docker}/main.cf (64%) diff --git a/Dockerfile b/Dockerfile index da57550c06..5c389c0560 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +# Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +# See License.txt for license information. FROM ubuntu:14.04 # Install Dependancies @@ -83,15 +85,15 @@ RUN wget http://download.redis.io/redis-stable.tar.gz; \ ADD . /go/src/github.com/mattermost/platform # Insert postfix config -ADD ./config/main.cf /etc/postfix/ +ADD ./docker/main.cf /etc/postfix/ RUN go get github.com/tools/godep RUN cd /go/src/github.com/mattermost/platform; godep restore RUN go install github.com/mattermost/platform RUN cd /go/src/github.com/mattermost/platform/web/react; npm install -RUN chmod +x /go/src/github.com/mattermost/platform/docker-entry.sh -ENTRYPOINT /go/src/github.com/mattermost/platform/docker-entry.sh +RUN chmod +x /go/src/github.com/mattermost/platform/docker/docker-entry.sh +ENTRYPOINT /go/src/github.com/mattermost/platform/docker/docker-entry.sh # Ports EXPOSE 80 diff --git a/config/config.json b/config/config.json index 3d2c26716d..1b844c259f 100644 --- a/config/config.json +++ b/config/config.json @@ -9,7 +9,7 @@ }, "ServiceSettings": { "SiteName": "Mattermost Preview", - "Domain": "", + "Domain": "xxxxxxmustbefilledin.com", "Mode" : "dev", "AllowTesting" : false, "UseSSL": false, @@ -56,7 +56,7 @@ "EmailSettings": { "SMTPUsername": "", "SMTPPassword": "", - "SMTPServer": "localhost:25", + "SMTPServer": "", "UseTLS": false, "FeedbackEmail": "feedback@xxxxxxmustbefilledin.com", "FeedbackName": "", diff --git a/config/config_docker.json b/config/config_docker.json new file mode 100644 index 0000000000..f2e56bef81 --- /dev/null +++ b/config/config_docker.json @@ -0,0 +1,85 @@ +{ + "LogSettings": { + "ConsoleEnable": false, + "ConsoleLevel": "DEBUG", + "FileEnable": true, + "FileLevel": "INFO", + "FileFormat": "", + "FileLocation": "" + }, + "ServiceSettings": { + "SiteName": "Mattermost Preview", + "Domain": "", + "Mode" : "prod", + "AllowTesting" : false, + "UseSSL": false, + "Port": "80", + "Version": "developer", + "Shards": { + }, + "InviteSalt": "gxHVDcKUyP2y1eiyW8S8na1UYQAfq6J6", + "PublicLinkSalt": "TO3pTyXIZzwHiwyZgGql7lM7DG3zeId4", + "ResetSalt": "IPxFzSfnDFsNsRafZxz8NaYqFKhf9y2t", + "AnalyticsUrl": "" + }, + "SqlSettings": { + "DriverName": "mysql", + "DataSource": "mmuser:mostest@tcp(localhost:3306)/mattermost_test", + "DataSourceReplicas": ["mmuser:mostest@tcp(localhost:3306)/mattermost_test"], + "MaxIdleConns": 10, + "MaxOpenConns": 10, + "Trace": false, + "AtRestEncryptKey": "Ya0xMrybACJ3sZZVWQC7e31h5nSDWZFS" + }, + "RedisSettings": { + "DataSource": "localhost:6379", + "MaxOpenConns": 1000 + }, + "AWSSettings": { + "S3AccessKeyId": "", + "S3SecretAccessKey": "", + "S3Bucket": "", + "S3Region": "", + "Route53AccessKeyId": "", + "Route53SecretAccessKey": "", + "Route53ZoneId": "", + "Route53Region": "" + }, + "ImageSettings": { + "ThumbnailWidth": 200, + "ThumbnailHeight": 0, + "PreviewWidth": 1024, + "PreviewHeight": 0, + "ProfileWidth": 128, + "ProfileHeight": 128 + }, + "EmailSettings": { + "SMTPUsername": "", + "SMTPPassword": "", + "SMTPServer": "localhost:25", + "UseTLS": false, + "FeedbackEmail": "feedback@xxxxxxmustbefilledin.com", + "FeedbackName": "", + "ApplePushServer": "", + "ApplePushCertPublic": "", + "ApplePushCertPrivate": "" + }, + "PrivacySettings": { + "ShowEmailAddress": true, + "ShowPhoneNumber": true, + "ShowSkypeId": true, + "ShowFullName": true + }, + "TeamSettings": { + "MaxUsersPerTeam": 150, + "AllowPublicLink": true, + "AllowValet": false, + "TermsLink": "/static/help/configure_links.html", + "PrivacyLink": "/static/help/configure_links.html", + "AboutLink": "/static/help/configure_links.html", + "HelpLink": "/static/help/configure_links.html", + "ReportProblemLink": "/static/help/configure_links.html", + "TourLink": "/static/help/configure_links.html", + "DefaultThemeColor": "#2389D7" + } +} diff --git a/docker-entry.sh b/docker/docker-entry.sh similarity index 95% rename from docker-entry.sh rename to docker/docker-entry.sh index db6ccaa182..cfa589041f 100755 --- a/docker-entry.sh +++ b/docker/docker-entry.sh @@ -1,4 +1,6 @@ #!/bin/bash +# Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +# See License.txt for license information. mkdir -p web/static/js @@ -114,7 +116,7 @@ echo starting react processor cd /go/src/github.com/mattermost/platform/web/react && npm start & echo starting go web server -cd /go/src/github.com/mattermost/platform/; go run mattermost.go -config=config.json & +cd /go/src/github.com/mattermost/platform/; go run mattermost.go -config=config_docker.json & echo starting compass watch cd /go/src/github.com/mattermost/platform/web/sass-files && compass watch diff --git a/config/main.cf b/docker/main.cf similarity index 64% rename from config/main.cf rename to docker/main.cf index 72eba333ff..ed97d37efd 100644 --- a/config/main.cf +++ b/docker/main.cf @@ -1,21 +1,11 @@ -# See /usr/share/postfix/main.cf.dist for a commented, more complete version - - -# Debian specific: Specifying a file name will cause the first -# line of that file to be used as the name. The Debian default -# is /etc/mailname. myorigin = mattermost.com myhostname = mattermost.com smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) biff = no -# appending .domain is the MUA's job. append_dot_mydomain = no -# Uncomment the next line to generate "delayed mail" warnings -#delay_warning_time = 4h - readme_directory = no # TLS parameters @@ -26,9 +16,6 @@ smtp_use_tls=no smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache -# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for -# information on enabling SSL in the smtp client. - smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases diff --git a/utils/config_test.go b/utils/config_test.go index f6746f3ac4..9067dc6478 100644 --- a/utils/config_test.go +++ b/utils/config_test.go @@ -4,7 +4,7 @@ package utils import ( - //"os" + "os" "testing" ) @@ -12,7 +12,6 @@ func TestConfig(t *testing.T) { LoadConfig("config.json") } -/* func TestEnvOverride(t *testing.T) { os.Setenv("MATTERMOST_DOMAIN", "testdomain.com") @@ -26,4 +25,3 @@ func TestEnvOverride(t *testing.T) { t.Fail() } } -*/ From 6eb3775956974c510122261346edc5fe230f3cf3 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Wed, 17 Jun 2015 11:50:51 -0400 Subject: [PATCH 22/35] Adding check of email configuation settings when config file is loaded --- utils/config.go | 5 +++ utils/mail.go | 108 +++++++++++++++++++++++++++++++----------------- 2 files changed, 76 insertions(+), 37 deletions(-) diff --git a/utils/config.go b/utils/config.go index 745887c703..4180417064 100644 --- a/utils/config.go +++ b/utils/config.go @@ -222,6 +222,11 @@ func LoadConfig(fileName string) { config.ServiceSettings.Domain = os.Getenv("MATTERMOST_DOMAIN") } + // Validates our mail settings + if err := CheckMailSettings(); err != nil { + l4g.Error("Email settings are not valid err=%v", err) + } + configureLog(config.LogSettings) Cfg = &config diff --git a/utils/mail.go b/utils/mail.go index bf1cc9d465..2fb7f801d5 100644 --- a/utils/mail.go +++ b/utils/mail.go @@ -13,6 +13,69 @@ import ( "net/smtp" ) +func CheckMailSettings() *model.AppError { + if len(Cfg.EmailSettings.SMTPServer) == 0 { + return model.NewAppError("CheckMailSettings", "No email settings present, mail will not be sent", "") + } + conn, err := connectToSMTPServer() + if err != nil { + return err + } + defer conn.Close() + c, err2 := newSMTPClient(conn) + if err2 != nil { + return err + } + defer c.Quit() + defer c.Close() + + return nil +} + +func connectToSMTPServer() (net.Conn, *model.AppError) { + host, _, _ := net.SplitHostPort(Cfg.EmailSettings.SMTPServer) + + var conn net.Conn + var err error + + if Cfg.EmailSettings.UseTLS { + tlsconfig := &tls.Config{ + InsecureSkipVerify: true, + ServerName: host, + } + + conn, err = tls.Dial("tcp", Cfg.EmailSettings.SMTPServer, tlsconfig) + if err != nil { + return nil, model.NewAppError("SendMail", "Failed to open TLS connection", err.Error()) + } + } else { + conn, err = net.Dial("tcp", Cfg.EmailSettings.SMTPServer) + if err != nil { + return nil, model.NewAppError("SendMail", "Failed to open connection", err.Error()) + } + } + + return conn, nil +} + +func newSMTPClient(conn net.Conn) (*smtp.Client, *model.AppError) { + host, _, _ := net.SplitHostPort(Cfg.EmailSettings.SMTPServer) + c, err := smtp.NewClient(conn, host) + if err != nil { + l4g.Error("Failed to open a connection to SMTP server %v", err) + return nil, model.NewAppError("SendMail", "Failed to open TLS connection", err.Error()) + } + // GO does not support plain auth over a non encrypted connection. + // so if not tls then no auth + auth := smtp.PlainAuth("", Cfg.EmailSettings.SMTPUsername, Cfg.EmailSettings.SMTPPassword, host) + if Cfg.EmailSettings.UseTLS { + if err = c.Auth(auth); err != nil { + return nil, model.NewAppError("SendMail", "Failed to authenticate on SMTP server", err.Error()) + } + } + return c, nil +} + func SendMail(to, subject, body string) *model.AppError { fromMail := mail.Address{"", Cfg.EmailSettings.FeedbackEmail} @@ -36,53 +99,24 @@ func SendMail(to, subject, body string) *model.AppError { return nil } - host, _, _ := net.SplitHostPort(Cfg.EmailSettings.SMTPServer) - - auth := smtp.PlainAuth("", Cfg.EmailSettings.SMTPUsername, Cfg.EmailSettings.SMTPPassword, host) - - var conn net.Conn - var err error - - if Cfg.EmailSettings.UseTLS { - tlsconfig := &tls.Config{ - InsecureSkipVerify: true, - ServerName: host, - } - - conn, err = tls.Dial("tcp", Cfg.EmailSettings.SMTPServer, tlsconfig) - if err != nil { - return model.NewAppError("SendMail", "Failed to open TLS connection", err.Error()) - } - } else { - conn, err = net.Dial("tcp", Cfg.EmailSettings.SMTPServer) - if err != nil { - return model.NewAppError("SendMail", "Failed to open connection", err.Error()) - } + conn, err1 := connectToSMTPServer() + if err1 != nil { + return err1 } - defer conn.Close() - c, err := smtp.NewClient(conn, host) - if err != nil { - l4g.Error("Failed to open a connection to SMTP server %v", err) - return model.NewAppError("SendMail", "Failed to open TLS connection", err.Error()) + c, err2 := newSMTPClient(conn) + if err2 != nil { + return err2 } defer c.Quit() defer c.Close() - // GO does not support plain auth over a non encrypted connection. - // so if not tls then no auth - if Cfg.EmailSettings.UseTLS { - if err = c.Auth(auth); err != nil { - return model.NewAppError("SendMail", "Failed to authenticate on SMTP server", err.Error()) - } - } - - if err = c.Mail(fromMail.Address); err != nil { + if err := c.Mail(fromMail.Address); err != nil { return model.NewAppError("SendMail", "Failed to add from email address", err.Error()) } - if err = c.Rcpt(toMail.Address); err != nil { + if err := c.Rcpt(toMail.Address); err != nil { return model.NewAppError("SendMail", "Failed to add to email address", err.Error()) } From 20ead3585d77d32862065749bdb25eed9fee0f25 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Wed, 17 Jun 2015 12:25:41 -0400 Subject: [PATCH 23/35] fix an auto-complete bug for mentions --- web/react/components/textbox.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/react/components/textbox.jsx b/web/react/components/textbox.jsx index 45798809ff..7a4762e074 100644 --- a/web/react/components/textbox.jsx +++ b/web/react/components/textbox.jsx @@ -204,7 +204,7 @@ module.exports = React.createClass({ // If there is a space after the last @, nothing to do. if (lastSpace > atIndex || lastCharSpace > atIndex) { - this.setState({ mentionText: '-1' }); + this.updateMentionTab('-1', null); return; } From bf1e35bc19d6cb1308e328443a4a411eae6549ae Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Wed, 17 Jun 2015 09:53:15 -0700 Subject: [PATCH 24/35] Simplified code changes --- config/config.json | 1 - web/react/components/login.jsx | 4 ++-- web/static/config/config.js | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/config/config.json b/config/config.json index 3d2c26716d..0ca072194b 100644 --- a/config/config.json +++ b/config/config.json @@ -56,7 +56,6 @@ "EmailSettings": { "SMTPUsername": "", "SMTPPassword": "", - "SMTPServer": "localhost:25", "UseTLS": false, "FeedbackEmail": "feedback@xxxxxxmustbefilledin.com", "FeedbackName": "", diff --git a/web/react/components/login.jsx b/web/react/components/login.jsx index 85be3d45b6..65f1da1f88 100644 --- a/web/react/components/login.jsx +++ b/web/react/components/login.jsx @@ -52,7 +52,7 @@ var FindTeamDomain = React.createClass({
{ config.SiteName }
- Enter your {strings.TeamPossessive} domain. + Enter your {strings.Team}'s domain.

@@ -65,7 +65,7 @@ var FindTeamDomain = React.createClass({
- Don't remember your {strings.TeamPossessive} domain? Find it here + Don't remember your {strings.Team}'s domain? Find it here


diff --git a/web/static/config/config.js b/web/static/config/config.js index 12cbb4019e..a9a3e732ec 100644 --- a/web/static/config/config.js +++ b/web/static/config/config.js @@ -33,8 +33,6 @@ var config = { var strings = { Team: "team", TeamPlural: "teams", - TeamPossessive: "team's", Company: "company", CompanyPlural: "companies", - CompanyPossessive: "company's" }; From 3d1975dea40c96ca65f7203cf32a11f9fd65bfc3 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Wed, 17 Jun 2015 09:54:06 -0700 Subject: [PATCH 25/35] Removed unnecessary comma --- web/static/config/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/static/config/config.js b/web/static/config/config.js index a9a3e732ec..82d4bbf702 100644 --- a/web/static/config/config.js +++ b/web/static/config/config.js @@ -34,5 +34,5 @@ var strings = { Team: "team", TeamPlural: "teams", Company: "company", - CompanyPlural: "companies", + CompanyPlural: "companies" }; From f74ced758f083f6d7b75ad08fe2d18303d0e6465 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Tue, 16 Jun 2015 17:08:06 -0700 Subject: [PATCH 26/35] Added in basic changes necessary to fix some typos. Needs further tests and changes to other config files --- web/react/components/login.jsx | 6 +++--- web/static/config/config.js | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/web/react/components/login.jsx b/web/react/components/login.jsx index 103a93bc68..85be3d45b6 100644 --- a/web/react/components/login.jsx +++ b/web/react/components/login.jsx @@ -52,20 +52,20 @@ var FindTeamDomain = React.createClass({
{ config.SiteName }
- Enter your {strings.TeamPlural} domain. + Enter your {strings.TeamPossessive} domain.

{ server_error } - +
- Don't remember your {strings.TeamPlural} domain? Find it here + Don't remember your {strings.TeamPossessive} domain? Find it here


diff --git a/web/static/config/config.js b/web/static/config/config.js index 5a12942c86..12cbb4019e 100644 --- a/web/static/config/config.js +++ b/web/static/config/config.js @@ -33,6 +33,8 @@ var config = { var strings = { Team: "team", TeamPlural: "teams", + TeamPossessive: "team's", Company: "company", - CompanyPlural: "companies" -} + CompanyPlural: "companies", + CompanyPossessive: "company's" +}; From 519bebcaeeef46bbe8bbc8ac17e348316fd4903f Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Wed, 17 Jun 2015 09:53:15 -0700 Subject: [PATCH 27/35] Simplified code changes --- config/config.json | 1 - web/react/components/login.jsx | 4 ++-- web/static/config/config.js | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/config/config.json b/config/config.json index 3d2c26716d..0ca072194b 100644 --- a/config/config.json +++ b/config/config.json @@ -56,7 +56,6 @@ "EmailSettings": { "SMTPUsername": "", "SMTPPassword": "", - "SMTPServer": "localhost:25", "UseTLS": false, "FeedbackEmail": "feedback@xxxxxxmustbefilledin.com", "FeedbackName": "", diff --git a/web/react/components/login.jsx b/web/react/components/login.jsx index 85be3d45b6..65f1da1f88 100644 --- a/web/react/components/login.jsx +++ b/web/react/components/login.jsx @@ -52,7 +52,7 @@ var FindTeamDomain = React.createClass({
{ config.SiteName }
- Enter your {strings.TeamPossessive} domain. + Enter your {strings.Team}'s domain.

@@ -65,7 +65,7 @@ var FindTeamDomain = React.createClass({
- Don't remember your {strings.TeamPossessive} domain? Find it here + Don't remember your {strings.Team}'s domain? Find it here


diff --git a/web/static/config/config.js b/web/static/config/config.js index 12cbb4019e..a9a3e732ec 100644 --- a/web/static/config/config.js +++ b/web/static/config/config.js @@ -33,8 +33,6 @@ var config = { var strings = { Team: "team", TeamPlural: "teams", - TeamPossessive: "team's", Company: "company", CompanyPlural: "companies", - CompanyPossessive: "company's" }; From 806eb40f5f3d6c89b7d06fb19ec75420ff4e9c28 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Wed, 17 Jun 2015 09:54:06 -0700 Subject: [PATCH 28/35] Removed unnecessary comma --- web/static/config/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/static/config/config.js b/web/static/config/config.js index a9a3e732ec..82d4bbf702 100644 --- a/web/static/config/config.js +++ b/web/static/config/config.js @@ -34,5 +34,5 @@ var strings = { Team: "team", TeamPlural: "teams", Company: "company", - CompanyPlural: "companies", + CompanyPlural: "companies" }; From 2a427254f4263b1d0b5f7c44268a0d34948971a7 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Wed, 17 Jun 2015 11:16:03 -0700 Subject: [PATCH 29/35] Fixing compatibility --- config/config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.json b/config/config.json index 0ca072194b..6e5fb8d0e9 100644 --- a/config/config.json +++ b/config/config.json @@ -56,6 +56,7 @@ "EmailSettings": { "SMTPUsername": "", "SMTPPassword": "", + "SMTPServer": "", "UseTLS": false, "FeedbackEmail": "feedback@xxxxxxmustbefilledin.com", "FeedbackName": "", From cbc3f4c5c1824695877c2e1419493d92acd97543 Mon Sep 17 00:00:00 2001 From: it33 Date: Thu, 18 Jun 2015 06:42:40 -0700 Subject: [PATCH 30/35] Update NOTICE.txt --- NOTICE.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/NOTICE.txt b/NOTICE.txt index 07c6a8bf4f..a58e425bb1 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,4 +1,9 @@ Mattermost Platform Preview Copyright 2015 SpinPunch, Inc. -Regular expression support is provided by the PCRE library package, which is open source software, written by Philip Hazel, and copyright by the University of Cambridge, England. The original software is available from ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ +This product contains a modified portion of 'draw2d', a Go library to draw 2d geometrical forms on images by Laurent Le Goff + +* LICENSE: + * http://opensource.org/licenses/BSD-3-Clause (BSD 3-Clause) +* HOMEPAGE: + * https://code.google.com/p/draw2d/ From e05f9bf15e51a918ed3495ec131c2c462917d8f1 Mon Sep 17 00:00:00 2001 From: it33 Date: Thu, 18 Jun 2015 07:04:52 -0700 Subject: [PATCH 31/35] Update NOTICE.txt --- NOTICE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NOTICE.txt b/NOTICE.txt index a58e425bb1..1d867eb5b1 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,5 +1,5 @@ Mattermost Platform Preview -Copyright 2015 SpinPunch, Inc. +© 2015 Spinpunch, Inc. All Rights Reserved. See LICENSE.txt for license information. This product contains a modified portion of 'draw2d', a Go library to draw 2d geometrical forms on images by Laurent Le Goff From 1f66c44632369f635b397dfb2b01a026f39b51a5 Mon Sep 17 00:00:00 2001 From: it33 Date: Thu, 18 Jun 2015 07:05:42 -0700 Subject: [PATCH 32/35] Update NOTICE.txt --- NOTICE.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NOTICE.txt b/NOTICE.txt index 1d867eb5b1..fd5fc74b51 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,6 +1,8 @@ Mattermost Platform Preview © 2015 Spinpunch, Inc. All Rights Reserved. See LICENSE.txt for license information. +NOTICES: + This product contains a modified portion of 'draw2d', a Go library to draw 2d geometrical forms on images by Laurent Le Goff * LICENSE: From 65318de9ae18b4e01d110effaa1576843ccf3b78 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Thu, 18 Jun 2015 15:34:23 -0700 Subject: [PATCH 33/35] Changed the new messages separator location in the markup to be at the same level as the date seperator --- web/react/components/post_list.jsx | 12 +++++------- web/react/utils/utils.jsx | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/web/react/components/post_list.jsx b/web/react/components/post_list.jsx index 65247b7052..47ecc16809 100644 --- a/web/react/components/post_list.jsx +++ b/web/react/components/post_list.jsx @@ -444,13 +444,11 @@ module.exports = React.createClass({ if (post.create_at > last_viewed && !rendered_last_viewed) { rendered_last_viewed = true; postCtls.push( -
-
-
-
New Messages
-
- {postCtl} -
+
+
+
New Messages
+ {postCtl} +
); } else { postCtls.push(postCtl); diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 72ed48faf5..8fc25cc612 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -716,7 +716,7 @@ Image.prototype.load = function(url, progressCallback) { m = h.match( /^Content-Type\:\s*(.*?)$/mi ), mimeType = m[ 1 ] || 'image/png'; - var blob = new Blob([this.response], { type: mimeType }); + var blob = new Blob([this.response.buffer], { type: mimeType }); thisImg.src = window.URL.createObjectURL(blob); }; xmlHTTP.onprogress = function(e) { From 8ae7afa5cc0119c7308aa87ce65c3c6c875da985 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Thu, 18 Jun 2015 15:38:03 -0700 Subject: [PATCH 34/35] Removed extraneous code --- web/react/utils/utils.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 8fc25cc612..72ed48faf5 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -716,7 +716,7 @@ Image.prototype.load = function(url, progressCallback) { m = h.match( /^Content-Type\:\s*(.*?)$/mi ), mimeType = m[ 1 ] || 'image/png'; - var blob = new Blob([this.response.buffer], { type: mimeType }); + var blob = new Blob([this.response], { type: mimeType }); thisImg.src = window.URL.createObjectURL(blob); }; xmlHTTP.onprogress = function(e) { From 32025e43799324523988af040085d95ec6b6e80e Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Thu, 18 Jun 2015 11:46:40 -0700 Subject: [PATCH 35/35] Removed extraneous post control from within new message separator --- web/react/components/post_list.jsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/web/react/components/post_list.jsx b/web/react/components/post_list.jsx index 47ecc16809..97f9fa943b 100644 --- a/web/react/components/post_list.jsx +++ b/web/react/components/post_list.jsx @@ -447,12 +447,10 @@ module.exports = React.createClass({

New Messages
- {postCtl}
); - } else { - postCtls.push(postCtl); } + postCtls.push(postCtl); previousPostDay = utils.getDateForUnixTicks(post.create_at); }