#!/bin/bash

#This script shuts down a DtCyber VM that has a shutdown.js Node script. The URL
#is specified as dtcyber_js_shutdown:// without any path.

. bootscriptfunctions.sh

exec {shutdown_lock_fd}<> shutdown_lock
flock -n "$shutdown_lock_fd" || panic "shutdown already in progress"
enable -f /usr/lib/bash/fdflags fdflags
fdflags -s+cloexec $update_lock_fd

cd images
NODE_PATH="$PWD/node_modules" node shutdown
