aperezbios

BCM50 linuxrc

Nov 26th, 2022
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.53 KB | None | 0 0
  1. init-2.05b# ls
  2. Readme.txt dev lib lost+found opt root sysroot usr
  3. bin etc linuxrc nn proc sbin tmp var
  4. init-2.05b# cat ./linuxrc
  5. #!/bin/bash
  6.  
  7. . /etc/rc.d/init.d/functions
  8. . /etc/rc.d/init.d/init_functions
  9.  
  10. echo "Setting PATHs"
  11. PATH=/sbin:/usr/sbin:/bin:/usr/bin:/opt/sbin:/nn/bin:/nn/sbin
  12. LD_LIBRARY_PATH=/lib:/usr/lib:/var/lib:/nn/lib:/usr/local/lib
  13. LD_RUN_PATH="$LD_LIBRARY_PATH"
  14. TERM=xterm
  15. export PATH LD_LIBRARY_PATH LD_RUN_PATH TERM
  16.  
  17. echo "Mounting /proc"
  18. #action $"Mounting proc filesystem: " /bin/mount -n -t proc /proc /proc
  19. /bin/mount -n -t proc none /proc
  20.  
  21. echo "Mounting /dev/pts"
  22. /bin/mount -t devpts none /dev/pts
  23.  
  24. fw_print=/nn/bin/fw_printenv
  25. fw_set=/nn/bin/fw_setenv
  26. nn_setled=/nn/bin/setled
  27. word_count=/opt/bin/wc
  28. num_partitions=0
  29. num_flash_partitions=0
  30. num_hd_partitions=0
  31. usb_flash=0
  32. hd_exist=0
  33. logfile="/mnt/factoryImg/ResetButton.log"
  34. reset_request=
  35. _mode=
  36.  
  37. /sbin/ldconfig
  38.  
  39. ###################################################################
  40. #
  41. # Determine hardware type
  42. # : hw_type - M50
  43. # : default is 50
  44. #
  45. # Detect devices, look for
  46. # : sda - usb flash - Not used
  47. # : sda - hard disk
  48. #
  49. #
  50. ###################################################################
  51.  
  52. init_setup()
  53. {
  54.  
  55. echo "Entering init_setup..."
  56.  
  57. flash_id=
  58. hd_id=
  59.  
  60. #need to load the modules for fw_printenv and fw_setenv
  61. /etc/rc.d/init.d/nn_modules start
  62.  
  63. # First the /proc/partitions entries
  64. if [ ! -e /proc/partitions ]; then
  65. # No usb or HD devices present or /proc failed to load, nothing to do
  66. echo "No /proc/partitions, cannot detect hard disk or internal flash device. Please check hard disk or contact support."
  67. /bin/sleep 60
  68. echo "Rebooting..."
  69. /bin/sleep 5
  70. /sbin/shutdown -rn now
  71. fi
  72.  
  73. if [ -e /dev/mainfs ]; then
  74. /bin/rm -f /dev/mainfs
  75. fi
  76.  
  77. if [ -e /dev/mfgfs ]; then
  78. /bin/rm -f /dev/mfgfs
  79. fi
  80.  
  81. # Set the default /dev/mainfs value to /dev/sdb3
  82. # It may be overwritten if logic dictates
  83. /bin/ln -sf /dev/sdb3 /dev/mainfs
  84.  
  85. #Need to figure out if HD is sda or sdb
  86. #Required before we had the kernel dedicate sda to flash and sdb for HD
  87. num_sda_partitions=`/bin/cat /proc/partitions | /bin/grep sda[1-9] | $word_count -l`
  88. num_sdb_partitions=`/bin/cat /proc/partitions | /bin/grep sdb[1-9] | $word_count -l`
  89.  
  90. #hard disk exists at sdb
  91. if [ $num_sdb_partitions -eq 12 ]; then
  92. hd_id=sdb
  93. #hard disk exists at sda
  94. elif [ $num_sda_partitions -eq 12 ]; then
  95. hd_id=sda
  96. else
  97. return 1
  98. fi
  99.  
  100. hd_exist=1
  101. ext2_parts="sda7 sda8 sda9"
  102. ext3_parts="sda3 sda5 sda6"
  103. /bin/ln -sf /dev/sda3 /dev/mainfs
  104. /bin/ln -s /dev/sda5 /dev/mfgfs
  105. # used for hard disk info in inventory manager
  106. # should always be sda on m50
  107. /bin/ln -sf /dev/sda /dev/bcm_hdd1
  108.  
  109. echo hd_exist=$hd_exist
  110.  
  111. }
  112.  
  113. ####################################################################
  114. #
  115. # Set the LED status
  116. # reset request - POWER LED/STATUS LED
  117. # mfg mode - SOLID RED/SOLID GREEN
  118. # L2 - SOLID RED/SOLID RED
  119. # L1 - SOLID RED/BLINK YELLOW
  120. #
  121. ####################################################################
  122. set_leds()
  123. {
  124.  
  125. if [ $# -ne 2 ]; then
  126. return 1
  127. fi
  128.  
  129. #First variable is LED device
  130. #Second value is what to set LED to
  131. echo -en "\x$2" > /dev/led"$1"
  132.  
  133. }
  134.  
  135.  
  136. ####################################################################
  137. #
  138. # Filesystem check based on devices detected
  139. #
  140. ####################################################################
  141.  
  142. # USB flash partitions
  143. # /dev/sda3 Config Data ext2
  144. # /dev/sda5 Logs ext2
  145. # /dev/sda6 MFG,Diags,reset ext2
  146. # /dev/sda7 MSW ext2
  147.  
  148. # Hard Disk partitions - 450
  149. #/dev/sdb3 / ext3
  150. #/dev/sdb5 /nn/altroot ext3 defaults 1 2
  151. #/dev/sdb6 /var ext3 defaults 1 2
  152. #/dev/sdb7 /var/shadow ext2 defaults 1 2
  153. #/dev/sdb8 /var/log ext2 defaults 1 2
  154. #/dev/sdb9 /nn/patches ext2 defaults 1 2
  155.  
  156.  
  157. # Hard Disk partitions - M50
  158. #/dev/sda3 / ext3
  159. #/dev/sda5 /nn/altroot ext3 defaults 1 2
  160. #/dev/sda6 /var ext3 defaults 1 2
  161. #/dev/sda7 /var/shadow ext2 defaults 1 2
  162. #/dev/sda8 /var/log ext2 defaults 1 2
  163. #/dev/sda9 /nn/patches ext2 defaults 1 2
  164.  
  165. file_system_check()
  166. {
  167. echo "Entering file_system_check..."
  168.  
  169. #The ext2_parts and ext3_parts were set in init_setup
  170. #These should really be split to use a seperate function
  171. if [ $hd_exist -eq 1 ]; then
  172. for _part in $ext2_parts; do
  173. echo Checking $ext2_parts
  174. /sbin/fsck -t ext2 -y /dev/$_part
  175. _rc=$?
  176. if [ $_rc -gt 1 ]; then
  177. #We need to set LED's and halt
  178. echo Error detected error $_rc
  179. set_leds 0 8c #POWER LED BLINK RED
  180. set_leds 1 8c #STATUS LED BLINK RED
  181. else
  182. echo $_part check complete
  183. fi
  184. done
  185.  
  186. for _part in $ext3_parts; do
  187. /sbin/fsck -t ext3 -y /dev/$_part
  188. _rc=$?
  189. if [ $_rc -gt 1 ]; then
  190. #We need to set LED's and halt
  191. echo Error detected error $_rc
  192. set_leds 0 8c #POWER LED BLINK RED
  193. set_leds 1 8c #STATUS LED BLINK RED
  194. else
  195. echo $_part check complete
  196. fi
  197. done
  198. fi
  199.  
  200. if [ $usb_flash -eq 1 ]; then
  201. for _part in $flash_parts; do
  202. /sbin/fsck -t ext2 -y /dev/$_part
  203. _rc=$?
  204. if [ $_rc -gt 1 ]; then
  205. #We need to set LED's and halt
  206. echo Error detected error $_rc
  207. set_leds 0 8c #POWER LED BLINK RED
  208. set_leds 1 8c #STATUS LED BLINK RED
  209. else
  210. echo $_part check complete
  211. fi
  212. done
  213. fi
  214.  
  215. }
  216.  
  217. ####################################################################
  218. #
  219. # Mount /dev/sdb10 and look for flag
  220. # if not file /mnt/config/foundandlost
  221. # Set bootdelay=5
  222. # touch /mnt/configfs/foundandlost
  223. # unmount /dev/sdb10
  224. # reboot
  225. #
  226. ####################################################################
  227. check_first_boot()
  228. {
  229.  
  230. if [ ! -e /mnt/configfs ]; then
  231. /bin/mkdir -p /mnt/configfs
  232. fi
  233.  
  234. /bin/mount -t auto /dev/"$hd_id"10 /mnt/configfs
  235.  
  236. if [ ! -e /mnt/configfs/foundandlost ]; then
  237. /bin/touch /mnt/configfs/foundandlost || /bin/echo `date` " Failed to create foundandlost" >/mnt/configfs/mfg_error.log
  238. if [ ! `$fw_print | grep "bootdelay=5"` ]; then
  239. /nn/bin/fw_setenv bootdelay 5
  240. /bin/umount /dev/"$hd_id"10
  241. /bin/sync
  242. /sbin/shutdown -rn now
  243. fi
  244. fi
  245.  
  246. /bin/umount /dev/"$hd_id"10
  247.  
  248. }
  249.  
  250. ####################################################################
  251. #
  252. # Copy networking and account information from mainfs
  253. #
  254. ####################################################################
  255. sync_with_hd()
  256. {
  257. if [ ! -e /dev/mainfs ]; then
  258. echo "mainfs not defined, using default account and networking values"
  259. fi
  260.  
  261. if [ ! -e /mnt/mainfs ]; then
  262. /bin/mkdir -p /mnt/mainfs
  263. fi
  264.  
  265. /bin/mount -t auto /dev/mainfs /mnt/mainfs
  266.  
  267. #network configuration
  268. /bin/cp -a /mnt/mainfs/etc/hosts /etc/hosts
  269. /bin/cp -a /mnt/mainfs/etc/sysconfig/network /etc/sysconfig/network
  270. /bin/cp -a /mnt/mainfs/etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/
  271.  
  272. #account information
  273. #first test to make sure nnadmin exists and root account set properly
  274.  
  275. _bcount=`grep root /etc/shadow | cut -f2 -d : | $word_count -c`
  276.  
  277. /bin/grep -q nnadmin /mnt/mainfs/etc/passwd
  278. _passwdrc=$?
  279. /bin/grep -q nnadmin /mnt/mainfs/etc/shadow
  280. _shadowrc=$?
  281.  
  282. if [ $_bcount -gt 4 -a $_passwdrc -eq 0 -a $_shadowrc -eq 0 ]; then
  283. /bin/cp -a /mnt/mainfs/etc/passwd /etc/passwd
  284. /bin/cp -a /mnt/mainfs/etc/shadow /etc/shadow
  285. echo 0
  286. fi
  287.  
  288. if [ -e /mnt/mainfs/nn/etc/.systemid ]; then
  289. /bin/cp -a /mnt/mainfs/nn/etc/.systemid /nn/etc/
  290. fi
  291.  
  292. if [ -e /mnt/mainfs/usr/local/etc/ssh_host_key ]; then
  293. cp -a /mnt/mainfs/usr/local/etc/ssh_host_key /usr/local/etc/
  294. fi
  295.  
  296. if [ -e /mnt/mainfs/usr/local/etc/ssh_host_rsa_key ]; then
  297. cp -a /mnt/mainfs/usr/local/etc/ssh_host_rsa_key /usr/local/etc/
  298. fi
  299.  
  300. if [ -e /mnt/mainfs/usr/local/etc/ssh_host_dsa_key ]; then
  301. cp -a /mnt/mainfs/usr/local/etc/ssh_host_dsa_key /usr/local/etc/
  302. fi
  303.  
  304. #initialize the layer 2 switch
  305. /nn/sbin/swctl init
  306.  
  307. /sbin/ifdown eth1
  308. /sbin/ifup eth1
  309.  
  310. #bring up OAM interface
  311. /sbin/ifup eth2
  312.  
  313. /etc/rc.d/init.d/sshd start
  314.  
  315. /bin/umount /dev/mainfs
  316.  
  317. }
  318.  
  319. ####################################################################
  320. #
  321. # Read the uboot variable for reset_request and act accordingly
  322. #
  323. # L1 - mount reset partitions and perfrom a L1 reset
  324. # L2 - mount reset partitions and perform a L2 reset
  325. # mfg - mount /dev/sda5 and start stestd
  326. # mainos - pivot root and boot main file system using init
  327. # safeos - start CLI and halt in safeos
  328. #
  329. # If reset_request is explicitly set to safeos then call
  330. # CallBCMCli with the long parameter to indicate a 60 second timeout
  331. #
  332. # If reset_request is blank, the CLI timeout is 10 seconds
  333. #
  334. ####################################################################
  335. read_request()
  336. {
  337. echo "Entering read_request..."
  338. echo $1
  339. _request=none
  340. _cleanup=0
  341. _mfgtest=0
  342.  
  343. #enable boot delay and reboot if set
  344. if [ $hd_exist -eq 1 ]; then
  345. check_first_boot
  346. fi
  347.  
  348. if [ -n "$_mode" ]; then
  349. _request="reset_request=$_mode"
  350. _cleanup=1
  351. else
  352. _request=`$fw_print reset_request`
  353. fi
  354.  
  355. #Blank the reset_request, default will booot to safeos
  356. $fw_print | grep "mfgtest" >/dev/null 2>&1
  357. _rc=$?
  358. if [ $_rc -ne 0 ]; then
  359. $fw_set reset_request
  360. $fw_set bootdelay 5
  361. elif [ "$_request" != "reset_request=mfg" ]; then
  362. $fw_set mfgtest
  363. $fw_set bootdelay 5
  364. fi
  365.  
  366. echo $_request
  367.  
  368. case "$_request" in
  369. "reset_request=mainos" | "reset_request=mainos_mode" )
  370. if [ $_cleanup -eq 1 ]; then
  371. unload_things
  372. else
  373. unload_modules_only
  374. fi
  375. mainos_chroot
  376. ;;
  377. "reset_request=safeos" )
  378. sync_with_hd
  379. start_services
  380. /nn/sbin/CallBCMCLI long &
  381. safeos_mode
  382. ;;
  383. "reset_request=l1" | "reset_request=L1" )
  384. set_leds 0 89 #POWER LED SOLID RED
  385. set_leds 1 cc #STATUS LED BLINK YELLOW
  386. start_services
  387. l1_reset
  388. ;;
  389. "reset_request=l2" | "reset_request=L2" )
  390. set_leds 0 89 #POWER LED SOLID RED
  391. set_leds 1 89 #STATUS LED SOLID RED
  392. sync_with_hd
  393. start_services
  394. l2_reset
  395. ;;
  396. "reset_request=mfg" )
  397. if [ $hd_exist -eq 1 ]; then
  398. sync_with_hd
  399. fi
  400. set_leds 0 89 #POWER LED SOLID RED
  401. set_leds 1 98 #STATUS LED GREEN
  402. start_services
  403. #/nn/sbin/CallBCMCLI wait &
  404. echo "Swapping to manufacturing mode..."
  405. mfg_mode
  406. ;;
  407. "reset_request=reset" )
  408. /sbin/shutdown -nr now
  409. ;;
  410. "reset_request=idle" )
  411. unload_things
  412. safeos_mode
  413. ;;
  414. * )
  415. sync_with_hd
  416. start_services
  417. /nn/sbin/CallBCMCLI short &
  418. safeos_mode
  419. ;;
  420. esac
  421. }
  422.  
  423. ####################################################################
  424. #
  425. # Start the test daemon
  426. #
  427. ####################################################################
  428. start_stestd()
  429. {
  430.  
  431. /etc/rc.d/init.d/xinetd start
  432.  
  433. echo "Starting stestd..."
  434. prog="stestd"
  435. RC=0
  436. export HOME=/root/
  437. if [ -e /nn/sbin/stestd ]; then
  438. /nn/sbin/stestd 6800 &
  439. echo "stestd started"
  440. else
  441. echo "WARNING: stestd does not exist in /nn/sbin"
  442. fi
  443. }
  444.  
  445. ####################################################################
  446. #
  447. # Start the test daemon
  448. #
  449. ####################################################################
  450. start_services()
  451. {
  452.  
  453. /etc/rc.d/init.d/portmap start
  454. /etc/rc.d/init.d/syslog start
  455. /etc/rc.d/init.d/random start
  456.  
  457. }
  458.  
  459.  
  460. ####################################################################
  461. #
  462. # Start the test daemon
  463. #
  464. ####################################################################
  465. safeos_mode()
  466. {
  467.  
  468. rc=0
  469. while [ $rc -eq 0 ]; do
  470. if [ -e /root/swap ]; then
  471. /usr/bin/killall BCMCli >/dev/null 2>&1
  472. _mode=`cat /root/swap`
  473. echo "Swapping to $_mode"
  474. /bin/rm -f /root/swap
  475. read_request $_mode
  476. rc=1
  477. else
  478. sleep 10
  479. fi
  480. done
  481.  
  482. }
  483.  
  484.  
  485. ####################################################################
  486. #
  487. # Mount altroot partition /dev/sdb5
  488. # For L1, L2 resets and manufacturing
  489. #
  490. ####################################################################
  491. mfg_mode()
  492. {
  493.  
  494. if [ ! -d /mnt/altroot ]; then
  495. /bin/mkdir -p /mnt/altroot
  496. fi
  497.  
  498. if [ ! -d /mnt/mainfs ]; then
  499. /bin/mkdir -p /mnt/mainfs
  500. fi
  501.  
  502. /bin/mount -t auto /dev/mfgfs /mnt/altroot
  503. /bin/mount -t ext3 /dev/mainfs /mnt/mainfs
  504. #make stestd utilities visible
  505. /bin/mount --bind /mnt/altroot/nn /nn
  506.  
  507. #load additional required klms
  508. #BCM50 requires lm85.o, nn_secsi.o and nn_timeswitch.o
  509.  
  510. if [ -e /nn/lib/modules/lm85.o ]; then
  511. /sbin/insmod -f /nn/lib/modules/lm85.o
  512. fi
  513.  
  514. if [ -e /nn/lib/modules/nn_secsi.o ]; then
  515. /sbin/insmod -f /nn/lib/modules/nn_secsi.o
  516. fi
  517.  
  518. if [ -e /nn/lib/modules/nn_timeswitch.o ]; then
  519. /sbin/insmod -f /nn/lib/modules/nn_timeswitch.o
  520. fi
  521.  
  522. if [ -e /nn/lib/modules/nn_dchan_drv.o ]; then
  523. /sbin/insmod -f /nn/lib/modules/nn_dchan_drv.o
  524. fi
  525.  
  526. #replace the existing configuration files so telnet/ftp are enabled
  527. #telnet and ftp are started by xinetd, started later in start_stestd
  528. /bin/rm -f /etc/xinetd.d/telnet
  529. /bin/cp -a /mnt/altroot/etc/xinetd.d/telnet /etc/xinetd.d/telnet
  530. /bin/cp -a /mnt/altroot/usr/bin/ftp /usr/bin/
  531. /bin/cp -a /mnt/altroot/root/.netrc /root/
  532.  
  533. /sbin/ifup eth2
  534.  
  535. echo "Starting stestd"
  536. start_stestd
  537.  
  538. /bin/touch /tmp/CLITimeout #meh
  539.  
  540. if [ ! -e /dev/nn_secsi ]; then
  541. /bin/mknod /dev/nn_secsi c 0 29
  542. fi
  543.  
  544. if [ ! -e /dev/mtd4 ]; then
  545. /bin/mknod /dev/mtd4 c 90 8
  546. fi
  547.  
  548. #CLI should not be used often in mfg mode, present it just in case
  549. #/nn/sbin/CallBCMCLI wait &
  550.  
  551. #call safeos_mode so we do not restart
  552. safeos_mode
  553.  
  554. }
  555.  
  556. ####################################################################
  557. #
  558. # Unload modules and stop running processes before going into mainos
  559. #
  560. ####################################################################
  561.  
  562. unload_things()
  563. {
  564.  
  565. #Stop services
  566. echo "Stopping portmap..."
  567. /etc/rc.d/init.d/portmap stop
  568. echo "Stopping sshd..."
  569. /etc/rc.d/init.d/sshd stop
  570. echo "Stopping network..."
  571. /etc/rc.d/init.d/network stop
  572. echo "stopping syslog..."
  573. /etc/rc.d/init.d/syslog stop
  574.  
  575.  
  576. #Unload modules
  577. echo "Unloading modules..."
  578. /etc/rc.d/init.d/nn_modules stop
  579.  
  580. }
  581.  
  582. ####################################################################
  583. #
  584. # Unload modules
  585. #
  586. ####################################################################
  587.  
  588. unload_modules_only()
  589. {
  590.  
  591. #Unload modules
  592. echo "Unloading modules..."
  593. /etc/rc.d/init.d/nn_modules stop
  594.  
  595. }
  596.  
  597. ####################################################################
  598. #
  599. # Mount mainos partition, pivot_root, execute rc.sysinit, chroot
  600. # to finish transferring to mainos
  601. #
  602. ####################################################################
  603. mainos_chroot()
  604. {
  605.  
  606. echo "Entering mainos_chroot..."
  607.  
  608. if [ ! -e /dev/mainfs ]; then
  609. echo "!!!ERROR!!! mainfs not defined. either no hard disk present or it is not partitioned, halting in safeos..."
  610. safeos_mode
  611. fi
  612.  
  613. /bin/mount -t auto /dev/mainfs /sysroot
  614. /bin/umount /dev/pts
  615. /bin/umount /proc
  616. /bin/mkdir -p /sysroot/initrd
  617. cd /sysroot
  618. /bin/pivot_root . initrd
  619.  
  620. exec /sbin/chroot . /bin/bash -c '/sbin/init 3'<dev/console >dev/console 2>&1
  621.  
  622. }
  623.  
  624. ####################################################################
  625. #
  626. # Mount reset partitions
  627. #
  628. ####################################################################
  629. mount_reset_partitions()
  630. {
  631.  
  632. if [ ! -d /mnt/factoryImg ]; then
  633. /bin/mkdir -p /mnt/factoryImg
  634. fi
  635.  
  636. if [ ! -d /mnt/configfs ]; then
  637. /bin/mkdir -p /mnt/configfs
  638. fi
  639.  
  640. if [ ! -d /mnt/mainfs/var ]; then
  641. /bin/mkdir -p /mnt/mainfs/var
  642. fi
  643.  
  644. if [ ! -d /mnt/mainfs/var/shadow ]; then
  645. /bin/mkdir -p /mnt/mainfs/var/shadow
  646. fi
  647.  
  648. if [ ! -d /mnt/mainfs/var/log ]; then
  649. /bin/mkdir -p /mnt/mainfs/var/log
  650. fi
  651.  
  652. if [ ! -d /mnt/mainfs/nn/patches ]; then
  653. /bin/mkdir -p /mnt/mainfs/nn/patches
  654. fi
  655.  
  656. if [ ! -d /mnt/mainfs/nn/images/kernels ]; then
  657. /bin/mkdir -p /mnt/mainfs/nn/images/kernels
  658. fi
  659.  
  660. #was using hd_id for device name but issue with missing /proc/partitions
  661. #forced the partitions to be hard-coded for now
  662.  
  663. /bin/mount -t auto /dev/"$hd_id"3 /mnt/mainfs
  664. /bin/mount -t auto /dev/"$hd_id"6 /mnt/mainfs/var
  665. /bin/mount -t auto /dev/"$hd_id"7 /mnt/mainfs/var/shadow
  666. /bin/mount -t auto /dev/"$hd_id"8 /mnt/mainfs/var/log
  667. /bin/mount -t auto /dev/"$hd_id"9 /mnt/mainfs/nn/patches
  668. /bin/mount -t auto /dev/"$hd_id"1 /mnt/mainfs/nn/images/kernels
  669. /bin/mount -t auto /dev/"$hd_id"10 /mnt/factoryImg
  670. /bin/mount >>/mnt/factoryImg/ResetButton.log
  671. echo "Reset partitions mounted"
  672.  
  673. }
  674.  
  675. umount_reset_partitions()
  676. {
  677.  
  678. echo "Reset partitions unmounted"
  679. /bin/umount /dev/"$hd_id"10
  680. /bin/umount /dev/"$hd_id"1
  681. /bin/umount /dev/"$hd_id"9
  682. /bin/umount /dev/"$hd_id"8
  683. /bin/umount /dev/"$hd_id"7
  684. /bin/umount /dev/"$hd_id"6
  685. /bin/umount /dev/"$hd_id"3
  686. /bin/mount >>/mnt/factoryImg/ResetButton.log
  687.  
  688. }
  689.  
  690.  
  691. ####################################################################
  692. #
  693. # Perform L1 reset
  694. #
  695. ####################################################################
  696. l1_reset()
  697. {
  698. mount_reset_partitions
  699. echo `date` "LEVEL 1 RESET REQUESTED" >> $logfile
  700. /nn/bin/Level1.sh
  701. rc=$?
  702. /bin/sleep 3
  703. if [ "$rc" = "0" ]; then
  704. /nn/bin/fw_setenv reset_request "mainos"
  705. /bin/sync
  706. umount_reset_partitions
  707. /sbin/shutdown -rn now
  708. else
  709. echo `date` " L1 reset FAILED" >> $logfile
  710. /nn/bin/fw_setenv reset_request "mainos"
  711. /bin/sync
  712. umount_reset_partitions
  713. /sbin/shutdown -rn now
  714. fi
  715.  
  716. }
  717.  
  718. ####################################################################
  719. #
  720. # Perform L2 reset
  721. #
  722. ####################################################################
  723. l2_reset()
  724. {
  725. echo `date` "LEVEL 2 RESET REQUESTED" >> $logfile
  726. mount_reset_partitions
  727. #Call L2 with sda or sdb, $boot_hd_id for 450 and just $hd_id for 50
  728. /nn/bin/Level2.sh $hd_id
  729. rc=$?
  730. sleep 3
  731. if [ "$rc" = "0" ]; then
  732. echo "l2 test done"
  733. /nn/bin/fw_setenv reset_request "mainos"
  734. /bin/sync
  735. umount_reset_partitions
  736. /sbin/shutdown -rn now
  737. else
  738. echo `date` " L2 reset FAILED" >> $logfile
  739. /nn/bin/fw_setenv reset_request "mainos"
  740. /bin/sync
  741. umount_reset_partitions
  742. /sbin/shutdown -rn now
  743. fi
  744.  
  745. }
  746.  
  747. ####################################################################
  748. #
  749. # Main
  750. #
  751. ####################################################################
  752.  
  753. echo "linuxrc starting..."
  754. if [ $# -eq 0 ]; then
  755. init_setup
  756. file_system_check
  757. read_request
  758. echo "Should not have gone this far"
  759. exit 0
  760. else
  761. echo "linuxrc test"
  762. fi
  763.  
  764. #Should never actually exit from here
  765.  
  766. exit 0
  767. init-2.05b#
  768.  
Advertisement
Add Comment
Please, Sign In to add comment