forked from rundeck/rundeck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_job.sh
executable file
·57 lines (47 loc) · 1.13 KB
/
generate_job.sh
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
TEMPLATE='job.definition'
COUNT=100
export LC_ALL=C
random_line() {
numlines=`wc -l $1| awk {'print $1'}`
t=`date +%s`
t=`expr $t + $RANDOM`
a=`expr $t % $numlines + 1`
RETURN=`head -n $a $1|tail -n 1`
return 0
}
genrand() {
cat /dev/random | tr -dc ${2:-' A-Za-z1-9'} | head -c${1:-1024}
}
gengroup() {
for y in {0..7}; do
genrand 6 'A-Za-z1-9'
printf "/"
done
genrand 6 'A-Za-z1-9'
}
seloptions() {
RAND=`od -d -N2 -An /dev/urandom`
echo $RAND
}
echo '<?xml version="1.0" encoding="UTF-8"?><joblist>'
for x in {0..0} ; do
name=`genrand 512`
desc=`genrand 1024`
addl=`genrand 4048`
proj=test
group=`gengroup`
for y in {1..10}; do
random_line jobs.definitions
commands+=$RETURN
done
for z in {1..10}; do
random_line options.definitions
options+=$RETURN
done
while read LINE; do
echo $LINE |
sed "s/@NAME@/${name}/g;s/@DESCRIPTION@/${desc}/g;s/@ADDITIONAL@/${addl}/g;s/@PROJECT@/$proj/g;s#@GROUP@#${group}#g;s#@OPTIONS@#$options#g;s#@COMMANDS@#$commands#g"
done < $TEMPLATE
done
echo '</joblist>'