forked from bartonski/bywater-utilities
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bywater
763 lines (651 loc) · 21.4 KB
/
.bywater
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
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
source ${EMPLOYER_PATH}/.bywater_environment
# Shell Functions
# Checks for the existance of a directory; if it does not exist, creates it.
checkdir() {
if [ ! -d $1 ]; then
mkdir -p $1
fi
}
# Takes rt ticket number as argument, opens ticket in browser.
ticket() {
local ticket_url="${RTSERVER}/Ticket/Display.html?id=${1}"
echo "$ticket_url"
$OPEN "$ticket_url"
sleep 1
echo
}
rtmodify() {
local ticket_url="${RTSERVER}/Ticket/Modify.html?id=${1}"
echo "$ticket_url"
$OPEN "$ticket_url"
sleep 1
echo
}
# Takes rt ticket number as argument, opens self service view of ticket in browser.
partner_ticket() {
local partner_url="${RTSERVER}/SelfService/Display.html?id=${1}"
echo "$partner_url"
$OPEN "$partner_url"
sleep 1
echo
}
# look up bug in bugzilla
bug() { $OPEN http://${BUGZILLA}/bugzilla3/show_bug.cgi?id=${1}; sleep 1; echo; }
# 'annon ssh' -- ssh to remote server via annon.
assh() {
if [ -z $1 ]; then # If no arguments, log into $BYWATER_GATEWAY directly.
time ssh -t ${BYWATER_USER}@$BYWATER_GATEWAY
else
if shortname "$@" > /dev/null
then
kohaversion "$@"
fi
#ssh $BYWATER_GATEWAY ssh "$@" "egrep \'KOHA_CONF|PERL5LIB|ErrorLog\'" '/etc/apache2/sites-enabled/*'
time ssh -t ${BYWATER_USER}@$BYWATER_GATEWAY ssh "$@";
fi
}
# 'Straight' assh -- use when you want to keep the integrity of STDIN / STDOUT,
# e.g. $ tar cf - backup.20150719.sql.gz | sassh bwsdev tar xvf -
sassh() { ssh ${BYWATER_USER}@$BYWATER_GATEWAY ssh "$@"; }
# Copy file from remote server to local /tmp
asshcp() {
local shortname=$1
local filepath=$2
local filename="$( basename $filepath )"
sassh $shortname cat $filepath > /tmp/$filename
if [ $! ]
then
echo "/tmp/$filename"
fi
}
# remove host key from annon.
asshrmkey() {
set -x
ssh ${BYWATER_USER}@$BYWATER_GATEWAY ssh-keygen -R "$1"
sleep 2
time ssh -t ${BYWATER_USER}@$BYWATER_GATEWAY ssh "$1"
set +x
}
# Look up shortname
shortname() {
ssh ${BYWATER_USER}@$BYWATER_GATEWAY ./bin/shortname "$1"
}
# I don't keep that much data locally, so I never use this...
mksupport() { mkdir -p $SUPPORT/$1/files; }
# Not sure what this was for.
append_shortname() {
local shortname="$1"
local template="$2"
local linkfile="$3"
echo "$template" | sed "s/xxx/$shortname/g" >> $linkfile
}
# Look up site by shortname, output sugar, staff client and opac URLs for that site.
# TODO: put this in a shell script of its own.
sugar()
{
sugarfile=$HOME/Support/notes/ticketlinks.txt # Global
local shortname=$1
local sugarurl="$(ssh ${BYWATER_USER}@$BYWATER_GATEWAY watchcat -tsugarv -k$shortname | sed -n '/Suite Systems URL: /s/Suite Systems URL: //p')"
if [ -z "$sugarurl" ]; then
sugarurl="https://sugar2.bywatersolutions.com/"
sugarurl="${sugarurl}index.php?action=UnifiedSearch&module="
sugarurl="${sugarurl}Home&search_form=false&advanced="
sugarurl="${sugarurl}false&query_string=$shortname"
fi
echo "sugar file: $sugarfile"
if grep -q $shortname $sugarfile
then
grep $shortname $sugarfile | cut -d: -f 2-
else
$OPEN "$sugarurl" > /dev/null 2> /dev/null &
append_shortname $shortname 'xxx: xxx:' $sugarfile
append_shortname $shortname 'xxx: Sugar URL: ' $sugarfile
append_shortname $shortname 'xxx: Staff: ' $sugarfile
append_shortname $shortname 'xxx: Opac: ' $sugarfile
vim + $sugarfile
grep $shortname $sugarfile | cut -d: -f 2-
fi
}
# Open sugar URL in firefox.
sugarff() {
local shortname=$1
local linkfile=$HOME/Support/notes/ticketlinks.txt
local sugarurl="$(sed -n "/$shortname: Sugar URL: /s/^.*Sugar URL: //p" $linkfile )"
$FIREFOX "$sugarurl" 2> /dev/null &
}
# look up opac URL in 'ticketlinks.txt', open URL in web browser
_opacurl () {
local linkfile=$HOME/Support/notes/ticketlinks.txt
if grep "^${1}\>" $linkfile 2>&1 > /dev/null
then
opac="$(grep ^${1}: $linkfile | grep 'Opac' | cut -d ':' -f 3- | sed 's|/$||')"
echo $opac
fi
}
# look up opac URL in 'ticketlinks.txt', open URL in web browser
opacurl () {
if local opac="$(_opacurl $1)"
then
url="${opac}/${2}"
echo $url
$OPEN $url
fi
}
_sugarlookup ()
{
COMPREPLY=();
local word="${COMP_WORDS[COMP_CWORD]}";
local linkfile=$HOME/Support/notes/ticketlinks.txt
COMPREPLY=($(compgen -W "$(cut -d : -f 1 $linkfile | sort -u | egrep -v '^($| |#)')" -- "$word"))
# if [ "$COMP_CWORD" -eq 1 ]; then
# COMPREPLY=($(compgen -W "$(cut -d : -f 1 $linkfile | sort -u | egrep -v '^($| |#)')"));
# else
# local words=("${COMP_WORDS[@]}");
# unset words[0];
# unset words[$COMP_CWORD];
# COMPREPLY=($(compgen -W "$(cut -d : -f 1 $linkfile | sort -u | egrep -v '^($| |#)')" ));
# fi
}
complete -F _sugarlookup kohaurl
complete -F _sugarlookup sugar
# look up opac Staff client URL in 'ticketlinks.txt', open URL in web browser
kohaurl () {
local linkfile=$HOME/Support/notes/ticketlinks.txt
if grep "^${1}:" $linkfile 2>&1 > /dev/null
then
staffclient="$(grep ^${1}: $linkfile | grep Staff | cut -d ':' -f 3- | sed 's|/$||')"
url="${staffclient}/${2}"
echo $url
$OPEN $url
fi
}
# look up opac Staff client URL in 'ticketlinks.txt'. Print link without opening it.
kohaprinturl () {
local linkfile=$HOME/Support/notes/ticketlinks.txt
if grep "^${1}:" $linkfile 2>&1 > /dev/null
then
staffclient="$(grep ^${1}: $linkfile | grep Staff | cut -d ':' -f 3- | sed 's|/$||')"
url="${staffclient}/${2}"
echo $url
fi
}
# open staff client in firefox.
kohaff () {
local linkfile=$HOME/Support/notes/ticketlinks.txt
if grep "^${1}\>" $linkfile 2>&1 > /dev/null
then
staffclient="$(grep ^${1}: $linkfile | grep Staff | cut -d ':' -f 3- | sed 's|/$||')"
url="${staffclient}/${2}"
echo $url
$FIREFOX $url 2> /dev/null &
fi
}
# run watchcat remotely.
watchcat() {
echo "watchcat " "$@"
ssh ${BYWATER_USER}@$BYWATER_GATEWAY watchcat "$@"
}
# get urls via watchcat
wcaturl() {
watchcat -tgeturls -k$1
}
# get surgar urls via watchcat
sugarv() {
watchcat -tsugarv -k$1 | sed -n 's/http:/https:/p'
}
wclist() {
watchcat -twclist -k$1
}
# look up koha version using watchcat.
kohaversion() {
echo watchcat -tkohav -k$1
watchcat -tkohav -k$1
}
getcrons() {
echo watchcat -tgetcrons -k$1
watchcat -tgetcrons -k$1 | less
}
ckextras() {
echo watchcat -tckextras -k$1
watchcat -tckextras -k$1
}
# Grep larryb's stash of cron scripts on annon.
grepcrons() {
ssh $BYWATER_GATEWAY egrep --color "${1}" '~larry/crons_backups/crons.*'
}
grepbug() {
sassh bwsdev grep --color "${@}" '/var/lib/koha/community/kohaclone/misc/release_notes/*' | grep "${@}"
}
# koha* and opac* below all open various staff client or opac urls.
# Some of these take additional arguments.
# Usage: (koha*|opac*) SHORTNAME [ARGS]
# Open notices and slips
kohaletter() {
kohaurl "$1" "cgi-bin/koha/tools/letter.pl"
}
# Open a given syspref
# usage: kohasyspref SHORTNAME SYSPREF
kohasyspref() {
kohaurl "$1" "cgi-bin/koha/admin/preferences.pl?op=search&searchfield=${2}"
}
# Open intranetuserjs
kohaijs() {
kohasyspref "$1" "intranetuserjs"
}
# Open opacuserjs
kohaojs() {
kohasyspref "$1" "opacuserjs"
}
# Open admin page
kohaconf() {
kohaurl "$1" "cgi-bin/koha/admin/admin-home.pl"
}
# Open circ page
kohacirc() {
kohaurl "$1" "cgi-bin/koha/circ/circulation-home.pl"
}
# Open borrower page
kohapatron() {
kohaurl "$1" "cgi-bin/koha/members/members-home.pl"
}
# Open advanced search page
kohasearch() {
kohaurl "$1" "cgi-bin/koha/catalogue/search.pl"
}
# Virtual shelves (??)
kohalist() {
kohaurl "$1" "cgi-bin/koha/virtualshelves/shelves.pl"
}
# Add bib page
kohacatalog() {
kohaurl "$1" "cgi-bin/koha/cataloguing/addbooks.pl"
}
# Authorities
kohaauthorities() {
kohaurl "$1" "cgi-bin/koha/authorities/authorities-home.pl"
}
# Serials
kohaserials() {
kohaurl "$1" "cgi-bin/koha/serials/serials-home.pl"
}
# Logout
kohalogout() {
kohaurl "$1" "cgi-bin/koha/mainpage.pl?logout.x=1"
}
# Acquisitions
kohaacq() {
echo "*** Log in as bwssupport! ***"
kohaurl "$1" "cgi-bin/koha/acqui/acqui-home.pl"
}
# Koha reports page
kohareport() {
kohaurl "$1" "cgi-bin/koha/reports/reports-home.pl"
}
# Start new SQL report
kohanewreport() {
kohaurl "$1" "cgi-bin/koha/reports/guided_reports.pl?phase=Create%20report%20from%20SQL";
}
# Open a report by number
kohareportnum() {
kohaurl "$1" "cgi-bin/koha/reports/guided_reports.pl?reports=${2}&phase=Show+SQL";
}
# Edit a report by number
kohaeditreport ()
{
kohaurl "$1" "cgi-bin/koha/reports/guided_reports.pl?phase=Edit%20SQL&reports=${2}"
}
# Open a report by number
kohafixreport() {
kohaurl "$1" "cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&op=convert&report_id=${2}";
}
# Koha tools page
kohatools() {
kohaurl "$1" "cgi-bin/koha/tools/tools-home.pl"
}
# Open a given '.pl' page
# Usage: kohapl SHORTNAME PAGE.pl
kohapl() {
kohaurl "$1" "cgi-bin/koha/$2"
}
# Open detail page for a given bib
# Usage: kohabib SHORTNAME BIBLIONUMBER
kohabib() {
kohaurl "$1" "cgi-bin/koha/catalogue/detail.pl?biblionumber=$2"
}
# Export bib as marc
# Usage kohadlbib SHORTNAME BIBLIONUMBER
kohadlbib() {
kohaurl "$1" "cgi-bin/koha/catalogue/export.pl?format=utf8&op=export&bib=$2"
}
kohaviewlog() {
# TODO: we could run a case statement on $module, then prompt for object.
select module in FINES CIRCULATION MEMBERS SERIAL AUTHORITIES SYSTEMPREFERENCE REPORTS CATALOGUING HOLDS CRONJOBS
do
kohaprinturl "$1" "cgi-bin/koha/tools/viewlog.pl?do_it=1&modules=${module}"
echo "append &object=YOUR_OBJECT:"
echo " FINES, CIRCULATION and members MEMBERS: borrowernumber"
echo " SERIAL: subscription.subscriptionid"
echo " AUTHORITIES: auth_header.authid"
echo " REPORTS: saved_sql.id"
echo " CATALOGUING: itemnumber or biblionumber"
echo " HOLDS: reserve_id"
break;
done
}
# Self Check Out
opacselfcheck() {
opacurl "$1" "cgi-bin/koha/sco/sco-main.pl"
}
# Library of congress marc reference.
marcrefrence() {
$OPEN "http://www.loc.gov/marc/bibliographic/bd${1}.html"
}
# Just because I probably won't remember "opacselfcheck"
kohaselfcheck() {
opacurl "$1" "cgi-bin/koha/sco/sco-main.pl"
}
# Create comment suitable for adding to crontab. Takes RT ticket number as argument. ouput looks like this:
# 2014-02-07 -- Barton Chittenden -- http://ticket.bywatersolutions.com/Ticket/Display.html?id=18204
croncomment () {
echo "# $(date +%Y-%m-%d) -- $USER@bywatersolutions.com -- http://ticket.bywatersolutions.com/Ticket/Display.html?id=$1"
}
# Render markdown file using pandoc, put in HOME/public_html/markdown
md() {
local htmldir="$HOME/public_html/markdown"
test -d $htmldir || mkdir $htmldir
local base="$(basename $1 '.markdown')"
local htmlfile="$htmldir/${base}.html"
pandoc -f markdown+pipe_tables $1 > "$htmlfile"
echo "$htmlfile"
}
# Render markdown file using pandoc, put in current directory -- useful for blog posts.
bmd ()
{
local htmldir=".";
test -d $htmldir || mkdir $htmldir;
local base="$(basename $1 '.markdown')";
local htmlfile="$htmldir/${base}.html";
pandoc -f markdown+pipe_tables $1 > "$htmlfile";
echo "$htmlfile"
}
# show the tables that contain a search term in kohastructure.sql.
grepks ()
{
egrep --color=auto -i "^(CREATE TABLE|[)])|$1" $KOHA/installer/data/mysql/kohastructure.sql | grep --color=auto -i --color=auto -B1 "$1"
}
# round up to the next multiple of 15 -- used for calculating time to report in RT.
rttime () {
perl -e '$minutes = $ARGV[0] + 15; $quarter_hours = int($minutes/15); print $quarter_hours*15 . " minutes\n" ' $1
}
# An extension of querymarc, generating actual sql. Needs to be split into two functions.
qm ()
{
qm="$(querymarc $1)";
echo "select $qm as '$1' from biblio_metadata where $qm != '' limit 1;";
echo "select $qm as '$1', title from biblio_metadata inner join biblio using (biblionumber) where $qm != '' limit 1;";
echo "select marcxml from biblio_metadata where $qm != '' limit 1;"
}
# This was something that I added when I was working on zebra indexing. Pay it very little mind...
# nextrecord 13 20930 gts 'add zebra indexes 260$e, 264$a, 752$a-$h => publisher location' '260$e'
nextrecord ()
{
bibnum=$1;
rtnum=$2;
shortname=$3;
subject="$4";
edbib $bibnum;
t $rtnum $shortname "$subject";
qm="$(querymarc $5)";
echo "assh $shortname";
echo "sudo koha-list";
echo "ps aux | grep $shortname";
echo "sudo koha-mysql $shortname";
echo "select $qm from biblioitems where $qm != '' limit 1;";
echo "select marcxml from biblioitems where $qm != '' limit 1;"
}
# Crontab entries to schedule 'run_rebuild.sh' -- takes RT ticket number as argument
schedule_rebuild() {
local ticket=${1}
local instance=${2}
echo "# $(date +%Y-%m-%d) -- $USER@bywatersolutions.com -- http://ticket.bywatersolutions.com/Ticket/Display.html?id=$1"
echo
echo "# Git"
date +"# 5 0 %d %m %u /home/koha/run_rebuild.sh" -d tomorrow;
if [ -z $instance ]
then
echo "No instance given"
else
echo
echo "# Package: /etc/cron.d/koha-$instance"
date +"# 5 0 %d %m %u ${instance}-koha /var/lib/koha/$instance/run_rebuild.sh" -d tomorrow;
echo
echo "# Cluster: -- schedule in bywater crontab"
date +"# 5 0 %d %m %u sudo /home/bywater/run-rebuild-from-bywater.sh $instance" -d tomorrow
fi
}
# Some sort of date difference thingus -- not sure why.
datediff() {
later="${1}"
earlier="${2}"
echo $(( $(date -d "$later" +%j) - $(date -d "$earlier" +%j) ))
}
# An attempt to figure out which release a bug is in.
bugrelease() {
git log --oneline | egrep -i "Bug $1|release" | grep --context=10 "Bug $1"
}
# search for terms on bywater wiki.
bwiki() {
local searchparams="$(sed 's/ \+/+/' <<< "$*")"
$OPEN "http://wiki.bywatersolutions.com/doku.php?do=search&id=${searchparams}"
}
# Reformat arguments (as copied from IRC) and put them into 'xsel', ready for pasting.
kbticket() { echo "${@}" | sed 's/^.* <samwise> Ticket //; s/(open): //; s/ - http:.*//' | $CLIPCOPY; }
# Today's date, in the format YYYY-MM-DD
today() { local d="$(date --rfc-3339='date')"; echo "Today: $d" ; }
# Daily wrap
dw() {
checkdir "$EMPLOYER_PATH/daynotes/"
local notefile="$EMPLOYER_PATH/daynotes/$(date +%Y%m%d).note.txt"
echo "Daily Wrap-up ( $( date +'%a %b %d, %Y') )"
sed -n '1,/^---- 1/p' $notefile
local EOB="$(sed -n '1,/^---- 1/p' $notefile | grep EOB)"
if [[ ! -z $EOB ]]; then
echo
echo "============================ Un-closed EOB items: ============================="
echo "$EOB"
echo "==============================================================================="
echo
fi
}
# Telnet to a given domain and port, see if the port is open. The commands to exit telnet
# are left in the copy/paste buffer.
porttest() { echo $'\c]quit' | $CLIPCOPY ; telnet $1 $2; }
#alias lynx='lynx -accept_all_cookies'
# Very similar to 'dw' above. This one is actually used internally in 'daynote'
dn ()
{
local notefile=$1;
echo $notefile;
echo;
echo "Daily Wrap-up ( $( date +'%a %b %d, %Y') )";
sed -n '/^---- Done Today/,/^----/p' $notefile | grep --color=auto --color=auto -v '^----';
local EOB="$(sed -n '/^---- Done Today/,/^----/p' $notefile | grep EOB)";
if [[ ! -z $EOB ]]; then
echo
echo "============================ Un-closed EOB items: ============================="
echo "$EOB"
echo "==============================================================================="
echo
fi;
sed -n '/^---- Done Today/,/^----/p' $notefile | grep --color=auto '^ticket' | stdin_gmtix.pl
echo
echo "Daily wrap-up emails"
echo "https://mail.google.com/mail/u/1/#search/Daily+Wrap-up"
checkdir "$EMPLOYER_PATH/daynotes/markdown/"
sed -n '/^---- Personal Notes/,/^----/p' $notefile | grep -v '^----' > \
"$EMPLOYER_PATH/daynotes/markdown/$(date +%Y%m%d)_notes.markdown"
cd $EMPLOYER_PATH/daynotes/markdown/
local htmlfile=$(bmd $(date +%Y%m%d)_notes.markdown)
$OPEN "$htmlfile"
}
# Open daily notes. Print wrap-up when vim closes.
daynote() {
checkdir "$EMPLOYER_PATH/daynotes/"
notefile="$EMPLOYER_PATH/daynotes/$(date +%Y%m%d).note.txt"
if [[ ! -e $notefile ]]
then
cat > $notefile << DAYNOTE
---- Done Today
Linux tip of the day:
What I Learned:
---- My Tickets
Other tickets
---- Queries
--
foo
--
foo
--
foo
--
foo
--
foo
--
foo
---- Scratch
...
...
...
---- Personal Notes
----
DAYNOTE
fi
vim -S $EMPLOYER_PATH/.bywater_vimrc +/"My Tickets" $notefile
echo
dn $notefile
}
# Reads argument list containing RT ticket numbers, search for unread emails containing those tickets.
gmtix() {
echo ""
echo "Emails today about tickets I've touched."
perl -E 'say "https://mail.google.com/mail/u/1/#search/(from%3Asupport%40bywatersolutions.com)+is%3Aunread+subject%3A(" . join( "+OR+", @ARGV ) . ")"' $@;
echo ""
}
# Look up opac and staff client URLs. (Somewhat) suitable for pasting into vim for 'sugar' above.
kohalinks() {
watchcat -tgeturls -k$1 | grep http | while read url; do
local wget_out="$(wget --quiet -O - $url)"
if [[ $? = 0 ]]; then
if grep -q 'TEMPLATE FILE: opac-main.tt' <<< "$wget_out"; then
echo "$1 OPAC: $url"
else
echo "$1 Staff: $url"
fi
fi
done | sort -r
}
# Allows you to choose queries listed in the '$SUPPORT_QUERIES' directory and
# gives you the wget line that you can paste into ssh to run the queries via koha-mysql.
# May optionally take an instance name.
sq() {
(
cd $SUPPORT_QUERIES
local INSTANCE=${1}
local SQLCMD="sudo koha-mysql $INSTANCE"
select query in *.sql quit; do
case $query in
quit)
break
;;
*)
echo "wget -q -O - http://bywatersolutions.github.io/koha_support_queries/$query | $SQLCMD"
break
;;
esac
done
)
}
wiki() {
$OPEN http://wiki.bywatersolutions.com/
}
dlmarc ()
{
local linkfile=$HOME/Support/notes/ticketlinks.txt;
if grep "^${1}\>" $linkfile 2>&1 > /dev/null; then
opac="$(grep ^${1}: $linkfile | grep 'Opac' | cut -d ':' -f 3- | sed 's|/$||')";
url="${opac}/cgi-bin/koha/opac-export.pl?op=export&bib=${2}&format=utf8";
marcfile="${1}.${2}.marc"
echo $url;
echo $marcfile;
wget --no-check-certificate -O $marcfile $url;
fi;
}
dlmarcxml ()
{
local linkfile=$HOME/Support/notes/ticketlinks.txt;
if grep "^${1}\>" $linkfile 2>&1 > /dev/null; then
opac="$(grep ^${1}: $linkfile | grep 'Opac' | cut -d ':' -f 3- | sed 's|/$||')";
url="${opac}/cgi-bin/koha/opac-export.pl?op=export&bib=${2}&format=marcxml";
marcfile="${1}.${2}.marcxml"
echo $url;
echo $marcfile;
wget --no-check-certificate -O $marcfile $url;
fi;
}
ggrep ()
{
git grep "${@}" -- './*' ':(exclude)misc/translator/po' ':(exclude)installer/data/mysql' ':(exclude)t/edi_testfiles'
}
rtcomponent() {
local subject="$1"
echo "http://ticket.bywatersolutions.com/Search/Results.html?Format=%27__CustomField.%7BComponent%2FModule%7D__%27%2C%0A%27%3Cb%3E%3Ca%20href%3D%22__WebPath__%2FTicket%2FDisplay.html%3Fid%3D__id__%22%3E__id__%3C%2Fa%3E%3C%2Fb%3E%2FTITLE%3A%23%27%2C%0A%27%3Cb%3E%3Ca%20href%3D%22__WebPath__%2FTicket%2FDisplay.html%3Fid%3D__id__%22%3E__Subject__%3C%2Fa%3E%3C%2Fb%3E%2FTITLE%3ASubject%27&Order=ASC%7CASC%7CASC%7CASC&OrderBy=id%7C%7C%7C&Query=Subject%20LIKE%20%27${subject}%27%20AND%20%27CF.%7BComponent%2FModule%7D%27%20IS%20NOT%20NULL&RowsPerPage=50&SavedChartSearchId=new&SavedSearchId=new"
}
kohadoc() {
$OPEN file:///home/barton/Employer/bywater/support/notes/translate.koha-community.org/manual/16.11/en/html-desktop/index.html
}
c() {
local f=/tmp/sql.sql
rm $f
$CLIPPASTE > $f
egrep '\<(items|statistics|location)\>' $f
echo
echo $f
}
rtrequestor() {
if [[ ! -z "$*" ]]; then
rt ls -l -t ticket "RequestorGroup = '$*' AND Created > '2017-01-01'" \
| sed -n '/Requestors: /{s/Requestors: //p}' \
| sed 's/, /\n/' | sort | uniq -c | sort -n
fi
}
rtlistnew() {
rt list "( Status = 'new' ) OR ( Status != 'new' AND Created > '7 days ago' AND 'CF.{Component/Module}' IS NULL ) OR ( Owner = 'Nobody' AND Status != 'resolved' AND Status != 'answered' )"
}
# echo ticket subject line matching rt ticket regex.
tsubject() {
echo "[ticket.bywatersolutions.com #$1]"
}
bennysuggs() {
echo "brendan@bywatersolutions.com joy@bywatersolutions.com"
echo "Benny suggs $(date +%Y-%m-%d)"
}
tl() {
ticketlink $1 > /tmp/${1}.markdown
( cd /tmp; bmd ${1}.markdown; xdg-open ${1}.html )
}
grepticket ()
{
ticketnum=$1;
shift;
rt show $ticketnum | egrep --color=auto -i "$*";
sleep 1
}
ticket ()
{
local ticket_url="${RTSERVER}/Ticket/Display.html?id=${1}";
echo "$ticket_url";
chromium-browser --new-window "$ticket_url";
sleep 1;
echo
}