forked from NMAAHC/nmaahcmm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgmconfig
executable file
·320 lines (307 loc) · 12.2 KB
/
gmconfig
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#!/usr/bin/env bash
#set Great Migration appointment variables
CONFIG="Y"
CONFIG_VERSION="1.0"
SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/nmaahcmmfunctions" || { echo "Missing '${SCRIPTDIR}/nmaahcmmfunctions'. Exiting." ; exit 1 ;};
RUNPASHUA="Y"
#if [[ "$(uname -s)" = "Darwin" ]] ; then
# RUNPASHUA="Y"
#fi
_usage(){
echo
echo "$(basename "${0}") ${VERSION}"
echo "This application will set Great Migration appointment variables."
echo "Usage: $(basename ${0}) [ options ]"
echo " -t set configuration file using the CLI"
echo " -a set configuration file using a Pashua GUI (default, will happen without specifying this option)"
echo " -h display this help"
exit
}
# local variables
REQUIRED_VARIABLES=("${GM_DIR}" "${GM_PROFILE_LAST}" "${GM_PROFILE_FIRST}" "${GM_OPERATOR}" "${MAKEGM}")
OPTIND=1
while getopts ":ath" OPT ; do
case "${OPT}" in
a) RUNPASHUA="Y" ;;
t) RUNPASHUA="N" ;;
h) _usage ;;
:) echo "Option -${OPTARG} requires an argument" ; exit 1 ;;
*) echo "bad option -${OPTARG}" ; _usage ;;
esac
done
#_config_edit(){
# [ -z "${1}" -o -z "${2}" ] && { _report -r "The config_edit function requires two arguments. Error." ; exit ;};
# SEDTEMP=$(_maketemp)
# sed "s:^${1}=[^ ]*:$1=$2:" "${GM_CONFIG_FILE}" > "${SEDTEMP}"
# cp "${SEDTEMP}" "${GM_CONFIG_FILE}"
#}
#_add_key(){
# KEY_TO_ADD="${1}"
# grep -q "^${KEY_TO_ADD}=" "${GM_CONFIG_FILE}" ; GREP_CODE="$?"
# if [[ ! "${GREP_CODE}" -eq "0" ]] ; then
# _report -td "Adding NEW variable ${KEY_TO_ADD} to ${GM_CONFIG_FILE}"
# echo "${KEY_TO_ADD}=" >> "${GM_CONFIG_FILE}"
# fi
#}
## PASHUA INTERFACE
CONF="
# Set transparency: 0 is transparent, 1 is opaque
*.transparency=1.00
*.x = 250
*.y = 250
# Set window title
*.title = Great Migration config file
# intro text
intro.x = 20
intro.y = 620
intro.width = 500
intro.type = text
intro.text = Set up GMconfig variables
#GM_DIR
GM_DIR.x = 20
GM_DIR.y = 570
GM_DIR.type = openbrowser
GM_DIR.label = Please navigate to and select the Great Migration directory to save to:
GM_DIR.width = 600
GM_DIR.default = ${GM_DIR}
#GM_FORMATS
GM_FORMATS.text = Please choose the formats for this Great Migration appointment:
GM_FORMATS.type = text
GM_FORMATS.x = 20
GM_FORMATS.y = 520
#GM_FORMATS_35MM
GM_FORMATS_35MM.x = 60
GM_FORMATS_35MM.y = 500
GM_FORMATS_35MM.type = checkbox
GM_FORMATS_35MM.label = 35mm (35mm)
GM_FORMATS_35MM.tooltip = If activated this creates a 35mm directory with ACCESS and PRESERVATION folders.
GM_FORMATS_35MM.default = ${GM_FORMATS_35MM}
#GM_FORMATS_16MM
GM_FORMATS_16MM.x = 60
GM_FORMATS_16MM.y = 480
GM_FORMATS_16MM.type = checkbox
GM_FORMATS_16MM.label = 16mm (16mm)
GM_FORMATS_16MM.tooltip = If activated this creates a 16mm directory with ACCESS and PRESERVATION folders.
GM_FORMATS_16MM.default = ${GM_FORMATS_16MM}
#GM_FORMATS_R8
GM_FORMATS_R8.x = 60
GM_FORMATS_R8.y = 460
GM_FORMATS_R8.type = checkbox
GM_FORMATS_R8.label = Regular 8mm (R8)
GM_FORMATS_R8.tooltip = If activated this creates a Regular8mm directory with ACCESS and PRESERVATION folders.
GM_FORMATS_R8.default = ${GM_FORMATS_R8}
#GM_FORMATS_S8
GM_FORMATS_S8.x = 60
GM_FORMATS_S8.y = 440
GM_FORMATS_S8.type = checkbox
GM_FORMATS_S8.label = Super 8mm (S8)
GM_FORMATS_S8.tooltip = If activated this creates a Super8mm directory with ACCESS and PRESERVATION folders.
GM_FORMATS_S8.default = ${GM_FORMATS_S8}
#GM_FORMATS_VHS
GM_FORMATS_VHS.x = 60
GM_FORMATS_VHS.y = 420
GM_FORMATS_VHS.type = checkbox
GM_FORMATS_VHS.label = VHS (VHS)
GM_FORMATS_VHS.tooltip = If activated this creates a VHS directory with ACCESS and PRESERVATION folders.
GM_FORMATS_VHS.default = ${GM_FORMATS_VHS}
#GM_FORMATS_MiniDV
GM_FORMATS_MINIDV.x = 60
GM_FORMATS_MINIDV.y = 400
GM_FORMATS_MINIDV.type = checkbox
GM_FORMATS_MINIDV.label = MiniDV (MiniDV)
GM_FORMATS_MINIDV.tooltip = If activated this creates a MiniDV directory with ACCESS and PRESERVATION folders.
GM_FORMATS_MINIDV.default = ${GM_FORMATS_MINIDV}
#GM_FORMATS_Video8
GM_FORMATS_V8.x = 60
GM_FORMATS_V8.y = 380
GM_FORMATS_V8.type = checkbox
GM_FORMATS_V8.label = Video8 (V8)
GM_FORMATS_V8.tooltip = If activated this creates a Video8 directory with ACCESS and PRESERVATION folders.
GM_FORMATS_V8.default = ${GM_FORMATS_V8}
#GM_FORMATS_Hi8
GM_FORMATS_HI8.x = 60
GM_FORMATS_HI8.y = 360
GM_FORMATS_HI8.type = checkbox
GM_FORMATS_HI8.label = Hi8 (Hi8)
GM_FORMATS_HI8.tooltip = If activated this creates a Hi8 directory with ACCESS and PRESERVATION folders.
GM_FORMATS_HI8.default = ${GM_FORMATS_HI8}
#GM_FORMATS_Digital8
GM_FORMATS_D8.x = 60
GM_FORMATS_D8.y = 340
GM_FORMATS_D8.type = checkbox
GM_FORMATS_D8.label = Digital8 (D8)
GM_FORMATS_D8.tooltip = If activated this creates a Digital8 directory with ACCESS and PRESERVATION folders.
GM_FORMATS_D8.default = ${GM_FORMATS_D8}
#GM_FORMATS_U-Matic
GM_FORMATS_UMATIC.x = 60
GM_FORMATS_UMATIC.y = 320
GM_FORMATS_UMATIC.type = checkbox
GM_FORMATS_UMATIC.label = U-matic (Umatic)
GM_FORMATS_UMATIC.tooltip = If activated this creates a Umatic directory with ACCESS and PRESERVATION folders.
GM_FORMATS_UMATIC.default = ${GM_FORMATS_UMATIC}
#GM_FORMATS_Betacam
GM_FORMATS_BETA.x = 60
GM_FORMATS_BETA.y = 300
GM_FORMATS_BETA.type = checkbox
GM_FORMATS_BETA.label = Betacam (Beta)
GM_FORMATS_BETA.tooltip = If activated this creates a Betacam directory with ACCESS and PRESERVATION folders.
GM_FORMATS_BETA.default = ${GM_FORMATS_BETA}
#GM_FORMATS_BetacamSP
GM_FORMATS_BETASP.x = 60
GM_FORMATS_BETASP.y = 280
GM_FORMATS_BETASP.type = checkbox
GM_FORMATS_BETASP.label = BetacamSP (BetaSP)
GM_FORMATS_BETASP.tooltip = If activated this creates a BetacamSP directory with ACCESS and PRESERVATION folders.
GM_FORMATS_BETASP.default = ${GM_FORMATS_BETASP}
#GM_FORMATS_Digital Betacam
GM_FORMATS_DIGIBETA.x = 60
GM_FORMATS_DIGIBETA.y = 260
GM_FORMATS_DIGIBETA.type = checkbox
GM_FORMATS_DIGIBETA.label = Digital Betacam (DigiBeta)
GM_FORMATS_DIGIBETA.tooltip = If activated this creates a DigiBeta directory with ACCESS and PRESERVATION folders.
GM_FORMATS_DIGIBETA.default = ${GM_FORMATS_DIGIBETA}
#GM_FORMATS_OneInchVideo
GM_FORMATS_ONEINCHVIDEO.x = 60
GM_FORMATS_ONEINCHVIDEO.y = 240
GM_FORMATS_ONEINCHVIDEO.type = checkbox
GM_FORMATS_ONEINCHVIDEO.label = 1\" Video (TypeC)
GM_FORMATS_ONEINCHVIDEO.tooltip = If activated this creates a OneInchVideo directory with ACCESS and PRESERVATION folders.
GM_FORMATS_ONEINCHVIDEO.default = ${GM_FORMATS_ONEINCHVIDEO}
#GM_FORMATS_HalfInchVideo
GM_FORMATS_HALFINCHVIDEO.x = 60
GM_FORMATS_HALFINCHVIDEO.y = 220
GM_FORMATS_HALFINCHVIDEO.type = checkbox
GM_FORMATS_HALFINCHVIDEO.label = 1/2\" Open-Reel Video (EIAJ)
GM_FORMATS_HALFINCHVIDEO.tooltip = If activated this creates a HalfInchVideo directory with ACCESS and PRESERVATION folders.
GM_FORMATS_HALFINCHVIDEO.default = ${GM_FORMATS_HALFINCHVIDEO}
#GM_FORMATS_CompactAudioCassette
GM_FORMATS_COMPACTAUDIOCASSETTE.x = 60
GM_FORMATS_COMPACTAUDIOCASSETTE.y = 200
GM_FORMATS_COMPACTAUDIOCASSETTE.type = checkbox
GM_FORMATS_COMPACTAUDIOCASSETTE.label = Compact Audio Cassette (CAC)
GM_FORMATS_COMPACTAUDIOCASSETTE.tooltip = If activated this creates a CompactAudioCassette directory with ACCESS and PRESERVATION folders.
GM_FORMATS_COMPACTAUDIOCASSETTE.default = ${GM_FORMATS_COMPACTAUDIOCASSETTE}
#GM_FORMATS_QuarterInchOpenReelAudio
GM_FORMATS_QUARTERINCHOPENREELAUDIO.x = 60
GM_FORMATS_QUARTERINCHOPENREELAUDIO.y = 180
GM_FORMATS_QUARTERINCHOPENREELAUDIO.type = checkbox
GM_FORMATS_QUARTERINCHOPENREELAUDIO.label = 1/4\" Reel-To-Reel Audio (QinA)
GM_FORMATS_QUARTERINCHOPENREELAUDIO.tooltip = If activated this creates a QuarterInchOpenReelAudio directory with ACCESS and PRESERVATION folders.
GM_FORMATS_QUARTERINCHOPENREELAUDIO.default = ${GM_FORMATS_QUARTERINCHOPENREELAUDIO}
#GM_PROFILE_LAST
GM_PROFILE_LAST.x = 20
GM_PROFILE_LAST.y = 130
GM_PROFILE_LAST.type = textfield
GM_PROFILE_LAST.mandatory = true
GM_PROFILE_LAST.label = Enter last name of Great Migration appointment:
GM_PROFILE_LAST.width = 125
GM_PROFILE_LAST.default = ${GM_PROFILE_LAST}
#GM_PROFILE_FIRST
GM_PROFILE_FIRST.x = 20
GM_PROFILE_FIRST.y = 80
GM_PROFILE_FIRST.type = textfield
GM_PROFILE_FIRST.mandatory = true
GM_PROFILE_FIRST.label = Enter first name of Great Migration appointment:
GM_PROFILE_FIRST.width = 125
GM_PROFILE_FIRST.default = ${GM_PROFILE_FIRST}
#GM_OPERATOR
GM_OPERATOR.x = 20
GM_OPERATOR.y = 30
GM_OPERATOR.type = textfield
GM_OPERATOR.mandatory = true
GM_OPERATOR.label = Enter the name of the technician running the appointment:
GM_OPERATOR.width = 125
GM_OPERATOR.default = ${GM_OPERATOR}
# GM naming
gmnaming.x = 300
gmnaming.y = 450
gmnaming.width = 600
gmnaming.type = text
gmnaming.text = Great Migration file naming convention:[return][return][studyCollectionNumber]_[yyyymmdd]_[familyName]_[formatIdentifier]_[inventoryNumber][return][return]ex. SC_0001_20170412_Williams_MiniDV_01
# makeGM
makegm.x = 300
makegm.y = 350
makegm.type = radiobutton
makegm.label = Create ACCESS and PRESERVATION directories for each format selected?:
makegm.option = Yes
makegm.option = No
makegm.width = 75
makegm.default = Yes
# Add a cancel button with default label
cb.type=cancelbutton
";
# if a config file does not exist, create one using this GUI
if [[ "${RUNPASHUA}" = "Y" ]] ; then
PASHUA_CONFIGFILE=$(/usr/bin/mktemp /tmp/pashua_XXXXXXXXX)
echo "${CONF}" > "${PASHUA_CONFIGFILE}"
_pashua_run
rm "${PASHUA_CONFIGFILE}"
if [ "${PASHUAFAIL}" = "Y" ] ; then
echo "Pashua is not installed. Exiting."
#echo "Pashua is not installed. Opening via CLI."
#sleep 1
#exec $(basename "${0}") -t
exit
fi
# write to the config file
{
echo "GM_DIR=\"${GM_DIR}\""
echo "GM_FORMATS_35MM=\"${GM_FORMATS_35MM}\""
echo "GM_FORMATS_16MM=\"${GM_FORMATS_16MM}\""
echo "GM_FORMATS_R8=\"${GM_FORMATS_R8}\""
echo "GM_FORMATS_S8=\"${GM_FORMATS_S8}\""
echo "GM_FORMATS_VHS=\"${GM_FORMATS_VHS}\""
echo "GM_FORMATS_MINIDV=\"${GM_FORMATS_MINIDV}\""
echo "GM_FORMATS_V8=\"${GM_FORMATS_V8}\""
echo "GM_FORMATS_HI8=\"${GM_FORMATS_HI8}\""
echo "GM_FORMATS_D8=\"${GM_FORMATS_D8}\""
echo "GM_FORMATS_UMATIC=\"${GM_FORMATS_UMATIC}\""
echo "GM_FORMATS_BETA=\"${GM_FORMATS_BETA}\""
echo "GM_FORMATS_BETASP=\"${GM_FORMATS_BETASP}\""
echo "GM_FORMATS_DIGIBETA=\"${GM_FORMATS_DIGIBETA}\""
echo "GM_FORMATS_ONEINCHVIDEO=\"${GM_FORMATS_ONEINCHVIDEO}\""
echo "GM_FORMATS_HALFINCHVIDEO=\"${GM_FORMATS_HALFINCHVIDEO}\""
echo "GM_FORMATS_COMPACTAUDIOCASSETTE=\"${GM_FORMATS_COMPACTAUDIOCASSETTE}\""
echo "GM_FORMATS_QUARTERINCHOPENREELAUDIO=\"${GM_FORMATS_QUARTERINCHOPENREELAUDIO}\""
echo "GM_PROFILE_LAST=\"${GM_PROFILE_LAST}\""
echo "GM_PROFILE_FIRST=\"${GM_PROFILE_FIRST}\""
echo "GM_OPERATOR=\"${GM_OPERATOR}\""
echo "MAKEGM=\"${MAKEGM}\""
} > "${GM_CONFIG_FILE}"
else
# set up configuration file using the command line
for KEY in "${REQUIRED_VARIABLES[@]}" ; do
_add_key "${KEY}"
done
_report -g "Table of existing variables:"
for KEY in "${REQUIRED_VARIABLES[@]}" ; do
VALUE=$(grep "^${KEY}=" "${GM_CONFIG_FILE}" | cut -d= -f2)
printf '\t%-40s %-40s\n' "${KEY}" "${VALUE}"
done
while true ; do
EDITOPTION1="Edit config file in nano"
EDITOPTION2="Edit config file in TextMate"
_report -q "Edit a variable? "
PS3="Selection (enter by number)? "
select CONFIG_KEY in "${EDITOPTION1}" "${EDITOPTION2}" "${REQUIRED_VARIABLES[@]}" "Quit" ; do
break
done
[ "${CONFIG_KEY}" = "Quit" ] && { echo Goodbye. ; exit 1 ;};
[ "${CONFIG_KEY}" = "${EDITOPTION1}" ] && { nano "${GM_CONFIG_FILE}" ; exit 1 ;};
[ "${CONFIG_KEY}" = "${EDITOPTION2}" ] && { mate "${GM_CONFIG_FILE}" ; exit 1 ;};
echo -n "Enter the value for ${CONFIG_KEY}: "
read -e "CONFIG_VALUE"
echo "${CONFIG_KEY} is now set to ${CONFIG_VALUE}"
_config_edit "${CONFIG_KEY}" "${CONFIG_VALUE}"
done
fi
# test whether requested output directory exists
if [[ ! -d "${GM_DIR}" ]] ; then
_report -r "${GM_DIR} is not a valid directory. Exiting..."
exit 1
_log -a "Process terminated by script (no valid directory at requested Great Migration location)."
fi
if [[ "${MAKEGM}" = "Yes" ]]; then
"${SCRIPTDIR}/makegm"
fi