Skip to content

Commit

Permalink
chore: add reboot script for post-v7.4.9 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
CrypticaScriptura committed Jun 16, 2020
1 parent b2c5991 commit 496d1ac
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
32 changes: 32 additions & 0 deletions deploy/reboot-749/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -e

SUB_DIR=reboot-749
SCRIPT_DIR=$(dirname $0)

EXPORT_ROOT=${1-$LAMASSU_EXPORT}

if [ -z "$EXPORT_ROOT" ]
then
echo "Builds an update package file for rebooting l-m and browser across aaeon-acp and ssuboard."
echo -e "\nUsage:"
echo -e "build <target directory>\n"
exit 1
fi

MACHINE_DIR=$SCRIPT_DIR/../..
EXPORT_BASE=$EXPORT_ROOT/$SUB_DIR
EXPORT_DIR=$EXPORT_BASE/package
UPDATESCRIPT=$SCRIPT_DIR/updatescript.js
rm -rf $EXPORT_DIR
mkdir -p $EXPORT_DIR

# Needed for update script on target device
cp $MACHINE_DIR/node_modules/async/lib/async.js $EXPORT_DIR
cp $SCRIPT_DIR/../report.js $EXPORT_DIR
cp $UPDATESCRIPT $EXPORT_DIR

echo "Building..."
node $SCRIPT_DIR/../build.js $EXPORT_BASE
rm -rf $EXPORT_DIR
echo "Complete."
29 changes: 29 additions & 0 deletions deploy/reboot-749/updatescript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';

var cp = require('child_process');
var async = require('./async');
var report = require('./report').report;

const hardwareCode = process.argv[2].toLowerCase();
var TIMEOUT = 10000;

let restartCommand = null
if (hardwareCode === 'aaeon')
restartCommand = 'restart lamassu-machine; killall chromium-browser; killall start-chrome'
else if (hardwareCode === 'ssuboard' || hardwareCode === 'upboard')
restartCommand = 'supervisorctl restart lamassu-machine lamassu-browser'
else restartCommand = ''

function command(cmd, cb) {
cp.exec(cmd, {timeout: TIMEOUT}, function(err) {
cb(err);
});
}

async.series([

async.apply(command, restartCommand),
async.apply(report, null, 'finished.')
], function(err) {
if (err) throw err;
});

0 comments on commit 496d1ac

Please sign in to comment.