Fixed need_restart flag for OffileDataRelevanceTime
[public/netxms.git] / tools / sharIt
CommitLineData
39cc66bb 1#!/usr/local/bin/bash
d7b7ed9e
AK
2#
3# vim:ts=3 sw=3
b78936e5 4
d7b7ed9e
AK
5trap '
6 rm -f tmp
7' INT EXIT
b78936e5
AK
8
9if [ "x"$3 = "x" ]; then
10 echo "Usage: $0 input.tar.gz scriptname output.sh"
11 exit
12fi
13
2dad1e4c
AK
14if [ ! -r $1 ]; then
15 echo "Can't read $1"
16 exit
17fi
71a419d0 18
3fbc3b89 19stub=`dirname \`echo $0\``/stub.sh
d7b7ed9e
AK
20if [ ! -r $stub ]; then
21 echo "$stub not found!"
22 exit
23fi
24
2dad1e4c 25md5=`which md5 2>/dev/null`
b78936e5 26if [ $? != 0 ]; then
2dad1e4c 27 md5=`which md5sum 2>/dev/null`
b78936e5 28 if [ $? != 0 ]; then
2dad1e4c 29 md5=`which openssl 2>/dev/null`
b78936e5
AK
30 if [ $? != 0 ]; then
31 echo "Can't calculate MD5, exiting"
32 exit
33 else
34 md5="$md5 md5"
35 fi
b78936e5
AK
36 fi
37fi
38
90d5014d 39skip=`echo \`wc -l $stub|awk '{ print $1 }'\``
d7b7ed9e 40
9c96f75c
AK
41if [ "x$BASH" == "x" ]; then
42 skip1=`let $skip+1`
43else
44 skip1=$skip
45 let skip1++
46fi
2dad1e4c 47
d7b7ed9e 48sed "s,__SKIP__,$skip,g" < $stub |
3e80aa9c
AK
49 sed "s,__SKIP1__,$skip1,g" |
50 sed "s,__COMMAND__,$2,g" > tmp
6d26c4a7
VK
51hash1=`tail -n +5 tmp | $md5 | cut -c1-32 | tr A-Z a-z`
52hash2=`cat $1 | $md5 | cut -c1-32 | tr A-Z a-z`
b78936e5
AK
53sed "s,__HASH1__,$hash1,g" < tmp | sed "s,__HASH2__,$hash2,g" > $3
54
55cat $1 >> $3