aboutsummaryrefslogtreecommitdiff
path: root/enable-plugin.js
diff options
context:
space:
mode:
authorcel <cel@lOUVT+Phkvai9a/cCS/RKo+S9hnPAQdVixms/7ldpPA=.ed25519>2020-06-14 11:47:26 -0400
committercel <cel@lOUVT+Phkvai9a/cCS/RKo+S9hnPAQdVixms/7ldpPA=.ed25519>2020-06-14 11:53:56 -0400
commit475c443979b6933ed8d7421a7b4aef619d6b51f8 (patch)
treea4fbb6ce97854e0b576728bf1b968e3fca53e3f6 /enable-plugin.js
parentbe16025cfbbafcffe26d2b6e7a17952a39c2cd67 (diff)
downloadpatchfoo-475c443979b6933ed8d7421a7b4aef619d6b51f8.tar.gz
patchfoo-475c443979b6933ed8d7421a7b4aef619d6b51f8.zip
Update readme. Add enable plugin.
- Use enable script instead of plugins.enable which is broken. plugins.enable is also no longer needed after plugins.install. - Recommend using ssb-npm command instead of ssb-npm-registry. Using ssb-npm command should be a little simpler and more obvious, since when you don't have the prerequisite you will get "command not found" which implies you need to install something, rather than the mysterious "connect ECONNREFUSED 127.0.0.1:8043" - Remove blobs.max setting. Recent ssb-npm hard-codes workarounds for sodium-native which is (was) the only oversized blob. - Don't need to say restart ssb-server; the commands will do that. - Explain installation as standalone process vs. as ssb-server plugin. - scuttlebot -> ssb-server
Diffstat (limited to 'enable-plugin.js')
-rw-r--r--enable-plugin.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/enable-plugin.js b/enable-plugin.js
new file mode 100644
index 0000000..2586b7e
--- /dev/null
+++ b/enable-plugin.js
@@ -0,0 +1,27 @@
+// Work around broken plugins.enable RPC method
+
+var fs = require('fs')
+var path = require('path')
+
+var pluginName = require('./package').name
+
+var ssbAppname = process.env.ssb_appname || 'ssb'
+var ssbPath = process.env.ssb_path ||
+ path.join(require('os').homedir(), '.' + ssbAppname)
+var confPath = path.join(ssbPath, 'config')
+var confPathTmp = confPath + '~'
+var confData = fs.existsSync(confPath)
+ ? fs.readFileSync(confPath, 'utf8')
+ : 'null'
+var conf = JSON.parse(confData) || {}
+
+var plugins = conf.plugins || (conf.plugins = {})
+if (plugins[pluginName]) {
+ console.log(pluginName + ' already enabled')
+ process.exit(0)
+}
+plugins[pluginName] = true
+
+fs.writeFileSync(confPathTmp, JSON.stringify(conf, 0, 2))
+fs.renameSync(confPathTmp, confPath)
+console.log(pluginName + ' enabled. Restart ssb-server.')