blob: 4e6b0720f59d5b81c1c8df0f7c438f7c380c7ba8 (
plain)
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
|
#!/bin/bash
# This script used to register the UDF functions required during the running process.
# All are registered by default. You can also choose what you need. At same time, you need to configure knowledge base in config/grootstream.yaml.
# get groot stream home
GROOTSTREAM_HOME=$(cd $(dirname $0);cd ../;pwd)
#Default version is 1.3.1, you can also choose a custom version. eg: 1.4.0: sh install_cn_udf.sh 1.4.0
VERSION_DEFAULT=1.3.1
CN_UDF_FILE="${GROOTSTREAM_HOME}/plugins/cn_udf.plugins"
GROOTSTREAM_UDF_FILE="${GROOTSTREAM_HOME}/config/udf.plugins"
# Function to log messages
log() {
echo "$(date +"%Y-%m-%d %H:%M:%S") - $1"
}
# Function to handle errors
handle_error() {
local message=$1
log "ERROR: $message"
exit 1
}
# Validate arguments
if [ $# -gt 1 ]; then
handle_error "Usage: $0 [version]"
fi
# Set version
version=${1:-$VERSION_DEFAULT}
log "Installing CN UDFs. Version: $version"
# Verify existence of necessary files
if [ ! -f "$CN_UDF_FILE" ]; then
handle_error "File $CN_UDF_FILE not found."
fi
# Ensure GROOTSTREAM_UDF_FILE ends with a blank line
if [ -n "$(tail -c 1 "$GROOTSTREAM_UDF_FILE")" ]; then
echo "" >> "$GROOTSTREAM_UDF_FILE"
fi
# Register UDFs
while IFS= read -r line || [ -n "$line" ]; do
if [[ "$line" == com.geedgenetworks.core.udf* ]] && ! grep -qxF "$line" "$GROOTSTREAM_UDF_FILE"; then
log "Registering UDF: $line"
echo "$line" >> "$GROOTSTREAM_UDF_FILE" || handle_error "Failed to register UDF: $line"
fi
done < "$CN_UDF_FILE"
# shellcheck disable=SC1073
log "Installation completed successfully."
|