blob: 52c798a99e094d91272dbe2efe88beff8c0eca0f [file] [log] [blame]
Joey Armstrong7c3a1e02023-07-01 16:21:24 -04001#!/bin/bash
2# -----------------------------------------------------------------------
3# Copyright 2023 Open Networking Foundation (ONF) and the ONF Contributors
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
18##-------------------##
19##---] GLOBALS [---##
20##-------------------##
21set -euo pipefail
22
23umask 022
24
25## -----------------------------------------------------------------------
26## Intent: Display an error mesage then exit with shell exit status
27## -----------------------------------------------------------------------
28function error()
29{
30 local iam="${BASH_SOURCE[0]}::${FUNCNAME[1]}"
31 echo "$iam: ERROR: $*"
32 exit 1
33}
34
35## -----------------------------------------------------------------------
36## Intent: Display a message labeled for the running script
37## -----------------------------------------------------------------------
38function func_echo()
39{
40 local iam="${BASH_SOURCE[0]}::${FUNCNAME[1]}"
41 echo "$iam: $*"
42 return
43}
44
45## -----------------------------------------------------------------------
46## Intent: Display a message labeled for the running script
47## -----------------------------------------------------------------------
48function usage()
49{
50 [[ $# -gt 0 ]] && echo "$*"
51
52 func_echo "USAGE: $0 [args] dir[, .. dir]"
53 cat <<EOH
54Create a directory structure required for Dockerfile use.
55 --debug Enable debug mode
56 --help This message
57EOH
58
59 return
60}
61
62##----------------##
63##---] MAIN [---##
64##----------------##
65func_echo "HELLO"
66
67declare -a dirs=()
68while [[ $# -gt 0 ]]; do
69 arg="$1"; shift
70 case "$arg" in
71 -*debug) set -x ;;
72 -*help) usage ;;
73 -*) error "Detected unknown switch [$arg]" ;;
74 *) dirs+=("$arg") ;;
75 esac
76done
77
78[[ ${#dirs[@]} -eq 0 ]] && {
79 usage "At least one directory is required"
80 exit 1;
81}
82
83for dir in "${dirs[@]}";
84do
85 active="$dir/active"
86 mkdir -p "$dir"
87 touch "$active"
88done
89
90# find "${dirs[@]}" -ls
91
92# [EOF]