astrXbian_UX-et-webUI/.install/ssb-patchfoo/install

66 lines
2.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# shellcheck disable=SC1091
true
VERSION="TO-V0.5"
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CURRENT_DIR="$(pwd)"
# Install node.js shared module
# shellcheck source=../shared/node.js/install
source "$BASE_DIR/../shared/node.js/install"
# Make folder if service did not
mkdir -p ~/.ssb/node_modules || true
# shellcheck disable=SC2164
cd ~/.ssb/node_modules
# Install dependencies
npm install --unsafe-perm asyncmemo hashlru pull-stream pull-cat multicb hyperscript pull-paramap ssb-contact ssb-sort stream-to-pull-stream emoji-server pull-paginate ssb-mentions busboy mime-types pull-identify-filetype human-time pull-hyperscript jpeg-autorotate pull-catch diff pull-split pull-utf8-decoder ssb-web-resolver highlight.js pull-box-stream base64-url ssb-backlinks ssb-private
# Install patchfoo and enable plugin
git clone https://github.com/tomeshnet/patchfoo.git patchfoo
(
# shellcheck disable=SC2164
cd patchfoo
git checkout ${VERSION}
)
# Replace ssb-server plugins.install with a static config file
# This will prevent the installation of these modules a second time
# and compiling downlevel for a 3rd time
cp "$BASE_DIR/config" ~/.ssb
#ssb-server plugins.install ssb-private
#ssb-server plugins.install ssb-backlinks
#ssb-server plugins.enable patchfoo
# Stop ssb service to process plugin
sudo systemctl stop ssb
# Disable the git-ssb and npm-ssb prerequisite
# Comment out two lines in patchwork that create a prerequisite for git-ssb and npm-ssb
# but don't seem to serve any purpose. git-ssb and and npm-ssbis not available on npm
sed -i 's#var Git#//var Git#' patchfoo/lib/app.js patchfoo/lib/app.js
sed -i 's#this.git = new Git(this.sbot, this.config)#//this.git = new Git(this.sbot, this.config)#' patchfoo/lib/app.js
sed -i 's#var SsbNpmRegistry#//var SsbNpmRegistry#' patchfoo/lib/app.js patchfoo/lib/app.js
sed -i 's#this.serveSsbNpmRegistry = SsbNpmRegistry.respond(this.sbot, this.config)#//this.serveSsbNpmRegistry = SsbNpmRegistry.respond(this.sbot, this.config)#' patchfoo/lib/app.js
# Comment out line that breaks things
sed -i "s#h('input', {type: 'file', name: 'upload'})#//h('input', {type: 'file', name: 'upload'})#" patchfoo/lib/serve.js
# Start service again to start patchfoo
sudo systemctl start ssb
# Install nginx reverse proxy file
sudo cp "$BASE_DIR/ssb-patchfoo.conf" /etc/nginx/site-path-enabled/ssb-patchfoo.conf
# Add entry into nginx home screen
APP="<div class='app'><h2>Patch Foo</h2>Plain SSB web UI. <br/><a href='/patchfoo'>Go</a></div>"
sudo sed -i "s#<\!--APPLIST-->#$APP\n<\!--APPLIST-->#" "/var/www/html/index.html"
# shellcheck disable=SC2164
cd "$CURRENT_DIR"