-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathutil
More file actions
129 lines (116 loc) · 5.77 KB
/
Copy pathutil
File metadata and controls
129 lines (116 loc) · 5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR=$(realpath $SCRIPTDIR/..)
SKELETON_DIR=$ROOT_DIR/skeleton
TEMPLATE_DIR=$ROOT_DIR/templates
function apply-configurations() {
DEST=$1
SAMPLENAME=$2
TEMPLATE_TECHDOC_TYPE=$3
DOC_SRC_ROOT="$ROOT_DIR/documentation/$TEMPLATE_TECHDOC_TYPE"
# documentation (sample, prerequisites, remote cluster)
SAMPLE_DOC_SRC="$DOC_SRC_ROOT/$SAMPLENAME"
PREREQ_DOC_SRC="$DOC_SRC_ROOT/template-prerequisites.md"
REMOTE_DOC_SRC="$DOC_SRC_ROOT/template-remote-cluster.md"
if [ -d $DOC_SRC_ROOT ]; then
if [ -d $SAMPLE_DOC_SRC ]; then
cp -r $SAMPLE_DOC_SRC $DEST/docs
if [ -f $PREREQ_DOC_SRC ]; then
cp $PREREQ_DOC_SRC $DEST/docs/template-prerequisites.md
fi
if [ -f $REMOTE_DOC_SRC ]; then
cp $REMOTE_DOC_SRC $DEST/docs/template-remote-cluster.md
fi
fi
cp -r $DOC_SRC_ROOT/mkdocs.yml $DEST/mkdocs.yml
fi
cp $SKELETON_DIR/template.yaml $DEST/template.yaml
# get default env variables
source $SCRIPTDIR/envs/base
# get sample env variables
source $SCRIPTDIR/envs/$SAMPLENAME
# if using darwin (macos)
if ! sed --version >/dev/null 2>&1; then
if [ -f $f/Containerfile ]; then
sed -i '' "s!sed.edit.DOCKERFILE!Containerfile!g" $DEST/template.yaml
sed -i '' "s!sed.edit.BUILDCONTEXT!.!g" $DEST/template.yaml
fi
sed -i '' "s!sed.edit.APP_NAME!$APP_NAME!g" $DEST/template.yaml
sed -i '' "s!sed.edit.APP_DISPLAY_NAME!$APP_DISPLAY_NAME!g" $DEST/template.yaml
sed -i '' "s!sed.edit.DESCRIPTION!$APP_DESC!g" $DEST/template.yaml
sed -i '' "s!sed.edit.APPTAGS!$APP_TAGS!g" $DEST/template.yaml
sed -i '' "s!sed.edit.CATALOG_DESCRIPTION!Secure Supply Chain Example for $APP_DISPLAY_NAME!g" $DEST/template.yaml
sed -i '' "s!sed.edit.OWNER!$OWNER!g" $DEST/template.yaml
if [ $SUPPORT_APP == false ]; then
sed -i '' '/# SED_APP_SUPPORT_START/,/# SED_APP_SUPPORT_END/d' $DEST/template.yaml
fi
if [ $SUPPORT_LLM == false ]; then
sed -i '' '/# SED_LLM_SERVER_START/,/# SED_LLM_SERVER_END/d' $DEST/template.yaml
fi
if [ $SUPPORT_LLM_LLAMA == false ]; then
sed -i '' '/# SED_LLM_LLAMA_SERVER_START/,/# SED_LLM_LLAMA_SERVER_END/d' $DEST/template.yaml
sed -i '' 's/llama.cpp: ${MODEL_SERVICE_DESC}. | \[Learn more\][(]${MODEL_SERVICE_SRC}[)]//' $DEST/template.yaml
fi
if [ $SUPPORT_ASR == false ]; then
sed -i '' '/# SED_ASR_MODEL_SERVER_START/,/# SED_ASR_MODEL_SERVER_END/d' $DEST/template.yaml
fi
if [ $SUPPORT_DETR == false ]; then
sed -i '' '/# SED_DETR_MODEL_SERVER_START/,/# SED_DETR_MODEL_SERVER_END/d' $DEST/template.yaml
fi
if [ $SUPPORT_DB == false ]; then
sed -i '' '/# SED_DB_START/,/# SED_DB_END/d' $DEST/template.yaml
fi
if [ $SUPPORT_EXISTING == false ]; then
sed -i '' '/# SED_EXISTING_START/,/# SED_EXISTING_END/d' $DEST/template.yaml
fi
if [ $SUPPORT_EXISTING_SERVER == false ]; then
sed -i '' '/# SED_EXISTING_SERVER_START/,/# SED_EXISTING_SERVER_END/d' $DEST/template.yaml
fi
if [ $SUPPORT_MODEL_CATALOG == false ]; then
sed -i '' '/# SED_EXISTING_FROM_CATALOG_START/,/# SED_EXISTING_FROM_CATALOG_END/d' $DEST/template.yaml
fi
# if using linux
else
if [ -f $f/Containerfile ]; then
sed -i "s!sed.edit.DOCKERFILE!Containerfile!g" $DEST/template.yaml
sed -i "s!sed.edit.BUILDCONTEXT!.!g" $DEST/template.yaml
fi
sed -i "s!sed.edit.APP_NAME!$APP_NAME!g" $DEST/template.yaml
sed -i "s!sed.edit.APP_DISPLAY_NAME!$APP_DISPLAY_NAME!g" $DEST/template.yaml
sed -i "s!sed.edit.DESCRIPTION!$APP_DESC!g" $DEST/template.yaml
sed -i "s!sed.edit.APPTAGS!$APP_TAGS!g" $DEST/template.yaml
sed -i "s!sed.edit.CATALOG_DESCRIPTION!Secure Supply Chain Example for $APP_DISPLAY_NAME!g" $DEST/template.yaml
sed -i "s!sed.edit.OWNER!$OWNER!g" $DEST/template.yaml
if [ $SUPPORT_APP == false ]; then
sed -i '/# SED_APP_SUPPORT_START/,/# SED_APP_SUPPORT_END/d' $DEST/template.yaml
fi
if [ $SUPPORT_LLM == false ]; then
sed -i '/# SED_LLM_SERVER_START/,/# SED_LLM_SERVER_END/d' $DEST/template.yaml
fi
if [ $SUPPORT_LLM_LLAMA == false ]; then
sed -i '/# SED_LLM_LLAMA_SERVER_START/,/# SED_LLM_LLAMA_SERVER_END/d' $DEST/template.yaml
sed -i 's/llama.cpp: ${MODEL_SERVICE_DESC}. | \[Learn more\][(]${MODEL_SERVICE_SRC}[)]//' $DEST/template.yaml
fi
if [ $SUPPORT_ASR == false ]; then
sed -i '/# SED_ASR_MODEL_SERVER_START/,/# SED_ASR_MODEL_SERVER_END/d' $DEST/template.yaml
fi
if [ $SUPPORT_DETR == false ]; then
sed -i '/# SED_DETR_MODEL_SERVER_START/,/# SED_DETR_MODEL_SERVER_END/d' $DEST/template.yaml
fi
if [ $SUPPORT_DB == false ]; then
sed -i '/# SED_DB_START/,/# SED_DB_END/d' $DEST/template.yaml
fi
if [ $SUPPORT_EXISTING == false ]; then
sed -i '/# SED_EXISTING_START/,/# SED_EXISTING_END/d' $DEST/template.yaml
fi
if [ $SUPPORT_EXISTING_SERVER == false ]; then
sed -i '/# SED_EXISTING_SERVER_START/,/# SED_EXISTING_SERVER_END/d' $DEST/template.yaml
fi
if [ $SUPPORT_MODEL_CATALOG == false ]; then
sed -i '/# SED_EXISTING_FROM_CATALOG_START/,/# SED_EXISTING_FROM_CATALOG_END/d' $DEST/template.yaml
fi
fi
source $ROOT_DIR/properties
cat $DEST/template.yaml | envsubst >$DEST/new-template.yaml
mv $DEST/new-template.yaml $DEST/template.yaml
}