3
# This script interviews a new user of edbrowse,
4
# and creates an initial version of the .ebrc config file.
5
# The config file can be edited thereafter.
7
# Abort if an error occurs
15
if [ $SHELL = /bin/bash ]
18
shellstart=.bash_login
37
function responsenumber()
42
if [ -z "${answer/[0-9]*/}" ]
46
echo "Please enter a number."
50
function responserange()
57
if [ $answer -ge $start -a $answer -le $end ]
61
echo "Please enter a number between $start and $end."
65
# respond with a certain letter
66
function responselrs()
73
if [ -z "${answer/[$lrs]/}" ]
77
echo "Please enter one of the letters $lrs."
87
if [ "$answer" = y -o "$answer" = n ]
91
echo "Please enter y or n."
97
question="Hit return to continue"
102
# edbrowse config file
104
function configstart()
108
echo "I am creating your edbrowse config file in $ebcf.
109
I will write text into this file as we go along.
110
This file contains passwords, and should not be readable by others.
111
I will set the permissions accordingly; please leave it at 600.
114
echo '# edbrowse configuration file.
115
# You can edit this file via edbrowse -c.
117
# autosetup 1' >$ebcf
121
echo "File created successfully.
126
lastline=`tail -1 $ebcf`
128
prelevel=${lastline:3:9}
133
if [ "$prelevel" != autosetup ]
135
echo "You already have an edbrowse config file in place;
136
I will be working with the file $ebcf.new.
137
When we're done, you can move this back to $ebcf, but beware,
138
you will lose all the configuration information that you currently have in that file.
146
if [ "$prelevel" != autosetup ]
148
echo "Your .ebrc.new file seems to be complete, or corrupted.
149
I cannot safely update either of these files.
150
Please remove one or both of them, and start this script again."
156
echo "*** level 1, default behaviors ***
159
echo "The debug level determines the amount of output you will receive.
160
0 is silent, except for errors.
161
1 prints the size of each file as it is read or written.
162
2 prints the different urls as you are redirected from one website to another.
163
Higher levels crank out more output, but you probably don't want to see that.
164
Most people like level 1."
165
question="Enter debug level"
171
echo "When a simple error occurs, I usually print out a question mark,
172
and nothing more. I can however print the error message every time.
173
Most people like the quick question marks for simple typos."
174
question="Do you want to read the error message every time"
180
echo "When scanning through a directory, it is readonly by default.
181
This means you cannot delete a file, simply by deleting the corresponding line.
182
You can change this behavior so that deleted files are moved
183
to your trash bin, or deleted altogether.
184
r = directories are readonly.
185
m = deleted files move to your trash bin.
186
x = deleted files go away forever."
187
question="How should deletes in directory mode behave"
201
echo "When you edit a directory, some files are hidden by default.
202
These are the files that begin with a dot, like .ebrc."
203
question="Do you want to see these files"
209
echo "When a line is listed with the l command,
210
I can put ^ at the beginning of the line and $ at the end.
211
Or I can do this all the time.
213
l = end markers on listed lines.
214
p = end markers every time I print a line."
215
question="When do you want ^ $ markers to appear"
230
echo "# The init function is run when edbrowse is started.
231
# It can be used to establish the settings you want,
232
# or preload common files such as your bookmarks etc.
234
# debug level is 0 at the start, to avoid a lot of messages at startup
236
# end markers for listed lines
240
echo "# Show hidden files in a directory
243
echo "# Manage deleted files in directory mode
247
echo "# Show the error messages every time.
252
echo "# set the debug level
265
echo "*** level 2, special edbrowse files ***
268
echo "Many people put their bookmarks, email addresses, certificates, etc in an edbrowse directory.
269
Enter a directory now, or just hit return for the default."
270
question="Edbrowse system directory"
280
echo "$ebdir is not a directory"
285
echo "It is convenient to have a file of bookmarks, also known as favorites
286
in the Windows world.
287
It isn't strictly necessary, but if you have this set up,
288
I can create some aliases and functions that will make it easier
289
to access, and add to, your bookmarks."
290
question="Enter the location of your bookmarks file"
291
defans=$ebdir/bookmarks
298
<!-- Bookmark file, compatible with edbrowse.
299
A bookmark typically consists of 3 lines.
303
This is created by the A command.
304
Of course this file can be viewed by any browser.
308
<A HREF=http://www.eklhad.net>
309
Karl Dahlke home page
311
<A HREF=http://www.mathreference.com>
314
<A HREF=http://www.space.com>
320
# put bookmark variables in the shell files?
323
if [ $shellknown = y ]
325
echo "I can create, in your $shellstart file, a variable like this:
326
export bookmarks=$ebbm
327
so you can access your bookmarks from anywhere.
328
I can also put an alias in your $shellfns file
329
alias ebm='edbrowse \$bookmarks'
330
so you can type in ebm and edet or access your bookmarks from anywhere.
331
(You will need to log out and log back in for this alias to take effect.)"
332
question="Would you like me to create this alias"
339
echo "I will create, in your config file, a function wbm that you can invoke via
341
This will add the contents of your current buffer to your bookmarks.
342
Usually this follows the A command, which builds your bookmark.
343
Check it out in your config file when this program is over."
347
echo "It is convenient to have a file of email addresses,
348
i.e. your address book.
349
It isn't strictly necessary, but if you have this set up,
350
I can create some aliases and functions that will make it easier
351
to access, and add to, your address book."
352
question="Enter the location of your address book"
359
echo "# Address book, compatible with edbrowse.
368
eklhad:eklhad@gmail.com:home phone:cell phone:anything else you like
373
# put address book variables in the shell files?
376
if [ $shellknown = y ]
378
echo "I can create, in your $shellstart file, a variable like this:
380
so you can access your address book from anywhere.
381
I can also put an alias in your $shellfns file
382
alias eab='edbrowse \$adbook'
383
so you can type in eab and edet or access your email addresses from anywhere.
384
(You will need to log out and log back in for this alias to take effect.)"
385
question="Would you like me to create this alias"
392
echo "I need a file for cookies.
393
If you don't know what cookies are, don't worry about it.
394
It's just something I need to browse certain websites."
395
question="Enter the location of your cookie jar"
396
defans=$ebdir/cookies
400
# Some cookies contain passwords.
404
echo "I need a file for secure certificates.
405
These are used for secure transactions on the web, such as amazon.com."
406
lynxcert=/etc/ssl/cert.pem
410
echo "I see you already have such a file, $lynxcert,
411
which is used by lynx.
412
Would you like edbrowse to use the same file,
413
so that lynx and edbrowse share the same certificates?"
414
question="Share with $lynxcert"
425
question="Enter the location of your certificate file"
433
echo "Would you like me to retrieve a file of certificates from the internet?
434
You must be on line for this to work."
435
question="Fetch from internet"
440
wget -q -O $ebcert http://www.eklhad.net/linux/app/ssl-certs
443
echo "Ok, you can get a certificate file later."
446
echo "Later on, when you are logged in as root, you may want to move this
447
to $lynxcert, so that your certificates can be shared among
448
edbrowse, lynx, and other browsers."
452
echo "I need a file to store IP addresses that usually generate spam.
453
This file can be empty for now; as long as it exists.
454
We'll worry about how to populate it later."
455
question="List of suspect IP addresses"
456
defans=$ebdir/ipblack
462
echo "When edbrowse fetches your mail, it automatically moves to a directory
463
that you can think of as your in-box."
464
question="Enter mail directory"
474
if [ $shellknown = y ]
476
# It's really stupid that bash doesn't call .bashrc after invoking .bash_login.
477
# So you should call .bashrc from insinde .bash_login.
480
if grep -q "^\. *$shellfns" $shellstart
489
export bookmarks=$ebbm" >> $shellstart
491
alias ebm='edbrowse $ebbm'" >> $shellfns
492
if [ $callbashrc = n ]
495
alias ebm='edbrowse $ebbm'" >> $shellstart
502
export adbook=$ebad" >> $shellstart
504
alias eab='edbrowse $ebad'" >> $shellfns
505
if [ $callbashrc = n ]
508
alias eab='edbrowse $ebad'" >> $shellstart
512
echo "# My address book.
518
# secure certificates for https
521
# ip addresses in the blacklist
524
# Write spam messages here. I use a file in my trash bin,
525
# so I know it gets cleaned out every week.
526
spamcan = $HOME/.Trash/spamcan
528
# Function to write a bookmark to your list of favorites.
529
# Best to use this function every time, because it appends.
530
# If you do it manually you might accidentally write without append,
531
# and clobber all the bookmarks you have accumulated.
536
# Move to this directory when fetching mail.
539
# autosetup 3" >> $ebcf
546
echo "*** level 3, mail accounts ***
548
It's time to configure your mail accounts,
549
so that edbrowse can act as a mail client, retrieving and sending mail
550
over the Internet. I only need to know about direct mail accounts.
551
If you have a mail account, such as hotmail.com, that you access
552
through your browser, as a website, I don't need to know about that.
553
I only need to know about mail accounts that you access through a mail client
554
like Outlook, Pine, Eudora, etc."
555
question="Do you have any of these mail accounts"
560
# Build the mail string as we go.
561
# I'll turn & into newline later.
562
mst="# Mail accounts.&# These are the direct mail accounts, web based email is not needed here.&"
566
mst="$mst&# No mail accounts at the present time.&"
570
echo "Great. Here is what you will need for each mail account.
571
1. The machine that you get your mail from, and send your mail to.
572
These are often the same machine, such as mail.somedomain.com,
573
but sometimes they are different, such as pop3.somedomain.com
574
and smtp.somedomain.com.
575
2. Whether these connections are secure/encrypted.
576
Local mail, offered by your ISP, is usually not.
577
Distant mail, such as Google mail, usually is, since your personal email
578
travels across the Internet to get to and from the server.
579
3. Your email address relative to this account.
580
This takes the form: username@somedomain.com.
581
4. Login, usually the same as username.
582
5. Password. This is the secret that keeps others from accessing your mail.
583
6. Full name. This appears in your emails.
584
Of course you know what your name is, but you may want different names
585
for different accounts.
586
Home account, work account, your child's account, etc.
587
So I give you the chance to enter a different name with each account.
588
You need all this information at hand, for each account, before we proceed."
599
echo "Enter your first mail account.
600
This should be the primary account, the one offered by your ISP.
601
For technical reasons, this will become the default account.
602
If you just type sm, without specifying an account,
603
I will use this account to send your mail."
607
question="Do you have another mail account"
617
echo "Enter the email address.
618
This looks like user@somedomain.com."
619
question="Email address"
626
question="Enter user name"
631
question="Enter password"
636
question="Enter the full name associated with this account"
641
question="Enter the machine where you get your mail"
642
defans="mail.$domain"
646
question="Enter the machine where you send your mail"
648
defans=${defans/#pop3./smtp.}
649
defans=${defans/#pop./smtp.}
653
question="Is this a secure/encrypted connection"
658
mst="$mst&mail {&inserver = $pop&outserver = $smtp"
665
mst="$mst&inport = *995&outport = *465"
667
mst="$mst&inport = 110&outport = 25"
669
mst="$mst&login = $user&password = $password&from = $fullname&reply = $reply&}&"
671
echo "You may want to create an alias for convenient access to this account.
672
alias whatevermail='edbrowse -m$mailnum'
673
I'll leave that to you.
675
mailnum=$((mailnum+1))
680
echo "$mst&# autosetup 4" |
681
tr '&' '\12' >> $ebcf
688
echo "*** level 4, filters ***
690
I will place a from filter block in your config file.
691
This directs email from certain people, by name or by email address,
693
I'm only creating the fromfilter { } block at this time.
694
You can edit your config file and fill in the details later.
695
Remember that every line in your address book becomes its own from filter,
696
so you don't have to duplicate all those entries. For instance,
697
fred:fred.flintstone@cartoons.com
698
will save any message from fred.flintstone@cartoons.com to a file called fred.
699
But Fred might have a work email down at the Cave Construction Company,
700
so you might want to filter him by name as well.
701
Fred Flintstone > fred
702
I will add an entry for myself, by name, in case you get email from me
703
in the future, from any of my numerous email accounts.
705
That will be the only entry in your fromfilter block, for now."
709
echo "I will create a subject filter block, which saves emails into files
710
based on subject, and a to filter block, which saves emails into files
711
based on the email address it was sent to.
712
Again, these blocks will be empty."
716
echo "I will create a last spamm function, <lspam, that will retrieve the last
717
message that was placed in your spam area.
718
Similarly, <bspam steps back to the previous spam message, and so on.
719
You should really review your spam emails, because my source IP
720
test is really quite crude, and there are plenty of false positives."
724
echo "# to, from, and subject filters
736
# Function to read the last spam message.
738
e /home/eklhad/.Trash/spamcan
745
# Back up to the previous spam message.
758
# Sometimes javascript does nothing more than deliver advertisements,
759
# and edbrowse javascript is not the greatest,
760
# so turn it off for certain domains.
763
# autosetup 5" >> $ebcf
770
echo "*** level 5, audio files ***
772
Enter the program, with parameters, that plays wave, voc, and audio files."
773
playloc=`whereis -b play`
774
playloc=${playloc/#play:/}
775
playloc=${playloc/# /}
778
echo "Audio player found in $playloc,
779
but you can use another player if you wish."
782
echo "Leave blank if you have no player installed."
785
question="Audio player"
790
echo "Enter the program, with parameters, that plays mp3 files."
791
mpgloc=`whereis -b mpg123`
792
mpgloc=${mpgloc/#mpg123:/}
796
echo "MP3 player found in $mpgloc,
797
but you can use another player if you wish."
800
echo "Leave blank if you have no mp3 player installed."
803
question="MP3 player"
808
echo "Enter the program, with parameters, that plays streaming audio.
809
This is RealPlayer audio, not Windows Media or Quicktime;
810
those are not supported yet."
811
trloc=`whereis -b trplayer`
812
trloc=${trloc/#trplayer:/}
816
echo "Streaming audio player found in $trloc,
817
but you can use another player if you wish."
820
echo "Leave blank if you have no streaming audio player installed."
823
question="Streaming audio player"
829
echo "# Describe the mime types and the programs to run them.
832
if [ -n "$playprog" ]
836
desc = audio file in a wave format
838
# The star is replaced with the suffix at runtime
848
desc = audio file in mp3 format
858
# the < forces it to be a stream, hence the url is passed to the program
859
type = <audio/x-pn-realaudio
860
desc = streaming audio real player
876
echo "*** level 6, sample functions ***
878
Perhaps the two most useful sites on the Internet are google and wikipedia.
879
I will create two functions that make it easy to access these sites.
880
They are similar to shortcuts in the desktop world.
881
To search for kangaroo in google, type <gg kangaroo.
882
To search for kangaroo in wikipedia, type <wk kangaroo.
883
These functions will also show you, by example,
884
how to write your own functions with parameters etc.
885
Please review your config file and look for the functions gg and wk."
890
# User defined functions, macros, and shortcuts.
894
b http://www.wikipedia.org/search-redirect.php?search=~0&language=en&go=%3E&go=Go
899
b www.google.com/search?q=~0&hl=n&btnG=Google+Search&meta=
900
# invoke the google cleanup routine
904
# strip the trash off of a google page.
905
# This can become out of date if google changes its page layout.
907
# get rid of pdf warnings
908
g/^Your browser may not have a PDF reader available.$/d
909
g/^{Similar pages}$/d
910
# trailing lines, after "search next", can go away
911
/^{search Next}$/+,$d
912
# initial lines and stats can go away
914
# move the "did you mean" line to the end; we need to keep this one
915
/^Did you mean:$/,/^Did you mean:$/+2m$
916
# more stuff at the start that we don't need
917
1,/^Tip: Save time by hitting/+d
918
# put the "did you mean" line back to the top, if it's there
919
/^Did you mean:$/,$m0
924
# Get rid of the autosetup lines.
925
ed $ebcf <<! >/dev/null 2>&1
926
g/^# autosetup [0-9]$/d
931
echo "Congratulations, your config file $ebcf is complete."