blob: 4ac1ec4d05ec1089f9ce8fe49a289f567e2d5bb2 [file] [log] [blame]
Austin Cormier3aeed122016-05-23 19:12:00 -04001#!/bin/bash
Austin Cormier3a1c3352016-05-23 21:46:17 -04002#
3# Copyright 2016 RIFT.IO Inc
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17# Author(s): Austin Cormier
18# Creation Date: 2016/05/23
19#
Austin Cormier3aeed122016-05-23 19:12:00 -040020
21# Generates a NSD descriptor package from a source directory
22# Usage:
23# gen_nsd_pkg.sh <pkg_src_dir> <pkg_dest_dir>
24
25set -o nounset
26
27if [ $# -ne 2 ]; then
28 echo "Error: Must provide 2 parameters" >@2
29 exit 1
30fi
31
32pkg_src_dir="$1"
33pkg_dest_dir="$2"
34
35if [ ! -e ${pkg_src_dir} ]; then
36 echo "Error: ${pkg_src_dir} does not exist"
37 exit 1
38fi
39
40if [ ! -e ${pkg_dest_dir} ]; then
41 echo "Error: ${pkg_src_dir} does not exist"
42 exit 1
43fi
44
Mike Marchetti230c5402017-09-20 13:43:06 -040045#echo "Generating package in directory: ${pkg_dest_dir}"
Austin Cormier3aeed122016-05-23 19:12:00 -040046
47# Create any missing directories/files so each package has
48# a complete hierachy
49nsd_dirs=( ns_config vnf_config icons scripts )
50nsd_files=( README )
51
52nsd_dir="${pkg_src_dir}"
Mike Marchetti230c5402017-09-20 13:43:06 -040053#echo $(pwd)
Austin Cormier3aeed122016-05-23 19:12:00 -040054
55mkdir -p "${pkg_dest_dir}"
56cp -rf ${nsd_dir}/* "${pkg_dest_dir}"
57for sub_dir in ${nsd_dirs[@]}; do
58 dir_path=${pkg_dest_dir}/${sub_dir}
59 mkdir -p ${dir_path}
60done
61
62for file in ${nsd_files[@]}; do
63 file_path=${pkg_dest_dir}/${file}
64 touch ${file_path}
65done