forked from kubernetes/release
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script-template
executable file
·168 lines (153 loc) · 5.31 KB
/
script-template
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash
#
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Set PROGram name
PROG=${0##*/}
########################################################################
#+ NAME
#+ $PROG - Create a kubernetes release script template
#+
#+ SYNOPSIS
#+ $PROG
#+ $PROG [--help | -man]
#+ $PROG [--usage | -?]
#+
#+ DESCRIPTION
#+ $PROG produces a general template for use within the kubernetes/release
#+ script/tool ecosystem with a *nix-style header and some useful comments
#+ to get you started.
#+
#+ OPTIONS
#+ [--help | -man] - display man page for this script
#+ [--usage | -?] - display usage information
#+
#+ EXAMPLES
#+
#+ FILES
#+
#+ SEE ALSO
#+
#+ BUGS
#+
#-
########################################################################
source $(dirname $(readlink -ne $0))/lib/common.sh
cat <<EOF_CAT
#!/bin/bash
#
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Set PROGram name
PROG=\${0##*/}
########################################################################
#+
#+ NAME
#+ \$PROG - Short description
#+
#+ SYNOPSIS
#+ \$PROG --requiredarg=<value1|value2> [--optionalarg=[value1|value2]]
#+ \$PROG [--helpshort|--usage|-?]
#+ \$PROG [--help|-man]
#+
#+ DESCRIPTION
#+ Detailed description of script and options
#+
#+ OPTIONS
#+ --requiredarg= - Detail of --requiredarg
#+ [--optionalarg=] - Detail of option2 and arguments
#+ [--help | -man] - display man page for this script
#+ [--usage | -?] - display in-line usage
#+
#+ EXAMPLES
#+ \$PROG --requiredarg=value - How script works with --requiredarg=value
#+ \$PROG --optionalarg=value - How script works with --optionalarg=value
#+
#+ FILES
#+ Applicable files
#+ Related files
#+
#+ SEE ALSO
#+ common.sh - base function definitions
#+ Other related scripts
#+
#+ BUGS/TODO
#+ Known problems with script
#+
########################################################################
# If NO ARGUMENTS should return *usage*, uncomment the following line:
#usage=\${1:-yes}
source \$(dirname \$(readlink -ne \$BASH_SOURCE))/lib/common.sh
# Process Command-line arguments
# POSITIONAL_ARGV is provided by common::namevalue after arg preprocessing
# * --name=value becomes FLAGS_name=value
# * --name becomes FLAGS_name=1 (boolean)
# Optionally validate number of POSITIONAL_ARGV
#common::argc_validate 2
###############################################################################
# FUNCTIONS
###############################################################################
# OPTIONAL: Overwrite common.sh's common::cleanexit
#common::cleanexit () {
#rm -rf \$TMPDIR \$TMPFILE
#tput cnorm
#
## Do stuff here to clean up after this specific script
#
#common::timestamp end
#exit \${1:-0}
#}
###############################################################################
# MAIN
###############################################################################
##############################################################################
# Initialize logs
##############################################################################
# Initialize and save up to 10 (rotated logs)
#MYLOG=\$TMPDIR/\$PROG.log
#common::logfileinit \$MYLOG 10
# BEGIN script
common::timestamp begin
##############################################################################
# OTHER HELPFUL FUNCTIONS (More in common.sh)
##############################################################################
# logecho - echo to stdout and MYLOG if set
# logrun - run a cmd to stdout and MYLOG if set
# common::askyorn - Ask a simple yes or no question (see common.sh for details)
# common::stepheader - Bolded, logged bullet points for your output
# common::exit - Exit cleanly
# common::check_packages - Check for package prereqs
# common::disk_space_check - Check disk space
##############################################################################
common::stepheader MAJOR STEP 1
##############################################################################
##############################################################################
common::stepheader MAJOR STEP 2
##############################################################################
# END script
common::timestamp end
EOF_CAT