summaryrefslogtreecommitdiff
path: root/filesystem/etc/rc.d/rc.sysinit
blob: 5b516f7f39c5e77a226c56c99bf26ee136584665 (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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#!/bin/sh

# Color set for ANSI TERM
_R='\033[0;31;1m'	#Red
_G='\033[0;32;1m'	#Green
_Y='\033[0;33;1m'	#Yellow
C_='\033[0m'		#Color off

echo -e "[${_G}rc.sysinit : script starts${C_}]"
echo -e "[${_G}mount...${C_}]"
mount -t proc none /proc  
mount -t tmpfs tmpfs /tmp
#for emulator : /var/run only for supporting dpkg command
mount -t tmpfs tmpfs /var/run
mount -t sysfs none /sys    
#for emulator : comment out
#mount -t tmpfs tmpfs /dev  # remount dev to make it writable  
mkdir -p /dev/pts
mkdir -p /dev/shm
mount -t tmpfs none /dev/shm
mount -t devpts devpts /dev/pts
mount -t debugfs none /sys/kernel/debug

echo -e "[${_G}prepare device node${C_}]"
if [ ! -e /dev/snd ]; then
	mkdir /dev/snd
fi

mdev -s
#mknod /dev/ttySAC1 c 204 65 # UART1 device node for GPS (requested by youngae.kang)
#mknod /dev/ttySAC2 c 204 66

#for emulator : comment out
#mount -t ubifs -o bulk_read,no_chk_data_crc ubi0!dbfs /mnt/db 

#echo -e "[${_G}Initialize display brightness.${C_}]"
#/usr/bin/vconftool set -t int db/setting/Brightness "24" -f
#echo 24 > /sys/class/backlight/emulator/brightness

echo -e "[${_G}set env varible -LAUNCHER_ENGINE- for menu-screen${C_}]"
export LAUNCHER_ENGINE=x11

echo -e "[${_G}loading MFC firmware${C_}]"
#for emulator : comment out
# loading firmware
#FIRMWARE=s3c_mfc_fw.bin
#DEVPATH=/sys/class/firmware/s3c-mfc
#HOTPLUC_FW_DIR=/lib/firmware

#echo 1 > $DEVPATH/loading
#cat $HOTPLUC_FW_DIR/$FIRMWARE > $DEVPATH/data
#echo 0 > $DEVPATH/loading    

echo -e "[${_G}mount mmc storage${C_}]"

# mount
# When first booting, there is no /opt/etc/.firstboot file
#for emulator : comment out
#NEW_EMMC_BINARY=`/bin/fw_printenv SLP_ROOTFS_NEW | grep 1`
#EMMC_PART="/dev/mmcblk0p1 /dev/mmcblk0p2 /dev/mmcblk0p7"
#if [ $NEW_EMMC_BINARY ]; then
#	# Firstboot or movinand binary is downloaded.
#	echo -e "\t[${_Y}It seems firstboot since mmc downloaded${C_}]"
#	for part in $EMMC_PART; do
#		_fstype=`/sbin/fs-type-checker ${part}`
#		if [ "$_fstype" == "ext4" ]; then
#			e2fsck -y -f $part
#			echo "resize $part"
#			resize2fs $part
#		fi
#	done
#fi

#for emulator : commnet out. mount all filesystems mentioned in fstab.
#/usr/bin/mount_slp.sh -a
mount -a

#emulator's swapon
/usr/bin/swapon_emul

echo -e "[${_G}udev start${C_}]"
UDEVD_MAX_CHILDS=1 /sbin/udevd --daemon
/sbin/udevadm trigger

echo -e "[${_G}create base directory in /opt, /var${C_}]"
# construct directory hierarchy
mkdir -p /opt/var/log/apt
ln -s /opt/var/log /var/log
mkdir -p /opt/var/lib
ln -s /opt/var/lib /var/lib		# for apt
mkdir -p /opt/var/cache
ln -s /opt/var/cache /var/cache		# for apt
mkdir -p /var/run

#make a file for /dev/rtc1
touch /dev/rtc1
chmod 777 /dev/rtc1

if [ ! -e /opt/etc/.firstboot ]; then
	echo -e "[${_Y}rc.firstboot${C_}]"
	/etc/rc.d/rc.firstboot
	touch /opt/etc/.firstboot

	if [ -e /etc/rc.d/rc.run_hibernation ]; then
		touch /opt/etc/.hib_capturing
	fi
fi

#for emulator : comment out
#NEW_KERNEL_BINARY=`/bin/fw_printenv SLP_KERNEL_NEW | grep 1`
#NEW_ROOTFS_BINARY=`/bin/fw_printenv SLP_ROOTFS_NEW | grep 1`
#if [ $NEW_KERNEL_BINARY ] || [ $NEW_ROOTFS_BINARY ]; then
#	echo -e "\t[${_Y}mark for hibernation${C_}]"
#	touch /opt/etc/.hib_capturing
#	/bin/fw_setenv SLP_KERNEL_NEW 0
#	/bin/fw_setenv SLP_ROOTFS_NEW 0
#fi

echo -e "[${_G}set device node perm & security${C_}]"
# Set device node permissions for security
chown 0:6501 /dev/video0
#for emulator : comment out
#chown 0:6501 /dev/s3c-jpg
#for emulator : comment out
#chmod 666 /dev/pvrsrvkm
chown 0:6509 /dev/log_main
chown 0:6509 /dev/log_events
chown 0:6509 /dev/log_radio
chown :audio /dev/snd/
chmod 775 /dev/snd/
chown :audio /dev/snd/controlC0
chown :audio /dev/snd/pcmC0D0p
chown :audio /dev/snd/pcmC0D1p
#for emulator : comment out
#chown :audio /dev/snd/pcmC0D2p
#chown :audio /dev/snd/pcmC0D3p
chown :audio /dev/snd/timer
chown 0:6508 /dev/snd/pcmC0D0c
#for emulator : comment out
#chown 0:6508 /dev/snd/pcmC0D1c
#chown 0:6508 /dev/snd/pcmC0D2c
#chown 0:6508 /dev/snd/pcmC0D3c
#chown 0:6510 /dev/s3c-mfc
chmod 666 /dev/random
chmod 666 /dev/urandom
chown :video /dev/fb0
chown :video /dev/video1
#for emulator : comment out
#chown :video /dev/video2
#chown :6512 /dev/radio0
#chown :6702 /sys/class/backlight/*/brightness
#chmod 664 /sys/class/backlight/*/brightness

echo -e "[${_G}make gstreamer registery${C_}]"
# Make gst registry 
export GST_PLUGIN_PATH=/opt/lib/gstreamer-0.10:/usr/lib/gstreamer-0.10 # Set PATH variable for codec (requested by condolkd)
export GST_REGISTRY=/opt/etc/.gstreamer-0.10/registry.bin.arm
gst-inspect 1> /dev/null
chmod 655 /opt/etc/.gstreamer-0.10
chmod 644 /opt/etc/.gstreamer-0.10/registry.bin.arm


# Modem power on
#for emulator : comment out
#if [ ! -f /opt/etc/.hib_capturing ]; then
#	echo -e "[${_Y}modem power on${C_}]"
#	echo on > /sys/devices/platform/modemctl/exec_util
#else
#	echo "dont execute util in fastboot..."
#fi
            
#touch sensor start
#for emulator : comment out
#echo 1 > /sys/class/i2c-adapter/i2c-2/2-004a/touchstart
            
echo -e "[${_G}camera firmware update${C_}]"
# Camera Firmware Update
#for emulator : comment out
#/usr/bin/camtest -t 1
            
echo -e "[${_G}run profile${C_}]"
# Run profile
. /etc/profile

if [ -e /opt/etc/.debugmode ]; then
        echo "debug mode enabled"
        # for bluescreen
        export LD_PRELOAD=/usr/lib/libsys-assert.so
        # enable coredump
        echo "/opt/bs/core/core.%p" > /proc/sys/kernel/core_pattern
        ulimit -c unlimited
else
       echo "debug mode disabled"
fi
# Check rw mode
DEVEL_UPDATE_MODE=`grep devel_update_boot /proc/cmdline`
if [ -f /opt/etc/.devel_update ] && [ -z "$DEVEL_UPDATE_MODE" ]; then
	touch /opt/etc/.hib_capturing
	rm /opt/etc/.devel_update
fi

#for emulator
echo -e "[${_G}make symbolic link for i686${C_}]"
cd /usr/lib/enlightenment/modules/comp-slp/
ln -s linux-gnu-i686-ver-pre-svn-08 linux-gnu-i486-ver-pre-svn-08
cd /usr/lib/enlightenment/modules/e17-extra-module-keyrouter/
ln -s linux-gnu-i686-ver-pre-svn-08 linux-gnu-i486-ver-pre-svn-08
cd /usr/lib/enlightenment/modules/e17-extra-module-wmready/
ln -s linux-gnu-i686-ver-pre-svn-08 linux-gnu-i486-ver-pre-svn-08
cd /usr/lib/enlightenment/modules/illume2-slp/
ln -s linux-gnu-i686-ver-pre-svn-08 linux-gnu-i486-ver-pre-svn-08
cd /usr/lib/edje/modules/icon_calendar/
ln -s linux-gnu-i686-1.0.0 linux-gnu-i486-1.0.0

#for emulator : where is press binary?
/usr/bin/press 1 # wait input to stop running scripts
if [ $? -eq 0 ]; then
	echo "script is stopped"
	# prepare usbnet before exit
	insmod /opt/driver/g_ether.ko
	sleep 1
	ifconfig usb0 192.168.129.3 netmask 255.255.255.0
	# Run all rc0 scripts
	for i in /etc/rc.d/rc0.d/*; do
		echo -e "[${_G}${i} start${C_}]"
		$i start
	done
elif [ -f /opt/etc/.hib_capturing ] && [ -z "$DEVEL_UPDATE_MODE" ]; then
	echo -e "[${_Y}run all rc4 scripts${C_}]"
	# Run all rc4 scripts
	/usr/bin/write-to-lcd /dev/fb3 "Initializing daemons"
	echo "there is /opt/etc/.hib_capturing  hibernation capturing mode"
	for i in /etc/rc.d/rc4.d/*; do
		echo -e "[${_G}${i} start${C_}]"
		$i start
	done
else
	# Run all rc3 scripts
	echo -e "[${_G}run all rc3 scripts${C_}]"
	echo "normal boot"
	for i in /etc/rc.d/rc3.d/*; do
		echo -e "[${_G}${i} start${C_}]"
		$i start
	done

    #for i in /etc/rc3.d/S*; do
    #	echo -e "[${_G}${i} start${C_}]"
    #    $i start
    #done

	echo -e "[${_G}set cpufreq governor${C_}]"
	# Set default cpufreq governor
	#for emulator : comment out
	#echo slp > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
	#if [ $? -ne 0 ];then
	#	echo -e "\t[${_Y}slp not exits, set default ondemand${C_}]"
	#	echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
	#fi
fi


# symbolic link
if [ ! -e /opt/apps ]; then
	echo -e "[${_G}link /opt/apps -> /opt/media/apps${C_}]"
	ln -s /opt/media/apps /opt/apps
fi

# inhouse home-directory
chown 5000:5000 /home/inhouse

if [ "$DEVEL_UPDATE_MODE" ]; then
	touch /opt/etc/.devel_update
fi

#for emulator : 
/etc/rc.d/rc.emul

echo -e "[${_G}rc.sysinit : script end ${C_}]"