]> git.vomp.tv Git - vompserver.git/blob - copyClientFiles.sh
Compatibility for VDR 1.7.30, thanks to hondansx, Uwe and MartenR.
[vompserver.git] / copyClientFiles.sh
1 #! /bin/sh
2
3 filelist="mediaprovider.h media.h media.cc mediaplayer.h mediaplayer.cc mediafile.h mediafile.cc serialize.h serialize.cc vdrcommand.h mediaproviderids.h"
4 usage() {
5   echo "usage: $0 [-f] [clientdir]"
6   echo "   if clientdir is not given VOMPCLIENT has to be set"
7 }
8
9 error() {
10   echo "--ERROR-- "$*
11   exit 1
12 }
13
14 #p1 - in name
15 translateName() {
16   echo $1 | sed 's/\.cc$/.c/'
17 }
18
19 if [ "$1" = "-h" ] ; then
20   usage
21   exit 0
22 fi
23
24 if [ "$1" = "-f" ] ; then
25   force=1
26   shift
27 fi
28
29 clientdir=$1
30 if [ "$clientdir" = "" ] ; then
31   clientdir=$VOMPCLIENT
32 fi
33 if [ "$clientdir" = "" ] ; then
34   echo neither clientdir provided nor VOMPCLIENT set
35   usage
36   exit 1
37 fi
38 backupdir=../vompserver-backup
39 if [ "$VOMPSERVERBACKUP" != "" ] ; then
40   backupdir=$VOMPSERVERBACKUP
41 fi
42
43 be=`date +%Y%m%d%H%M%S`
44
45 backupdir=$backupdir/$be
46 echo "backing up to $backupdir"
47 mkdir -p $backupdir || error "unable to create backup directorry $backupdir"
48
49 for file in $filelist
50 do
51   [ ! -f $clientdir/$file ] && error "$clientdir/$file not found"
52 done
53
54 for file in $filelist
55 do
56   ofile=`translateName $file`
57   if [ -f $ofile -a ! -L $ofile ] ; then
58     echo backing up $ofile to $backupdir/$ofile
59     cp $ofile $backupdir/$ofile || error "failed to backup $ofile"
60     rm -f $ofile
61   fi
62   if [ "$force" = 1 ] ; then
63     rm -f $ofile
64   fi
65   if [ ! -L $ofile ] ; then
66     echo linking $clientdir/$file $ofile
67     ln -s $clientdir/$file $ofile || error "unable to link $clientdir/$file to $ofile"
68   else
69     echo $ofile already exists as link, skip
70   fi
71 done
72
73