source: titan/oealliance/var/etc/autostart/start.sh @ 44881

Last change on this file since 44881 was 44881, checked in by obi, 3 years ago

fix cifs

  • Property svn:executable set to *
File size: 10.5 KB
Line 
1startconfig=/mnt/config/start-config
2if [ ! -e "$startconfig" ]; then startconfig="/etc/titan.restore/mnt/config/start-config"; fi
3
4. $startconfig
5. /sbin/start-progress
6. /sbin/start-function
7
8model=`cat /etc/model`
9realbox=`cat /proc/stb/info/boxtype`
10arch=`cat /etc/.arch`
11board=`cat /etc/.board`
12
13starthotplug()
14{
15        echo "[$0] starthotplug"
16        hotplug.sh first
17
18    CIFSGUESTLIST=$(cat /mnt/network/auto.misc | grep cifs | grep guest | sed -nr 's!.*\t:([^:]+).*!\1!p')
19    for ROUND in $CIFSGUESTLIST; do
20        mkdir /tmp/tmpmount
21        mount -o guest $ROUND /tmp/tmpmount
22        umount -fl /tmp/tmpmount
23        rmdir /tmp/tmpmount
24    done
25}
26
27startlibs()
28{
29        #check for sundtek tuner helper lib
30        if [ -e /opt/lib/libmediaclient.so ]; then
31                LIBS="/opt/lib/libmediaclient.so /usr/lib/libopen.so.0.0.0"
32        elif [ -e /usr/lib/libopen.so.0.0.0 ]; then
33                LIBS="/usr/lib/libopen.so.0.0.0"
34        fi
35
36        #check for specific pagecache helper lib
37        if [ -e /usr/lib/libpagecache.so ]; then
38                LIBS="$LIBS /usr/lib/libpagecache.so"
39        fi
40
41        #check for receiver specific passthrough helper lib
42        if [ -e /usr/lib/libpassthrough.so ]; then
43                LIBS="$LIBS /usr/lib/libpassthrough.so"
44        fi
45
46        # in case sysctl.conf is not properly loaded - load sysctl.conf here again...
47        sysctl -p
48
49        if [ -e /usr/lib/libssl.so.1.0.2 ] && [ ! -e /usr/lib/libssl.so.1.0.0 ];then
50                echo "create symlink /usr/lib/libssl.so.1.0.2 -> /usr/lib/libssl.so.1.0.0"
51                ln -s /usr/lib/libssl.so.1.0.2 /usr/lib/libssl.so.1.0.0
52        fi
53
54        if [ -e /usr/lib/libcrypto.so.1.0.2 ] && [ ! -e /usr/lib/libcrypto.so.1.0.0 ];then
55                echo "create symlink /usr/lib/libcrypto.so.1.0.2 -> /usr/lib/libcrypto.so.1.0.0"
56                ln -s /usr/lib/libcrypto.so.1.0.2 /usr/lib/libcrypto.so.1.0.0
57        fi
58
59        if [ -e /usr/lib/libssl.so.1.0.2 ] && [ ! -e /usr/lib/libssl.so.0.9.8 ];then
60                echo "create symlink /usr/lib/libssl.so.1.0.2 -> /usr/lib/libssl.so.0.9.8"
61                ln -s /usr/lib/libssl.so.1.0.2 /usr/lib/libssl.so.0.9.8
62        fi
63
64        if [ -e /usr/lib/libcrypto.so.1.0.2 ] && [ ! -e /usr/lib/libcrypto.so.0.9.8 ];then
65                echo "create symlink /usr/lib/libcrypto.so.1.0.2 -> /usr/lib/libcrypto.so.0.9.80"
66                ln -s /usr/lib/libcrypto.so.1.0.2 /usr/lib/libcrypto.so.0.9.8
67        fi
68}
69
70startdate()
71{
72# dm7020hdv2 ok
73#               (ntpdate -b ptbtime1.ptb.de; time=`date +%s`; echo -e `expr $time + 7200`  > /proc/stb/fp/rtc) &
74#               echo "[startdate] ntpdate -b ptbtime1.ptb.de; /bin/fake-hwclock save force"
75#               (ntpdate -b ptbtime1.ptb.de; /bin/fake-hwclock save force; date; date -u) &
76                if [ -e /bin/fake-hwclock ]; then
77                        opkg remove fake-hwclock --force-depends
78                        date -d "1974-01-04"
79                fi
80#               if [ ! -e /tmp/.timefix ] && [ "$board" == "spark7162" ]; then
81#                       time=`date +%s`
82#                       echo -e `expr $time + 7200` > /proc/stb/fp/rtc
83#                       touch /tmp/.timefix
84#               fi
85}
86
87startdelpack()
88{
89        if [ -e /var/etc/.firstok ]; then
90                opkg remove minidlna --force-depends
91                rm /var/etc/.firstok
92        fi
93}
94
95startbootlogo()
96{
97        if [ -e /proc/stb/info/boxtype ]; then
98                stbcheck=`cat /proc/stb/info/boxtype`
99                if [ $stbcheck == "sf8008" ] || [ $stbcheck == "sf8008s" ] || [ $stbcheck == "sf8008t" ] || [ $stbcheck == "ustym4kpro" ] || [ $stbcheck == "cc1" ]; then
100                        count=`ps -ef |grep libreader |grep -v "grep" |wc -l`
101                        if [ 0 == $count ];then
102                                libreader 720P_50
103                        fi
104                fi
105        fi
106
107        if [ -x /usr/bin/showiframe ]; then
108                if [ -e /proc/stb/info/boxtype ]; then
109                        stbcheck=`cat /proc/stb/info/boxtype | cut -c1-2`
110                        if [ ! $stbcheck == "u5" ]; then
111                                killall -9 showiframe; sleep 1
112                        fi
113                else
114                        killall -9 showiframe; sleep 1
115                fi
116                if [ -f /etc/enigma2/backdrop.mvi ]; then
117                        /usr/bin/showiframe /etc/enigma2/backdrop.mvi
118                elif [ -f /usr/share/backdrop.mvi ]; then
119                        /usr/bin/showiframe /usr/share/backdrop.mvi
120                fi
121        fi
122}
123
124starthomedir()
125{
126        if [ -d /home/root ]; then
127                cd /home/root
128                export HOME=/home/root
129        fi
130}
131
132startemu()
133{
134        emu.sh "start" "" &
135}
136
137checkemu()
138{
139        emuret=`emu.sh check | grep "checkemu running emu="`
140        if [ -z "$emuret" ]; then
141                startemu restart
142        fi
143}
144
145startusercmd()
146{
147        if [ -e /mnt/config/usercmd.sh ]; then
148                /mnt/config/usercmd.sh
149        fi
150}
151
152startdropcaches()
153{
154        echo 3 > /proc/sys/vm/drop_caches
155}
156
157startrcreboot()
158{
159        RCOK=$(cat /mnt/config/rcconfig | grep rcok | cut -d= -f2)
160        RCPOWER=$(cat /mnt/config/rcconfig | grep rcpower | cut -d= -f2)
161        RCDEV=$(grep "rcdev=" /mnt/config/titan.cfg | cut -d "=" -f 2)
162        VFDDEV=$(grep "vfddev=" /mnt/config/titan.cfg | cut -d "=" -f 2)
163        VFDTYPE=$(grep "vfdtype=" /mnt/config/titan.cfg | cut -d "=" -f 2)
164        evtest $RCDEV | LC_ALL=C awk -v VFDTYPE=$VFDTYPE -v VFDDEV=$VFDDEV -v RCOK=$RCOK -v RCPOWER=$RCPOWER -f /etc/init.d/getfb.awk &
165}
166
167workarounds()
168{
169        if [ "$board" == "hd51" ] || [ "$board" == "multibox" ]; then
170                if [ ! -e "/usr/bin/enigma2" ];then
171                        touch /usr/bin/enigma2
172                        /etc/init.d/partitions-by-name &
173                fi
174        fi
175}
176
177startCi()
178{
179        if [ "$board" == "hd51" ]; then
180                if [ -e /mnt/bin/ciplushelper ];then
181                        /mnt/bin/ciplushelper &
182                        sleep 1
183                fi
184        fi
185}
186
187startled()
188{
189        if [ "$model" == "sf8008" ]; then
190                echo "[$0] startled ser power > blue"
191                echo 1 > /proc/stb/fp/ledpowercolor
192        fi
193}
194
195starthostname()
196{
197#    IP=$(ifconfig | grep inet | grep Bcast | awk '{print $2}' | cut -d":" -f2 | tr '.' '-')
198    IP=$(ifconfig | grep inet | grep Bcast | awk '{print $2}' | cut -d":" -f2 | cut -d"." -f4)
199    MODEL=$(cat /etc/model)
200#    hostname "$MODEL ($IP)"
201    echo "$MODEL-$IP" > /etc/hostname
202    sysctl "kernel.hostname=$MODEL-$IP.local.host"
203    hostname -F /etc/hostname
204    mv -f /etc/samba/private/smbpasswd /etc/samba/private/smbpasswd.org
205    /etc/init.d/samba restart
206    /etc/init.d/vsftpd restart
207    /etc/init.d/dropbear restart
208}
209
210startcifswork()
211{
212        echo "[$0] startcifswork"
213    CIFSGUESTLIST=$(cat /mnt/network/auto.misc | grep cifs | grep guest | sed -nr 's!.*\t:([^:]+).*!\1!p')
214    for ROUND in $CIFSGUESTLIST; do
215        mkdir /tmp/tmpmount
216        mount -o guest $ROUND /tmp/tmpmount
217        sleep 3
218        ls -al /media/net/
219        umount -fl /tmp/tmpmount
220        rmdir /tmp/tmpmount
221    done
222}
223
224startgui()
225{
226        STARTDEFAULT="/usr/local/bin/titan /mnt/config/titan.cfg"
227
228        if [ -e "/var/etc/.checkdualboot" ] && [ -e "/usr/bin/enigma2" ] && [ -e "/usr/share/enigma2/skin.xml" ];then
229#               startbootlogo
230                (sleep 10; killall infobox) &
231                pid=$!
232                if [ -e "/mnt/config/dualboot" ];then
233                        infobox -pos -1 75% GUI#2 "Aktiviere Auswahlmenu (TitanNit/Enigma2)" "  Dualboot - nein" "  Dualboot - ja" ; ret=$?
234                else
235                        infobox -pos -1 75% GUI#1 "Aktiviere Auswahlmenu (TitanNit/Enigma2)" "  Dualboot - nein" "  Dualboot - ja" ; ret=$?
236                fi
237                kill -9 $pid
238                echo " " > /dev/vfd
239
240                if [ "$ret" = "2" ];then
241                        infobox -pos -1 75% 2 "Dualboot"  "  an" &
242                        echo enable dualboot
243                        touch /mnt/config/dualboot
244                else
245                        if [ "$ret" = "1" ];then
246                                rm /mnt/config/dualboot
247                                infobox -pos -1 75% 2 "Dualboot" "  aus" &
248                        else
249                                if [ -e "/mnt/config/dualboot" ];then
250                                        infobox -pos -1 75% 2 "Dualboot"  "  an" &
251                                else
252                                        infobox -pos -1 75% 2 "Dualboot" "  aus" &
253                                fi
254                        fi
255                fi
256                echo "Starting" > /dev/vfd
257                echo remove checkdualboot flag
258                rm -f /var/etc/.checkdualboot
259                sync
260                sleep 10
261#       else
262#               rm -f /etc/rc2.d/*
263#               rm -f /etc/rc3.d/*
264#               rm -f /etc/rcS.d/*
265        fi
266
267        # kill webif
268        fuser -k 80/tcp
269
270        if [ -e /mnt/config/dualboot ] && [ -e "/usr/bin/enigma2" ] && [ -e "/usr/share/enigma2/skin.xml" ];then
271                if [ ! -e /mnt/config/dualboot.titan ] && [ ! -e /mnt/config/dualboot.enigma2 ] || [ -e /mnt/config/dualboot.titan ];then
272
273                        (sleep 10; killall infobox) &
274                        pid=$!
275                        infobox -pos -1 75% GUI#1 "++ DualBoot-Auswahl ++" "---- TitanNit  ----" "---- Enigma2 ----" ; ret=$?
276                        kill -9 $pid
277                        echo " " > /dev/vfd
278
279                        case $ret in
280                                2)
281                                        START="/usr/bin/enigma2"
282                                        rm -f /mnt/config/dualboot.titan
283                                        touch /mnt/config/dualboot.enigma2
284                                        $STARTDEFAULT;;
285                                *)
286                                        START="/usr/local/bin/titan /mnt/config/titan.cfg"
287                                        rm -f /mnt/config/dualboot.enigma2
288                                        touch /mnt/config/dualboot.titan;;
289                        esac
290                else
291
292                        (sleep 10; killall infobox) &
293                        pid=$!
294                        infobox -pos -1 75% GUI#2 "++ DualBoot-Auswahl ++" "---- TitanNit  ----" "---- Enigma2 ----" ; ret=$?
295                        kill -9 $pid
296                        echo " " > /dev/vfd
297
298                        case $ret in
299                                1)
300                                        START="/usr/local/bin/titan /mnt/config/titan.cfg"
301                                        rm -f /mnt/config/dualboot.enigma2
302                                        touch /mnt/config/dualboot.titan;;
303                                *)
304                                        START="/usr/bin/enigma2"
305                                        rm -f /mnt/config/dualboot.titan
306                                        touch /mnt/config/dualboot.enigma2
307                                        $STARTDEFAULT;;
308                        esac
309                fi
310        fi
311
312#       if [ "$START" = "/usr/bin/enigma2" ];then
313#               startInit3
314#               #/usr/bin/showiframe /usr/share/bootlogo.mvi
315#               startbootlogo
316#       fi
317
318        if [ -z "$START" ]; then START="$STARTDEFAULT"; fi
319
320        LD_PRELOAD=$LIBS $START
321
322        # titan exit codes:
323        #
324        # 1 - halt
325        # 2 - reboot
326        # 3 - restart enigma
327        #
328        # >128 signal
329
330        ret=$?
331
332        if [ "$ret" -ne "1" ]; then
333                if [ -e /proc/stb/info/boxtype ]; then
334                        stbcheck=`cat /proc/stb/info/boxtype | cut -c1-2`
335                        if [ $stbcheck == "u5" ]; then
336                                killall -9 showiframe; sleep 5
337                        fi
338                        stbcheck=`cat /proc/stb/info/boxtype`
339                        if [ $stbcheck == "sf8008" ] || [ $stbcheck == "sf8008s" ] || [ $stbcheck == "sf8008t" ] || [ $stbcheck == "ustym4kpro" ] || [ $stbcheck == "cc1" ] ; then
340                                killall -9 libreader; sleep 5
341                        fi
342                fi
343        fi
344
345        case $ret in
346                1)
347                        /sbin/halt
348                        ;;
349                2)
350                        if [ -f /proc/stb/fp/force_restart ]; then
351                                echo 1 > /proc/stb/fp/force_restart
352                        fi
353                        /var/etc/autostart/start.sh reboot
354                        /sbin/reboot
355                        ;;
356                3)
357                        rm -fR /home/root/.gstreamer-0.10
358                        rm -f /tmp/.listen.camd.socket.ignore
359                        ;;
360                4)
361                        /sbin/rmmod lcd
362                        /usr/sbin/fpupgrade --upgrade 2>&1 | tee /home/root/fpupgrade.log
363                        sleep 1;
364                        /sbin/rmmod fp
365                        /sbin/modprobe fp
366                        /sbin/reboot
367                        ;;
368                16)
369                        echo "rescue" > /proc/stb/fp/boot_mode
370                        /sbin/reboot
371                        ;;
372                42)
373                        python /usr/lib/enigma2/python/upgrade.pyo
374                        ;;
375                43)
376                        init 1
377                        ;;
378                44)
379                        # little hack but it will be fixed soon in drivers
380                        /usr/lib/enigma2/python/Plugins/SystemPlugins/MICOMUpgrade/bin/fbclear
381                        /usr/bin/showiframe /usr/lib/enigma2/python/Plugins/SystemPlugins/MICOMUpgrade/wait.mvi
382                        echo fpupload >/proc/vfd && sleep 3 && dd bs=256k if=/tmp/micom.bin of=/dev/mcu
383                        /usr/bin/showiframe /usr/lib/enigma2/python/Plugins/SystemPlugins/MICOMUpgrade/reboot.mvi
384                        # Wait forever for the user to power off
385                        while(true) ; do sleep 60 ; done
386                        ;;
387                45)
388                        echo "    " > /dev/lcd0
389                        /usr/bin/gigablue_wol
390                        ;;
391                *)
392                        rm -f /tmp/.listen.camd.socket.ignore
393                        ;;
394        esac
395}
396
397case $1 in
398        first)
399#               starthyprid
400#               startmnt
401#               startplugins
402                starthotplug
403                startemu
404#               startopkg
405                startdate
406                startbootlogo
407                startlibs
408                starthomedir
409                startrcreboot
410#               startdelpack
411                startCi
412                workarounds
413                startled
414        startcifswork &
415                starthostname &
416                startgui;;
417        last)
418                checkemu
419                startusercmd;;
420        reboot)
421                starthyprid
422                startdropcaches;;
423esac
424
Note: See TracBrowser for help on using the repository browser.