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