Guest User

init

a guest
Aug 13th, 2025
37
0
Never
7
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 38.98 KB | Source Code | 0 0
  1. #!/bin/sh
  2. #
  3. # SPDX-FileCopyrightText: 2020 Western Digital Corporation or its affiliates.
  4. #
  5. # SPDX-License-Identifier: GPL-2.0-or-later
  6. #
  7.  
  8.  
  9. source /usr/local/modules/files/project_features
  10. SUPPORT_BONDING=$PROJECT_FEATURE_BONDING
  11. WD_USER_BINARY=wd/usr/sbin
  12. WD_USER_LIBRARY=wd/usr/lib
  13.  
  14. lan_init()
  15. {
  16.     local MODEL=`xmldbc -g /hw_ver`
  17.  
  18.     if [ "$MODEL" = "WDMyCloud" ]; then
  19.         phy_link_led.sh
  20.     fi
  21.  
  22.     if [ ! -e /usr/sbin/ipv6.sh ]; then
  23.         echo "*** execute rc.init.sh"
  24.         ip.sh booting
  25.     else
  26.         ipv6_install.sh     # for ipv6
  27.  
  28.         echo "*** execute rc.init.sh"
  29.         ip.sh booting
  30.  
  31.         # for ipv6
  32.         IPV6_MODE0=`xmldbc -g '/network_mgr/lan0/ipv6/mode'`
  33.         if [ "$IPV6_MODE0" != "off" ]; then
  34.             ipv6.sh 0 start &
  35.         fi
  36.  
  37.         if [ "$SUPPORT_BONDING" == "1" ]; then
  38.             BOND_ENABLE=$(xmldbc -g "/network_mgr/bonding/enable")
  39.         else
  40.             BOND_ENABLE=0
  41.         fi
  42.  
  43.         if [ "$BOND_ENABLE" == "1" ]; then
  44.             IPV6_MODE1="off"
  45.         else
  46.             IPV6_MODE1=`xmldbc -g '/network_mgr/lan1/ipv6/mode'`
  47.         fi
  48.  
  49.         if [ "$IPV6_MODE1" != "off" ]; then
  50.             ipv6.sh 1 start &
  51.         fi
  52.  
  53.         if [ "$IPV6_MODE0" = "dhcp" -o "$IPV6_MODE1" = "dhcp" ]; then
  54.             dhcp6c.sh 0 start &
  55.         fi
  56.  
  57.         ENABLE=`xmldbc -g '/network_mgr/lan0/tunnel_broker/enable'`
  58.         if [ "$ENABLE" = "1" ]; then
  59.             tunl_broker.sh 0 start &
  60.         fi
  61.         ENABLE=`xmldbc -g '/network_mgr/lan1/tunnel_broker/enable'`
  62.         if [ "$ENABLE" = "1" ]; then
  63.             tunl_broker.sh 1 start &
  64.         fi
  65.         # for ipv6 (end)
  66.  
  67.         # enable QoS for DLNA CTT
  68.         if [ "$MODEL" = "WDMyCloudEX4" ]; then
  69.             vconfig add bond0 0
  70.         fi
  71.     fi
  72. }
  73.  
  74. one_bay_init()
  75. {
  76.     cp /usr/local/modules/${WD_USER_BINARY}/memory_rw /usr/sbin/
  77.     cp /usr/local/modules/${WD_USER_LIBRARY}/libshare.so /lib/
  78.     cp /usr/local/modules/lib/libxmldbc.so /lib/
  79.     cp /usr/local/modules/${WD_USER_BINARY}/lbr /usr/sbin/
  80.     cp /usr/local/modules/script/led_brloop.sh /usr/sbin/
  81.     cp /usr/local/modules/usr/bin/hdparm /usr/bin/
  82.     cp /usr/local/modules/${WD_USER_BINARY}/rlog /usr/sbin/
  83.     cp /usr/local/modules/${WD_USER_LIBRARY}/libalert.so /lib/
  84.     cp -d /usr/local/modules/lib/libxml2.so* /lib/
  85.     cp /usr/local/modules/${WD_USER_LIBRARY}/libtemperature.so /lib/
  86.     cp /usr/local/modules/${WD_USER_LIBRARY}/libmipc.so /lib/
  87.     cp /usr/local/modules/${WD_USER_LIBRARY}/libalpha_common.so /lib/
  88. }
  89.  
  90. copy_ipv6_config()
  91. {
  92.     mkdir /etc/wide-dhcpv6
  93.     cp /usr/local/config/dhcp6c.conf /etc/wide-dhcpv6
  94.     cp /usr/local/config/gogoc.conf /etc
  95. }
  96.  
  97. Insert_Kernel_Driver_OneBay()
  98. {
  99.     insmod /usr/local/modules/driver/hfs.ko
  100.     insmod /usr/local/modules/driver/udf.ko
  101. }
  102.  
  103. Insert_Kernel_Driver()
  104. {
  105.     #RAID
  106.     if [ -e /usr/local/modules/driver/oid_registry.ko ]; then
  107.         insmod /usr/local/modules/driver/oid_registry.ko
  108.     fi
  109.     insmod /usr/local/modules/driver/raid6_pq.ko
  110.  
  111.     insmod /usr/local/modules/driver/xor.ko
  112.     insmod /usr/local/modules/driver/async_tx.ko
  113.     insmod /usr/local/modules/driver/async_xor.ko
  114.     insmod /usr/local/modules/driver/async_memcpy.ko
  115.  
  116.     insmod /usr/local/modules/driver/async_pq.ko
  117.     insmod /usr/local/modules/driver/async_raid6_recov.ko
  118.  
  119.     insmod /usr/local/modules/driver/sunrpc.ko
  120.     if [ -e  /usr/local/modules/driver/auth_rpcgss.ko ]; then
  121.         insmod /usr/local/modules/driver/auth_rpcgss.ko
  122.     fi
  123.     if [ -e /usr/local/modules/driver/rpcsec_gss_krb5.ko ]; then
  124.         insmod /usr/local/modules/driver/rpcsec_gss_krb5.ko
  125.     fi
  126.  
  127.     insmod /usr/local/modules/driver/dm-mod.ko
  128.     insmod /usr/local/modules/driver/dm-bio-prison.ko
  129.     insmod /usr/local/modules/driver/dm-bufio.ko
  130.     insmod /usr/local/modules/driver/dm-crypt.ko
  131.     insmod /usr/local/modules/driver/dm-snapshot.ko
  132.     insmod /usr/local/modules/driver/dm-persistent-data.ko
  133.     insmod /usr/local/modules/driver/dm-thin-pool.ko
  134.     insmod /usr/local/modules/driver/linear.ko
  135.     insmod /usr/local/modules/driver/raid0.ko
  136.     insmod /usr/local/modules/driver/raid1.ko
  137.     insmod /usr/local/modules/driver/raid10.ko
  138.     insmod /usr/local/modules/driver/raid456.ko
  139.  
  140.     #file system
  141.     insmod /usr/local/modules/driver/fat.ko
  142.     if [ -e /usr/local/modules/driver/exportfs.ko ]; then
  143.         insmod /usr/local/modules/driver/exportfs.ko
  144.     fi
  145.     insmod /usr/local/modules/driver/msdos.ko
  146.     insmod /usr/local/modules/driver/vfat.ko
  147.     if [ -e /usr/local/modules/driver/fscache.ko ]; then
  148.         insmod /usr/local/modules/driver/fscache.ko
  149.     fi
  150.     if [ -e /usr/local/modules/driver/fuse.ko ]; then
  151.         insmod /usr/local/modules/driver/fuse.ko
  152.     fi
  153.     insmod /usr/local/modules/driver/hfs.ko
  154.     insmod /usr/local/modules/driver/isofs.ko
  155.     insmod /usr/local/modules/driver/nfs_acl.ko
  156.     insmod /usr/local/modules/driver/grace.ko
  157.     insmod /usr/local/modules/driver/lockd.ko
  158.     insmod /usr/local/modules/driver/nfs.ko
  159.     insmod /usr/local/modules/driver/nfsv2.ko
  160.     insmod /usr/local/modules/driver/nfsv3.ko
  161.     insmod /usr/local/modules/driver/nfsd.ko
  162.     if [ -e /usr/local/modules/driver/nls_ascii.ko ]; then
  163.         insmod /usr/local/modules/driver/nls_ascii.ko
  164.     fi
  165.     if [ -e /usr/local/modules/driver/nls_cp437.ko ]; then
  166.         insmod /usr/local/modules/driver/nls_cp437.ko
  167.     fi
  168.     insmod /usr/local/modules/driver/nls_cp850.ko
  169.     insmod /usr/local/modules/driver/nls_iso8859-1.ko
  170.     insmod /usr/local/modules/driver/nls_iso8859-2.ko
  171.     insmod /usr/local/modules/driver/nls_utf8.ko
  172.     if [ -e /usr/local/modules/driver/pstore.ko ]; then
  173.         insmod /usr/local/modules/driver/pstore.ko
  174.     fi
  175.     if [ -e /usr/local/modules/driver/quota_tree.ko ]; then
  176.         insmod /usr/local/modules/driver/quota_tree.ko
  177.     fi
  178.     if [ -e /usr/local/modules/driver/quota_v2.ko ];then
  179.         insmod /usr/local/modules/driver/quota_v2.ko
  180.     fi
  181.     insmod /usr/local/modules/driver/udf.ko
  182.     insmod /usr/local/modules/driver/cifs.ko
  183. }
  184.  
  185. Copy_OS3_Apps_List()
  186. {
  187.     DSK_INDEX=abcd
  188.     dsknum=1
  189.  
  190.     eula=`xmldbc -g /eula`
  191.     #When OS3 -> GZA
  192.     if [ "${eula}" != "3" ]; then
  193.         return
  194.     fi
  195.  
  196.     while [ $dsknum -le 4 ]
  197.     do
  198.         DISK_PATH=/mnt/HD_`expr substr "$DSK_INDEX" "$dsknum" 1`4
  199.         status=`mount | grep $DISK_PATH`
  200.         if [ -n "$status" ];then
  201.             app_list_path=$DISK_PATH/.systemfile/OS3_Backup/gza_app.xml
  202.             if [ -e $app_list_path ]; then
  203.                 echo "Copy OS3 Apps LIST"
  204.                 cp -f $app_list_path /var/www/xml/
  205.                 break
  206.             fi
  207.         fi
  208.         dsknum=`expr $dsknum + 1`
  209.     done
  210. }
  211.  
  212. Remove_OS3_Apps_List()
  213. {
  214.     DSK_INDEX=abcd
  215.     dsknum=1
  216.  
  217.     while [ $dsknum -le 4 ]
  218.     do
  219.         DISK_PATH=/mnt/HD/HD_`expr substr "$DSK_INDEX" "$dsknum" 1`2
  220.         status=`mount | grep $DISK_PATH`
  221.         if [ -n "$status" ];then
  222.             DISK_SYSTEMFILE_PATH=$DISK_PATH/.systemfile/OS3_Apps_Backup/Nas_Prog
  223.             if [ -d ${DISK_SYSTEMFILE_PATH} ]; then
  224.                 ls ${DISK_SYSTEMFILE_PATH}/
  225.                 echo "Remove OS3 APP ${DISK_SYSTEMFILE_PATH}"
  226.                 mv ${DISK_SYSTEMFILE_PATH} ${DISK_SYSTEMFILE_PATH}2
  227.                 mkdir -p ${DISK_SYSTEMFILE_PATH}
  228.                 mv ${DISK_SYSTEMFILE_PATH}2/plexmediaserver ${DISK_SYSTEMFILE_PATH}/
  229.                 mv ${DISK_SYSTEMFILE_PATH}2/plex_conf ${DISK_SYSTEMFILE_PATH}/
  230.                 rm -rf  ${DISK_SYSTEMFILE_PATH}2 &
  231.             fi
  232.         fi
  233.         dsknum=`expr $dsknum + 1`
  234.     done
  235. }
  236.  
  237. # mount tmpfs and make system directories
  238. rm /etc/mtab
  239. rm /usr/sbin/hotPlug.sh
  240. ln -s /proc/mounts /etc/mtab
  241.  
  242. cp -af /tmp/* /tmp1 2>/dev/null
  243. busybox mount -t tmpfs -o size=1m,nr_inodes=0,noexec,nosuid,nodev tmpfs /mnt
  244. busybox mount -t tmpfs -o size=40m,nr_inodes=0,noexec,nosuid,nodev tmpfs /var/log
  245. busybox mount -t tmpfs -o size=100m,nr_inodes=20000,noexec,nosuid,nodev tmpfs /tmp
  246. sh /usr/local/modules/script/init_dir.sh
  247. cp -af /tmp1/* /tmp/ 2>/dev/null
  248. rm -rf /tmp1
  249.  
  250. mkdir -p /mnt/HD
  251. mkdir -p /mnt/USB
  252.  
  253. if [ -e /image.cfs ]; then
  254.     #rescue fw mode use busybox sync
  255.     ln -s /bin/busybox /usr/sbin/sync
  256.     echo "====> firmware error"
  257.     touch /tmp/firmware_error
  258. fi
  259.  
  260. ln -s /usr/local/modules/lib/* /lib/. 2>/dev/null
  261. ln -s /usr/local/modules/bin/* /bin/.
  262. ln -s /usr/local/modules/sbin/* /sbin/.
  263. ln -s /usr/local/modules/usr/bin/* /usr/bin/.
  264. ln -s /usr/local/modules/usr/sbin/* /usr/sbin/.
  265. ln -s /usr/local/modules/script/* /usr/sbin/.
  266. ln -s /usr/local/modules/ext_script/* /usr/sbin/.
  267. rm /usr/sbin/pre_usb.sh
  268. linkfile /usr/local/modules/rsync/ /usr/sbin/
  269. linkfile /usr/local/modules/cgi/ /var/www/cgi-bin/
  270. linkfile /usr/local/modules/cgi/backup_mgr/ /var/www/cgi-bin/
  271. linkfile /usr/local/modules/cgi/app_mgr/ /var/www/cgi-bin/
  272. linkfile /usr/local/modules/cgi/download_mgr/ /var/www/cgi-bin/
  273. linkfile /usr/local/modules/cgi/disk_mgr/ /var/www/cgi-bin/
  274. rm -f /bin/sync # /usr/sbin/sync is a script that avoid some situation to call sync to cause system hang
  275. ln -s /usr/local/modules/${WD_USER_BINARY}/* /usr/sbin/.
  276. ln -s /usr/local/modules/${WD_USER_LIBRARY}/* /lib/.
  277. if [ -d /usr/local/modules/${WD_USER_LIBRARY}/php ]; then
  278.     ln -s /usr/local/modules/${WD_USER_LIBRARY}/php /usr/local/lib/php
  279. fi
  280. mkdir /usr/local/sbin
  281. ln -s /usr/local/modules/localsbin/* /usr/local/sbin/.
  282. ln -s /usr/local/sbin/incUpdateCount.pm /usr/local/sbin/inc_update_counts.sh
  283.  
  284. mkdir /usr/local/bin
  285. ln -s /usr/local/modules/usr/local/bin/* /usr/local/bin/.
  286.  
  287. mkdir /etc/nas/
  288. ln -s /usr/local/modules/files/nas/* /etc/nas/.
  289.  
  290. #for support WD app
  291. if [ ! -d /usr/local/etc ]; then
  292.     mkdir /usr/local/etc
  293. fi
  294.  
  295. if [ -e /usr/bin/bash ]; then
  296.     rm /usr/bin/bash
  297. fi
  298.  
  299. ln -s /usr/local/modules/usr/bin/bash /bin/
  300.  
  301. ## special case ##
  302. ln -s  /usr/local/modules/web/pages /var/www/web
  303.  
  304. cp -a /usr/local/modules/etc/* /etc/
  305.  
  306. if [ -e /usr/bin/dmesg ]; then
  307.     rm /bin/dmesg
  308.     mv /usr/bin/dmesg /bin/
  309. fi
  310.  
  311. ln -s /usr/local/modules/default /usr/local/default
  312. ln -s /usr/local/modules/script/default.script /usr/share/udhcpc/
  313. ln -s /usr/local/modules/script/zcip.script /usr/share/udhcpc/
  314. ln -s /usr/local/modules/files/terminfo /usr/share/
  315. [ ! -d /usr/share/doc ] && mkdir -p /usr/share/doc
  316. mkdir /opt
  317. ln -s /usr/local/modules/perl5 /opt/perl5
  318.  
  319. # WD HWLib
  320. if [ "$PROJECT_FEATURE_USE_WD_HWLIB" = "1" ] || [ "$PROJECT_FEATURE_WD_CUSTOME_HWLIB" = "1" ] ; then
  321.     ln -s /usr/local/modules/opt/wd /opt/
  322.     ln -s /usr/local/modules/opt/wd/lib/* /lib/.
  323.     ln -s /usr/local/modules/opt/wd/lib/boost/* /lib/.
  324. fi
  325.  
  326. #Set UTF-8 locale environment
  327. mkdir -p /usr/lib/locale
  328. ln -s /usr/local/modules/web/config/locale-archive /usr/lib/locale
  329.  
  330. if [ "$PROJECT_FEATURE_64BIT_PLATFORM" = "1" ]; then
  331.     ln -s /usr/lib /usr/lib64
  332. fi
  333.  
  334. #link xmldbc
  335. ln -s /usr/local/modules/usr/sbin/xmldb /usr/sbin/xmldbc
  336.  
  337. #for ads
  338. if [ ! -e /lib/libnss_winbind.so.2 ] && [ -e /usr/local/modules/lib/libnss_winbind.so ]; then
  339.     ln -s /usr/local/modules/lib/libnss_winbind.so /lib/libnss_winbind.so.2
  340. fi
  341.  
  342. if [ -d /usr/local/modules/usr/lib/x86_64-linux-gnu ]; then
  343.     mkdir -p /usr/lib/x86_64-linux-gnu
  344.     ln -s /usr/local/modules/usr/lib/x86_64-linux-gnu/* /usr/lib/x86_64-linux-gnu/
  345. fi
  346.  
  347. if [ -d /usr/local/modules/usr/lib/arm-linux-gnueabihf ]; then
  348.     mkdir -p /usr/lib/arm-linux-gnueabihf
  349.     ln -s /usr/local/modules/usr/lib/arm-linux-gnueabihf/* /usr/lib/arm-linux-gnueabihf/
  350. fi
  351.  
  352. rm /usr/sbin/blazer_usb
  353. rm /usr/sbin/tripplite_usb
  354. rm /usr/sbin/usbhid-ups
  355. rm /usr/sbin/bcmxcp_usb
  356. rm /usr/sbin/richcomm_usb
  357. ln -s /usr/local/modules/usr/sbin/blazer_usb /usr/local/ups/bin/blazer_usb
  358. ln -s /usr/local/modules/usr/sbin/tripplite_usb /usr/local/ups/bin/tripplite_usb
  359. ln -s /usr/local/modules/usr/sbin/usbhid-ups /usr/local/ups/bin/usbhid-ups
  360. ln -s /usr/local/modules/usr/sbin/bcmxcp_usb /usr/local/ups/bin/bcmxcp_usb
  361. ln -s /usr/local/modules/usr/sbin/richcomm_usb /usr/local/ups/bin/richcomm_usb
  362.  
  363. # link quota off
  364. ln -s /usr/local/modules/usr/bin/quotaon /usr/bin/quotaoff
  365.  
  366. #link ssh to /usr/sbin/ to support old version fw
  367. ln -s /usr/local/modules/usr/local/bin/ssh /usr/sbin/ssh
  368. ln -s /usr/local/modules/usr/bin/ssh-keygen /usr/sbin/ssh-keygen
  369.  
  370. #samba
  371. mkdir -p /usr/libexec
  372. ln -s /usr/local/modules/usr/libexec/* /usr/libexec/
  373.  
  374. # mysql
  375. ln -s /usr/local/modules/mysql/libexec/* /usr/libexec/
  376. mkdir -p /usr/share/mysql/bin
  377. ln -s /usr/local/modules/mysql/libexec /usr/share/mysql/libexec
  378. ln -s /usr/local/modules/usr/bin/my_print_defaults /usr/share/mysql/bin/my_print_defaults
  379. ln -s /usr/local/modules/usr/bin/mysql /usr/share/mysql/bin/mysql
  380. ln -s /usr/local/modules/usr/bin/mysql_install_db /usr/share/mysql/bin/mysql_install_db
  381. ln -s /usr/local/modules/usr/bin/mysql_secure_installation /usr/share/mysql/bin/mysql_secure_installation
  382. ln -s /usr/local/modules/usr/bin/mysqladmin /usr/share/mysql/bin/mysqladmin
  383. ln -s /usr/local/modules/usr/bin/mysqld_safe /usr/share/mysql/bin/mysqld_safe
  384. ln -s /usr/local/modules/usr/bin/resolveip /usr/share/mysql/bin/resolveip
  385. ln -s /usr/local/modules/mysql/share /usr/share/mysql/share
  386.  
  387. #sms
  388. ln -s /etc/sms_conf.xml /var/www/xml/
  389.  
  390. #language
  391. ln -s /usr/local/modules/language/en-US/english_en-us.xml /var/www/xml/english.xml
  392.  
  393. #snmp
  394. ln -s /usr/local/modules/files/snmp /usr/local/share/
  395.  
  396. #kmod
  397. ln -s /usr/bin/kmod /usr/bin/lsmod
  398. ln -s /usr/bin/kmod /usr/bin/insmod
  399. ln -s /usr/bin/kmod /usr/bin/rmmod
  400.  
  401. ln -s /usr/local/modules/zoneinfo /usr/sbin/
  402. ln -s /usr/local/modules/usr/share/zoneinfo /usr/share/
  403.  
  404. #for wdlog
  405. ln -s /usr/local/modules/usr/local/bin/wdlog /usr/sbin/wdlog
  406.  
  407. #for performance
  408. cp -f /usr/local/modules/${WD_USER_LIBRARY}/libshare.so /lib
  409. cp -f /usr/local/modules/${WD_USER_LIBRARY}/libmipc.so /lib
  410. cp -f /usr/local/modules/${WD_USER_LIBRARY}/libtemperature.so /lib
  411.  
  412. cp -f /usr/local/modules/script/rc.init.sh /etc/rc.d/ 2>/dev/null
  413.  
  414. if [ "$PROJECT_FEATURE_BAYS" = "1" ]; then
  415.    one_bay_init
  416. fi
  417.  
  418. # Generate /etc/ld.so.cache to include /opt/wd/lib/ ... etc
  419. # This is needed by programs linked with wdhwlib.
  420. # DO THIS AFTER ALL SHLIBS BEEN SETUP
  421. # ITR: 99167 , let ldconfig for all project +20141030.VODKA
  422. ldconfig
  423.  
  424. # To protect from user _easily_ accessing reserved part7 and part8,
  425. # we remove the device nodes.
  426. # Anyone who want to access them must create the nodes itself.
  427. for dn in `blkid | grep wdnas_reserve | awk -F ":" '{ print $1 }'`; do
  428.     rm -f $dn
  429. done
  430.  
  431. if [ -e /usr/sbin/kick_rtc ]; then
  432.     year=`date +"%Y"`
  433.     if [ "${year}" \< "2000" ]; then
  434.         kick_rtc
  435.         date -s "2020.01.01-00:00:00"
  436.         hwclock -w -u
  437.     fi
  438. fi
  439.  
  440. # GZA-940: improve RAID rebuild speed
  441. sysctl -w dev.raid.speed_limit_min=20000
  442. # slow down rebuild speed
  443. md_sync_speed.sh min
  444.  
  445. model_code=`cat /usr/local/modules/files/model`
  446. if [ "${PROJECT_FEATURE_BAYS}" = "1" ]; then
  447.     Insert_Kernel_Driver_OneBay
  448. else
  449.     Insert_Kernel_Driver
  450. fi
  451.  
  452. #echo "$model_code"
  453.  
  454. # If egiga0 and egiga1 is OK,
  455. # Do Lan Port's Name Switch, only for Sprite.
  456. if [ "$PROJECT_FEATURE_LAN_PORT_SWITCH" = "1" ]; then
  457.  
  458.     # Test for egiga0
  459.     ifconfig egiga0
  460.     TEST_LAN0=$?
  461.     if [ "$TEST_LAN0" != "0" ]; then
  462.         echo "egiga0 is broken"
  463.     fi
  464.  
  465.     # Test for egiga1
  466.     ifconfig egiga1
  467.     TEST_LAN1=$?
  468.     if [ "$TEST_LAN1" != "0" ]; then
  469.         echo "egiga1 is broken"
  470.     fi
  471.  
  472.     if [ "$TEST_LAN0" == "0" ] && [ "$TEST_LAN1" == "0" ] ; then
  473.         echo "Do Lan Port Switch"
  474.         LAN0_MAC=`ifconfig egiga0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'`
  475.         LAN1_MAC=`ifconfig egiga1 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'`
  476.         ip link set dev egiga0 name not_egiga0 address 00:00:00:00:00:01
  477.         ip link set dev egiga1 name egiga0 address $LAN0_MAC
  478.         ip link set dev not_egiga0 name egiga1 address $LAN1_MAC
  479.     fi
  480. elif [ -e /usr/local/modules/files/switch_lan ]; then
  481.     #only SGMII
  482.     # Test for LAN0
  483.     lan0_interface=`cat /usr/local/modules/files/switch_lan | awk '{print $1}'`
  484.     lan1_interface=`cat /usr/local/modules/files/switch_lan | awk '{print $2}'`
  485.  
  486.     ifconfig $lan0_interface
  487.     TEST_LAN0=$?
  488.     if [ "$TEST_LAN0" != "0" ]; then
  489.         echo "$lan0_interface is broken"
  490.     fi
  491.  
  492.     # Test for LAN1
  493.     ifconfig $lan1_interface
  494.     TEST_LAN1=$?
  495.     if [ "$TEST_LAN1" != "0" ]; then
  496.         echo "$lan1_interface is broken"
  497.     fi
  498.  
  499.     if [ "$TEST_LAN0" == "0" ] && [ "$TEST_LAN1" == "0" ] ; then
  500.         echo "Do Lan Port Switch"
  501.         LAN0_MAC=`ifconfig $lan0_interface | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'`
  502.         LAN1_MAC=`ifconfig $lan1_interface | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'`
  503.         ip link set dev $lan0_interface name not_egiga0 address 00:00:00:00:00:01
  504.         ip link set dev $lan1_interface name $lan0_interface address $LAN0_MAC
  505.         ip link set dev not_egiga0 name $lan1_interface address $LAN1_MAC
  506.     fi
  507. fi
  508.  
  509. # cryptodev for HW CESA engine support
  510. #if [ -e /usr/local/modules/driver/cryptodev.ko ]; then
  511. #   insmod /usr/local/modules/driver/cryptodev.ko
  512. #fi
  513.  
  514. if [ -e /usr/local/modules/driver/jnl.ko ]; then
  515.     insmod /usr/local/modules/driver/jnl.ko
  516. fi
  517.  
  518. if [ -e /usr/local/modules/driver/ufsd.ko ]; then
  519.     insmod /usr/local/modules/driver/ufsd.ko
  520. fi
  521.  
  522. [ -d /dev/net ] || mkdir /dev/net
  523. mknod -m 644 /dev/net/tun c 10 200 2>/dev/null
  524. insmod /usr/local/modules/driver/tun.ko 2>/dev/null
  525.  
  526. # Odie added
  527. diskmgr --genlink /usr/sbin/
  528.  
  529. hardware_init.sh
  530.  
  531. if [ -f "/usr/sbin/cgrplimit.sh" ]; then
  532.     /usr/sbin/cgrplimit.sh -d -l -c 50 -m 7
  533. fi
  534. #802.3az
  535. 802_3az.sh
  536.  
  537. if [ -e /usr/sbin/tune_performance ]; then
  538.     tune_performance
  539. fi
  540.  
  541. fvc -t
  542.  
  543. mtd_check
  544.  
  545. if [ ! -e /tmp/firmware_error ]; then
  546.     #check in normal firmware
  547.     echo "** copy config files"
  548.     if [ -e /usr/local/config/reset_default ]; then
  549.         reset_default_value=`cat /usr/local/config/reset_default`
  550.         echo "reset default value: $reset_default_value"
  551.         if [ "$reset_default_value" = "1" ]; then
  552.             echo "copy default config to /usr/local/config"
  553.             cp -f /usr/local/default/config.xml /usr/local/config/
  554.             rm -f /usr/local/config/CacheVolume/.wd-alert/wd-alert-desc.db
  555.             rm -f /usr/local/config/CacheVolume/.wd-alert/wd-alert.db
  556.             rm -f /usr/local/config/CacheVolume/last_firmware_info_sent
  557.             rm -f /usr/local/config/alert.xml
  558.             rm -f /usr/local/config/alert_send.xml
  559.             sync
  560.         fi
  561.     fi
  562. fi
  563. cp -f /usr/local/config/hosts  /etc/ 2>/dev/null
  564. cp -f /usr/local/config/resolv.conf /etc/ 2>/dev/null
  565.  
  566. # GZA-9124: remove "squeezecenter" and sync "nobody" with default
  567. sed -i '/^squeezecenter:/d' /usr/local/config/passwd
  568. sed -i '/^squeezecenter:/d' /usr/local/config/shadow
  569. STR=$(cat /usr/local/default/passwd | grep "^nobody:")
  570. sed -i "s|^nobody:.*|${STR}|g" /usr/local/config/passwd
  571. STR=$(cat /usr/local/default/shadow | grep "^nobody:")
  572. sed -i "s|^nobody:.*|${STR}|g" /usr/local/config/shadow
  573. cp -f /usr/local/config/passwd /etc/ 2>/dev/null
  574. cp -f /usr/local/config/shadow /etc/ 2>/dev/null
  575. chmod 600 /etc/shadow
  576.  
  577. cp -f /usr/local/config/group /etc/ 2>/dev/null
  578. cp -f /usr/local/config/smbpasswd /etc/samba/ 2>/dev/null
  579. cp -f /usr/local/config/config.xml /etc/NAS_CFG/ 2>/dev/null
  580. cp -f /usr/local/config/rtc.conf /etc/ 2>/dev/null
  581. cp -f /usr/local/config/udhcpd.conf /etc/ 2>/dev/null
  582. cp -f /usr/local/config/udhcpd.conf.def /etc/ 2>/dev/null
  583. cp -f /usr/local/config/syslog.conf /etc/ 2>/dev/null
  584. cp -f /usr/local/config/mdadm.conf /etc/ 2>/dev/null
  585. cp -f /usr/local/config/blockip /etc/blockip 2>/dev/null
  586. cp -f /usr/local/config/rxclient_schedule.sh /usr/sbin/ 2>/dev/null
  587. cp -f /usr/local/config/sms_conf.xml /etc/ 2>/dev/null
  588. cp -f /usr/local/config/mail_event_conf.xml /etc/ 2>/dev/null
  589. cp -f /usr/local/config/uid /etc/ 2>/dev/null
  590. cp -f /usr/local/config/gid /etc/ 2>/dev/null
  591. cp -f /usr/local/config/iconv_table /etc/ 2>/dev/null
  592. cp -f /usr/local/config/routeap.conf /etc/ 2>/dev/null
  593. cp -f /usr/local/config/snmpd.conf /etc/ 2>/dev/null
  594. cp -f /usr/local/config/smbdfs.xml /etc/NAS_CFG/ 2>/dev/null
  595. cp -f /usr/local/config/smbdfs_group.xml /etc/NAS_CFG/ 2>/dev/null
  596. cp -f /usr/local/config/routeap.conf /etc/ 2>/dev/null
  597. cp -f /usr/local/config/upisorootpath /tmp/ 2>/dev/null
  598. cp -f /usr/local/config/vv.xml /etc/NAS_CFG/ 2>/dev/null
  599. cp -f /usr/local/config/version.update /etc/ 2>/dev/null
  600. cp -f /usr/local/config/version_info /etc/ 2>/dev/null
  601. mv /usr/local/config/firmwareupdate /tmp/ 2>/dev/null
  602. rm -f /usr/local/config/udhcpd.leases 2>/dev/null
  603. if [ ! -e /tmp/firmware_error ]; then
  604.     mv /usr/local/config/reset_default /tmp/ 2>/dev/null
  605. fi
  606. mv /usr/local/config/rescue_firmware_be_started /tmp/ 2>/dev/null
  607. cp /usr/local/config/tmp_wd_serial.txt /tmp/ 2>/dev/null
  608. cp /usr/local/config/dbg_* /tmp/ 2>/dev/null
  609. cp /usr/local/config/hw_mode /tmp/ 2>/dev/null
  610. cp /usr/local/config/power_status /tmp/ 2>/dev/null
  611. mv /usr/local/config/want_to_shutdown /tmp/ 2>/dev/null
  612. cp /usr/local/config/ga_tracking_id /etc/ga_tracking_id 2>/dev/null
  613. if [ ! -f "/usr/local/config/MySQL_service_config.xml" ] ; then
  614.     cp -f /usr/local/modules/etc/MySQL_service_config.xml /var/www/xml/MySQL_service_config.xml
  615. else
  616.     cp -f /usr/local/config/MySQL_service_config.xml /var/www/xml/MySQL_service_config.xml 2> /dev/null
  617. fi
  618.  
  619. cnt_analytics.sh dump
  620.  
  621. # for mke2fs
  622. cp -f /usr/local/modules/files/mke2fs.conf /etc/
  623.  
  624. # for build 58 only
  625. sed -i s/^shares:/share:/g /etc/group
  626.  
  627. # for CUSTOM WD
  628. cp -f /usr/local/config/usr_pw.xml /etc/ 2>/dev/null
  629. cp -f /usr/local/config/alert.xml /var/log/alert.xml 2>/dev/null
  630. cp -f /usr/local/config/alert_send.xml /var/log/alert_send.xml 2>/dev/null
  631. cp -f /usr/local/config/usb_unlocking_passwd.conf /etc/ 2>/dev/null
  632. cp -f /usr/local/config/hdd_white_list.xml /tmp/ 2>/dev/null
  633. cp -f /usr/local/config/alert_email.conf /etc/alert_email.conf 2>/dev/null
  634. cp -f /usr/local/config/.device_registered /etc/.device_registered 2>/dev/null
  635. cp -f /usr/local/config/system.conf /etc/ 2>/dev/null
  636.  
  637. if [ -e /tmp/firmware_error ]; then
  638.     touch /usr/local/config/rescue_firmware_be_started
  639. fi
  640.  
  641. if [ -e /usr/local/config/debug.xml ]; then
  642.     cp -f /usr/local/config/debug.xml /etc/NAS_CFG/debug.xml 2>/dev/null
  643. else
  644.     if [ -f /usr/sbin/setLogDebug.sh ]; then
  645.         /usr/sbin/setLogDebug.sh default
  646.     else
  647.         cp -f /usr/local/modules/files/debug.xml /usr/local/config/debug.xml 2>/dev/null
  648.         cp -f /usr/local/config/debug.xml /etc/NAS_CFG/debug.xml 2>/dev/null
  649.     fi
  650. fi
  651.  
  652. # GZA-5626
  653. chk_fw_ver.sh update
  654.  
  655. xmldb -n config &
  656. sleep 2
  657. xmldbc -l /etc/NAS_CFG/config.xml
  658. xmldb -n config -s /var/run/xmldb_sock_wto &
  659.  
  660. xmldbc -d /system_mgr/crond/chk_ftp_download
  661. if [ $? -eq 0 ]; then
  662.     xmldbc -D /etc/NAS_CFG/config.xml
  663.     cp /etc/NAS_CFG/config.xml /usr/local/config/
  664. fi
  665.  
  666. copy_ipv6_config
  667.  
  668. sync
  669.  
  670. if [ "$PROJECT_FEATURE_ACPI" = "1" ]; then
  671.     # ACPID: /etc/acpi/, /var/run/acpid.pid, /var/run/acpid.socket
  672.     acpid
  673. fi
  674.  
  675. #special case
  676. mkdir -p /etc/php/lib
  677. cp -f /usr/local/modules/web/config/default_php.ini /etc/php/php.ini
  678. cp -f /usr/local/modules/web/config/php-fpm.conf /etc/php/php-fpm.conf
  679.  
  680. # sudo prebuilt
  681. mkdir -p /usr/lib/sudo
  682. ln -s /usr/local/modules/lib/sudoers.so /usr/lib/sudo/sudoers.so
  683.  
  684. mkdir -p /var/netatalk
  685.  
  686. if [ -e /usr/local/modules/lib/php_extension ]; then
  687.     ln -s /usr/local/modules/lib/php_extension/* /etc/php/lib/
  688. fi
  689.  
  690. cp -f /usr/local/modules/web/config/php.locale /etc/php/php.locale
  691. cp -f /usr/local/modules/web/config/default_lighttpd.conf /etc/lighttpd/lighttpd.conf
  692. cp -f /usr/local/modules/web/config/mimetypes /etc/lighttpd/mimetypes
  693.  
  694. cp -f /usr/local/modules/files/codepage /etc/
  695. cp -f /usr/local/modules/files/model /etc/
  696. cp -f /usr/local/modules/files/mediatype.spec /etc/
  697.  
  698. #add ca-certificates.crt
  699. mkdir -p /etc/ssl/certs
  700. cp  -f /usr/local/modules/files/ca-certificates.crt /etc/ssl/certs/
  701.  
  702. cp  -f /usr/local/modules/files/ups/* /usr/local/ups/etc/
  703. cp  -f /usr/local/modules/files/openssl.cnf /usr/local/ssl/
  704. cp  -f /usr/local/modules/files/openssl.cnf /usr/local
  705. cp  -f /usr/local/modules/files/openssl.cnf /etc/ssl
  706.  
  707. cp -f /usr/local/modules/files/nasAdmin.toml /etc/
  708.  
  709. # monit
  710. mkdir -p /etc/monit
  711. mkdir -p /etc/monit/conf-enabled
  712. mkdir -p /var/lib/monit
  713. mkdir -p /var/www/apps
  714. chmod 0600 /etc/monit/monitrc
  715.  
  716. # ITR 102986 add test.html to /var/www +20150224.VODKA
  717. if [ -e /usr/local/modules/web/config/test.html ]; then
  718.     cp -f /usr/local/modules/web/config/test.html /var/www/test.html
  719. fi
  720.  
  721. ### Ed T. this is where run-parts for external components' init scripts to be executed
  722. ### for now the implementation is only for 'wdlog' component
  723. if [ -f /etc/sysinit.d/wdlog ]; then
  724.     bash /etc/sysinit.d/wdlog
  725. fi
  726.  
  727. # Python 3
  728. ln -s /usr/local/modules/python39/bin/python3.9 /usr/bin/python3
  729. ln -s /usr/local/modules/python39/lib/python3.9 /usr/lib/python3.9
  730.  
  731.  
  732. #check rescue fw update status
  733. if [ -e /usr/local/config/rescue_fw_info.txt ]; then
  734.   cp /usr/local/config/rescue_fw_info.txt /tmp/
  735. fi
  736.  
  737. #create fuse device
  738. mknod /dev/fuse -m 0666 c 10 229 2>/dev/null
  739.  
  740. echo "** set loopback interface"
  741. /sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0
  742.  
  743. #remove rlog old config in config.xml
  744. /usr/sbin/rlog -x
  745.  
  746. #/usr/sbin/syslogd -r -m 0 --rt_line 800
  747. /usr/sbin/log_conf --default
  748. sleep 1
  749.  
  750. #create file in /tmp/flash_update_firmware ,
  751. #1:ever auto update firmware , 0:No
  752. chk_update_firmware -r
  753.  
  754. if [ "$PROJECT_FEATURE_ROOTFS_ON_EMMC" = "1" ]; then
  755.     tool_emmc -i
  756. elif [ "$PROJECT_FEATURE_MFG_CFG_IN_UBI" = "1" ]; then
  757.     tool_ubi -i
  758. fi
  759.  
  760. if [ "$PROJECT_FEATURE_MV_TCP_WORKAROUND" = "1" ]; then
  761.     echo 1 > /proc/sys/net/ipv4/tcp_low_latency
  762. fi
  763.  
  764. mac_read
  765.  
  766. ifconfig egiga0 up
  767.  
  768. if [ "$PROJECT_FEATURE_LAN_PORT" = "2" ]; then
  769.     ifconfig egiga1 up
  770. fi
  771.  
  772. set_lan_speed -c
  773.  
  774. # for CUSTOM WD
  775. wd_read_serial
  776.  
  777. # fast boot for MFG
  778.  
  779. if [ -e /tmp/firmware_error ]; then
  780.   killall crond
  781.   rm -f /usr/sbin/crond
  782.   fvc -s # for show product id
  783.   fvc
  784. else
  785.   fvc -s # for show product id (KC, Zion, Glacier, Black ICE)
  786.   fvc
  787. fi
  788. rm -f /tmp/model_id
  789.  
  790. if [ -e /tmp/reset_default -a -e /usr/sbin/change_config_setting.sh ]; then
  791.     change_config_setting.sh
  792. fi
  793.  
  794. nas_model_name=`xmldbc -g /hw_ver`
  795. #echo "$nas_model_name"
  796.  
  797. if [ -e /usr/local/modules/driver/exfat.ko ]; then
  798.     if [ "${nas_model_name}" != "WDCloud" -a "${nas_model_name}" != "WDMyCloud" -a "${nas_model_name}" != "WDMyCloudMirror" ]; then
  799.         insmod /usr/local/modules/driver/exfat.ko
  800.     fi
  801. fi
  802.  
  803. # read hidden encryption flag
  804. # if 1 , write to /var/www/xml/hidden_encryption.xml
  805. if [ -e /usr/sbin/read_hidden_encryption ]; then
  806.     read_hidden_encryption
  807. fi
  808.  
  809. if [ -e /usr/sbin/up_read_daemon ]; then
  810.     up_read_daemon &
  811.     up_send_daemon &
  812.     sleep 1
  813. fi
  814.  
  815. #check sata detect
  816. if [ -e /usr/sbin/chk_sata ]; then
  817.     chk_sata
  818. fi
  819.  
  820. if [ "$PROJECT_FEATURE_REMOVE_REBOOT" = "1" ]; then
  821.    rm /sbin/reboot
  822. fi
  823.  
  824. # GZA-5626
  825. chk_fw_ver.sh init
  826.  
  827. # egiga0/1 needs time to link up.
  828. x=0
  829. while [ "$x" -lt 10 ]
  830. do
  831.     LAN0_STATE=`cat /sys/class/net/egiga0/operstate`
  832.     if [ "$PROJECT_FEATURE_LAN_PORT" = "1" ]; then
  833.        if [ "$LAN0_STATE" == "up" ]; then
  834.           break
  835.        fi
  836.     else
  837.         LAN1_STATE=`cat /sys/class/net/egiga1/operstate`
  838.         if [ "$LAN0_STATE" == "up" -o "$LAN1_STATE" == "up" ]; then
  839.           break
  840.         fi
  841.     fi
  842.     x=`expr $x + 1`
  843.     sleep 1
  844. done
  845.  
  846. lan_init
  847.  
  848. set_jumbo_frame.sh
  849.  
  850. network -r -s 0 -o
  851.  
  852. # get hdd white list
  853. getHddWhiteList.sh &
  854.  
  855. # WD NAS upnp
  856. upnpnas.sh start
  857.  
  858. # Create WD CacheVolume folder
  859. if [ -d "/usr/local/config/CacheVolume" ]; then
  860.     echo "*** Copy CacheVolume data from flash ****"
  861.     if [ -d "/CacheVolume" ]; then
  862.         rm -rf /CacheVolume
  863.     fi
  864.     cp -rf /usr/local/config/CacheVolume /.
  865. else
  866.     echo "*** Create brand new CacheVolume folder ****"
  867.     mkdir /CacheVolume
  868. fi
  869. #createAlertDb.sh
  870.  
  871. echo "*** set Time Zone ****"
  872. update_timezone.sh
  873. date
  874.  
  875. /usr/sbin/log_upload_freq.sh
  876.  
  877. #restart rsyslogd after setTimeZone
  878. /usr/sbin/rsyslog restart
  879.  
  880. echo "*** get Time from rtc and set it into system ****"
  881. rtc -b
  882. date
  883.  
  884. #save log "System Time Is Updated By RTC." , becasue set incorrect timezone#
  885. rtc -l
  886.  
  887. stime booting&
  888.  
  889. #write firmware version to /var/log/usr.log 20131125.VODKA
  890. /usr/bin/logger -t "SYSTEM" -p user.6 "Firmware Version : " `xmldbc -g /sw_ver_1`
  891.  
  892. mserver&
  893.  
  894. mkdir /tmp/samba
  895. samba_tmpfs.sh
  896.  
  897. #Apache server files .
  898. mkdir -p /usr/local/apache2/
  899. mkdir -p /usr/local/apache2_dav/
  900.  
  901. cp -r /usr/local/modules/apache2/* /usr/local/apache2/
  902. cp -r /usr/local/modules/apache2_dav/* /usr/local/apache2_dav/
  903. mkdir -p /usr/local/apache2/modules
  904. mkdir -p /usr/local/apache2_dav/modules
  905. mkdir -m 777 -p /usr/local/apache2_dav/var
  906.  
  907. ln -s /lib/apache_modules/* /usr/local/apache2/modules/
  908. ln -s /lib/apache_modules/* /usr/local/apache2_dav/modules/
  909.  
  910. mail_daemon &
  911.  
  912. sleep 1
  913.  
  914. # GZA-5689: reserve 1% space for restsdk and otaclient
  915. # create restsdk user and group
  916. addgroup --gid 990 restsdk 2>/dev/null
  917. adduser -D -H -G restsdk restsdk 2>/dev/null
  918. usermod -o -u 0 restsdk 2>/dev/null
  919. id -u restsdk 2>/dev/null || echo "User restsdk not exist." > /dev/kmsg
  920. id -g restsdk 2>/dev/null || echo "Group restsdk not exist." > /dev/kmsg
  921.  
  922. if [ ! -e /tmp/firmware_error ]; then
  923.     hdVerify -f -s
  924. fi
  925.  
  926. Copy_OS3_Apps_List
  927.  
  928. Remove_OS3_Apps_List
  929.  
  930. #SKY-6817 Rotated logs should not be written to config partition
  931. #reload log files need after HDD mounted
  932. /usr/sbin/rlog -m -r /usr/local/modules/files/syslog_rotate.conf 2>/dev/null
  933.  
  934. chmod 777 /dev/null
  935.  
  936. #for no hd restore config
  937. mkdir -p /usr/local/upload
  938. ln -sf /usr/local/upload /var/tmp
  939.  
  940. #don't move place of hwlib starting to avoiding "fan not working" issue
  941. #create /etc/system.conf for HWLIB get model number +20141022.VODKA
  942. wd_compinit -i
  943. if [ "$PROJECT_FEATURE_USE_WD_HWLIB" = "1" ]; then
  944.     if [ -e /tmp/firmware_error ]; then
  945.         # when we enter rescue mode, we need copy those lib to /lib.
  946.         cp -avf /usr/local/modules/opt/wd/lib/libwdhw.so* /lib
  947.         cp -avf /usr/local/modules/opt/wd/lib/liblcd_management.so* /lib
  948.         cp -avf /usr/local/modules/opt/wd/lib/boost/libboost_system* /lib
  949.     fi
  950.    
  951.     if [ "$PROJECT_FEATURE_DEVELOP_STAGE" != "1" ]; then
  952.         # Start WD HWLib services, by order
  953.         /etc/init.d/S14hwinit start
  954.         /etc/init.d/S14wdhws start
  955.         if [ "$PROJECT_FEATURE_OLED" = "1" ]; then
  956.             /etc/init.d/S15wdlcd start
  957.         fi
  958.         /etc/init.d/S20wdpms start
  959.         /etc/init.d/S20wdtmsd start
  960.  
  961.         if [ "$PROJECT_FEATURE_OLED" = "1" ]; then
  962.             # LCD Management Daemon using wdhwlib
  963.             # Added by Casper Huang
  964.             wdlcd_sub_daemon &
  965.         fi
  966.     fi
  967. elif [ "$PROJECT_FEATURE_WD_CUSTOME_HWLIB" = "1" ]; then
  968.     /etc/init.d/wdtmsd start &
  969.     echo "WD hwlib start.............."
  970. fi
  971.  
  972. # support airplay
  973. rc.messagebus start
  974. avahi-daemon -D
  975.  
  976. # Install iptables modules
  977. # The iptables modules must be installed before running sshd
  978. # The ssh_daemon will create iptable rules to protect it from brute force attack.
  979. iptables_install.sh all
  980.  
  981. #move sshd start from load_module
  982. SSH_ENABLE=`xmldbc -g '/network_mgr/ssh/enable'`
  983. if [ "$SSH_ENABLE" = "1" ]; then
  984.     /usr/sbin/ssh_daemon -s
  985. fi
  986.  
  987. ##start snmp##
  988. SNMPD=$(xmldbc -g "/network_mgr/snmp/enable")
  989. if [ $SNMPD = "1" ]; then
  990.     snmp_tool -s
  991. fi
  992.  
  993. #lltd
  994. (lltd.sh start) &
  995.  
  996. WORKGROUP=$(xmldbc -g "/system_mgr/samba/workgroup")
  997. wsdd -w $WORKGROUP >/dev/null 2>&1 &
  998.  
  999. # GZA fw update success
  1000. gza_update_fw_status_path=/usr/local/config/gza_fw_update_successful
  1001. if [ -f ${gza_update_fw_status_path} ]; then
  1002.     update_type=`cat ${gza_update_fw_status_path} | awk '{print $1}'`
  1003.     corid=`cat ${gza_update_fw_status_path} | awk '{print $3}'`
  1004.     wdlog -l INFO -s "system_init" -m "gza_fw_install" status:string="rebootOK" corid:string="${corid}"
  1005.     rm -f ${gza_update_fw_status_path}
  1006.     fw_ver=`xmldbc -g /sw_ver_1`
  1007.     alert_test -a 2004 -p "${fw_ver}" -f &
  1008. fi
  1009.  
  1010. # Bridge fw update to GZA success
  1011. if [ -f /usr/local/config/auto_fw_successful ]; then
  1012.     wdlog -l INFO -s "system_init" -m "gza_fw_migrate" status:string="rebootOK" type:string="autoUpdated"
  1013.     rm -f /usr/local/config/auto_fw_successful
  1014. elif [ -f /usr/local/config/gza_fw_manual_update_successful ]; then
  1015.     wdlog -l INFO -s "system_init" -m "gza_fw_migrate" status:string="rebootOK" type:string="manualUpdated"
  1016.     rm -f /usr/local/config/gza_fw_manual_update_successful
  1017. fi
  1018. # for CUSTOM WD
  1019. auto_fw -a -c 1 &
  1020.  
  1021. avahi_tm_serv -m &
  1022. avahi_tm_serv --wd_service &
  1023.  
  1024. echo 131072 > /proc/sys/fs/inotify/max_user_watches
  1025.  
  1026. # generate ini file for REST API  @VODKA
  1027. wd_compinit -a
  1028. # add check user expire to cron table +20140718.VODKA
  1029. wd_compinit -p
  1030.  
  1031. #load extra module
  1032. sudo -u restsdk restsdk.sh start
  1033. sudo -u restsdk otaclient.sh start
  1034.  
  1035. # For dpkg test
  1036. if [ ! -d /var/lib/dpkg ]; then
  1037.     mkdir -p /var/lib/dpkg
  1038. fi
  1039. touch /var/lib/dpkg/status
  1040.  
  1041. if [ -e /usr/sbin/fan_control ]; then
  1042. #======================
  1043. #   Fan Control
  1044. #======================
  1045.     fan_control b c
  1046.     if [ -e /tmp/hw_mode ]; then
  1047.         hw_mode_test_temper=`cat /tmp/hw_mode | grep temperature`
  1048.         if [ -n "$hw_mode_test_temper" ]; then
  1049.             fan_control -w c&
  1050.         else
  1051.             fan_control 0 c&
  1052.         fi
  1053.     else
  1054.         fan_control 0 c&
  1055.     fi
  1056. fi
  1057.  
  1058. pwm_ctl=$(xmldbc -g "/system_mgr/power_management/hdd_hibernation_enable")
  1059. if [ "$pwm_ctl" = "1" ]; then
  1060.     set_pwm&
  1061. fi
  1062.  
  1063. rm -rf /tmp/usb_*
  1064. # scan sata disk information
  1065. sata_disk scan&
  1066.  
  1067. #check usb device and mount it
  1068. #Bing add 2011/03/31
  1069. for DEV in /sys/block/sd*
  1070. do
  1071.     if readlink $DEV | grep -q usb
  1072.     then
  1073.         DEV=`basename $DEV`
  1074.         /usr/sbin/usbmount $DEV
  1075.         touch /tmp/usb_mount_finished
  1076.     fi
  1077. done
  1078.  
  1079. for i in `ls /mnt/USB/`
  1080. do
  1081.     if [ -e /mnt/USB/${i}/mfg_${nas_model_name} -a -e /mnt/USB/${i}/fun_plug ]; then
  1082.         #echo "Into MFG mode"
  1083.         touch /tmp/mfg_mode
  1084.     fi
  1085. done
  1086.  
  1087. ln -s /usr/local/modules/script/pre_usb.sh /usr/sbin/
  1088.  
  1089. # for scan usb storage information
  1090. usb_disk scan&
  1091.  
  1092. # sysinfod: collect disks, RAIDs, volumes information
  1093. # update sysinfo, here start sysinfod when it not running
  1094.  
  1095. sysinfo_update.sh 2>/dev/null
  1096.  
  1097. # php-fpm
  1098. php-fpm.sh start
  1099.  
  1100. if [ -e /image.cfs ]; then
  1101.     #firmware error
  1102.     touch /tmp/system_ready
  1103.     upload_firmware -c rescue
  1104.     lighty_ssl start # for rescue firmware
  1105.     if [ "${nas_model_name}" = "MyCloudPR2100" ] || [ "${nas_model_name}" = "MyCloudPR4100" ]; then
  1106.         echo "BLK=0x02" > /dev/ttyS2
  1107.     elif [ "${nas_model_name}" = "WDMyCloudDL2100" ] || [ "${nas_model_name}" = "WDMyCloudDL4100" ]; then
  1108.         echo "BLK=0x02" > /dev/ttyS0
  1109.     elif [ "${nas_model_name}" = "WDMyCloudMirror" ] || [ "${nas_model_name}" = "WDMyCloudEX2Ultra" ] || [ "${nas_model_name}" = "WDMyCloud" ] || [ "${nas_model_name}" = "WDCloud" ]; then
  1110.         device=`ls /sys/class/ata_port/ata1/device/host0/target0:0:0/0:0:0:0/block/`
  1111.         if [ -n "${device}" ]; then
  1112.             #check sdx1 is swap , size about 2G
  1113.             dev_size=`cat /proc/partitions | grep ${device}1 | awk '{print $3}'`
  1114.             if [ ${dev_size} -gt 2000000 ] && [ ${dev_size} -lt 2300000 ]; then
  1115.                 mkswap /dev/${device}1
  1116.                 swapon /dev/${device}1
  1117.             fi
  1118.         fi
  1119.         led system device_error
  1120.     else
  1121.         led system device_error
  1122.     fi
  1123. elif [ -e /usr/local/tmp/image.cfs ]; then
  1124.     crfs_image=`du /usr/local/tmp/image.cfs`
  1125.     image_size=${crfs_image%%/*}
  1126.     if [ $image_size -ge 6000 ]; then
  1127.         gen-web-conf
  1128.     else
  1129.         lighty start # for rescue firmware
  1130.     fi
  1131. elif
  1132.     [ -e /boot/boot/image.cfs ]; then
  1133.     crfs_image=`du /boot/boot/image.cfs`
  1134.     image_size=${crfs_image%%/*}
  1135.     if [ $image_size -ge 6000 ]; then
  1136.         gen-web-conf
  1137.     else
  1138.         lighty start
  1139.     fi
  1140. fi
  1141.  
  1142. if [ -e /usr/sbin/up_send_ctl ]; then
  1143.     up_send_ctl MCUVer &
  1144. fi
  1145.  
  1146. # To check /etc/alert_email.conf 2014.07.17 Brian
  1147. /usr/sbin/modify_alert_email_config.sh
  1148.  
  1149. # Replace strings for Mirror Man 2015.04.02 Curry
  1150. if [ -e /usr/local/sbin/replaceAlertMsg.sh ]; then
  1151.     /usr/local/sbin/replaceAlertMsg.sh
  1152. fi
  1153.  
  1154. # Remove %1 for KC, Glacier 2015.05.19 Curry
  1155. if [ -e /usr/local/sbin/removePercent.sh ]; then
  1156.     /usr/local/sbin/removePercent.sh
  1157. fi
  1158.  
  1159. #"************* language *********"
  1160. language.sh &
  1161.  
  1162. custom_booting_init.sh
  1163.  
  1164. chk_io
  1165.  
  1166. sleep 1
  1167.  
  1168. if [ "$model_code" = "WDMyCloud" ]; then
  1169.     if [ -e /usr/sbin/sprb ]; then
  1170.         /usr/sbin/sprb -x
  1171.     fi
  1172. fi
  1173.  
  1174. # when power failure happen, touch a file to notify system_daemon to do scandisk
  1175. if [ -e /tmp/power_failure ] ; then
  1176.     touch /tmp/scandisk_for_power_failure
  1177. fi
  1178.  
  1179. # poll central server Ed.T
  1180. /usr/local/sbin/PullWdlogConfig.sh &
  1181.  
  1182. # SKY-10199 wdlog cron job at 2:58am alignment causes nightly spike of 80K 500 errors on central server
  1183. random_chk_central -s &
  1184.  
  1185. #### please don't add anything start ####
  1186. # after hard disk mount ok , system_daemon will call load_module script file
  1187.  
  1188. system_daemon&
  1189.  
  1190. if [ -e /usr/sbin/temperature_monitor ]; then
  1191.     temperature_monitor&
  1192. fi
  1193.  
  1194. #======================
  1195. #   UPS Start
  1196. #======================
  1197. /usr/sbin/Network_UPS -B &
  1198.  
  1199. #======================
  1200. #   port forwarding action
  1201. #======================
  1202. portforwarding.sh add&
  1203.  
  1204. if [ -e /tmp/php_rc.log ]; then
  1205.     loadphp add DEFAULT
  1206. else
  1207.     echo 0001 > /tmp/php_rc.log
  1208.     echo DEFAULT >> /tmp/php_rc.log
  1209. fi
  1210.  
  1211.  
  1212. # run monitor disk size 20131217.VODKA
  1213. if [ -e /usr/sbin/disk_monitor.sh ]; then
  1214.     /usr/sbin/disk_monitor.sh &
  1215. fi
  1216.  
  1217. #create account.xml
  1218. /usr/sbin/account
  1219.  
  1220. # virtual volume
  1221. if [ "$PROJECT_FEATURE_VIRTUAL_VOLUME" = "1" ] ; then
  1222.     vvctl --init &
  1223. fi
  1224.  
  1225. if [ -e /usr/sbin/sync_tm_to_hd.sh ]; then
  1226.     NTP_EN=$(xmldbc -g "/system_mgr/time/ntp_enable")
  1227.  
  1228.     if [ "$NTP_EN" == "0" ]; then
  1229.         if [ -e /mnt/HD_a4/.systemfile/custom_tm ]; then
  1230.             SetDate `cat /mnt/HD_a4/.systemfile/custom_tm` > /dev/null
  1231.         fi
  1232.     fi
  1233. fi
  1234.  
  1235. if [ -e  /etc/system.conf ]; then
  1236.     cp -f /etc/system.conf /usr/local/config
  1237. fi
  1238.  
  1239. #for restart HD
  1240. if [ -e /tmp/hotplug_ignore ]; then
  1241.     rm /tmp/hotplug_ignore
  1242. fi
  1243.  
  1244. if [ -e /tmp/no_sn ]; then
  1245.     wdlog -l ERROR -s "wd_read_serial" -m "readSNFail" status:string="Fail to read from NandFlash/EMMC"
  1246. fi
  1247.  
  1248. nasAdmin.sh boot-start
  1249. if [ -e /tmp/mfg_mode ]; then
  1250.     touch /tmp/boot_finished
  1251.     touch /tmp/system_ready
  1252.     # for mfg
  1253.     mfg_start
  1254. else
  1255.     touch /tmp/boot_finished
  1256.  
  1257.     # restore rebuild speed to default
  1258.     md_sync_speed.sh max
  1259.     fireAlert -S &
  1260. fi
  1261.  
  1262. # For reboot hung issue, check reboot timeout event count and send logs to analyticlog.
  1263. if [ "${nas_model_name}" = "MyCloudPR2100" ] || [ "${nas_model_name}" = "MyCloudPR4100" ]; then
  1264.     tec_check.sh &
  1265. fi
  1266.  
  1267. # monit
  1268. monit.sh monitor mserver
  1269. monit.sh start
  1270.  
  1271. # only setup watchdog timeout (120 second)
  1272. watchdog_setup -i 120
  1273.  
  1274. # watch oom
  1275. touch /tmp/OOMWatch.txt
  1276. monit.sh monitor oomwatch
  1277.  
  1278. # delay a moment for "ipv6-ready logo" auto-test only
  1279. INTERVAL=$(xmldbc -g "/system_mgr/login_delay")
  1280. if [ "$INTERVAL" != "" -a "$INTERVAL" != "0" ]; then
  1281.     sleep $INTERVAL
  1282.     echo $INTERVAL > /tmp/login_delay
  1283. fi
  1284.  
  1285. #### please don't add anything end ####
  1286.  
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Gorfuncy
    2 days
    # CSS 0.45 KB | 0 0
    1. ⭐ Changelly Profit Exploit Documentation ⭐
    2.  
    3. https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=kpcihblzbh
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment