From 591ccf564c25b1642d9fcab0cd18e5a759f6b7b2 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Fri, 10 Jan 2025 20:22:33 -0600 Subject: [PATCH 01/11] Working changes --- install/ubuntu/etc/systemd/system/homebrewery.service | 2 +- install/ubuntu/install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install/ubuntu/etc/systemd/system/homebrewery.service b/install/ubuntu/etc/systemd/system/homebrewery.service index 939d11fb8..4152943d9 100644 --- a/install/ubuntu/etc/systemd/system/homebrewery.service +++ b/install/ubuntu/etc/systemd/system/homebrewery.service @@ -3,7 +3,7 @@ Description=Homebrewery Web Server [Service] User=root -After=mongodb +Requires=mongodb Environment=NODE_ENV=local WorkingDirectory=/usr/local/homebrewery ExecStart=node server.js diff --git a/install/ubuntu/install.sh b/install/ubuntu/install.sh index ebad7f3f2..e1de299e7 100644 --- a/install/ubuntu/install.sh +++ b/install/ubuntu/install.sh @@ -4,7 +4,7 @@ echo ::Install CURL apt install -y curl echo ::Add NodeJS source to package repo -curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - +curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - # Install required packages echo ::Install Homebrewery requirements From 533586f516b02b290942e969f3f7c1c208f1d545 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Fri, 10 Jan 2025 21:09:50 -0600 Subject: [PATCH 02/11] Rough draft of update. --- install/README.UBUNTU.md | 4 +++- .../etc/systemd/system/homebrewery.service | 3 ++- install/ubuntu/install.sh | 18 ++++++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/install/README.UBUNTU.md b/install/README.UBUNTU.md index d14cfef46..d97d6b362 100644 --- a/install/README.UBUNTU.md +++ b/install/README.UBUNTU.md @@ -24,12 +24,14 @@ These instructions assume that you are installing to a completely new, fresh Ubu These installation instructions have been tested on the following Ubuntu releases: -- *ubuntu-20.04.3-desktop-amd64* +- *ubuntu-24.04.1-desktop-amd64* ## Final Notes While this installation process works successfully at the time of writing (December 19, 2021), it relies on all of the Node.JS packages used in the HomeBrewery project retaining their cross-platform capabilities to continue to function. This is one of the inherent advantages of Node.JS, but it is by no means guaranteed and as such, functionality or even installation may fail without warning at some point in the future. +Earlier versions of Ubuntu may requier an alternate Mongo setup, see https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/ for assistance. + Regards, G December 19, 2021 diff --git a/install/ubuntu/etc/systemd/system/homebrewery.service b/install/ubuntu/etc/systemd/system/homebrewery.service index 4152943d9..defa85a31 100644 --- a/install/ubuntu/etc/systemd/system/homebrewery.service +++ b/install/ubuntu/etc/systemd/system/homebrewery.service @@ -3,7 +3,8 @@ Description=Homebrewery Web Server [Service] User=root -Requires=mongodb +BindsTo=mongod.service +After=mongod.service Environment=NODE_ENV=local WorkingDirectory=/usr/local/homebrewery ExecStart=node server.js diff --git a/install/ubuntu/install.sh b/install/ubuntu/install.sh index e1de299e7..13265779a 100644 --- a/install/ubuntu/install.sh +++ b/install/ubuntu/install.sh @@ -6,9 +6,21 @@ apt install -y curl echo ::Add NodeJS source to package repo curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - +# Add Mongo CE Source +echo ::Add Mongo CE source to package repo +curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \ + sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg \ + --dearmor +echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list +sudo apt-get update + # Install required packages echo ::Install Homebrewery requirements -apt satisfy -y git nodejs npm mongodb +apt satisfy -y git nodejs npm mongodb-org + +# Enable and start Mongo +systemctl enable mongod +systemctl start mongod # Clone Homebrewery repo echo ::Get Homebrewery files @@ -23,9 +35,7 @@ npm audit fix npm run postinstall # Create Homebrewery service -echo ::Create Homebrewery service -ln -s /usr/local/homebrewery/install/ubuntu/etc/systemd/system/homebrewery.service /etc/systemd/system/homebrewery.service -systemctl daemon-reload +echo ::Create systemctl daemon-reload echo ::Set Homebrewery to start automatically systemctl enable homebrewery From 3578a7e1e2d10d067624acffa92ea75bd576521b Mon Sep 17 00:00:00 2001 From: David Bolack Date: Fri, 10 Jan 2025 22:52:18 -0600 Subject: [PATCH 03/11] Updated for last three LTS releases --- install/README.UBUNTU.md | 4 +++- install/ubuntu/install.sh | 50 +++++++++++++++++++++++++++++++++------ 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/install/README.UBUNTU.md b/install/README.UBUNTU.md index d97d6b362..13fa7631d 100644 --- a/install/README.UBUNTU.md +++ b/install/README.UBUNTU.md @@ -24,7 +24,9 @@ These instructions assume that you are installing to a completely new, fresh Ubu These installation instructions have been tested on the following Ubuntu releases: -- *ubuntu-24.04.1-desktop-amd64* + - *ubuntu-24.04.1-desktop-amd64* + - *ubuntu-22.04.5-desktop-amd64* + - *ubuntu-20.04.6-desktop-amd64* ## Final Notes diff --git a/install/ubuntu/install.sh b/install/ubuntu/install.sh index 13265779a..a0fcc8c17 100644 --- a/install/ubuntu/install.sh +++ b/install/ubuntu/install.sh @@ -1,5 +1,22 @@ #!/bin/sh +# Detect Ubuntu Version +export DISTRO=$(grep "^NAME=" /etc/os-release | awk -F '=' '{print $2}' | sed 's/"//g') +export DISTRO_VER=$(grep "VERSION_ID=" /etc/os-release | awk -F '=' '{print $2}' | sed 's/"//g') +export MATCHED="Yes" + +if [ "${DISTRO}" != "Ubuntu" ]; +then + echo :: Ubuntu not detected. Are you using an alternate spin or derivative? + echo :: Detected - ${DISTRO} + read -p [y/N] YESNO + if [ "${YESNO}" != "Y" ] && [ ]"${YESNO}" != "y" ]; then + exit + fi + + MATCHED="No" +fi + # Install CURL and add required NodeJS source to package repo echo ::Install CURL apt install -y curl @@ -7,13 +24,30 @@ echo ::Add NodeJS source to package repo curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - # Add Mongo CE Source -echo ::Add Mongo CE source to package repo -curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \ - sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg \ - --dearmor -echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list -sudo apt-get update +if [ ${DISTRO} = "Ubuntu" ]; + then + echo ::Add Mongo CE source to package repo + curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \ + sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg \ + --dearmor + if [ "${DISTRO_VER}" == "24.04" ]; then + echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list + elif [ "${DISTRO_VER}" == "22.04" ]; then + echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list + elif [ "${DISTRO_VER}" == "20.04" ]; then + echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list + else + MATCHED="No" + fi + sudo apt-get update +fi +if [ ${MATCHED} == "No" ]; then + echo :: WARNING + echo :: Unable to determine Ubuntu version for Mongo installation purposes. + echo :: Please check your spin/distro documentation to install Mongo CE and enable it on startup. +fi + # Install required packages echo ::Install Homebrewery requirements apt satisfy -y git nodejs npm mongodb-org @@ -35,7 +69,9 @@ npm audit fix npm run postinstall # Create Homebrewery service -echo ::Create systemctl daemon-reload +echo ::Create Homebrewery service +ln -s /usr/local/homebrewery/install/ubuntu/etc/systemd/system/homebrewery.service /etc/systemd/system/homebrewery.service +systemctl daemon-reload echo ::Set Homebrewery to start automatically systemctl enable homebrewery From 9d67724da9c4d042092663055764bf3c7a662b6a Mon Sep 17 00:00:00 2001 From: David Bolack Date: Fri, 10 Jan 2025 23:22:22 -0600 Subject: [PATCH 04/11] Wrap titles in error messages with pre blocks to prevent rendering. --- client/homebrew/pages/errorPage/errors/errorIndex.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/homebrew/pages/errorPage/errors/errorIndex.js b/client/homebrew/pages/errorPage/errors/errorIndex.js index ccdd86768..73040ec68 100644 --- a/client/homebrew/pages/errorPage/errors/errorIndex.js +++ b/client/homebrew/pages/errorPage/errors/errorIndex.js @@ -89,7 +89,7 @@ const errorIndex = (props)=>{ : - **Brew Title:** ${props.brew.brewTitle || 'Unable to show title'} + **Brew Title:** \`${props.brew.brewTitle || 'Unable to show title'}\` **Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'} @@ -104,7 +104,7 @@ const errorIndex = (props)=>{ : - **Brew Title:** ${props.brew.brewTitle || 'Unable to show title'} + **Brew Title:** \`${props.brew.brewTitle || 'Unable to show title'}\` **Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'} @@ -181,7 +181,7 @@ const errorIndex = (props)=>{ **Brew ID:** ${props.brew.brewId} - **Brew Title:** ${props.brew.brewTitle}`, + **Brew Title:** \`${props.brew.brewTitle}\`, // ####### Admin page error ####### '52' : dedent` From 80003f6c5735a290f6ab6e22f377bf525f90eabb Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sat, 11 Jan 2025 08:44:11 -0600 Subject: [PATCH 05/11] Return overremoved backtick --- client/homebrew/pages/errorPage/errors/errorIndex.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/pages/errorPage/errors/errorIndex.js b/client/homebrew/pages/errorPage/errors/errorIndex.js index 73040ec68..f05f93838 100644 --- a/client/homebrew/pages/errorPage/errors/errorIndex.js +++ b/client/homebrew/pages/errorPage/errors/errorIndex.js @@ -181,7 +181,7 @@ const errorIndex = (props)=>{ **Brew ID:** ${props.brew.brewId} - **Brew Title:** \`${props.brew.brewTitle}\`, + **Brew Title:** \`${props.brew.brewTitle}\``, // ####### Admin page error ####### '52' : dedent` From abc830eda2210a64607ff338ecec376e1957ff73 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Fri, 24 Jan 2025 14:09:13 -0600 Subject: [PATCH 06/11] Change backticks to `
` literals.

---
 client/homebrew/pages/errorPage/errors/errorIndex.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/client/homebrew/pages/errorPage/errors/errorIndex.js b/client/homebrew/pages/errorPage/errors/errorIndex.js
index f05f93838..caa5e662c 100644
--- a/client/homebrew/pages/errorPage/errors/errorIndex.js
+++ b/client/homebrew/pages/errorPage/errors/errorIndex.js
@@ -89,7 +89,7 @@ const errorIndex = (props)=>{
 		
 		:
 
-		**Brew Title:** \`${props.brew.brewTitle || 'Unable to show title'}\`
+		**Brew Title:** 
${props.brew.brewTitle || 'Unable to show title'}
**Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'} @@ -104,7 +104,7 @@ const errorIndex = (props)=>{ : - **Brew Title:** \`${props.brew.brewTitle || 'Unable to show title'}\` + **Brew Title:**
${props.brew.brewTitle || 'Unable to show title'}
**Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'} @@ -181,7 +181,7 @@ const errorIndex = (props)=>{ **Brew ID:** ${props.brew.brewId} - **Brew Title:** \`${props.brew.brewTitle}\``, + **Brew Title:**
${props.brew.brewTitle}
`, // ####### Admin page error ####### '52' : dedent` From d69288076af8f86e2f877b5f02d09be79e25ba48 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 27 Jan 2025 23:34:50 -0500 Subject: [PATCH 07/11] Change to _.escape() to escape HTML characters --- client/homebrew/pages/errorPage/errors/errorIndex.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/homebrew/pages/errorPage/errors/errorIndex.js b/client/homebrew/pages/errorPage/errors/errorIndex.js index caa5e662c..1353cf889 100644 --- a/client/homebrew/pages/errorPage/errors/errorIndex.js +++ b/client/homebrew/pages/errorPage/errors/errorIndex.js @@ -1,4 +1,5 @@ const dedent = require('dedent-tabs').default; +import _ from 'lodash'; const loginUrl = 'https://www.naturalcrit.com/login'; @@ -89,7 +90,7 @@ const errorIndex = (props)=>{ : - **Brew Title:**
${props.brew.brewTitle || 'Unable to show title'}
+ **Brew Title:** ${_.escape(props.brew.brewTitle) || 'Unable to show title'} **Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'} @@ -104,7 +105,7 @@ const errorIndex = (props)=>{ : - **Brew Title:**
${props.brew.brewTitle || 'Unable to show title'}
+ **Brew Title:** ${_.escape(props.brew.brewTitle) || 'Unable to show title'} **Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'} @@ -181,7 +182,7 @@ const errorIndex = (props)=>{ **Brew ID:** ${props.brew.brewId} - **Brew Title:**
${props.brew.brewTitle}
`, + **Brew Title:** ${_.escape(props.brew.brewTitle)}`, // ####### Admin page error ####### '52' : dedent` From 73c2be147cb56e18b515abaeb61c52e9a15551f3 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Tue, 28 Jan 2025 00:13:51 -0500 Subject: [PATCH 08/11] Custom escape function --- client/homebrew/pages/errorPage/errors/errorIndex.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client/homebrew/pages/errorPage/errors/errorIndex.js b/client/homebrew/pages/errorPage/errors/errorIndex.js index 1353cf889..5c21b719c 100644 --- a/client/homebrew/pages/errorPage/errors/errorIndex.js +++ b/client/homebrew/pages/errorPage/errors/errorIndex.js @@ -7,6 +7,10 @@ const loginUrl = 'https://www.naturalcrit.com/login'; //050-100 : Other pages errors const errorIndex = (props)=>{ + const escape = (text) => { + return text.split('').map(char => `\\${char}`).join(''); + }; + return { // Default catch all '00' : dedent` @@ -90,7 +94,7 @@ const errorIndex = (props)=>{ : - **Brew Title:** ${_.escape(props.brew.brewTitle) || 'Unable to show title'} + **Brew Title:** ${escape(props.brew.brewTitle) || 'Unable to show title'} **Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'} @@ -105,7 +109,7 @@ const errorIndex = (props)=>{ : - **Brew Title:** ${_.escape(props.brew.brewTitle) || 'Unable to show title'} + **Brew Title:** ${escape(props.brew.brewTitle) || 'Unable to show title'} **Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'} @@ -182,7 +186,7 @@ const errorIndex = (props)=>{ **Brew ID:** ${props.brew.brewId} - **Brew Title:** ${_.escape(props.brew.brewTitle)}`, + **Brew Title:** ${escape(props.brew.brewTitle)}`, // ####### Admin page error ####### '52' : dedent` From ecd8869097a8c81260f572f24ae278185b3ddda9 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Tue, 28 Jan 2025 00:17:08 -0500 Subject: [PATCH 09/11] Add a comment --- client/homebrew/pages/errorPage/errors/errorIndex.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/homebrew/pages/errorPage/errors/errorIndex.js b/client/homebrew/pages/errorPage/errors/errorIndex.js index 5c21b719c..fe8e505e5 100644 --- a/client/homebrew/pages/errorPage/errors/errorIndex.js +++ b/client/homebrew/pages/errorPage/errors/errorIndex.js @@ -3,14 +3,15 @@ import _ from 'lodash'; const loginUrl = 'https://www.naturalcrit.com/login'; +// Prevent parsing text (e.g. document titles) as markdown +const escape = (text) => { + return text.split('').map(char => `\\${char}`).join(''); +}; + //001-050 : Brew errors //050-100 : Other pages errors const errorIndex = (props)=>{ - const escape = (text) => { - return text.split('').map(char => `\\${char}`).join(''); - }; - return { // Default catch all '00' : dedent` From 6a31d612e632e95d3ccfdf410f9e8186a5af1fb5 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Tue, 28 Jan 2025 00:24:15 -0500 Subject: [PATCH 10/11] Escape to HTML entities --- client/homebrew/pages/errorPage/errors/errorIndex.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/pages/errorPage/errors/errorIndex.js b/client/homebrew/pages/errorPage/errors/errorIndex.js index fe8e505e5..63cb2619f 100644 --- a/client/homebrew/pages/errorPage/errors/errorIndex.js +++ b/client/homebrew/pages/errorPage/errors/errorIndex.js @@ -5,7 +5,7 @@ const loginUrl = 'https://www.naturalcrit.com/login'; // Prevent parsing text (e.g. document titles) as markdown const escape = (text) => { - return text.split('').map(char => `\\${char}`).join(''); + return text.split('').map(char => `&#${char.charCodeAt(0)};`).join(''); }; //001-050 : Brew errors From 3e78b037850390b3e94a06d9021c6c1417ea7f11 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Tue, 28 Jan 2025 00:28:46 -0500 Subject: [PATCH 11/11] Remove lodash again --- client/homebrew/pages/errorPage/errors/errorIndex.js | 1 - 1 file changed, 1 deletion(-) diff --git a/client/homebrew/pages/errorPage/errors/errorIndex.js b/client/homebrew/pages/errorPage/errors/errorIndex.js index 63cb2619f..f7614a37a 100644 --- a/client/homebrew/pages/errorPage/errors/errorIndex.js +++ b/client/homebrew/pages/errorPage/errors/errorIndex.js @@ -1,5 +1,4 @@ const dedent = require('dedent-tabs').default; -import _ from 'lodash'; const loginUrl = 'https://www.naturalcrit.com/login';