blob: 9bd7cfe9c3b414f88e70d14c17142f3e11cc5aae [file] [log] [blame]
garciadeblas83775ba2025-07-23 18:35:24 +02001#!/bin/sh
2#######################################################################################
3# Copyright ETSI Contributors and Others.
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
14# implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#######################################################################################
18
19
20# If the main command is "nu", it should run as if it where a basic "nu" container, but with the expected environment variables and libraries.
21# Otherwise, it must be an OSM model operation, so it should be fed by the appropriate instance model in a pipeline
22
23# Check if the first argument is "nu"
24if [ "$1" = "nu" ]; then
25 # If it is just "nu", with no extra arguments, just runs it with the right environment
26 if [ "$#" -eq 1 ]; then
27 exec nu --env-config scripts/entrypoint-config.nu
28 # Otherwise, adds the rest of arguments after the environment is loaded
29 else
30 # Shift the first argument ("nu") off, leaving only the remaining arguments
31 shift
32
33 # Construct the final command with the joined arguments
34 exec nu --env-config scripts/entrypoint-config.nu "$@"
35 fi
36else
37 # Otherwise, launches the command with special configuration and feeding it by the instance model in a pipeline
38 NU_COMMAND="\$model_instance | $@"
39 exec nu --env-config scripts/entrypoint-config.nu -c "${NU_COMMAND}"
40fi