summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReed Garmsen <rgarmsen2295@gmail.com>2015-06-17 07:54:30 -0700
committerReed Garmsen <rgarmsen2295@gmail.com>2015-06-17 07:54:30 -0700
commit8e65f38979696df993c15a5c3752f4bba91a0978 (patch)
tree7ca8cb11aed7753b04d84fedfe0630879c30a069
parent9e0d4f70e01ecf8f157fed6e6145284c202bc44a (diff)
parent0d6ed4a6ab14c4fc4bbdf4bd0b63c19d896a7b48 (diff)
downloadchat-8e65f38979696df993c15a5c3752f4bba91a0978.tar.gz
chat-8e65f38979696df993c15a5c3752f4bba91a0978.tar.bz2
chat-8e65f38979696df993c15a5c3752f4bba91a0978.zip
Merge pull request #3 from mattermost/master
to me
-rw-r--r--Dockerfile97
-rw-r--r--config/config.json7
-rw-r--r--config/main.cf41
-rwxr-xr-xdocker-entry.sh120
-rw-r--r--store/sql_team_store_test.go5
-rw-r--r--utils/config.go6
-rw-r--r--utils/config_test.go17
-rw-r--r--utils/mail.go33
-rw-r--r--web/react/components/login.jsx4
-rw-r--r--web/react/components/signup_team_complete.jsx3
-rw-r--r--web/react/components/signup_user_complete.jsx1
-rw-r--r--web/react/utils/utils.jsx12
-rw-r--r--web/static/config/config.js2
13 files changed, 331 insertions, 17 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 000000000..da57550c0
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,97 @@
+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
+
+# Postfix
+RUN apt-get install -y postfix
+
+#
+# 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
+
+# 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
+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 80
diff --git a/config/config.json b/config/config.json
index a6c79efac..3d2c26716 100644
--- a/config/config.json
+++ b/config/config.json
@@ -8,8 +8,8 @@
"FileLocation": ""
},
"ServiceSettings": {
- "SiteName": "XXXXXXMustBeFilledIn",
- "Domain": "xxxxxxmustbefilledin.com",
+ "SiteName": "Mattermost Preview",
+ "Domain": "",
"Mode" : "dev",
"AllowTesting" : false,
"UseSSL": false,
@@ -56,7 +56,8 @@
"EmailSettings": {
"SMTPUsername": "",
"SMTPPassword": "",
- "SMTPServer": "",
+ "SMTPServer": "localhost:25",
+ "UseTLS": false,
"FeedbackEmail": "feedback@xxxxxxmustbefilledin.com",
"FeedbackName": "",
"ApplePushServer": "",
diff --git a/config/main.cf b/config/main.cf
new file mode 100644
index 000000000..72eba333f
--- /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
new file mode 100755
index 000000000..db6ccaa18
--- /dev/null
+++ b/docker-entry.sh
@@ -0,0 +1,120 @@
+#!/bin/bash
+
+mkdir -p web/static/js
+
+echo "127.0.0.1 dockerhost" >> /etc/hosts
+/etc/init.d/networking restart
+
+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 postfix
+/etc/init.d/postfix restart
+
+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.json &
+
+echo starting compass watch
+cd /go/src/github.com/mattermost/platform/web/sass-files && compass watch
diff --git a/store/sql_team_store_test.go b/store/sql_team_store_test.go
index 981817d90..1b03b75fd 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(err)
+ }
if r1 := <-store.Team().GetByDomain(o1.Domain); r1.Err != nil {
t.Fatal(r1.Err)
diff --git a/utils/config.go b/utils/config.go
index 1060c7550..745887c70 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
@@ -216,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 4d37b4e88..f6746f3ac 100644
--- a/utils/config_test.go
+++ b/utils/config_test.go
@@ -4,9 +4,26 @@
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()
+ }
+}
+*/
diff --git a/utils/mail.go b/utils/mail.go
index b8c2f4f9b..bf1cc9d46 100644
--- a/utils/mail.go
+++ b/utils/mail.go
@@ -40,15 +40,26 @@ 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,
+ 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, 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()
c, err := smtp.NewClient(conn, host)
@@ -59,8 +70,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 {
diff --git a/web/react/components/login.jsx b/web/react/components/login.jsx
index 8d82a4b62..103a93bc6 100644
--- a/web/react/components/login.jsx
+++ b/web/react/components/login.jsx
@@ -74,7 +74,7 @@ var FindTeamDomain = React.createClass({
<br/>
<br/>
<div>
- <span>{"Want to create your own " + strings.Team + "?"} <a href="/" className="signup-team-login">Sign up now</a></span>
+ <span>{"Want to create your own " + strings.Team + "?"} <a href={utils.getHomeLink()} className="signup-team-login">Sign up now</a></span>
</div>
</form>
</div>
@@ -188,7 +188,7 @@ module.exports = React.createClass({
<a href="/reset_password">I forgot my password</a>
</div>
<div className="external-link">
- <span>{"Want to create your own " + strings.Team + "?"} <a href={config.HomeLink} className="signup-team-login">Sign up now</a></span>
+ <span>{"Want to create your own " + strings.Team + "?"} <a href={utils.getHomeLink()} className="signup-team-login">Sign up now</a></span>
</div>
</form>
</div>
diff --git a/web/react/components/signup_team_complete.jsx b/web/react/components/signup_team_complete.jsx
index 066161a10..b038679e6 100644
--- a/web/react/components/signup_team_complete.jsx
+++ b/web/react/components/signup_team_complete.jsx
@@ -467,7 +467,8 @@ UsernamePage = React.createClass({
</div>
{ name_error }
</div>
- <p>{"Pick something " + strings.Team + "mates will recognize. Your username is how you will appear to others"}</p>
+ <p>{"Pick something " + strings.Team + "mates will recognize. Your username is how you will appear to others."}</p>
+ <p>It can be made of lowercase letters and numbers.</p>
<button className="btn btn-default" onClick={this.submitBack}><i className="glyphicon glyphicon-chevron-left"></i> Back</button>&nbsp;
<button className="btn-primary btn" onClick={this.submitNext}>Next<i className="glyphicon glyphicon-chevron-right"></i></button>
</div>
diff --git a/web/react/components/signup_user_complete.jsx b/web/react/components/signup_user_complete.jsx
index 0fcdc92b0..146419cf5 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({
<img className="signup-team-logo" src="/static/images/logo.png" />
<h4>Welcome to { config.SiteName }</h4>
<p>{"Choose your username and password for the " + this.props.team_name + " " + strings.Team +"."}</p>
+ <p>Your username can be made of lowercase letters and numbers.</p>
<label className="control-label">Username</label>
<div className={ name_error ? "form-group has-error" : "form-group" }>
<input type="text" ref="name" className="form-control" placeholder="" maxLength="128" />
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 72ed48faf..628d92342 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.protocol + "//" + window.location.host;
+ }
+ parts[0] = "www";
+ return window.location.protocol + "//" + parts.join(".");
+}
diff --git a/web/static/config/config.js b/web/static/config/config.js
index 080f16a30..5a12942c8 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"]
};