summaryrefslogtreecommitdiff
path: root/utilities/em8300/utilitie.sh
blob: 9b503e399b517ac89ab136c58e6494c278e353b9 (plain)
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
#!/bin/sh

# x-vdr (Installations-Skript fuer einen VDR mit Debian als Basis)
# von Marc Wernecke - www.zulu-entertainment.de
# 25.11.2007

# em8300 - module fuer dxr3

source ./../../x-vdr.conf
source ./../../setup.conf
source ./../../functions

WEB="http://www.zulu-entertainment.de/files/em8300/em8300-cvs20071122.tar.bz2"
VERSION="em8300-cvs20071122"
LINK="em8300"
CVS="2"

if [ "$CVS" = "1" ]; then
  VERSION="em8300-cvs"
fi

KERNEL=`uname -r`
EM8300="/lib/modules/$KERNEL/em8300"
VAR=`basename $WEB`
DIR=`pwd`

function make_util() {
  if [ "$CVS" = "1" ]; then
    [ ! -d "$DIR/em8300-cvs" ] && mkdir -p $DIR/em8300-cvs
    cd $DIR/em8300-cvs
    echo "CVS password: [Just press enter]"
    cvs -d:pserver:anonymous@dxr3.cvs.sourceforge.net:/cvsroot/dxr3 login
    cvs -z3 -d:pserver:anonymous@dxr3.cvs.sourceforge.net:/cvsroot/dxr3 co -P em8300
    [ -d "$DIR/em8300-cvs/em8300" ] || return 1
    [ -d "$SOURCEDIR/$VERSION" ] && rm -rf "$SOURCEDIR/$VERSION"
    cp -R em8300 $SOURCEDIR/$VERSION
    [ -d "$SOURCEDIR/$VERSION" ] || return 1
  else
    download_util
    extract_util
  fi

  cd $SOURCEDIR
  rm -f $LINK
  ln -vfs $VERSION $LINK

  # install tools
  cd $SOURCEDIR/$LINK
  [ "$CVS" != "0" ] && ./bootstrap
  ./configure --prefix=$PREFIX
  make
  make install

  # install modules
  cd $SOURCEDIR/$LINK/modules
  make
  make install
  # copy microcode
  cp em8300.uc /usr/share/misc
  # make devices
  #./devices.sh

  # Scripte kopieren
  cp -f $DIR/ldm $VDRSCRIPTDIR
  chmod 0744 $VDRSCRIPTDIR/ldm

  cp -f $DIR/rmm $VDRSCRIPTDIR
  chmod 0744 $VDRSCRIPTDIR/rmm
  chown $VDRUSER:$VDRGROUP $VDRSCRIPTDIR/ldm $VDRSCRIPTDIR/rmm

  ldconfig

  if [ -f $DIR/em8300 ]; then
    cp -f $DIR/em8300 /etc/modprobe.d
  elif [ -x /usr/sbin/dxr3config ]; then
    dxr3config
  fi

  if [ -f /etc/modprobe.d/em8300 ] && [ `grep -cw '^options em8300 .*audio_driver=oss' /etc/modprobe.d/em8300` -eq 0 ]; then
    em8300_options=`grep -m 1 '^options em8300'`
    if [ -n "$em8300_options" ]; then
      sed -i /etc/modprobe.d/em8300 -e s/"$em8300_options"/"$em8300_options audio_driver=oss"/g
    else
      echo "options em8300 audio_driver=oss" >> /etc/modprobe.d/em8300
    fi
  elif [ ! -f /etc/modprobe.d/em8300 ]; then
    echo "options em8300 audio_driver=oss" > /etc/modprobe.d/em8300
  fi

  depmod

  # test
  if [ -f $EM8300/adv717x.ko ] && [ -f $EM8300/bt865.ko ] && [ -f $EM8300/em8300.ko ]; then
    log "SUCCESS - $VERSION erstellt"
  else
    log "ERROR - $VERSION konnte nicht erstellt werden"
  fi
# Module laden
#cd $VDRSCRIPTDIR
#./rmm
#./ldm
#em8300setup
}

# uninstall
function clean_util() {
  # uninstall
  if [ -d $SOURCEDIR/em8300 ]; then
    cd $SOURCEDIR/em8300
    make uninstall
    cd $SOURCEDIR
    rm -rf em8300*
  else
    # remove source
    cd $SOURCEDIR
    rm -rf em8300*
  fi

  # remove modules
  rm -rf $EM8300

  # remove microcode
  rm -f /usr/share/misc/em8300.uc

  # remove scripts
  rm -f $VDRSCRIPTDIR/ldm
  rm -f $VDRSCRIPTDIR/rmm



  ldconfig
}

# test
function status_util() {
  if [ -f $EM8300/adv717x.ko ] && [ -f $EM8300/bt865.ko ] && [ -f $EM8300/em8300.ko ]; then
    [ -d $SOURCEDIR/$LINK ] && echo "2" && return 0
    echo "1"
  else
    echo "0"
  fi
}

# start

# plugin commands
if [ $# \> 0 ]; then
  cmd=$1
  cmd_util
else
  make_util
  status_util
fi

exit 0