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

Last change on this file since 44878 was 44878, checked in by obi, 4 years ago

fix

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