2 # Copyright (c) 2005/6 Andreas Mair
5 # Download and patchscript for VDRAdmin-AM
6 # (based on install.sh Copyright (c) 2003 Frank (xpix) Herrmann)
8 PATH
=$PATH:/sbin
:/bin
:/usr
/sbin
:/usr
/bin
10 LIBDIR
=${LIBDIR:-$DESTDIR/usr/share/vdradmin}
11 ETCDIR
=${ETCDIR:-$DESTDIR/etc/vdradmin}
12 DOCDIR
=${DOCDIR:-$DESTDIR/usr/share/doc/vdradmin}
13 BINDIR
=${BINDIR:-$DESTDIR/usr/bin}
14 LOCDIR
=${LOCDIR:-$DESTDIR/usr/share/locale}
15 MANDIR
=${MANDIR:-$DESTDIR/usr/share/man/man1}
16 LOGDIR
=${LOGDIR:-$DESTDIR/var/log}
17 CACHEDIR
=${CACHEDIR:-$DESTDIR/var/cache/vdradmin}
18 PIDFILE
=${PIDFILE:-$DESTDIR/var/run/vdradmind.pid}
19 VIDEODIR
=${VIDEODIR:-/var/video}
20 EPGIMAGES
=${EPGIMAGES:-$VIDEODIR/epgimages}
21 VDRCONF
=${VDRCONF:-/etc/vdr}
26 echo "usage: $(basename $0) [-c | -u | -p | -h]"
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."
36 function killRunningVDRAdmin
()
39 local PID
=$
(pidof vdradmind
)
40 [ "$PID" ] || PID
=$
(ps a |
grep vdradmind.pl |
grep perl |
grep -v grep | cut
-d' ' -f1)
49 # $1 - the Perl module to check for.
50 function checkPerlModule
()
52 [ -z "$1" ] && return 1
57 [ "$ALT_MODULE" ] && ALT_MESSAGE
=" or $ALT_MODULE"
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
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
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\"'"
75 function perlModules
()
78 echo "*** Required ***"
79 checkPerlModule locale
81 checkPerlModule Template
82 checkPerlModule Template
::Plugin
::JavaScript
84 checkPerlModule HTTP
::Date
85 checkPerlModule IO
::Socket
86 checkPerlModule Time
::Local
87 checkPerlModule MIME
::Base64
88 checkPerlModule File
::Temp
89 checkPerlModule URI
::Escape
93 echo "You need Locale::gettext OR Locale::Messages"
94 checkPerlModule Locale
::gettext Locale
::Messages
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
107 echo "* Required for SSL support (https)"
108 #checkPerlModule IO::Socket::SSL
109 echo "* Required if you want to use gzip'ed HTTP responses"
110 checkPerlModule Compress
::Zlib
111 echo "* Required if you want to log to syslog"
112 checkPerlModule Sys
::Syslog
117 [ -z "$1" ] && return 1
119 local MUST_CREATE
=${2:-0}
120 if [ -e "$DIR" -a ! -d "$DIR" ]; then
121 echo "$DIR exists but is no directory!"
124 elif [ -d $DIR -a $MUST_CREATE = 1 ]; then
125 echo "$DIR exists. Please remove it before calling install.sh!"
129 if [ ! -e "$DIR" ]; then
131 if [ $?
-ne 0 ]; then
132 echo "Failed to create directory $DIR!"
144 echo "********* Installing VDRAdmin-AM *************"
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
158 makeDir
$LOCDIR/$lang/LC_MESSAGES
/ && install -m 644 $lang/LC_MESSAGES
/vdradmin.mo
$LOCDIR/$lang/LC_MESSAGES
/vdradmin.mo ||
exit 1
163 [ ! -e $BINDIR ] && mkdir
-p $BINDIR
164 if [ -d $BINDIR ]; then
166 if [ $?
-ne 0 ] ; then
168 echo "Killed running VDRAdmin-AM..."
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}:" \
175 -e "s:/var/cache/vdradmin:${CACHEDIR}:" \
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}\";:"
183 chmod a
+x
$BINDIR/vdradmind
185 if [ "$CONFIG" ]; then
186 echo "Configuring VDRAdmin-AM..."
190 if [ "$RESTART" ]; then
191 echo "Restarting VDRAdmin-AM..."
196 if [ -e $BINDIR/vdradmind.pl
]; then
197 echo "Removing ancient $BINDIR/vdradmind.pl"
198 rm -f $BINDIR/vdradmind.pl
200 if [ -e $MANDIR/vdradmind.pl
.1 ]; then
201 echo "Removing ancient $MANDIR/vdradmind.pl.1"
202 rm -f $MANDIR/vdradmind.pl
.1
205 echo "$BINDIR exists but is no directory!"
212 echo "VDRAdmin-AM has been installed!"
214 if [ -z "$RESTART" ]; then
215 echo "Run \"$BINDIR/vdradmind\" to start VDRAdmin-AM."
219 echo "If you want to run VDRAdmin-AM in a different language you must set the LANG environment variable (see README)."
222 echo "If you would like VDRAdmin-AM to start at system's boot, please modify your system's init scripts."
226 function doUninstall
()
229 echo "********* Uninstalling VDRAdmin-AM *************"
233 if [ -d $DOCDIR ]; then
236 if [ -d $LIBDIR ]; then
239 if [ -d $CACHEDIR ]; then
242 if [ -e $MANDIR/vdradmind.pl
.1 ]; then
243 rm -f $MANDIR/vdradmind.pl
.1
245 if [ -e $MANDIR/vdradmind
.1 ]; then
246 rm -f $MANDIR/vdradmind
.1
248 if [ -e $BINDIR/vdradmind.pl
]; then
249 rm -f $BINDIR/vdradmind.pl
251 if [ -e $BINDIR/vdradmind
]; then
252 rm -f $BINDIR/vdradmind
254 rm -f $LOCDIR/*/LC_MESSAGES
/vdradmin.mo
257 echo "VDRAdmin-AM has been uninstalled!"
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!"
276 *) echo "Ignoring param \"$1\$.";;
281 if [ $
(basename $0) = "uninstall.sh" -o "$UNINSTALL" ]; then
283 elif [ "$PERL" ]; then
285 echo "Testing required Perl modules..."