Advertisement
Guest User

Untitled

a guest
May 16th, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.63 KB | None | 0 0
  1. --- initfs/skeleton/init 2013-05-16 01:02:00.928739996 +0200
  2. +++ ../nexus7-moslo/initfs/skeleton/init 2012-12-11 21:23:48.456722344 +0100
  3. @@ -8,110 +8,51 @@
  4. # Timo Kokkonen <timo.t.kokkonen@nokia.com>
  5. # Janne Lääkkö <janne.laakko@nokia.com>
  6. #
  7. +# Adaptation for Google Nexus 7 based on the Nokia version:
  8. +# Copyright 2012 Ruediger Gad <r.c.g@gmx.de>
  9. +#
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License version 2 as
  12. # published by the Free Software Foundation.
  13.  
  14. INIT_OPTS=
  15. MMC_DEV="/dev/mmcblk0"
  16. -ALT_OS_PART="$MMC_DEV"p4
  17. IP_ARRD="192.168.2.15"
  18. -# Text2screen wrapper for next lines
  19. -TTSYI=0 # Where to start
  20. -TTSX=0
  21. -TTSY=TTSYI
  22. -TTS_PIX_PER_CHAR=9
  23. -TTS_SCALE=2
  24. -TTSYM=480 # Max y lines
  25. -TTSXM=830 # Max x lines
  26. -TTSCM=$(($TTSXM/($TTS_PIX_PER_CHAR*$TTS_SCALE))) # Max char/line
  27. -TTSI=$(((TTS_PIX_PER_CHAR+1)*TTS_SCALE))
  28. -
  29. -ttsr()
  30. -{
  31. - TTSY=$TTSYI
  32. - fb_text2screen -c -B000
  33. -}
  34. -
  35. -tts()
  36. -{
  37. - fb_text2screen -s $TTS_SCALE -y $TTSY -t "$1"
  38. - echo $1
  39. - let "LINES=1+${#1}/$TTSCM"
  40. - let "TTSY+=($TTSI*$LINES)"
  41. - if [ $TTSY -gt $TTSYM ] ; then ttsr ; fi
  42. -}
  43. -
  44. -tts_dot_wait(){
  45. - TTSX=0
  46. - for i in 5 4 3 2 1 0; do
  47. - fb_text2screen -s $TTS_SCALE -y $TTSY -x $TTSX -t "$i "
  48. - echo -n "$i "
  49. - let "TTSX+=30"
  50. - sleep 1
  51. - done
  52. - let "LINES=1+6/$TTSCM"
  53. - let "TTSY+=($TTSI*$LINES)"
  54. - if [ $TTSY -gt $TTSYM ] ; then ttsr ; fi
  55. -}
  56.  
  57. shell()
  58. {
  59. echo "Starting shell..."
  60. getty 115200 ttyS0 -n -l /bin/sh &
  61. while : ; do
  62. - if [ -n "$WD_DEVICE" ]; then
  63. - echo "30" >&3
  64. - fi
  65. - sleep 2
  66. + sleep 2
  67. done
  68. }
  69.  
  70. -reboot_to_harmattan()
  71. -{
  72. - [ $# -ge 1 ] && TIMEOUT=$1 || TIMEOUT=0;
  73. - tts "Booting to Harmattan in $TIMEOUT seconds"
  74. - sleep $TIMEOUT
  75. - reboot2 s
  76. -}
  77. -
  78. -trap_func()
  79. -{
  80. - tts "Trap!"
  81. - reboot_to_harmattan
  82. -}
  83. -
  84. usb_is_plugged()
  85. {
  86. - # type is USB_DCP with wall charger, USB otherwise (including disconnected)
  87. - if [ "$(cat /sys/class/power_supply/usb/type)" == "USB" ]; then
  88. - usb=$(cat /sys/class/power_supply/usb/present)
  89. - return $usb
  90. - else
  91. - return 0
  92. - fi
  93. + usb=$(cat /sys/class/power_supply/usb/online)
  94. + return $usb
  95. }
  96.  
  97. wait_mmc()
  98. {
  99. TRY=0
  100. - tts "Waiting for eMMC device..."
  101. + echo "Waiting for eMMC device..."
  102. while [ ! -e "$MMC_DEV" -a $TRY -lt 10 ] ; do
  103. sleep 1
  104. TRY=$(($TRY+1))
  105. done
  106. if [ $TRY == 10 ]; then
  107. - tts "eMMC device not found!"
  108. + echo "eMMC device not found!"
  109. fi
  110. }
  111.  
  112. export_over_usb()
  113. {
  114. [ -e "$1" ] && {
  115. - umount "$1"
  116. EXPORT_FILE="$1"
  117. }
  118. - rmmod g_nokia
  119. +
  120. MP_ERR=1
  121. TRY=0
  122. while [ "$MP_ERR" -ne "0" -a $TRY -lt 10 ] ; do
  123. @@ -121,17 +62,17 @@ export_over_usb()
  124. lsmod |grep -q g_multi
  125. MP_ERR=$?
  126. TRY=$(($TRY+1))
  127. - #tts "Try $TRY ($MP_ERR)"
  128. + echo "Try $TRY ($MP_ERR)"
  129. done
  130. if [ $TRY == 10 ]; then
  131. - tts "Unable to load the USB modules!"
  132. + echo "Unable to load the USB modules!"
  133. else
  134. [ -n "$EXPORT_FILE" ] && \
  135. - tts "Rootfs of AlternateOS now exported via USB"
  136. + echo "Rootfs of AlternateOS now exported via USB"
  137. ifconfig usb0 $IP_ARRD up
  138. [ $? -eq 0 ] && \
  139. - tts "You can telnet into $IP_ARRD" || \
  140. - tts "Setting IP address failed!"
  141. + echo "You can telnet into $IP_ARRD" || \
  142. + echo "Setting IP address failed!"
  143. fi
  144.  
  145. sleep 1
  146. @@ -142,7 +83,25 @@ export_over_usb()
  147. done
  148. }
  149.  
  150. -trap "trap_func" 0 2
  151. +try_extract_rootfs() {
  152. + ROOTFS_IMAGE="$1"
  153. + echo "Looking for rootfs image: $ROOTFS_IMAGE"
  154. +
  155. + if [ -e "$ROOTFS_IMAGE" ]; then
  156. + echo "Found rootfs image."
  157. + echo "Will start to extract rootfs image in 5 seconds. This can take a while."
  158. + sleep 5s
  159. + cd "$USERDATA_MOUNT_DIR"
  160. + tar xvf "$ROOTFS_IMAGE"
  161. + echo "Rootfs extraction finished."
  162. +
  163. + echo "Removing rootfs tarball."
  164. + rm "$ROOTFS_IMAGE"
  165. + cd -
  166. + else
  167. + echo "No rootfs image found. Doing nothing."
  168. + fi
  169. +}
  170.  
  171. echo "START SYSTEM"
  172.  
  173. @@ -151,131 +110,122 @@ echo "START SYSTEM"
  174.  
  175. export PATH=/sbin:/bin:/usr/bin:/usr/sbin
  176. export MOUNT_DIR=/mnt
  177. +export USERDATA_MOUNT_DIR=$MOUNT_DIR/userdata
  178.  
  179. -echo -n "Doing mounts... "
  180. +echo "Doing mounts... "
  181. mount /dev
  182. mkdir /dev/pts
  183. mount -a
  184. cat /proc/mounts > /etc/mtab
  185.  
  186. -# Get the device specific configs
  187. -if [ -f /moslo.config ]; then
  188. - source /moslo.config
  189. -fi
  190. -
  191. -# If there is Watch dog device set then kick it
  192. -if [ -n "$WD_DEVICE" ]; then
  193. - # Kick the watch dog
  194. - exec 3>$WD_DEVICE
  195. - echo "30" >&3
  196. -fi
  197. +ALT_OS_PART="${MMC_DEV}p$(ls /dev/mmcblk0p* | wc -l)"
  198. +echo "Found userdata partition at: $ALT_OS_PART"
  199.  
  200. # adjust kernel to minimize memory consumption,
  201. # flushing of memory card buffers
  202. # and optimize IO pressure
  203.  
  204. #TODO fix pty/max and dirty ratio in kernel configuration
  205. +echo "Setting kernel and system settings."
  206. echo 256 > /proc/sys/kernel/threads-max || \
  207. - tts "Set fail for kernel thread-max"
  208. + echo "Set fail for kernel thread-max"
  209. echo 8192 > /proc/sys/fs/file-max || \
  210. - tts "Set fail for kernel file-max"
  211. + echo "Set fail for kernel file-max"
  212. echo 1 > /proc/sys/vm/swappiness || \
  213. - tts "Set fail for swappiness"
  214. + echo "Set fail for swappiness"
  215. echo 5 > /proc/sys/vm/page-cluster || \
  216. - tts "Set fail for page-cluster"
  217. + echo "Set fail for page-cluster"
  218. echo 500 > /proc/sys/vm/dirty_expire_centisecs || \
  219. - tts "Set fail for expire_centisecs"
  220. + echo "Set fail for expire_centisecs"
  221. echo 60 > /proc/sys/vm/dirty_background_ratio || \
  222. - tts "Set fail for dirty_background_ratio"
  223. + echo "Set fail for dirty_background_ratio"
  224. echo 65536 > /proc/sys/net/core/rmem_default || \
  225. - tts "Set fail for rmem_default"
  226. + echo "Set fail for rmem_default"
  227. echo 16384 > /proc/sys/net/core/wmem_default || \
  228. - tts "Set fail for wmem_default"
  229. + echo "Set fail for wmem_default"
  230.  
  231. #Run mdev
  232. +echo "Running mdev..."
  233. mdev -s
  234. -
  235. #Set mdev as hotplug manager
  236. echo /bin/mdev > /proc/sys/kernel/hotplug
  237.  
  238. +#Start services
  239. +echo "Starting syslogd..."
  240. syslogd &
  241. -
  242. -/sbin/init_preps.sh
  243. -
  244. -# Start telnetd service
  245. +echo "Starting telnetd..."
  246. telnetd -l/bin/sh
  247.  
  248. # Start shell for console use
  249. +echo "Starting shell..."
  250. shell &
  251.  
  252. -# Clear screen and display welcome message
  253. -ttsr
  254. VERSION=$(cat /etc/moslo-version)
  255. -tts " Welcome to MOSLO v$VERSION"
  256. -tts " check wiki.merproject.org/wiki/Nemo"
  257. -tts ""
  258. +echo " Welcome to MOSLO v$VERSION"
  259. +echo " check wiki.merproject.org/wiki/Nemo"
  260. +echo ""
  261.  
  262. # Wait for one second for eMMC to settle
  263. wait_mmc
  264.  
  265. usb_is_plugged
  266. if [ $? -eq 1 ]; then
  267. - if [ ! -b "$ALT_OS_PART" ]; then
  268. - tts "Repartitioning MMC for AlternateOS."
  269. - tts "Do not unplug USB or poweroff the device!!!"
  270. - autopartition.sh create $MMC_DEV > /var/log/repartition.log
  271. - case $? in
  272. - 0)
  273. - tts "Re-partitioning successful!"
  274. - ;;
  275. - 1)
  276. - tts "ERR: Re-partitioning failed! No partition created."
  277. - ;;
  278. - *)
  279. - tts "FATAL: Re-partitioning failed! You might be in trouble!"
  280. - tts "You can telnet in the device to try to debug!"
  281. - ;;
  282. - esac
  283. - fi
  284. + echo "Trying to export storage via USB."
  285.  
  286. # Export AlternateOS partition via USB
  287. export_over_usb "$ALT_OS_PART"
  288. fi
  289.  
  290. -mount $ALT_OS_PART $MOUNT_DIR
  291. -if [ $? -ne 0 ]; then
  292. - tts "Mounting AlternateOS failed. Not able to boot that."
  293. - reboot_to_harmattan 5
  294. -fi
  295. +echo "Mounting $ALT_OS_PART to $USERDATA_MOUNT_DIR."
  296. +mkdir -p "$USERDATA_MOUNT_DIR"
  297. +mount "$ALT_OS_PART" "$USERDATA_MOUNT_DIR"
  298. +
  299. +echo "Everything should be mounted now."
  300. +echo "Free space is as follows:"
  301. +df -h
  302. +
  303. +echo "Content of $USERDATA_MOUNT_DIR is:"
  304. +ls $USERDATA_MOUNT_DIR
  305. +
  306. +# We support gzip and bzip2 rootfs image tarballs.
  307. +# Note: rootfs.tar.* should resolve to a single file.
  308. +try_extract_rootfs "$USERDATA_MOUNT_DIR/rootfs.tar.bz2"
  309. +try_extract_rootfs "$USERDATA_MOUNT_DIR/rootfs.tar.gz"
  310.  
  311. # Try to load AlternateOS kernel
  312. -kexec_load $MOUNT_DIR
  313. +kexec_load $USERDATA_MOUNT_DIR
  314.  
  315. if [ $? -eq 0 ]; then
  316. - tts "Found AlternateOS kernel."
  317. - tts "Autoboot to AlternateOS in 15 seconds"
  318. - tts ""
  319. - tts "Press: VolumeUp button to boot to Harmattan"
  320. - tts " VolumeDown button to boot to AlternateOS."
  321. - # Check if keycode 115 is emitted
  322. - evkey -u -t 15000 /dev/input/event4 | grep -q -w 115
  323. - if [ $? -eq 0 ]; then
  324. - reboot_to_harmattan 0
  325. - else
  326. + echo "Found AlternateOS kernel."
  327. + echo "Trying to boot kernel in 5 seconds."
  328. + sleep 5s
  329. +# Lines starting with ## had been commented for now but may be used
  330. +# later again. Hence we keep em here but in a way we can identify
  331. +# that we might use these later.
  332. +## echo "Autoboot to AlternateOS in 15 seconds"
  333. +## echo ""
  334. +## echo "Press: VolumeUp button to boot to Harmattan"
  335. +## echo " VolumeDown button to boot to AlternateOS."
  336. +## # Check if keycode 115 is emitted
  337. +## evkey -u -t 15000 /dev/input/event4 | grep -q -w 115
  338. +## if [ $? -eq 0 ]; then
  339. +## reboot_to_harmattan 0
  340. +## else
  341. # Set disable PM features and set cpu clock to resemble POR
  342. - disable_pm
  343. +## disable_pm
  344. kexec -e
  345. - tts "kexec failed: $?"
  346. - tts "Failed to boot /boot/bzImage"
  347. - fi
  348. + echo "kexec failed: $?"
  349. + echo "Failed to boot /boot/bzImage"
  350. +## fi
  351. else
  352. - tts "Unable to load AlternateOS kernel."
  353. + echo "Unable to load AlternateOS kernel."
  354. fi
  355.  
  356. -reboot_to_harmattan 5
  357. +##reboot_to_harmattan 5
  358.  
  359. # exit would trap and start a new shell again, so stay in the loop
  360. # forever
  361. while true; do
  362. sleep 99999
  363. done
  364. +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement