-
Notifications
You must be signed in to change notification settings - Fork 0
/
templateScript.sh
64 lines (63 loc) · 1.95 KB
/
templateScript.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
58
59
60
61
62
63
64
#...5....|....5...2|0...5....|....5...4|0...5....|....5...6|0...5....|....5SRULE
#EINRGUISCRIPT###
#!/bin/bash
#
### HDRSection ##
#*******************************************************************************
# Filename : templateScript.sh
# Purpose : A template with some lines
# Input : none
# Output : none
# Author : rgui g3osytemx
# ToDo : 1. check if all dependencies are solved
# Bugs : dependencies are not checked
# Version : 0.0.2 - Auto update the "^# LastUpdate: " field
# : 0.0.1 - Initial idea and code
# LastUpdate: 2022.05.03Z22:07:12 *
#*******************************************************************************
#
### INISection ##
scrFName=$0; if [ ! -e ${scrFName} ]; then echo "${scrFName} lost"; exit 1; fi
#
### FUNSection ##
function doSomeThing {
inputVar=$1;
echo "${inputVar}";
}
#
### CHKSection ##
shaopts="--status --check"
grep "....5ERULE$" -B 999999 ${scrFName} | sha256sum ${shaopts} ${scrFName}
if [ $? -eq 0 ]; then
echo "Checksum OK";
else
echo "Bad checksum. Replaced it [Y/N]?";
read replaceCheckSum
if [ "${replaceCheckSum}" == "Y" ]; then
oldCheckSum=$(grep '^###.SHASection.##$' -A 3 ${scrFName} | tail -1 )
timeStampS=$(date -u +'%Y.%m.%dZ%H:%M:%S')
sed -i "/^# LastUpdate: /c\# LastUpdate: ${timeStampS} *" ${scrFName}
newCheckSum=$(grep "....5ERULE$" -B 999999 ${scrFName} | sha256sum)
addAutoMsg="\nHash replaced automatically by sed at ${timeStampS}"
sed -i "s/${oldCheckSum}/${newCheckSum}${addAutoMsg}/g" ${scrFName}
else
echo "Script aborted."; exit 1;
fi
fi
#
### DATSection ##
someVariable=0
#
### CODSection ##
doSomeThing ${someVariable}
#
### ENDSection ##
echo "ENDE"; exit 0;
#
#ENDRGUISCRIPT###
#...5....|....5...2|0...5....|....5...4|0...5....|....5...6|0...5....|....5ERULE
### SHASection ##
Hash: SHA256
e97309f7b9d4bc871f1c8fd2ab21de73f6fa0efcf2a14deb63de55277346e608 -
Hash replaced automatically by sed at 2022.05.03Z22:07:12
#