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 PIDFILE
=${PIDFILE:-$DESTDIR/var/run/vdradmind.pid}
18 VIDEODIR
=${VIDEODIR:-/var/video}
19 EPGIMAGES
=${EPGIMAGES:-$VIDEODIR/epgimages}
20 VDRCONF
=${VDRCONF:-/opt/vdr/etc}
25 echo "usage: $(basename $0) [-c | -u | -p | -h]"
27 echo -e "\t-c : Run \"vdradmind -c\" after installation (=configure)."
28 echo -e "\t-u : Perform uninstall."
29 echo -e "\t-p : List and optionally install required Perl modules."
30 echo -e "\t-h : This message."
35 function killRunningVDRAdmin
()
38 local PID
=$
(pidof vdradmind
)
39 [ "$PID" ] || PID
=$
(ps a |
grep vdradmind.pl |
grep perl |
grep -v grep | cut
-d' ' -f1)
48 # $1 - the Perl module to check for.
49 function checkPerlModule
()
51 [ -z "$1" ] && return 1
56 [ "$ALT_MODULE" ] && ALT_MESSAGE
=" or $ALT_MODULE"
58 echo -n "Checking for Perl module $MODULE$ALT_MESSAGE... "
59 perl
-ce 'BEGIN{$0 =~ /(^.*\/)/; $BASENAME = $1; unshift(@INC, $BASENAME . "lib/");} use '$MODULE >/dev
/null
2>&1
61 if [ "$ALT_MODULE" ]; then
62 perl
-ce 'BEGIN{$0 =~ /(^.*\/)/; $BASENAME = $1; unshift(@INC, $BASENAME . "lib/");} use '$ALT_MODULE >/dev
/null
2>&1
63 [ $?
-eq 0 ] && echo " $ALT_MODULE found" && return 0
66 read -p "Do you want to install $MODULE? [y/N]"
67 [ "$REPLY" = "y" -o "$REPLY" = "Y" ] && su
-c "perl -MCPAN -e 'CPAN::install \"$MODULE\"'"
74 function perlModules
()
77 echo "*** Required ***"
78 checkPerlModule locale
80 checkPerlModule Template
82 checkPerlModule IO
::Socket
83 checkPerlModule Time
::Local
84 checkPerlModule MIME
::Base64
85 checkPerlModule File
::Temp
86 checkPerlModule URI
::Escape
90 echo "You need Locale::gettext OR Locale::Messages"
91 checkPerlModule Locale
::gettext Locale
::Messages
94 echo "*** Optional ***"
95 echo "* Required for AutoTimer email notification"
96 #checkPerlModule Net::SMTP
97 #checkPerlModule Authen::SASL
98 echo "* Required for AutoTimer email notification and CRAM-MD5 authentication"
99 checkPerlModule Digest
::HMAC_MD5
100 echo "* Required if VDR and VDRAdmin-AM use different character encoding"
101 checkPerlModule Encode
102 echo "* Required for IPv6 support"
103 #checkPerlModule IO::Socket::INET6
104 echo "* Required if you want to use gzip'ed HTTP responses"
105 checkPerlModule Compress
::Zlib
110 [ -z "$1" ] && return 1
112 local MUST_CREATE
=${2:-0}
113 if [ -e "$DIR" -a ! -d "$DIR" ]; then
114 echo "$DIR exists but is no directory!"
117 elif [ -d $DIR -a $MUST_CREATE = 1 ]; then
118 echo "$DIR exists. Please remove it before calling install.sh!"
122 if [ ! -e "$DIR" ]; then
124 if [ $?
-ne 0 ]; then
125 echo "Failed to create directory $DIR!"
137 echo "********* Installing VDRAdmin-AM *************"
142 makeDir
$LIBDIR 1 && cp -r template lib
$LIBDIR ||
exit 1
143 makeDir
$DOCDIR && cp -r contrib COPYING CREDITS HISTORY INSTALL LGPL.txt README
* REQUIREMENTS FAQ
$DOCDIR ||
exit 1
144 makeDir
$MANDIR && cp vdradmind.pl
.1 $MANDIR/vdradmind
.1 ||
exit 1
145 makeDir
$ETCDIR ||
exit 1
151 makeDir
$LOCDIR/$lang/LC_MESSAGES
/ && install -m 644 $lang/LC_MESSAGES
/vdradmin.mo
$LOCDIR/$lang/LC_MESSAGES
/vdradmin.mo ||
exit 1
156 [ ! -e $BINDIR ] && mkdir
-p $BINDIR
157 if [ -d $BINDIR ]; then
159 if [ $?
-ne 0 ] ; then
161 echo "Killed running VDRAdmin-AM..."
163 sed <vdradmind.pl
>$BINDIR/vdradmind \
164 -e "s/^\(my \$SEARCH_FILES_IN_SYSTEM *=\) 0;/\1 1;/" \
165 -e "s:/usr/share/vdradmin/lib:${LIBDIR}/lib:" \
166 -e "s:/usr/share/vdradmin/template:${LIBDIR}/template:" \
167 -e "s:/var/log:${LOGDIR}:" \
168 -e "s:/var/run/vdradmind.pid:${PIDFILE}:" \
169 -e "s:\(\$ETCDIR *= \)\"/etc/vdradmin\";:\1\"${ETCDIR}\";:" \
170 -e "s:/usr/share/locale:${LOCDIR}:" \
171 -e "s:\(\$CONFIG{VIDEODIR} *= \)\"/video\";:\1\"${VIDEODIR}\";:" \
172 -e "s:\(\$CONFIG{EPGIMAGES} *= \)\"\$CONFIG{VIDEODIR}/epgimages\";:\1\"${EPGIMAGES}\";:" \
173 -e "s:\(\$CONFIG{VDRCONFDIR} *= \)\"\$CONFIG{VIDEODIR}\";:\1\"${VDRCONF}\";:"
175 chmod a
+x
$BINDIR/vdradmind
177 if [ "$CONFIG" ]; then
178 echo "Configuring VDRAdmin-AM..."
182 if [ "$RESTART" ]; then
183 echo "Restarting VDRAdmin-AM..."
188 if [ -e $BINDIR/vdradmind.pl
]; then
189 echo "Removing ancient $BINDIR/vdradmind.pl"
190 rm -f $BINDIR/vdradmind.pl
192 if [ -e $MANDIR/vdradmind.pl
.1 ]; then
193 echo "Removing ancient $MANDIR/vdradmind.pl.1"
194 rm -f $MANDIR/vdradmind.pl
.1
197 echo "$BINDIR exists but is no directory!"
204 echo "VDRAdmin-AM has been installed!"
206 if [ -z "$RESTART" ]; then
207 echo "Run \"$BINDIR/vdradmind\" to start VDRAdmin-AM."
211 echo "If you want to run VDRAdmin-AM in a different language you must set the LANG environment variable (see README)."
214 echo "If you would like VDRAdmin-AM to start at system's boot, please modify your system's init scripts."
218 function doUninstall
()
221 echo "********* Uninstalling VDRAdmin-AM *************"
225 if [ -d $DOCDIR ]; then
228 if [ -d $LIBDIR ]; then
231 if [ -e $MANDIR/vdradmind.pl
.1 ]; then
232 rm -f $MANDIR/vdradmind.pl
.1
234 if [ -e $MANDIR/vdradmind
.1 ]; then
235 rm -f $MANDIR/vdradmind
.1
237 if [ -e $BINDIR/vdradmind.pl
]; then
238 rm -f $BINDIR/vdradmind.pl
240 if [ -e $BINDIR/vdradmind
]; then
241 rm -f $BINDIR/vdradmind
243 rm -f $LOCDIR/*/LC_MESSAGES
/vdradmin.mo
246 echo "VDRAdmin-AM has been uninstalled!"
248 if [ -d $ETCDIR ]; then
249 echo "Your configuration files located in $ETCDIR have NOT been deleted!"
250 echo "If you want to get rid of them, please delete them manually!"
265 *) echo "Ignoring param \"$1\$.";;
270 if [ $
(basename $0) = "uninstall.sh" -o "$UNINSTALL" ]; then
272 elif [ "$PERL" ]; then
274 echo "Testing required Perl modules..."