| Austin Cormier | 3aeed12 | 2016-05-23 19:12:00 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| Austin Cormier | 3a1c335 | 2016-05-23 21:46:17 -0400 | [diff] [blame] | 2 | # |
| 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 Cormier | 3aeed12 | 2016-05-23 19:12:00 -0400 | [diff] [blame] | 20 | |
| 21 | # Generates a NSD descriptor package from a source directory |
| 22 | # Usage: |
| 23 | # gen_nsd_pkg.sh <pkg_src_dir> <pkg_dest_dir> |
| 24 | |
| 25 | set -o nounset |
| 26 | |
| 27 | if [ $# -ne 2 ]; then |
| 28 | echo "Error: Must provide 2 parameters" >@2 |
| 29 | exit 1 |
| 30 | fi |
| 31 | |
| 32 | pkg_src_dir="$1" |
| 33 | pkg_dest_dir="$2" |
| 34 | |
| 35 | if [ ! -e ${pkg_src_dir} ]; then |
| 36 | echo "Error: ${pkg_src_dir} does not exist" |
| 37 | exit 1 |
| 38 | fi |
| 39 | |
| 40 | if [ ! -e ${pkg_dest_dir} ]; then |
| 41 | echo "Error: ${pkg_src_dir} does not exist" |
| 42 | exit 1 |
| 43 | fi |
| 44 | |
| 45 | echo "Generating package in directory: ${pkg_dest_dir}" |
| 46 | |
| 47 | # Create any missing directories/files so each package has |
| 48 | # a complete hierachy |
| 49 | nsd_dirs=( ns_config vnf_config icons scripts ) |
| 50 | nsd_files=( README ) |
| 51 | |
| 52 | nsd_dir="${pkg_src_dir}" |
| 53 | echo $(pwd) |
| 54 | |
| 55 | mkdir -p "${pkg_dest_dir}" |
| 56 | cp -rf ${nsd_dir}/* "${pkg_dest_dir}" |
| 57 | for sub_dir in ${nsd_dirs[@]}; do |
| 58 | dir_path=${pkg_dest_dir}/${sub_dir} |
| 59 | mkdir -p ${dir_path} |
| 60 | done |
| 61 | |
| 62 | for file in ${nsd_files[@]}; do |
| 63 | file_path=${pkg_dest_dir}/${file} |
| 64 | touch ${file_path} |
| 65 | done |