diff --git a/client/App.test.js b/client/App.test.js
new file mode 100644
index 0000000..1f03afe
--- /dev/null
+++ b/client/App.test.js
@@ -0,0 +1,8 @@
+import { render, screen } from '@testing-library/react';
+import App from './App';
+
+test('renders learn react link', () => {
+ render();
+ const linkElement = screen.getByText(/learn react/i);
+ expect(linkElement).toBeInTheDocument();
+});
diff --git a/client/App.tsx b/client/App.tsx
new file mode 100644
index 0000000..4a1b298
--- /dev/null
+++ b/client/App.tsx
@@ -0,0 +1,25 @@
+import logo from './logo.svg';
+import './styles/App.css';
+
+function App() {
+ return (
+
+ );
+}
+
+export default App;
diff --git a/client/index.tsx b/client/index.tsx
new file mode 100644
index 0000000..80ecac8
--- /dev/null
+++ b/client/index.tsx
@@ -0,0 +1,17 @@
+import React from 'react';
+import ReactDOM from 'react-dom/client';
+import './styles/index.css';
+import App from './App';
+import reportWebVitals from './reportWebVitals';
+
+const root = ReactDOM.createRoot(document.getElementById('root'));
+root.render(
+
+
+
+);
+
+// If you want to start measuring performance in your app, pass a function
+// to log results (for example: reportWebVitals(console.log))
+// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
+reportWebVitals();
diff --git a/client/logo.svg b/client/logo.svg
new file mode 100644
index 0000000..9dfc1c0
--- /dev/null
+++ b/client/logo.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/client/styles/App.css b/client/styles/App.css
new file mode 100644
index 0000000..74b5e05
--- /dev/null
+++ b/client/styles/App.css
@@ -0,0 +1,38 @@
+.App {
+ text-align: center;
+}
+
+.App-logo {
+ height: 40vmin;
+ pointer-events: none;
+}
+
+@media (prefers-reduced-motion: no-preference) {
+ .App-logo {
+ animation: App-logo-spin infinite 20s linear;
+ }
+}
+
+.App-header {
+ background-color: #282c34;
+ min-height: 100vh;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ font-size: calc(10px + 2vmin);
+ color: white;
+}
+
+.App-link {
+ color: #61dafb;
+}
+
+@keyframes App-logo-spin {
+ from {
+ transform: rotate(0deg);
+ }
+ to {
+ transform: rotate(360deg);
+ }
+}
diff --git a/client/styles/index.css b/client/styles/index.css
new file mode 100644
index 0000000..ec2585e
--- /dev/null
+++ b/client/styles/index.css
@@ -0,0 +1,13 @@
+body {
+ margin: 0;
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
+ 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
+ sans-serif;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
+
+code {
+ font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
+ monospace;
+}
diff --git a/public/favicon.ico b/public/favicon.ico
new file mode 100644
index 0000000..a11777c
Binary files /dev/null and b/public/favicon.ico differ
diff --git a/public/index.html b/public/index.html
new file mode 100644
index 0000000..aa069f2
--- /dev/null
+++ b/public/index.html
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ React App
+
+
+
+
+
+
+
diff --git a/public/logo192.png b/public/logo192.png
new file mode 100644
index 0000000..fc44b0a
Binary files /dev/null and b/public/logo192.png differ
diff --git a/public/logo512.png b/public/logo512.png
new file mode 100644
index 0000000..a4e47a6
Binary files /dev/null and b/public/logo512.png differ
diff --git a/public/manifest.json b/public/manifest.json
new file mode 100644
index 0000000..080d6c7
--- /dev/null
+++ b/public/manifest.json
@@ -0,0 +1,25 @@
+{
+ "short_name": "React App",
+ "name": "Create React App Sample",
+ "icons": [
+ {
+ "src": "favicon.ico",
+ "sizes": "64x64 32x32 24x24 16x16",
+ "type": "image/x-icon"
+ },
+ {
+ "src": "logo192.png",
+ "type": "image/png",
+ "sizes": "192x192"
+ },
+ {
+ "src": "logo512.png",
+ "type": "image/png",
+ "sizes": "512x512"
+ }
+ ],
+ "start_url": ".",
+ "display": "standalone",
+ "theme_color": "#000000",
+ "background_color": "#ffffff"
+}
diff --git a/public/robots.txt b/public/robots.txt
new file mode 100644
index 0000000..e9e57dc
--- /dev/null
+++ b/public/robots.txt
@@ -0,0 +1,3 @@
+# https://www.robotstxt.org/robotstxt.html
+User-agent: *
+Disallow:
diff --git a/roles/chatbridge/defaults/main.yml b/roles/chatbridge/defaults/main.yml
index 8ccde10..a259f2d 100644
--- a/roles/chatbridge/defaults/main.yml
+++ b/roles/chatbridge/defaults/main.yml
@@ -15,3 +15,5 @@ chatbridge_fqdn: localhost
chatbridge_webroot: ""
chatbridge_api_port: 8999
+# false gives you an http-only nginx config
+chatbridge_https: true
diff --git a/roles/chatbridge/handlers/main.yml b/roles/chatbridge/handlers/main.yml
index 88a56ad..b95f5ec 100644
--- a/roles/chatbridge/handlers/main.yml
+++ b/roles/chatbridge/handlers/main.yml
@@ -1,2 +1,9 @@
---
# handlers file for ucla_chat
+
+- name: restart nginx
+ service:
+ name: nginx
+ state: restarted
+ enabled: yes
+ become: yes
diff --git a/roles/chatbridge/tasks/chatbridge.yml b/roles/chatbridge/tasks/chatbridge.yml
index 1b6b5ae..213615e 100644
--- a/roles/chatbridge/tasks/chatbridge.yml
+++ b/roles/chatbridge/tasks/chatbridge.yml
@@ -5,6 +5,6 @@
repo: https://git.jon-e.net/jonny/chatbridge
dest: "{{ chatbridge_user_home }}/chatbridge"
version: "HEAD"
- failed_when: "command_result.failed and 'Local modifications' not in command_result.msg"
+# failed_when: "command_result.failed and 'Local modifications' not in command_result.msg"
diff --git a/roles/chatbridge/tasks/checks.yml b/roles/chatbridge/tasks/checks.yml
new file mode 100644
index 0000000..f3548a0
--- /dev/null
+++ b/roles/chatbridge/tasks/checks.yml
@@ -0,0 +1,7 @@
+- name: check that mandatory variables are correctly defined
+ assert:
+ quiet: yes
+ that: "{{ item }}"
+ fail_msg: "One or more variables are not correctly defined. Check role documentation: https://gitlab.com/nodiscc/xsrv/-/tree/master/roles/matrix_synapse"
+ with_items:
+ - chatbridge_postgres_password is not search("CHANGEME")
diff --git a/roles/chatbridge/tasks/config.yml b/roles/chatbridge/tasks/config.yml
index a3117a4..405f0f8 100644
--- a/roles/chatbridge/tasks/config.yml
+++ b/roles/chatbridge/tasks/config.yml
@@ -5,11 +5,26 @@
src: chatbridge_env.j2
dest: "{{ chatbridge_user_home}}/.env"
-- name: create nginx config
+- name: create https nginx config
become: yes
template:
src: nginx_chatbridge.conf.j2
dest: /etc/nginx/sites-available/chatbridge.conf
+ when:
+ - chatbridge_https is defined
+ - chatbridge_https | bool
+ notify: restart nginx
+
+- name: create http nginx config
+ become: yes
+ template:
+ src: nginx_chatbridge_http.conf.j2
+ dest: /etc/nginx/sites-available/chatbridge.conf
+ when:
+ - chatbridge_https is defined
+ - not chatbridge_https
+ notify: restart nginx
+
- name: link nginx config
become: yes
@@ -18,7 +33,3 @@
src: /etc/nginx/sites-available/chatbridge.conf
dest: /etc/nginx/sites-enabled/chatbridge.conf
-- name: restart nginx
- service:
- name: nginx
- state: restarted
diff --git a/roles/chatbridge/tasks/postgres.yml b/roles/chatbridge/tasks/postgres.yml
new file mode 100644
index 0000000..ced6822
--- /dev/null
+++ b/roles/chatbridge/tasks/postgres.yml
@@ -0,0 +1,41 @@
+- name: install postgresql
+ become: yes
+ apt:
+ state: present
+ package:
+ - postgresql
+ - postgresql-client
+ - python3-psycopg2
+
+- name: postgres is enabled and running
+ become: yes
+ systemd:
+ name: postgresql
+ enabled: true
+ state: started
+
+- name: create postgres user
+ become: yes
+ become_user: postgres
+ postgresql_user:
+ name: "{{ chatbridge_postgres_user }}"
+ password: "{{ chatbridge_postgres_password }}"
+ state: present
+
+- name: create postgres database
+ become: yes
+ become_user: postgres
+ postgresql_db:
+ name: "{{ chatbridge_postgres_db }}"
+ state: present
+ owner: "{{ chatbridge_postgres_user }}"
+
+- name: assign postgres privileges
+ become: yes
+ become_user: postgres
+ postgresql_privs:
+ database: "{{ chatbridge_postgres_db }}"
+ state: present
+ privs: ALL
+ type: database
+ role: "{{ chatbridge_postgres_user }}"
diff --git a/roles/chatbridge/tasks/user.yml b/roles/chatbridge/tasks/user.yml
new file mode 100644
index 0000000..55970c9
--- /dev/null
+++ b/roles/chatbridge/tasks/user.yml
@@ -0,0 +1,24 @@
+- name: Create chatbridge group
+ group:
+ name: "{{ chatbridge_user }}"
+ system: true
+ state: present
+
+- name: Create chatbridge user and home directory
+ become: yes
+ user:
+ name: "{{ chatbridge_user }}"
+ state: present
+ group: "{{ chatbridge_user }}"
+ home: "{{ chatbridge_user_home }}"
+ system: true
+
+
+- name: Create public directory and give permissions to www-data
+ become: yes
+ file:
+ mode: '660'
+ state: directory
+ group: "www-data"
+ owner: "{{ chatbridge_user }}"
+ path: "{{ chatbridge_user_home }}/public"
diff --git a/roles/chatbridge/templates/nginx_chatbridge_http.conf.j2 b/roles/chatbridge/templates/nginx_chatbridge_http.conf.j2
new file mode 100644
index 0000000..fc5293f
--- /dev/null
+++ b/roles/chatbridge/templates/nginx_chatbridge_http.conf.j2
@@ -0,0 +1,21 @@
+server {
+ listen 80;
+ listen [::]:80;
+ server_name {{ chatbridge_fqdn }};
+
+ location {{ chatbridge_webroot }}/api/ {
+ proxy_pass http://127.0.0.1:{{ chatbridge_api_port }}/;
+ }
+
+ location {{ chatbridge_webroot }} {
+ root {{ chatbridge_user_home }}/public;
+ try_files $uri $uri/ $uri/index.html /index.html index.html;
+ }
+
+ location {{ chatbridge_webroot }}/ {
+ rewrite ^{{ chatbridge_webroot }}/?(.*)$ $1 break;
+ root {{ chatbridge_user_home }}/public;
+ try_files $uri $uri/ $uri/index.html =404;
+ }
+
+}