--- /dev/null
+#!/bin/bash
+
+#
+# Copyright 2016 RIFT.IO Inc
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Unpack tar archives for plugins. Maintain a timestamp.txt file for each, so
+# that tar archives are only unpacked if they have been changed.
+#
+# This script is needed to unpack the files as cpack cannot handle a lot of files.
+
+usage() {
+ echo "usage: $(basename ${BASH_SOURCE[0]})"
+}
+
+function extract_node_modules() {
+ tar xf node_modules.tar
+ touch timestamp.txt
+}
+
+# change to the directory of this script
+THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+
+cd $THIS_DIR
+echo "Handling plugin node modules"
+
+cd ../plugins
+for dir in */; do
+ echo "Checking plugin "${dir}" for newer node_modules"
+ cd ${dir}
+ if [ ! -f timestamp.txt ]; then
+ echo "timestamp file not found ... node_modules need to be expanded and timestamp needs to be touched"
+ extract_node_modules
+ else
+ echo "Checking if node_modules.tar has a newer timestamp than timestamp.txt"
+ if [[ node_modules.tar -nt timestamp.txt ]]; then
+ echo "node_modules.tar is newer than timestamp ... node modules need to be expanded and timestamp needs to be touched"
+ extract_node_modules
+ else
+ echo "node_modules.tar is older than timestamp ... nothing needs to be done"
+ fi
+ fi
+ cd ..
+ echo "Checking plugin "${dir}" for newer node_modules ...done"
+done
+