-
Notifications
You must be signed in to change notification settings - Fork 310
Expand file tree
/
Copy pathrundl.sh
More file actions
executable file
·93 lines (84 loc) · 2.46 KB
/
rundl.sh
File metadata and controls
executable file
·93 lines (84 loc) · 2.46 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
#!/bin/bash
# Reset getopts state (important for zsh)
OPTIND=1
# Initialize variables
debug=""
batchmodeargs=""
encryptionargs=""
configdir="salesforce.config.dir=./configs"
version=""
keyfile=""
password=""
# Parse command line options
while getopts ":dbe:v:k:D:" flag; do
case "${flag}" in
d)
debug="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=0.0.0.0:5005,suspend=y"
;;
b)
# batchmodeargs="run.mode=batch ./configs upsertAccounts"
batchmodeargs="run.mode=batch ./configs extractAccounts"
# batchmodeargs="run.mode=batch ./configs extract sfdc.entity=account sfdc.extractionSOQL='select id,name from account' dataAccess.name=batchextract.csv"
configdir=""
;;
e)
encryptionargs="run.mode=encrypt -e "
password="${OPTARG}"
# Check if next argument exists and is not another option
if [[ $OPTIND -le $# && ${!OPTIND} != -* ]]; then
keyfile="${!OPTIND}"
((OPTIND++))
fi
configdir=""
;;
D)
encryptionargs="run.mode=encrypt -d "
password="${OPTARG}"
# Check if next argument exists and is not another option
if [[ $OPTIND -le $# && ${!OPTIND} != -* ]]; then
keyfile="${!OPTIND}"
((OPTIND++))
fi
configdir=""
;;
k)
encryptionargs="run.mode=encrypt -k "
keyfile="${OPTARG}"
configdir=""
;;
v)
version="${OPTARG}"
;;
\?)
echo "Invalid option: -${OPTARG}" >&2
exit 1
;;
:)
echo "Option -${OPTARG} requires an argument." >&2
exit 1
;;
esac
done
# Shift past the processed options
shift $((OPTIND-1))
# Find the JAR file
jarname="$(find ./target -name 'dataloader-[0-9][0-9].[0-9].[0-9].jar' | tail -1)"
# Validate JAR exists
if [[ -z "$jarname" || ! -f "$jarname" ]]; then
echo "Error: Data Loader JAR not found in ./target" >&2
exit 1
fi
# Validate DATALOADER_JAVA_HOME
if [[ -z "$DATALOADER_JAVA_HOME" ]]; then
echo "Error: DATALOADER_JAVA_HOME environment variable not set" >&2
exit 1
fi
# Debug output (optional)
if [[ -n "$debug" ]]; then
echo "🔍 Starting Salesforce Data Loader in DEBUG mode..."
echo " Debug Port: 5005"
echo " JAR: $jarname"
echo ""
fi
# Execute Data Loader
${DATALOADER_JAVA_HOME}/bin/java --enable-native-access=ALL-UNNAMED ${debug} -cp "${jarname}" com.salesforce.dataloader.process.DataLoaderRunner ${batchmodeargs} ${configdir} ${encryptionargs} ${password} ${keyfile} $@