Create an update script and add an update command to the main process.

This commit is contained in:
mmcwilliams 2018-01-11 15:50:36 -05:00
parent ca4282c02f
commit 64adc6cc86
2 changed files with 14 additions and 0 deletions

View File

@ -3,6 +3,7 @@
const restify = require('restify') const restify = require('restify')
const log = require('./lib/log')('main') const log = require('./lib/log')('main')
const fs = require('fs') const fs = require('fs')
const { exec } = require('child_process')
const BLE = require('./lib/ble') const BLE = require('./lib/ble')
const intval = require('./lib/intval') 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) { function index (req, res, next) {
fs.readFile(INDEXPATH, 'utf8', (err, data) => { fs.readFile(INDEXPATH, 'utf8', (err, data) => {
if (err) { if (err) {

9
scripts/update.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
cd /home/pi/intval3
sudo -u pi -i<< EOF
git pull
EOF
sudo pm2 restart process.json