diff --git a/index.js b/index.js index 2937f23..02b217d 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ const restify = require('restify') const log = require('./lib/log')('main') const fs = require('fs') +const { exec } = require('child_process') const BLE = require('./lib/ble') const intval = require('./lib/intval') @@ -519,6 +520,10 @@ function seq () { } } +function update (req, res, next) { + exec('sh ./scripts/update.sh') +} + function index (req, res, next) { fs.readFile(INDEXPATH, 'utf8', (err, data) => { if (err) { diff --git a/scripts/update.sh b/scripts/update.sh new file mode 100644 index 0000000..db6f8b5 --- /dev/null +++ b/scripts/update.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +cd /home/pi/intval3 + +sudo -u pi -i<< EOF + git pull +EOF + +sudo pm2 restart process.json \ No newline at end of file