initial checkin
[grml-scripts.git] / usr_bin / grml-slrn
1 #!/bin/sh
2 # Filename:      grml-slrn
3 # Purpose:       configuration script for slrn
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 # Latest change: Sun Jan 15 22:46:00 CET 2006 [mika]
8 ################################################################################
9
10 PATH=${PATH:-'/bin/:/sbin/:/usr/local/bin:/usr/bin:/usr/sbin'}
11 PN=$(basename "$0")
12 USER=$(grep \`whoami\` /etc/passwd | cut -d: -f5 | cut -d, -f1)
13 HOST=$(hostname -f)
14
15 [ -z "$EDITOR" ] && EDITOR='vim'
16 [ -z "$NNTPSERVER" ] && NNTPSERVER="news.`hostname`"
17
18 # some functions used in the interactive part
19 testfiles() {
20   [ -d $HOME/News ] || mkdir $HOME/News
21   [ -f $HOME/.slrn_scoring ] || touch $HOME/.slrn_scoring
22 }
23
24 writeslrnrc() {
25 cat > $SLRNRC << EOF
26 % Filename:      .slrnrc
27 % Purpose:       configuration for newsreader slrn, created by 'grml-slrn'
28 % Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
29 % Bug-Reports:   see http://grml.org/bugs/
30 % License:       This file is licensed under the GPL v2.
31 % Latest change: Son Nov 28 22:38:30 CET 2004 [mika]
32 %###############################################################################
33
34 %###############################################################################
35 % Ressources:
36 % TFM:                         http://slrn.sourceforge.net/manual/slrn-manual.html
37 % Andrew Preater's .slrnrc:    http://www.preater.f9.co.uk/slrn/slrnrc.gz
38 % Jurriaan's page:             http://www.xs4all.nl/~thunder7/
39 % Emmanuele's page:            http://digilander.libero.it/ebassi/slrn.html
40 % Sven's site:                 http://www.guckes.net/slrn/
41 % tsca's s-lang macros:        http://www.geocities.com/tsca.geo/slang.html
42 % Tomasz K³oczko's slrn-stuff: http://cvs.pld.org.pl/slrn-pl/
43 % Tomasz K³oczko's macros:     http://cvs.pld.org.pl/slrn-pl/macros
44 % jbn's S-Lang code:           http://forestfield.org/slrn/
45 % S-lang regexps:              http://www.s-lang.org/doc/html/slang-18.html
46 %###############################################################################
47
48 % important variables - adjust them if necessary
49   set username "$USERNAME_SLRN"
50   set hostname "$HOSTNAME_SLRN"
51   set realname "$REALNAME_SLRN"
52   set organization "www.grml.org"
53 % set replyto  "devnull@grml.org"
54
55 % set signature "signature_ng"
56 % set signoff_string "-mika-"
57
58   server "$NEWSSERVER"  ".newsrc_$NEWSSERVER"
59
60 % If a server requires authentication, add a nnrpaccess line for it.
61 % If you leave username and/or password empty, slrn will prompt for it.
62 % nnrpaccess "news.isp.tld" "username" "password"
63
64   set write_newsrc_flags 0
65
66   set generate_message_id 0
67   set generate_date_header 1
68   set read_active 1
69
70   set editor_command "$EDITOR -f +%d '%s'"
71   set mail_editor_command "mutt -H '%s'"
72   set score_editor_command "$EDITOR '%s'" % $HOME/.slrn_scoring"
73   set abort_unmodified_edits 1
74   set metamail_command "metamail"
75   set non_Xbrowser "screen -t 'url' $BROWSER %s"
76   set Xbrowser "screen -t 'url' $BROWSER %s"
77
78 % Command to use for printing
79 #ifdef UNIX
80         set printer_name "muttprint"
81 #elifdef WIN32
82         % set printer_name "MyPrinter"
83 #endif
84
85   set save_posts "News/My_Posts"
86   set save_replies "News/My_Replies"
87   set failed_posts_file "~/dead.letter"
88
89   set scorefile "$HOME/.slrn_scoring"
90   set decode_directory "News"
91   set save_directory "News"
92   set postpone_directory "News/postponed"
93   set followup_string "* %r <%f> wrote:"
94   set followup_strip_signature 0
95   ignore_quotes "^ *[a-zA-Z-]*>" "^ *[\]|)]" "^ *:[^-()^]"
96   set reply_string "* %r <%f> [%n]:
97   set cc_followup 1
98   set cc_post_string "[This message has also been posted to %n.]"
99
100   header_display_format 0 "%F%-5S%-5l: [%20r] %t %70s %-12g[%10d]"
101   header_display_format 1 "%F%G%-5l:[%12r]%t%s"
102   header_display_format 2 "%F%-5l:%t%s"
103   header_display_format 3 "%F%-5S%-5l:%t%50s %r"
104   header_display_format 4 "%F%-5S [%10r]:%t%49s %-19g[%17d]"
105
106 % How to display the groups index
107   group_display_format 0 "  %F%-5u  %n%45g%d"
108   group_display_format 1 "  %F%-5u [%-6t]  %n"
109   group_display_format 2 "  %F [%-5u|%-6t] %n%45g%d"
110   group_display_format 3 "  %F%-5u  %n%50g%-8l-%h"
111
112   set spoiler_display_mode 1
113
114   set charset isolatin
115   set use_mime 1
116   set mime_charset "iso-8859-15"
117
118   set sorting_method 5
119   set check_new_groups 1         % let slrn check for new newsgroups
120   set unsubscribe_new_groups 1   % new groups are unsubscribed by default
121
122   set beep 2
123   set new_subject_breaks_threads 0 % No, no!
124
125   visible_headers "Subject:,From:,Organization:,Newsgroups:,Date:,Followup-To:,Mail-Copies-To:,Reply-To:,Message-ID:,Supersedes:,User-Agent,Approved,X-Mailer,X-Newsreader:,X-Posting-Agent:,X-Http-User-Agent:,X-,!X-Trace:,!X-Complaints-To:,!X-Face:,!X-MSMail-Priority:,!X-MimeOLE:,!X-Priority:,!X-Accept-Language:"
126
127   set process_verbatim_marks 1
128   set simulate_graphic_chars 1
129   set display_cursor_bar 0
130   set scroll_by_page 0
131   set color_by_score 3
132   set highlight_unread_subjects 2
133   set highlight_urls 1
134   set confirm_actions 31   % 1 & 2 & 4 & 8 & 16
135   set warn_followup_to 2
136   set emphasized_text_mask 1 % message only
137   set emphasized_text_mode 3 % Display text as text!
138   set query_next_article 0 % Very annoying until I turned it off.
139   set wrap_flags 7  % _Automatically_ wrap quoted material and body
140   set wrap_method 2
141 EOF
142 }
143
144 lightcolors() {
145 cat >> $SLRNRC << EOF
146
147 % color setup
148 color article              "blue"         "white"
149 color author               "red"          "white"
150 color boldtext             "black"        "white"
151 color box                  "black"        "white"
152 color cursor               "yellow"       "red"
153 color date                 "brightblue"   "black"
154 color description          "black"        "white"
155 color error                "red"          "white"
156 color frame                "yellow"       "blue"
157 color from_myself          "brightred"    "black"
158 color group                "blue"         "white"
159 color grouplens_display    "yellow"       "red"
160 color header_name          "green"        "white"
161 color header_number        "green"        "white"
162 color headers              "blue"         "white"
163 color high_score           "brightred"    "white"
164 color italicstext          "magenta"      "white"
165 color menu                 "yellow"       "red"
166 color menu_press           "blue"         "yellow"
167 color message              "black"        "white"
168 color neg_score            "magenta"      "white"
169 color normal               "black"        "white"
170 color pgpsignature         "brown"        "white"
171 color pos_score            "blue"         "white"
172 color quotes               "red"          "white"
173 color quotes1              "magenta"      "white"
174 color quotes2              "brown"        "white"
175 color quotes3              "red"          "white"
176 color quotes4              "brown"        "white"
177 color quotes5              "blue"         "white"
178 color quotes6              "black"        "white"
179 color quotes7              "brown"        "white"
180 color response_char        "green"        "white"
181 color selection            "yellow"       "white"
182 color signature            "black"        "white"
183 color status               "yellow"       "red"
184 color subject              "black"        "white"
185 color thread_number        "blue"         "white"
186 color tilde                "green"        "white"
187 color tree                 "red"          "white"
188 color underlinetext        "cyan"         "white"
189 color verbatim             "red"          "white"
190
191 % This color object is only used when highlight_unread_subjects is set to 2
192 % (see the reference manual for details)
193 color unread_subject    "red"        "white"
194 mono  unread_subject    "bold"
195
196 % These attributes are for terminals that cannot display color:
197 mono article            "none"
198 mono author             "none"
199 mono boldtext           "bold"
200 mono cursor             "bold"  "reverse"
201 mono date               "none"
202 mono description        "none"
203 mono error              "blink" "bold"
204 mono frame              "reverse"
205 mono from_myself        "bold"
206 mono group              "bold"
207 mono grouplens_display  "none"
208 mono header_number      "none"
209 mono headers            "bold"
210 mono high_score         "bold"
211 mono italicstext        "bold"
212 mono menu               "reverse"
213 mono menu_press         "none"
214 mono normal             "none"
215 mono pgpsignature       "none"
216 mono quotes             "underline"
217 mono quotes1            "underline"
218 mono quotes2            "underline"
219 mono quotes3            "underline"
220 mono quotes4            "underline"
221 mono quotes5            "underline"
222 mono quotes6            "underline"
223 mono quotes7            "underline"
224 mono response_char      "bold"
225 mono selection          "bold"  
226 mono signature          "none"
227 mono status             "reverse"
228 mono subject            "none"
229 mono thread_number      "bold"
230 mono tree               "bold"
231 mono underlinetext      "underline"
232 mono url                "bold"
233 mono verbatim           "none"
234 EOF
235 }
236
237 # FIXME TODO
238 darkcolors() {
239 cat >> $SLRNRC << EOF
240 % dark color setup
241 % ....
242 EOF
243 }
244
245 infoscreen() {
246 dialog --stdout --title "$PN" --msgbox "Thanks for using $PN!
247
248 More information on slrn:
249
250 Manual: man 1 slrn
251
252 Webpages:
253 www.slrn.org
254 www.michael-prokop.at/slrn/
255
256 #######################################################
257
258 Report bugs, send wishes and feedback to the grml team:
259 http://www.grml.org/ - contact (at) grml.org
260 " 20 65
261 }
262
263 # interactive part
264 dialog --stdout --title "$PN" --msgbox "Welcome to $PN!
265
266 This script will create a simple base
267 configuration for the newsreader slrn.
268
269 Report bugs, send wishes and feedback to the grml team:
270 http://www.grml.org/ - contact (at) grml.org
271 " 13 65
272
273 GETREALNAME_SLRN=$(dialog --stdout --title "$PN" --inputbox "Your real name (eg 'John GRML User'):" 0 65 "$USER" ) || exit 0
274 REALNAME_SLRN=${GETREALNAME_SLRN%/*}
275
276 GETMAILADDR=$(dialog --stdout --title "$PN" --inputbox "Your main mail address (eg 'joedoe@grml.org'):" 0 65 `whoami`@$HOST ) || exit 0
277 MAILADDR=${GETMAILADDR}
278 USERNAME_SLRN=$(echo "$MAILADDR" | sed "s/@.*//")
279 HOSTNAME_SLRN=$(echo "$MAILADDR" | sed "s/.*@//")
280
281 GETNEWSSERVER=$(dialog --stdout --title "$PN" --inputbox "What's the newsserver you want to use?
282 (eg 'news."$HOSTNAME_SLRN"'):" 8 65 "$HOST" ) || exit 0
283 NEWSSERVER=${GETNEWSSERVER}
284
285 GETCOLOR=$(dialog --stdout --title "$PN" \
286           --radiolist "Which color setup do you want to use?" 10 65 2 \
287           dark   "dark color setup (default)" on \
288           light  "light color setup" off)
289 retval=$?
290 case $retval in
291   0) COLOR=$GETCOLOR ;;
292   *) exit 1 ;;
293 esac
294
295 writecolors() {
296   if [ "$COLOR" == 'light' ] ; then
297     lightcolors
298   fi
299   if [ "$COLOR" == 'dark' ] ; then
300     darkcolors
301   fi
302 }
303
304 GETSLRNRC=$(dialog --stdout --title "$PN" --inputbox "Choose a filename for this configuration:" 0 65 "$HOME/.slrnrc") || exit 0
305 SLRNRC=${GETSLRNRC}
306
307 WRITESLRNRC=$(dialog --stdout --title "$PN" --yesno "Write $SLRNRC?" 5 65)
308 retval=$?
309
310 case $retval in
311   0) 
312     if [ -f "$SLRNRC" ] ; then
313       dialog --stdout --title "$PN" --yesno "$SLRNRC exists. Overwrite?" 5 65
314       retval=$?
315       case $retval in
316         0) 
317           writeslrnrc && writecolors && \
318           dialog --stdout --title "$PN" --msgbox "Writing $SLRNRC was successful." 7 65 || \
319           dialog --stdout --title "$PN" --msgbox "Error $?: writing $SLRNRC failed." 7 65
320           ;;
321 #        *) exit 1 ;;
322       esac
323     else
324        writeslrnrc && writecolors && \
325        dialog --stdout --title "$PN" --msgbox "Writing $SLRNRC was successfull." 7 65 || \
326        dialog --stdout --title "$PN" --msgbox "Error $?: writing $SLRNRC failed." 7 65
327     fi
328     ;;
329 #  *) exit 1 ;;
330 esac
331
332 infoscreen
333
334 ASKRUN=$(dialog --stdout --title "$PN" --yesno "Run slrn now?" 0 0)
335 retval=$?
336
337 case $retval in
338   0) 
339      slrn -create -h $NEWSSERVER -f $HOME/.newsrc_$NEWSSERVER -i $SLRNRC && \
340      echo ""
341      echo "Start slrn with taken settings via:
342 $ slrn -h $NEWSSERVER -f $HOME/.newsrc_$NEWSSERVER -i $SLRNRC
343
344 Thanks for using $PN and have fun with slrn!"
345      ;;
346 esac
347
348
349 ## END OF FILE #################################################################