-
Notifications
You must be signed in to change notification settings - Fork 0
/
rename-me
executable file
·83 lines (66 loc) · 1.39 KB
/
rename-me
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
#! /bin/bash
#
# README.md:
# https://github.com/rayelnigma/bash-boilerplate/blob/master/README.md
#
# A boilerplate/template for a bash script. The intention
# of this script is so that I can copy/paste it into a new
# location, rename the script, and then start writing code.
# Having functionality to all of my favorite features that
# I 'grew up with' ;-)
#
# remember to replace the 'rename-me' with your new script name
_THIS_SCRIPT="rename-me"
_LOG_DIR="/var/log/${_THIS_SCRIPT}"
LOG="${_LOG_DIR}/${_THIS_SCRIPT}.log"
debug="true"
# make sure we can do our logging to the file system...
mkdir -p ${_LOG_DIR}
if [ $? == "1" ]
then
echo "error creating ${_LOG_DIR}, exiting"
exit 1
fi
function log() {
DATE="date +%Y%m%d%H%M%S"
echo "$(${DATE}):${1}: ${2}"
echo "$(${DATE}):${1}: ${2}" >> ${LOG}
}
function debug() {
if [ ${debug} == "true" ]
then
log "D" "${1}"
fi
}
function info() {
log "I" "${1}"
}
function warn() {
log "W" "${1}"
}
function error() {
log "E" "${1}"
}
function fatal() {
log "F" "${1}"
die "${1}"
}
function logVariable() {
debug "${1}=${!1}"
}
function begin() {
debug "--> begin... ${1} --------->"
}
function end() {
debug "<----------- ${1} ...end <--"
}
function initialize() {
begin "INITIALIZE"
logVariable _THIS_SCRIPT
logVariable LOG
logVariable debug
# more variables go here:
end "INITIALIZE"
}
#debug="false"
initialize