File: postinst.beispiel

package info (click to toggle)
postit 0.5-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 160 kB
  • ctags: 218
  • sloc: ansic: 753; sh: 241; makefile: 61
file content (199 lines) | stat: -rw-r--r-- 4,765 bytes parent folder | download | duplicates (3)
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
#!/bin/bash

# Configurationscript for newsflash
# Copyright by Matthias Kabel <mkabel@debian.org> 1999
# Feel free to redistrubute and/or modify it  under the terms of the 
# GNU Public Licence
# You should hve the GPL somewhere on your computer if not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

CONFIG_PATH="/etc/news/newsflash/"
GROUPLIST="list"
GROUPLIST0="list0"
GROUPLIST1="list1"

SERVERLIST="serverlist"

ACTIVE_PATH="/var/lib/news/"
ACTIVE_FILE="active"

MAX_NUMBER=4

DATE=`date +%s`
DATE=`expr $DATE - 86400`

README="#Read /usr/doc/newsflash/README and edit the file for optimization"

##############################################################
ask_active_file()
{
	echo "There is an active file from inn, should we take this ?
This would be only a first guess, you have to optimize the resulting files.
Please answer y or n
"
	read a
	case $a in
		y|Y) create_grouplists ; useactive ;;
		n|N) readme ;;
		*) ask_active_file;;
	esac
}

##############################################################
ask_fqdn()
{
	echo -n "So I need the FQDN of your newsserver you want to fetch from
 (e.g. news.your_provider.com or news.your_univerity.edu)
"
	read fqdn	
	echo "Is $fqdn correct? Please say yY or nN"
	read a
	case $a in
		y|Y) return 0;;
		n|N) ask_fqdn 0;;
		*) ask_fqdn;;
	esac
}

##############################################################
ask_port()
{
	echo "Wich port are you using. Assuming 119 port=[119]"
	read port
	if $port [ "$port" = "" ]
	then
		port="119";
	else
		echo "Is $port correct? Please say yY or nN"
		read a	
		case $a in
			y|Y) return 0;;
			n|N) ask_port 0;;
			*) ask_port;;
		esac
	fi
}

##############################################################
create_grouplists()
{
	rm -f $CONFIG_PATH"list"*[0-9]

	cut -f 1 -d " " < $ACTIVE_PATH$ACTIVE_FILE | sed /junk/D | sed /control/D  |  sort > $CONFIG_PATH$GROUPLIST0
	
	file_no=1
	group_no=1
	while read group
	do
		filename1=$CONFIG_PATH"list"$file_no
		if  [ $group_no -le $MAX_NUMBER ] 
		then
			echo $group >> $filename1
			group_no=`expr $group_no + 1`
		else
			group_no=1
			filename2=$CONFIG_PATH"list"`expr $file_no + 1`
			sort -r  < $filename1 > $filename2
			file_no=`expr $file_no + 2`
		fi
	done < $CONFIG_PATH$GROUPLIST0
	
	rm $CONFIG_PATH$GROUPLIST0
	
}

##############################################################
readme()
{
echo "Ok, we do not use the active-file from inn, so please read
\"/usr/doc/newsflash/README\" and edit the folling files
\"/etc/news/newsflash/serverlist\"
\"/etc/news/newsflash/list\[?\]\""
echo "I will prepare there examplesfiles for you"
echo -n "somewhere news.somewhere.com    119 $GROUPLIST0 " > $CONFIG_PATH$SERVERLIST
echo $DATE >> $CONFIG_PATH$SERVERLIST
echo -n "somewhere news.somewhere.com    119 $GROUPLIST1 " >> $CONFIG_PATH$SERVERLIST
echo $DATE >> $CONFIG_PATH$SERVERLIST

echo "comp.os.linux.announce
alt.talk.bizarre
alt.sysadmin.recovery" > $CONFIG_PATH$GROUPLIST0

echo "alt.sysadmin.recovery
alt.talk.bizarre
comp.os.linux.announce" > $CONFIG_PATH$GROUPLIST1
}

##############################################################
save_oldfiles()
{
	if [ -f $CONFIG_PATH"serverlist" ]
	then
		mv $CONFIG_PATH"serverlist" $CONFIG_PATH"serverlist.old"
	fi
	if [ -f $CONFIG_PATH"list1" ] 
	then
		for i in $CONFIG_PATH"list"*[0-9]
		do
			mv $i $i.old
		done
	fi
}
##############################################################
useactive()
{
	ask_fqdn
	ask_port		
		
	echo "So we are using the active file, I will create the grouplistfiles therefrom.
	 
Read

/usr/doc/newsflash/README

for more information and how to optimize newsflash to your needs.
It will increase speed heavily if you play a little with the configuration.
I am sorry but optimization depends very heavily from your newsgroups, and your connection to the internet so I can not handle the optimization for you.


I will fetch the news of the last 24h hours for you.
This is only the initial value. If everything works well,
I will only fetch new news for you after the first time"		

i=1
file_no=`ls -l /etc/news/newsflash/list[0-9]* | wc -l`

while [ $i -le $file_no ] 
do
	echo -n "$fqdn $fqdn $port $CONFIG_PATH$GROUPLIST$i " >> $CONFIG_PATH$SERVERLIST
	echo $DATE >> $CONFIG_PATH$SERVERLIST
	i=`expr $i + 1`
done
}


#############################################################
#
# First we have to install the directory
install -d $CONFIG_PATH

# then we should save any old file if there are some
save_oldfiles

#
# Now we should look if there is an active file from inn

if [ -f $ACTIVE_PATH$ACTIVE_FILE ] 
then
	ask_active_file
else
	readme
fi

chown news.news /etc/news/newsflash -R
chmod ug+w /etc/news/newsflash/ -R

echo "Press RETURN to end" 
read a
exit 0