-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsmtpq
executable file
·559 lines (504 loc) · 24.2 KB
/
msmtpq
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
#!/usr/bin/env bash
##--------------------------------------------------------------
##
## msmtpq : queue funtions to both use & manage the msmtp queue,
## as it was defined by Martin Lambers
## Copyright (C) 2008 - 2015 Chris Gianniotis
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or, at
## your option, any later version.
##
##--------------------------------------------------------------
##
## msmtpq is meant to be used by an email client - in 'sendmail' mode
## for this purpose, it is invoked directly as 'msmtpq'
## it is also meant to be used to maintain the msmtp queue
## when it is evoked by the wrapper script 'msmtp-queue'
## (which calls this script as msmtpq --q-mgmt)
##
## there is a queue log file, distinct from the msmtp log,
## for all events & operations on the msmtp queue
## that is defined below
##
## (mutt users, using msmtpq in 'sendmail' mode,
## should make at least the following two settings in their .muttrc
## set sendmail = /path/to/msmtpq
## set sendmail_wait = -1
##
## please see the msmtp man page and docs for further mutt settings
## and optimisations
## )
##
## two essential patches by Philipp Hartwig
## 19 Oct 2011 & 27 Oct 2011
##
##--------------------------------------------------------------
## the msmtp queue contains unique filenames of the following form :
## two files for each mail in the queue
##
## creates new unique filenames of the form :
## MLF: ccyy-mm-dd-hh.mm.ss[-x].mail -- mail file
## MSF: ccyy-mm-dd-hh.mm.ss[-x].msmtp -- msmtp commands file
## where x is a consecutive number only appended for uniqueness
## if more than one mail per second is sent
##--------------------------------------------------------------
dsp() { local L ; for L ; do [ -n "$L" ] && echo " $L" || echo ; done ; }
err() { dsp '' "$@" '' ; exit 1 ; }
## ======================================================================================
## !!! please define or confirm the following three vars !!!
## !!! before using the msmtpq or msmtp-queue scripts !!!
## ======================================================================================
##
## only if necessary (in unusual circumstances - e.g. embedded systems),
## enter the location of the msmtp executable (no quotes !!)
## e.g. ( MSMTP=/path/to/msmtp )
## and uncomment the test for its existence
MSMTP=msmtp
DEFER_DELAY=3
#[ -x "$MSMTP" ] || \
# log -e 1 "msmtpq : can't find the msmtp executable [ $MSMTP ]" # if not found - complain ; quit
##
## set the queue var to the location of the msmtp queue directory
## if the queue dir doesn't yet exist, create it (0700)
## before using this script
## e.g. ( mkdir msmtp.queue )
## ( chmod 0700 msmtp.queue )
##
## the queue dir - modify this to reflect where you'd like it to be (no quotes !!)
Q=~/.msmtp.queue
[ -d "$Q" ] || \
err '' "msmtpq : can't find msmtp queue directory [ $Q ]" '' # if not present - complain ; quit
##
## set the queue log file var to the location of the msmtp queue log file
## where it is or where you'd like it to be
## ( note that the LOG setting could be the same as the )
## ( 'logfile' setting in .msmtprc - but there may be )
## ( some advantage in keeping the two logs separate )
## if you don't want the log at all unset (comment out) this var
## LOG=~/log/msmtp.queue.log --> #LOG=~/log/msmtp.queue.log
## (doing so would be inadvisable under most conditions, however)
##
## the queue log file - modify (or comment out) to taste (but no quotes !!)
LOG=~/msmtp.queue.log
## ======================================================================================
## msmtpq can use the following environment variables :
## EMAIL_CONN_NOTEST if set will suppress any testing for a connection
## (the above var is deprecated & will be removed ; use the var below)
## EMAIL_CONN_TEST if =x will suppress any testing for a connection
## if =p or unset will use a ping test (debian.org) for a connection
## if =P will use a fast ping test (8.8.8.8) for a connection
## if =n will use netcat (nc) to test for a connection
## if =s will use bash sockets to test for a connection
## EMAIL_QUEUE_QUIET if set will cause suppression of messages and 'chatter'
## (perhaps useful for some of the emacs mail clients)
##
## ======================================================================================
## !!! define or confirm the following vars if you wish to set !!!
## !!! these properties here in the script - the same properties !!!
## !!! may be set externally, by means of environment variables !!!
## !!! note the internal variables, if set, will take precedence !!!
## !!! over properties set via environment variables !!!
## ======================================================================================
##
#EMAIL_CONN_NOTEST=y # deprecated ; use below var
#EMAIL_CONN_TEST={x| |p|P|n|s} # see settings above for EMAIL_CONN_TEST
EMAIL_CONN_TEST=p
#EMAIL_QUEUE_QUIET=t
## ======================================================================================
umask 077 # set secure permissions on created directories and files
declare -i CNT # a count of mail(s) currently in the queue
declare -a Q_LST # queue list array ; used selecting a mail (to send or remove)
## do ; test this !
#for sig in INT TERM EXIT; do
# trap "rm -f \"\$TMPFILE\"; [[ $sig == EXIT ]] || kill -$sig $$" $sig
#done
trap on_exit INT TERM EXIT # run 'on_exit' on exit
on_exit() { # unlock the queue on exit if the lock was set here
[ -n "$LKD" ] && lock_queue -u 2>/dev/null
}
#
## ----------------------------------- functions common to both modes
## ----------------------------------- (msmtpq & msmtp-queue)
#
## make an entry to the queue log file, possibly an error
## (log queue changes only ; not interactive chatter)
## usage : log [ -e errcode ] msg [ msg ... ]
## opts : -e <exit code> an error ; log msg & terminate w/prejudice
## display msg to user, as well
##
log() {
local ARG RC PFX="$('date' +'%Y %d %b %H:%M:%S')"
# time stamp prefix - "2008 13 Mar 03:59:45 "
if [ "$1" = '-e' ] ; then # there's an error exit code
RC="$2" # take it
shift 2 # shift opt & its arg off
fi
[ -z "$EMAIL_QUEUE_QUIET" ] && dsp "$@" # display msg to user, as well as logging it
if [ -n "$LOG" ] ; then # log is defined and in use
for ARG ; do # each msg line out
[ -n "$ARG" ] && \
echo "$PFX : $ARG" >> "$LOG" # line has content ; send it to log
done
fi
if [ -n "$RC" ] ; then # an error ; leave w/error return
[ -n "$LKD" ] && lock_queue -u # unlock here (if locked)
[ -n "$LOG" ] && \
echo " exit code = $RC" >> "$LOG" # logging ok ; send exit code to log
exit $RC # exit w/return code
fi
}
## write/remove queue lockfile for a queue op
##
lock_queue() { # <-- '-u' to remove lockfile
local LOK="${Q}/.lock" # lock file name
local -i MAX=240 SEC=0 # max seconds to gain a lock ; seconds waiting
if [ -z "$1" ] ; then # lock queue
## Philipp Hartwig patch #2
'mkdir' "$LOK" 2>/dev/null && LKD='t'
while [ -z "$LKD" ] && (( SEC < MAX )) ; do # lock file present
sleep 1 # wait a second
(( ++SEC )) # accumulate seconds
'mkdir' "$LOK" 2>/dev/null && LKD='t' # make lockdir ; lock queue ; set flag
done # try again while locked for MAX secs
[ -z "$LKD" ] && \
err '' "cannot use queue $Q : waited $MAX seconds for"\
" lockdir [ $LOK ] to vanish ; giving up"\
'if you are certain that no other instance of this script'\
" is running, then 'rmdir' the lock dir manually" '' # lock file still there, give up
elif [ "$1" = '-u' ] ; then # unlock queue
'rmdir' "$LOK" # remove the lock
unset LKD # unset flag
fi
}
## test whether system is connected
## returns t/f (0/1)
##
connect_test() {
if [ -z "$EMAIL_CONN_TEST" ] || \
[ "$EMAIL_CONN_TEST" = 'p' ] ; then # use ping test (default)
# verify net connection - ping ip address of debian.org
# would ping -qnc2 -w4 be better ?
# would ping -qnc1 -w10 or -w20 be better ?
#ping -qnc1 -w4 debian.org >/dev/null 2>&1 || return 1
#return 1
ping -qnc2 -w10 debian.org >/dev/null 2>&1 || return 1
elif [ "$EMAIL_CONN_TEST" = 'P' ] ; then # use quicker ping test
# I personally think that including a DNS lookup
# is a better connection test but some
# have found the above test too slow
ping -qnc1 -w4 8.8.8.8 >/dev/null 2>&1 || return 1
elif [ "$EMAIL_CONN_TEST" = 'n' ] ; then # use netcat (nc) test
# must, of course, have netcat (nc) installed
which nc >/dev/null 2>&1 || \
log -e 1 "msmtpq : can't find netcat executable [ nc ]" # if not found - complain ; quit
'nc' -vz www.debian.org 80 >/dev/null 2>&1 || return 1
elif [ "$EMAIL_CONN_TEST" = 's' ] ; then # use sh sockets test
# note that this does not work on debian systems
# where bash opened sockets are suppressed for security
# reasons on multiuser systems - however, this should be
# ok for single user systems (including embedded systems)
# test whether this is supported on your system before using...
# thank you to Brian Goose, on the list, for encouraging this
exec 3<>/dev/udp/debian.org/80 || return 1 # open socket on site ; use dns
exec 3<&- ; exec 3>&- # close socket
fi
return 0
}
#
## ----------------------------------- functions for queue management
## ----------------------------------- queue maintenance mode - (msmtp-queue)
#
## show queue maintenance functions
##
usage() { # <-- error msg
dsp ''\
'usage : msmtp-queue functions' ''\
' msmtp-queue < op >'\
' ops : -r run (flush) mail queue - all mail in queue'\
' -R send selected individual mail(s) in queue'\
' -d display (list) queue contents (<-- default)'\
' -p purge individual mail(s) from queue'\
' -a purge all mail in queue'\
' -h this helpful blurt' ''\
' ( one op only ; any others ignored )' ''
[ -z "$1" ] && exit 0 || { dsp "$@" '' ; exit 1 ; }
}
## get user [y/n] acknowledgement
##
ok() {
local R YN='Y/n' # default to yes
[ "$1" = '-n' ] && \
{ YN='y/N' ; shift ; } # default to no ; change prompt ; shift off spec
dsp "$@"
while true ; do
echo -n " ok [${YN}] ..: "
read R
case $R in
y|Y) return 0 ;;
n|N) return 1 ;;
'') [ "$YN" = 'Y/n' ] && return 0 || return 1 ;;
*) echo 'yYnN<cr> only please' ;;
esac
done
}
## send a queued mail out via msmtp
##
send_queued_mail() { # <-- mail id
FQP="${Q}/${1}" # fully qualified path name
local -i RC=0 # for msmtp exit code
if [ -f "${FQP}.msmtp" ] ; then # corresponding .msmtp file found
[ "$EMAIL_CONN_TEST" != 'x' ] && \
[ -z "$EMAIL_CONN_NOTEST" ] && { # do connection test
connect_test || {
log "mail [ $2 ] [ $1 ] from queue ; couldn't be sent - host not connected"
return
}
}
schedule_send_mail "$1" "$2"
fi # (but allow continuation)
}
schedule_send_mail() {
if [ ! -f "${FQP}.sch" ] ; then # corresponding .sch file NOT found
if echo -n "sed -i \"s/^Date: .*/Date: \$(date -R)/\" ${FQP}.mail && " $MSMTP $(< "${FQP}.msmtp") "< ${FQP}.mail && rm -f ${FQP}.* && echo -n 'EMail sent successfully [${FQP}]' >> ${LOG} || echo -n 'ERROR sending the email [${FQP}]' >> ${LOG}"|at $(< "${FQP}.at") ; then # schedule sending the email from the pipeline with at
touch ${FQP}.sch # put the "sch" parameter within the file
log "mail [ $2 ] [ $1 ] from queue ; scheduled successfully" # good news to user
ALT='t' # set queue changed flag
else
RC=$? # take msmtp exit code
log "mail [ $2 ] [ $1 ] from queue ; scheduled failed ; msmtp rc = $RC; look at ${FQP}.at, modify it, and run msmtp-queue -r" # bad news ...
err "the at syntax is wrong"
fi
# if $MSMTP $(< "${FQP}.msmtp") < "${FQP}.mail" ; then # this mail goes out the door
# log "mail [ $2 ] [ $1 ] from queue ; send was successful ; purged from queue" # good news to user
# 'rm' -f ${FQP}.* # nuke both queue mail files
# ALT='t' # set queue changed flag
# else # send was unsuccessful
# RC=$? # take msmtp exit code
# log "mail [ $2 ] [ $1 ] from queue ; send failed ; msmtp rc = $RC" # bad news ...
# fi
# return $RC # func returns exit code
#else # corresponding MSF file not found
# log "preparing to send .mail file [ $1 ] [ ${FQP}.mail ] but"\
# " corresponding .msmtp file [ ${FQP}.msmtp ] was not found in queue"\
# ' skipping this mail ; this is worth looking into' # give user the bad news
fi
}
## run (flush) queue
##
run_queue() { # <- 'sm' mode # run queue
local M LST="$('ls' $Q/*.mail 2>/dev/null)" # list of mails in queue
local -i NDX=0
if [ -n "$LST" ] ; then # something in queue
for M in $LST ; do # process all mails
((NDX++))
send_queued_mail "$(basename $M .mail)" "$NDX" # send mail - pass {id} only
done
else # queue is empty
[ -z "$1" ] && \
dsp '' 'mail queue is empty (nothing to send)' ''
fi # inform user (if not running in sendmail mode)
}
## display queue contents
##
display_queue() { # <-- { 'purge' | 'send' } (op label) ; { 'rec' } (record array of mail ids)
local M ID LST="$('ls' ${Q}/*.mail 2>/dev/null)" # list of mail ids in queue
CNT=0
if [ -n "$LST" ] ; then # list has contents (any mails in queue)
for M in $LST ; do # cycle through each
ID="$(basename $M .mail)" # take mail id from filename
((CNT++))
dsp '' "mail num=[ $CNT ] id=[ $ID ]" # show mail id ## patch in
'egrep' -s --colour -h '(^From:|^To:|^Subject:)' "$M" # show mail info
[ -n "$2" ] && Q_LST[$CNT]="$ID" # bang mail id into array (note 1-based array indexing)
done
echo
else # no mails ; no contents
[ -z "$1" ] && \
dsp '' 'no mail in queue' '' || \
dsp '' "mail queue is empty (nothing to $1)" '' # inform user
exit 0
fi
}
## delete all mail in queue, after confirmation
##
purge_queue() {
display_queue 'purge' # show queue contents
if ok -n 'remove (purge) all mail from the queue' ; then
lock_queue # lock here
'rm' -f "$Q"/*.*
log 'msmtp queue purged (all mail)'
lock_queue -u # unlock here
else
dsp '' 'nothing done ; queue is untouched' ''
fi
}
## select a single mail from queue ; delete it or send it
## select by mail index (position in queue) or mail id
##
select_mail() { # <-- < 'purge' | 'send' >
local OK ID # mail id
local -i I NDX # mail index (position in queue)
while true ; do # purge an individual mail from queue
display_queue "$1" 'rec' # show queue contents ; make mail ids array
## allow selection also by mail index
if [ $CNT -eq 1 ] ; then # only one mail in queue ; take its id
NDX=1
ID="${Q_LST[1]}"
else # more than one mail ; select its id
while true ; do # get mail id
OK='t' # optimistic to a fault
dsp "enter mail number or id to $1" # <-- num or file name (only, no suff)
echo -n ' ( <cr> alone to exit ) ..: '
read ID
[ -n "$ID" ] || return # entry made - or say good bye
if [ "${ID:4:1}" != '-' ] ; then # mail id *not* entered ; test index num
for (( I=0 ; I<${#ID} ; I++ )) ; do # test index number
if [[ "${ID:${I}:1}" < '0' || \
"${ID:${I}:1}" > '9' ]] ; then
dsp '' "[ $ID ] is neither a valid mail id"\
'nor a valid mail number' ''
unset OK
fi
done
[ -z "$OK" ] && continue # format not ok (not all nums)
NDX=$ID
if [ $NDX -lt 1 ] || [ $NDX -gt $CNT ] ; then # test number range (1 - $CNT)
dsp '' "[ $NDX ] is out of range as a mail number"\
"validity is from 1 to $CNT"
continue # try again
fi
ID="${Q_LST[$NDX]}" # format & range were ok ; use it
break # valid mail selection
else # mail id entered
for (( NDX=1 ; NDX<=${#Q_LST[*]} ; NDX++ )) ; do # find entered id in queue list
[ "$ID" = "${Q_LST[$NDX]}" ] && break
done
[ $NDX -le ${#Q_LST[*]} ] && \
break || \
dsp '' "mail [ $ID ] not found ; invalid id" # mail selection valid (found) or
fi # fell through (not found) complain
done # and ask again
fi
if ok '' "$1 :"\
" mail num=[ $NDX ]"\
" id=[ $ID ]" '' ; then # confirm mail op
if [ "$1" = 'purge' ] ; then # purging
lock_queue # lock here
'rm' -f "$Q"/"$ID".* # msmtp - nukes single mail (both files) in queue
log "mail [ $ID ] purged from queue" # log op
lock_queue -u # unlock here
ALT='t' # mark that a queue alteration has taken place
else # sending
lock_queue # lock here
send_queued_mail "$ID" "$NDX" # send out the mail
lock_queue -u # unlock here
fi
else # user opts out
dsp '' 'nothing done to this queued email' # soothe user
[ $CNT -eq 1 ] && break # single mail ; user opted out
fi
dsp '' "--------------------------------------------------"
done
if [ -n "$ALT" ] ; then # queue was changed
dsp '' 'done' ''
else # queue is untouched
dsp '' 'nothing done ; queue is untouched' ''
fi
}
#
## ----------------------------------- functions for directly sending mail
## ----------------------------------- 'sendmail' mode - (msmtpq)
#
## ('sendmail' mode only)
## make base filename id for queue
##
make_id() {
local -i INC # increment counter for (possible) base fqp name collision
ID="$(date +%Y-%m-%d-%H.%M.%S)" # make filename id for queue (global
FQP="${Q}/$ID" # make fully qualified pathname vars)
## Philipp Hartwig patch #1
if [ -f "${FQP}.mail" -o -f "${FQP}.msmtp" ] ; then # ensure fqp name is unique
INC=1 # initial increment
while [ -f "${FQP}-${INC}.mail" -o -f "${FQP}-${INC}.msmtp" ] ; do # fqp name w/incr exists
(( ++INC )) # bump increment
done
ID="${ID}-${INC}" # unique ; set id
FQP="${FQP}-${INC}" # unique ; set fqp name
fi
}
## ('sendmail' mode only)
## enqueue a mail
##
enqueue_mail() { # <-- all mail args ; mail text via TMP
if echo "$@" > "${FQP}.msmtp" ; then # write msmtp command line to queue .msmtp file
log "enqueued mail as : [ $ID ] ( $* ) : successful" # (queue .mail file is already there)
else # write failed ; bomb
log -e "$?" "queueing - writing msmtp cmd line { $* }"\
" to [ ${ID}.msmtp ] : failed"
fi
}
## ('sendmail' mode only)
## send a mail (if possible, otherwise enqueue it)
## if send is successful, msmtp will also log it (if logging enabled in ~/.msmtprc)
##
send_mail() { # <-- all mail args ; mail text via TMP
[ "$EMAIL_CONN_TEST" != 'x' ] && \
[ -z "$EMAIL_CONN_NOTEST" ] && { # do connection test
connect_test || {
log "mail for [ $* ] : couldn't be sent - host not connected"
enqueue_mail "$@" # enqueue the mail
return
}
}
schedule_send_mail "$*" "${ID}"
# if $MSMTP "$@" < "${FQP}.mail" > /dev/null ; then # send mail using queue .mail fil
# log "mail for [ $* ] : send was successful" # log it
# 'rm' -f ${FQP}.* # remove all queue mail files .mail & .msmtp file
# run_queue 'sm' # run/flush any other mails in queue
# else # send failed - the mail stays in the queue
# log "mail for [ $* ] : send was unsuccessful ; msmtp exit code was $?"\
# "enqueued mail as : [ $ID ] ( $* )" # (queue .mail file is already there)
# fi
}
generate_at() {
if grep -q "^Scheduler: " ${FQP}.mail ; then # if a description header have been written
echo $(pcregrep -o1 "^Scheduler: (.*)$" "${FQP}.mail") # extract the at pattern
sed -i "/^Scheduler: /d" "${FQP}.mail" # remove the Description line that won't be used anymore
else
echo "now + ${DEFER_DELAY} minutes" # set default delay
fi
}
#
## -- entry point
#
if [ ! "$1" = '--q-mgmt' ] ; then # msmtpq - sendmail mode
lock_queue # lock here
make_id # make base queue filename id for this mail
# write mail body text to queue .mail file
cat > "${FQP}.mail" || \
log -e "$?" "creating mail body file [ ${FQP}.mail ] : failed" # test for error
# write msmtp command line to queue .msmtp file
echo -n $(generate_at) > ${FQP}.at # put the "at" parameter within the file
echo "$@" > "${FQP}.msmtp" || \
log -e "$?" "creating msmtp cmd line file { $* }"\
" to [ ${ID}.msmtp ] : failed" # test for error
send_mail "$@" # send the mail if possible, queue it if not
lock_queue -u # unlock here
else # msmtp-queue - queue management mode
shift # trim off first (--q-mgmt) arg
OP=${1:1} # trim off first char of OP arg
case "$OP" in # sort ops ; run according to spec
r) lock_queue
run_queue
lock_queue -u ;; # run (flush) the queue
R) select_mail send ;; # send individual mail(s) in queue
d|'') display_queue ;; # display (list) all mail in queue (default)
p) select_mail purge ;; # purge individual mail(s) from queue
a) purge_queue ;; # purge all mail in queue
h) usage ;; # show help
*) usage "[ -$OP ] is an unknown msmtp-queue option" ;;
esac
fi
exit 0