git ssb

16+

cel / patchfoo



Tree: 000ee106a73347a888eae87e6a1585383b5f7698

Files: 000ee106a73347a888eae87e6a1585383b5f7698 / enable-plugin.js

816 bytesRaw
1// Work around broken plugins.enable RPC method
2
3var fs = require('fs')
4var path = require('path')
5
6var pluginName = require('./package').name
7
8var ssbAppname = process.env.ssb_appname || 'ssb'
9var ssbPath = process.env.ssb_path ||
10 path.join(require('os').homedir(), '.' + ssbAppname)
11var confPath = path.join(ssbPath, 'config')
12var confPathTmp = confPath + '~'
13var confData = fs.existsSync(confPath)
14 ? fs.readFileSync(confPath, 'utf8')
15 : 'null'
16var conf = JSON.parse(confData) || {}
17
18var plugins = conf.plugins || (conf.plugins = {})
19if (plugins[pluginName]) {
20 console.log(pluginName + ' already enabled')
21 process.exit(0)
22}
23plugins[pluginName] = true
24
25fs.writeFileSync(confPathTmp, JSON.stringify(conf, 0, 2))
26fs.renameSync(confPathTmp, confPath)
27console.log(pluginName + ' enabled. Restart ssb-server.')
28

Built with git-ssb-web