]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - config/vdradmin/install-ipfire.sh
core76: Sort exclude file alphabetically.
[people/teissler/ipfire-2.x.git] / config / vdradmin / install-ipfire.sh
CommitLineData
ff1305e3
AF
1#!/bin/bash
2# Copyright (c) 2005/6 Andreas Mair
3#
4#
5# Download and patchscript for VDRAdmin-AM
6# (based on install.sh Copyright (c) 2003 Frank (xpix) Herrmann)
7
8PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin
9DESTDIR=${DESTDIR}
10LIBDIR=${LIBDIR:-$DESTDIR/usr/share/vdradmin}
11ETCDIR=${ETCDIR:-$DESTDIR/etc/vdradmin}
12DOCDIR=${DOCDIR:-$DESTDIR/usr/share/doc/vdradmin}
13BINDIR=${BINDIR:-$DESTDIR/usr/bin}
14LOCDIR=${LOCDIR:-$DESTDIR/usr/share/locale}
15MANDIR=${MANDIR:-$DESTDIR/usr/share/man/man1}
16LOGDIR=${LOGDIR:-$DESTDIR/var/log}
d4733815 17CACHEDIR=${CACHEDIR:-$DESTDIR/var/cache/vdradmin}
ff1305e3
AF
18PIDFILE=${PIDFILE:-$DESTDIR/var/run/vdradmind.pid}
19VIDEODIR=${VIDEODIR:-/var/video}
20EPGIMAGES=${EPGIMAGES:-$VIDEODIR/epgimages}
3ca08d60 21VDRCONF=${VDRCONF:-/etc/vdr}
ff1305e3
AF
22
23function usage()
24{
25 echo ""
26 echo "usage: $(basename $0) [-c | -u | -p | -h]"
27 echo ""
28 echo -e "\t-c : Run \"vdradmind -c\" after installation (=configure)."
29 echo -e "\t-u : Perform uninstall."
30 echo -e "\t-p : List and optionally install required Perl modules."
31 echo -e "\t-h : This message."
32 echo ""
33 exit 0
34}
35
36function killRunningVDRAdmin()
37{
38 local KILLED=0
39 local PID=$(pidof vdradmind)
40 [ "$PID" ] || PID=$(ps a | grep vdradmind.pl | grep perl | grep -v grep | cut -d' ' -f1)
41 if [ "$PID" ]; then
42 KILLED=1
43 kill $PID
44 fi
45
46 return $KILLED
47}
48
49# $1 - the Perl module to check for.
50function checkPerlModule()
51{
52 [ -z "$1" ] && return 1
53
54 local MODULE=$1
55 local ALT_MODULE=$2
56 local ALT_MESSAGE=
57 [ "$ALT_MODULE" ] && ALT_MESSAGE=" or $ALT_MODULE"
58
59 echo -n "Checking for Perl module $MODULE$ALT_MESSAGE... "
60 perl -ce 'BEGIN{$0 =~ /(^.*\/)/; $BASENAME = $1; unshift(@INC, $BASENAME . "lib/");} use '$MODULE >/dev/null 2>&1
61 if [ $? -eq 2 ]; then
62 if [ "$ALT_MODULE" ]; then
63 perl -ce 'BEGIN{$0 =~ /(^.*\/)/; $BASENAME = $1; unshift(@INC, $BASENAME . "lib/");} use '$ALT_MODULE >/dev/null 2>&1
64 [ $? -eq 0 ] && echo " $ALT_MODULE found" && return 0
65 fi
66 echo " MISSING"
67 read -p "Do you want to install $MODULE? [y/N]"
68 [ "$REPLY" = "y" -o "$REPLY" = "Y" ] && su -c "perl -MCPAN -e 'CPAN::install \"$MODULE\"'"
69 else
70 echo " found"
71 fi
72
73}
74
75function perlModules()
76{
77 echo ""
78 echo "*** Required ***"
79 checkPerlModule locale
80 checkPerlModule Env
81 checkPerlModule Template
d4733815 82 checkPerlModule Template::Plugin::JavaScript
ff1305e3 83 checkPerlModule CGI
d4733815 84 checkPerlModule HTTP::Date
ff1305e3
AF
85 checkPerlModule IO::Socket
86 checkPerlModule Time::Local
87 checkPerlModule MIME::Base64
88 checkPerlModule File::Temp
89 checkPerlModule URI::Escape
90
91
92 echo ""
93 echo "You need Locale::gettext OR Locale::Messages"
94 checkPerlModule Locale::gettext Locale::Messages
95
96 echo ""
97 echo "*** Optional ***"
98 echo "* Required for AutoTimer email notification"
99 #checkPerlModule Net::SMTP
100 #checkPerlModule Authen::SASL
101 echo "* Required for AutoTimer email notification and CRAM-MD5 authentication"
102 checkPerlModule Digest::HMAC_MD5
103 echo "* Required if VDR and VDRAdmin-AM use different character encoding"
104 checkPerlModule Encode
105 echo "* Required for IPv6 support"
106 #checkPerlModule IO::Socket::INET6
d4733815
SS
107 echo "* Required for SSL support (https)"
108 #checkPerlModule IO::Socket::SSL
ff1305e3
AF
109 echo "* Required if you want to use gzip'ed HTTP responses"
110 checkPerlModule Compress::Zlib
d4733815
SS
111 echo "* Required if you want to log to syslog"
112 checkPerlModule Sys::Syslog
ff1305e3
AF
113}
114
115function makeDir()
116{
117 [ -z "$1" ] && return 1
118 local DIR=$1
119 local MUST_CREATE=${2:-0}
120 if [ -e "$DIR" -a ! -d "$DIR" ]; then
121 echo "$DIR exists but is no directory!"
122 echo "Aborting..."
123 return 1
124 elif [ -d $DIR -a $MUST_CREATE = 1 ]; then
125 echo "$DIR exists. Please remove it before calling install.sh!"
126 echo "Aborting..."
127 return 1
128 fi
129 if [ ! -e "$DIR" ]; then
130 mkdir -p "$DIR"
131 if [ $? -ne 0 ]; then
132 echo "Failed to create directory $DIR!"
133 echo "Aborting..."
134 return 1
135 fi
136 fi
137
138 return 0
139}
140
141function doInstall()
142{
143 echo ""
144 echo "********* Installing VDRAdmin-AM *************"
145 echo ""
146
147 perlModules
148
149 makeDir $LIBDIR 1 && cp -r template lib $LIBDIR || exit 1
150 makeDir $DOCDIR && cp -r contrib COPYING CREDITS HISTORY INSTALL LGPL.txt README* REQUIREMENTS FAQ $DOCDIR || exit 1
151 makeDir $MANDIR && cp vdradmind.pl.1 $MANDIR/vdradmind.1 || exit 1
152 makeDir $ETCDIR || exit 1
153
154 (
155 cd locale
156 for lang in *
157 do
158 makeDir $LOCDIR/$lang/LC_MESSAGES/ && install -m 644 $lang/LC_MESSAGES/vdradmin.mo $LOCDIR/$lang/LC_MESSAGES/vdradmin.mo || exit 1
159 done
160 )
161
162 local RESTART=
163 [ ! -e $BINDIR ] && mkdir -p $BINDIR
164 if [ -d $BINDIR ]; then
165 killRunningVDRAdmin
166 if [ $? -ne 0 ] ; then
167 RESTART=1
168 echo "Killed running VDRAdmin-AM..."
169 fi
170 sed <vdradmind.pl >$BINDIR/vdradmind \
171 -e "s/^\(my \$SEARCH_FILES_IN_SYSTEM *=\) 0;/\1 1;/" \
172 -e "s:/usr/share/vdradmin/lib:${LIBDIR}/lib:" \
173 -e "s:/usr/share/vdradmin/template:${LIBDIR}/template:" \
174 -e "s:/var/log:${LOGDIR}:" \
d4733815 175 -e "s:/var/cache/vdradmin:${CACHEDIR}:" \
ff1305e3
AF
176 -e "s:/var/run/vdradmind.pid:${PIDFILE}:" \
177 -e "s:\(\$ETCDIR *= \)\"/etc/vdradmin\";:\1\"${ETCDIR}\";:" \
178 -e "s:/usr/share/locale:${LOCDIR}:" \
179 -e "s:\(\$CONFIG{VIDEODIR} *= \)\"/video\";:\1\"${VIDEODIR}\";:" \
180 -e "s:\(\$CONFIG{EPGIMAGES} *= \)\"\$CONFIG{VIDEODIR}/epgimages\";:\1\"${EPGIMAGES}\";:" \
181 -e "s:\(\$CONFIG{VDRCONFDIR} *= \)\"\$CONFIG{VIDEODIR}\";:\1\"${VDRCONF}\";:"
182
183 chmod a+x $BINDIR/vdradmind
184
185 if [ "$CONFIG" ]; then
186 echo "Configuring VDRAdmin-AM..."
187 $BINDIR/vdradmind -c
188 fi
189
190 if [ "$RESTART" ]; then
191 echo "Restarting VDRAdmin-AM..."
192 $BINDIR/vdradmind
193 fi
194
195 echo ""
196 if [ -e $BINDIR/vdradmind.pl ]; then
197 echo "Removing ancient $BINDIR/vdradmind.pl"
198 rm -f $BINDIR/vdradmind.pl
199 fi
200 if [ -e $MANDIR/vdradmind.pl.1 ]; then
201 echo "Removing ancient $MANDIR/vdradmind.pl.1"
202 rm -f $MANDIR/vdradmind.pl.1
203 fi
204 else
205 echo "$BINDIR exists but is no directory!"
206 echo "Aborting..."
207 exit 1
208 fi
209
210 echo ""
211 echo ""
212 echo "VDRAdmin-AM has been installed!"
213 echo ""
214 if [ -z "$RESTART" ]; then
215 echo "Run \"$BINDIR/vdradmind\" to start VDRAdmin-AM."
216 echo ""
217 fi
218 echo "NOTE:"
219 echo "If you want to run VDRAdmin-AM in a different language you must set the LANG environment variable (see README)."
220 echo ""
221 echo "NOTE2:"
222 echo "If you would like VDRAdmin-AM to start at system's boot, please modify your system's init scripts."
223 exit 0
224}
225
226function doUninstall()
227{
228 echo ""
229 echo "********* Uninstalling VDRAdmin-AM *************"
230 echo ""
231
232 killRunningVDRAdmin
233 if [ -d $DOCDIR ]; then
234 rm -rf $DOCDIR
235 fi
236 if [ -d $LIBDIR ]; then
237 rm -rf $LIBDIR
238 fi
d4733815
SS
239 if [ -d $CACHEDIR ]; then
240 rm -rf $CACHEDIR
241 fi
ff1305e3
AF
242 if [ -e $MANDIR/vdradmind.pl.1 ]; then
243 rm -f $MANDIR/vdradmind.pl.1
244 fi
245 if [ -e $MANDIR/vdradmind.1 ]; then
246 rm -f $MANDIR/vdradmind.1
247 fi
248 if [ -e $BINDIR/vdradmind.pl ]; then
249 rm -f $BINDIR/vdradmind.pl
250 fi
251 if [ -e $BINDIR/vdradmind ]; then
252 rm -f $BINDIR/vdradmind
253 fi
254 rm -f $LOCDIR/*/LC_MESSAGES/vdradmin.mo
255
256 echo ""
257 echo "VDRAdmin-AM has been uninstalled!"
258 echo ""
259 if [ -d $ETCDIR ]; then
260 echo "Your configuration files located in $ETCDIR have NOT been deleted!"
261 echo "If you want to get rid of them, please delete them manually!"
262 echo ""
263 fi
264}
265
266UNINSTALL=
267CONFIG=
268PERL=
269while [ "$1" ]
270do
271 case $1 in
272 -u) UNINSTALL=1;;
273 -c) CONFIG=1;;
274 -p) PERL=1;;
275 -h) usage;;
276 *) echo "Ignoring param \"$1\$.";;
277 esac
278 shift
279done
280
281if [ $(basename $0) = "uninstall.sh" -o "$UNINSTALL" ]; then
282 doUninstall
283elif [ "$PERL" ]; then
284 echo ""
285 echo "Testing required Perl modules..."
286 perlModules
287 echo "...done."
288else
289 doInstall
290fi