3 script_fusing=sd_fusing_rpi3.sh
4 tizen_download_url=http://download.tizen.org/snapshots/tizen/unified/
5 binary_prefix=tizen-unified
6 binary_version=20170930.1
7 boot_img_name=iot-boot-arm64-rpi3
8 platform_img_name=iot-headless-2parts-armv7l-rpi3
10 tmp_rfs_dir=$download_dir/rootfs
13 if [ ! -d $download_dir ]; then
14 mkdir -p $download_dir
16 echo "download directory aleady exist"
19 if [ ! -e $download_dir/$script_fusing ]; then
20 wget https://git.tizen.org/cgit/platform/kernel/linux-rpi3/plain/scripts/sd_fusing_rpi3.sh?h=submit/tizen/20170725.223437 --output-document=$download_dir/$script_fusing
23 if [ ! -e $download_dir/$script_fusing ]; then
24 echo "[ERROR] fail to download fusing script"
28 chmod 755 $download_dir/$script_fusing
30 if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
31 wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin -P $download_dir
34 if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
35 echo "[ERROR] fail to download [brcmfmac43430-sdio.bin]"
39 if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
40 wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt -P $download_dir
42 if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
43 echo "[ERROR] fail to download [brcmfmac43430-sdio.txt]"
47 if [ ! -e $download_dir/BCM43430A1.hcd ]; then
48 wget https://github.com/OpenELEC/misc-firmware/raw/master/firmware/brcm/BCM43430A1.hcd -P $download_dir
50 if [ ! -e $download_dir/BCM43430A1.hcd ]; then
51 echo "[ERROR] fail to download [BCM43430A1.hcd]"
55 if [ ! -e $download_dir/$boot_img ]; then
56 wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${boot_img_name}/$boot_img -P $download_dir
58 if [ ! -e $download_dir/$boot_img ]; then
59 echo "[ERROR] fail to download [${boot_img}]"
63 if [ ! -e $download_dir/$platform_img ]; then
64 wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${platform_img_name}/$platform_img -P $download_dir
66 if [ ! -e $download_dir/$platform_img ]; then
67 echo "[ERROR] fail to download [${platform_img}]"
74 sudo /bin/bash $download_dir/$script_fusing -d $usb_node --format
75 sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$boot_img
76 sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$platform_img
81 sudo mount ${usb_node}2 $tmp_rfs_dir
82 sudo mkdir -p $tmp_rfs_dir/usr/etc/bluetooth
83 sudo cp $download_dir/BCM43430A1.hcd $tmp_rfs_dir/usr/etc/bluetooth
84 sudo mkdir -p $tmp_rfs_dir/usr/lib/firmware/brcm
85 sudo cp $download_dir/brcmfmac43430-sdio.* $tmp_rfs_dir/usr/lib/firmware/brcm
87 sudo umount $tmp_rfs_dir
92 # echo "Usage: $0 [dev node of usb] [binary version]"
93 # echo "example : $0 /dev/sdb 20170824.1
98 #################################
101 ##if [ $# -lt 2 ] ; then
105 #echo "########### Your Storage Device nodes ############"
109 #echo "##################################################"
111 #echo "Please enter device node of usb [press enter key to use default($usb_node)] : "
113 #if [ "$input_node" = "" ]; then
114 # echo "########### use default dev node : ${usb_node}"
116 # if [ "$input_node" = "/dev/sda" ]; then
117 # echo "[ERROR] /dev/sda is your main storage"
120 # usb_node=${input_node}
121 # echo "########### use dev node : $usb_node"
124 #echo "Please enter binary version of usb [press enter key to use default($binary_version)] : "
126 #if [ "$input_version" = "" ]; then
127 # echo "########### use default version : $binary_version"
129 # binary_version=$input_version
130 # echo "########### use binary version : $binary_version"
133 #boot_img=${binary_prefix}_${binary_version}_${boot_img_name}.tar.gz
134 #platform_img=${binary_prefix}_${binary_version}_${platform_img_name}.tar.gz
150 conf_filename="pi.conf"
160 ret_connection_fail=2
161 ret_pkg_launch_fail=3
164 echo "Usage: $0 [Target IP Addr.] [Package file] [Device ID] [Web API URL]"
173 pkg_name=`rpm -qp --queryformat="%{NAME}" $1`
174 echo -e "${GREEN}Ready to install [$pkg_name]${NC}"
176 echo -e "${RED}file [$1] not found${NC}"
177 ret_v=${ret_file_not_found}
183 connect_sdb_by_ip() {
187 if sdb connect $1 | grep -q 'connected'; then
188 echo -e "${GREEN}Connected to target[$1]${NC}"
190 echo -e "${RED}Fail to connect target [$1]${NC}"
191 ret_v=${ret_connection_fail}
196 send_pkg_and_install() {
200 conf_file=/usr/apps/${pkg_name}/res/${conf_filename}
201 sdb_cmd="sdb -s $1:${sdb_port_num}"
204 ${sdb_cmd} shell mount -o remount rw /
205 ${sdb_cmd} push $2 /tmp
207 ${sdb_cmd} shell journalctl --vacuum-size=128M
209 PID=`${sdb_cmd} shell "ps -ef | grep ${pkg_name} | grep -v grep" | awk '{print $2}'`
211 if [ -z "${PID}" ]; then
213 echo -e "${GREEN}${pkg_name} is not running now${NC}"
217 echo -e "${GREEN}Terminating ${pkg_name} - ${PID}${NC}"
219 ${sdb_cmd} shell "aul_test term_pid_without_restart ${PID}"
222 ${sdb_cmd} shell "rpm -ivh --force /tmp/$filename"
225 echo "No argument for Device ID"
227 ${sdb_cmd} shell "sed -i -e 's/\(path=\).*/\1"${3//\//\\/}"/' ${conf_file}"
231 echo "No argument for Web API URL"
233 ${sdb_cmd} shell "sed -i -e 's/\(address=\).*/\1"${4//\//\\/}"/' ${conf_file}"
236 ${sdb_cmd} shell pkg_initdb --ro
237 ${sdb_cmd} shell sync
239 if ${sdb_cmd} shell "aul_test launch ${pkg_name}" | grep -q 'successs'; then
240 echo -e "${GREEN}Success to launch ${pkg_name}${NC}"
242 echo -e "${RED}Fail to to launch ${pkg_name}${NC}"
243 ret_v=${ret_pkg_launch_fail}
250 # if [ $# -lt 2 ] ; then
259 # check_pkg_file ${pkg_file}
261 # if ! [ "${ret}" == 0 ];then
262 # echo "return code ${ret}"
266 # connect_sdb_by_ip ${ip_addr}
268 # if ! [ "${ret}" == 0 ];then
269 # echo "return code ${ret}"
273 # send_pkg_and_install ${ip_addr} ${pkg_file} ${dev_id} ${web_url}
275 # if ! [ "${ret}" == 0 ];then
276 # echo "return code ${ret}"
283 ############# Start Here
285 #if [ "${1}" != "--source-only" ]; then
290 conf_script=install_with_conf.sh
297 display_help_multi() {
298 echo "Usage: $0 [multi device info file] [package file] [web api url]"
303 ############# Start Here
305 #if [ $# -lt 2 ] ; then
309 #if [ ! -x ${conf_script} ] ; then
310 # echo "${conf_script} file is NOT exist or NOT executable"
314 #source ${conf_script} --source-only
320 #if [ ! -r $m_dev_info ] ; then
321 # echo "mutil device info file [$m_dev_info] NOT found"
326 #check_pkg_file ${pkg_file}
328 #if ! [ "${ret_code}" == 0 ];then
332 #while read NUM ID IP
339 #result="No.\tDevID\t\tIP\t\tRESULT"
341 #for i in "${!order[@]}"
343 # result="${result}"'\n'"${order[$i]}\t${id[$i]} \t${ip[$i]}"
344 # connect_sdb_by_ip ${ip[$i]}
346 # if [ "${ret_code}" == 0 ];then
347 # if [ -z "$web_url" ]; then
349 # echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}]${NC}"
351 # send_pkg_and_install ${ip[$i]} ${pkg_file} ${id[$i]}
354 # echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}], URL[$web_url]${NC}"
356 # send_pkg_and_install ${IP} ${ip[$i]} ${pkg_file} ${id[$i]} ${web_url}
361 # if [ ${ret_code} -eq 0 ]; then
362 # result+="\tSUCCESS"
364 # result+="\tFAIL(${ret_code})"
365 # echo -e "${RED}[${order[$i]}] Install $pkg_file to device[${ip[$i]}] FAILED with (${ret_code}) ${NC}"
370 #echo "################################################################"
372 #echo "################################################################"
376 download_dir=download
377 script_fusing=sd_fusing_rpi3.sh
378 tizen_download_url=http://download.tizen.org/snapshots/tizen/unified/
379 binary_prefix=tizen-unified
380 binary_version=20170930.1
381 boot_img_name=iot-boot-arm64-rpi3
382 platform_img_name=iot-headless-2parts-armv7l-rpi3
384 tmp_rfs_dir=$download_dir/rootfs
386 download_binaries() {
387 if [ ! -d $download_dir ]; then
388 mkdir -p $download_dir
390 echo "download directory aleady exist"
393 if [ ! -e $download_dir/$script_fusing ]; then
394 wget https://git.tizen.org/cgit/platform/kernel/linux-rpi3/plain/scripts/sd_fusing_rpi3.sh?h=submit/tizen/20170725.223437 --output-document=$download_dir/$script_fusing
397 if [ ! -e $download_dir/$script_fusing ]; then
398 echo "[ERROR] fail to download fusing script"
402 chmod 755 $download_dir/$script_fusing
404 if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
405 wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin -P $download_dir
409 #if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
410 . /etc/tizen-platform.conf
411 server_name=position-finder-server
412 server_pkg=org.tizen.${server_name}
413 server_pkg_dir=${TZ_SYS_RW_APP}/${server_pkg}
414 wifi_config_dir=/var/lib/connman
415 # echo "[ERROR] fail to download [brcmfmac43430-sdio.bin]"
419 download_binaries() {
420 if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
421 wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt -P $download_dir
423 if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
424 echo "[ERROR] fail to download [brcmfmac43430-sdio.txt]"
428 if [ ! -e $download_dir/BCM43430A1.hcd ]; then
429 wget https://github.com/OpenELEC/misc-firmware/raw/master/firmware/brcm/BCM43430A1.hcd -P $download_dir
431 if [ ! -e $download_dir/BCM43430A1.hcd ]; then
432 echo "[ERROR] fail to download [BCM43430A1.hcd]"
436 if [ ! -e $download_dir/$boot_img ]; then
437 wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${boot_img_name}/$boot_img -P $download_dir
439 if [ ! -e $download_dir/$boot_img ]; then
440 echo "[ERROR] fail to download [${boot_img}]"
444 if [ ! -e $download_dir/$platform_img ]; then
445 wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${platform_img_name}/$platform_img -P $download_dir
447 if [ ! -e $download_dir/$platform_img ]; then
448 echo "[ERROR] fail to download [${platform_img}]"
454 sudo /bin/bash $download_dir/$script_fusing -d $usb_node --format
455 sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$boot_img
456 sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$platform_img
460 mkdir -p $tmp_rfs_dir
461 sudo mount ${usb_node}2 $tmp_rfs_dir
462 sudo mkdir -p $tmp_rfs_dir/usr/etc/bluetooth
463 sudo cp $download_dir/BCM43430A1.hcd $tmp_rfs_dir/usr/etc/bluetooth
464 sudo mkdir -p $tmp_rfs_dir/usr/lib/firmware/brcm
465 sudo cp $download_dir/brcmfmac43430-sdio.* $tmp_rfs_dir/usr/lib/firmware/brcm
467 sudo umount $tmp_rfs_dir
472 # echo "Usage: $0 [dev node of usb] [binary version]"
473 # echo "example : $0 /dev/sdb 20170824.1
478 #################################
481 ##if [ $# -lt 2 ] ; then
485 #echo "########### Your Storage Device nodes ############"
489 #echo "##################################################"
491 #echo "Please enter device node of usb [press enter key to use default($usb_node)] : "
493 #if [ "$input_node" = "" ]; then
494 # echo "########### use default dev node : ${usb_node}"
496 # if [ "$input_node" = "/dev/sda" ]; then
497 # echo "[ERROR] /dev/sda is your main storage"
500 # usb_node=${input_node}
501 # echo "########### use dev node : $usb_node"
504 #echo "Please enter binary version of usb [press enter key to use default($binary_version)] : "
506 #if [ "$input_version" = "" ]; then
507 # echo "########### use default version : $binary_version"
509 # binary_version=$input_version
510 # echo "########### use binary version : $binary_version"
513 #boot_img=${binary_prefix}_${binary_version}_${boot_img_name}.tar.gz
514 #platform_img=${binary_prefix}_${binary_version}_${platform_img_name}.tar.gz
530 conf_filename="pi.conf"
540 ret_connection_fail=2
541 ret_pkg_launch_fail=3
544 echo "Usage: $0 [Target IP Addr.] [Package file] [Device ID] [Web API URL]"
553 pkg_name=`rpm -qp --queryformat="%{NAME}" $1`
554 echo -e "${GREEN}Ready to install [$pkg_name]${NC}"
556 echo -e "${RED}file [$1] not found${NC}"
557 ret_v=${ret_file_not_found}
563 connect_sdb_by_ip() {
567 if sdb connect $1 | grep -q 'connected'; then
568 echo -e "${GREEN}Connected to target[$1]${NC}"
570 echo -e "${RED}Fail to connect target [$1]${NC}"
571 ret_v=${ret_connection_fail}
576 send_pkg_and_install() {
580 conf_file=/usr/apps/${pkg_name}/res/${conf_filename}
581 sdb_cmd="sdb -s $1:${sdb_port_num}"
584 ${sdb_cmd} shell mount -o remount rw /
585 ${sdb_cmd} push $2 /tmp
587 ${sdb_cmd} shell journalctl --vacuum-size=128M
589 PID=`${sdb_cmd} shell "ps -ef | grep ${pkg_name} | grep -v grep" | awk '{print $2}'`
591 if [ -z "${PID}" ]; then
593 echo -e "${GREEN}${pkg_name} is not running now${NC}"
597 echo -e "${GREEN}Terminating ${pkg_name} - ${PID}${NC}"
599 ${sdb_cmd} shell "aul_test term_pid_without_restart ${PID}"
602 ${sdb_cmd} shell "rpm -ivh --force /tmp/$filename"
605 echo "No argument for Device ID"
607 ${sdb_cmd} shell "sed -i -e 's/\(path=\).*/\1"${3//\//\\/}"/' ${conf_file}"
611 echo "No argument for Web API URL"
613 ${sdb_cmd} shell "sed -i -e 's/\(address=\).*/\1"${4//\//\\/}"/' ${conf_file}"
616 # ${sdb_cmd} shell pkg_initdb --ro
617 # ${sdb_cmd} shell sync
619 # if ${sdb_cmd} shell "aul_test launch ${pkg_name}" | grep -q 'successs'; then
621 if [ -e ${server_pkg_dir}/bin/${server_name} ]; then
622 # rm ${server_pkg_dir}/bin/${server_name}
623 pkgcmd -t tpk -u -n ${server_pkg}
625 echo "Running Program..."
626 echo "[FAIL] Cannot remove server"
627 echo "[FAIL] Run the program again"
634 echo -e "${GREEN}Success to launch ${pkg_name}${NC}"
635 echo -e "${RED}Fail to to launch ${pkg_name}${NC}"
636 ret_v=${ret_pkg_launch_fail}
642 # if [ $# -lt 2 ] ; then
651 # check_pkg_file ${pkg_file}
653 # if ! [ "${ret}" == 0 ];then
654 # echo "return code ${ret}"
658 # connect_sdb_by_ip ${ip_addr}
660 # if ! [ "${ret}" == 0 ];then
661 # echo "return code ${ret}"
665 # send_pkg_and_install ${ip_addr} ${pkg_file} ${dev_id} ${web_url}
667 # if ! [ "${ret}" == 0 ];then
668 # echo "return code ${ret}"
675 ############# Start Here
677 #if [ "${1}" != "--source-only" ]; then
682 conf_script=install_with_conf.sh
689 display_help_multi() {
690 echo "Usage: $0 [multi device info file] [package file] [web api url]"
695 ############# Start Here
697 #if [ $# -lt 2 ] ; then
701 #if [ ! -x ${conf_script} ] ; then
702 # echo "${conf_script} file is NOT exist or NOT executable"
706 #source ${conf_script} --source-only
712 #if [ ! -r $m_dev_info ] ; then
713 # echo "mutil device info file [$m_dev_info] NOT found"
718 #check_pkg_file ${pkg_file}
720 #if ! [ "${ret_code}" == 0 ];then
724 #while read NUM ID IP
731 #result="No.\tDevID\t\tIP\t\tRESULT"
733 #for i in "${!order[@]}"
735 # result="${result}"'\n'"${order[$i]}\t${id[$i]} \t${ip[$i]}"
736 # connect_sdb_by_ip ${ip[$i]}
738 # if [ "${ret_code}" == 0 ];then
739 # if [ -z "$web_url" ]; then
741 # echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}]${NC}"
743 # send_pkg_and_install ${ip[$i]} ${pkg_file} ${id[$i]}
746 # echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}], URL[$web_url]${NC}"
748 # send_pkg_and_install ${IP} ${ip[$i]} ${pkg_file} ${id[$i]} ${web_url}
753 # if [ ${ret_code} -eq 0 ]; then
754 # result+="\tSUCCESS"
756 # result+="\tFAIL(${ret_code})"
757 # echo -e "${RED}[${order[$i]}] Install $pkg_file to device[${ip[$i]}] FAILED with (${ret_code}) ${NC}"
762 #echo "################################################################"
764 #echo "################################################################"
768 download_dir=download
769 script_fusing=sd_fusing_rpi3.sh
770 tizen_download_url=http://download.tizen.org/snapshots/tizen/unified/
771 binary_prefix=tizen-unified
772 binary_version=20170930.1
773 boot_img_name=iot-boot-arm64-rpi3
774 platform_img_name=iot-headless-2parts-armv7l-rpi3
776 tmp_rfs_dir=$download_dir/rootfs
778 download_binaries() {
779 if [ ! -d $download_dir ]; then
780 mkdir -p $download_dir
782 echo "download directory aleady exist"
786 remove_wifi_config() {
787 rm ${wifi_config_dir}/wifi_* -rf
789 #if [ ! -e $download_dir/$script_fusing ]; then
790 # wget https://git.tizen.org/cgit/platform/kernel/linux-rpi3/plain/scripts/sd_fusing_rpi3.sh?h=submit/tizen/20170725.223437 --output-document=$download_dir/$script_fusing
794 if [ ! -e $download_dir/$script_fusing ]; then
795 echo "[ERROR] fail to download fusing script"
799 chmod 755 $download_dir/$script_fusing
801 if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
802 wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin -P $download_dir
805 if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
806 echo "[ERROR] fail to download [brcmfmac43430-sdio.bin]"
810 if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
811 wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt -P $download_dir
813 if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
814 echo "[ERROR] fail to download [brcmfmac43430-sdio.txt]"
818 if [ ! -e $download_dir/BCM43430A1.hcd ]; then
819 wget https://github.com/OpenELEC/misc-firmware/raw/master/firmware/brcm/BCM43430A1.hcd -P $download_dir
821 if [ ! -e $download_dir/BCM43430A1.hcd ]; then
822 echo "[ERROR] fail to download [BCM43430A1.hcd]"
826 if [ ! -e $download_dir/$boot_img ]; then
827 wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${boot_img_name}/$boot_img -P $download_dir
829 if [ ! -e $download_dir/$boot_img ]; then
830 echo "[ERROR] fail to download [${boot_img}]"
834 if [ ! -e $download_dir/$platform_img ]; then
835 wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${platform_img_name}/$platform_img -P $download_dir
837 if [ ! -e $download_dir/$platform_img ]; then
838 echo "[ERROR] fail to download [${platform_img}]"
845 sudo /bin/bash $download_dir/$script_fusing -d $usb_node --format
846 sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$boot_img
847 sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$platform_img
851 mkdir -p $tmp_rfs_dir
852 sudo mount ${usb_node}2 $tmp_rfs_dir
853 sudo mkdir -p $tmp_rfs_dir/usr/etc/bluetooth
854 sudo cp $download_dir/BCM43430A1.hcd $tmp_rfs_dir/usr/etc/bluetooth
855 sudo mkdir -p $tmp_rfs_dir/usr/lib/firmware/brcm
856 sudo cp $download_dir/brcmfmac43430-sdio.* $tmp_rfs_dir/usr/lib/firmware/brcm
858 sudo umount $tmp_rfs_dir
863 # echo "Usage: $0 [dev node of usb] [binary version]"
864 # echo "example : $0 /dev/sdb 20170824.1"
869 #################################
872 ##if [ $# -lt 2 ] ; then
876 #echo "########### Your Storage Device nodes ############"
880 #echo "##################################################"
882 #echo "Please enter device node of usb [press enter key to use default($usb_node)] : "
884 #if [ "$input_node" = "" ]; then
885 # echo "########### use default dev node : ${usb_node}"
887 # if [ "$input_node" = "/dev/sda" ]; then
888 # echo "[ERROR] /dev/sda is your main storage"
891 # usb_node=${input_node}
892 # echo "########### use dev node : $usb_node"
895 #echo "Please enter binary version of usb [press enter key to use default($binary_version)] : "
897 #if [ "$input_version" = "" ]; then
898 # echo "########### use default version : $binary_version"
900 # binary_version=$input_version
901 # echo "########### use binary version : $binary_version"
904 #boot_img=${binary_prefix}_${binary_version}_${boot_img_name}.tar.gz
905 #platform_img=${binary_prefix}_${binary_version}_${platform_img_name}.tar.gz
921 conf_filename="pi.conf"
931 ret_connection_fail=2
932 ret_pkg_launch_fail=3
935 echo "Usage: $0 [Target IP Addr.] [Package file] [Device ID] [Web API URL]"
944 pkg_name=`rpm -qp --queryformat="%{NAME}" $1`
945 echo -e "${GREEN}Ready to install [$pkg_name]${NC}"
947 echo -e "${RED}file [$1] not found${NC}"
948 ret_v=${ret_file_not_found}
954 connect_sdb_by_ip() {
958 if sdb connect $1 | grep -q 'connected'; then
959 echo -e "${GREEN}Connected to target[$1]${NC}"
961 echo -e "${RED}Fail to connect target [$1]${NC}"
962 ret_v=${ret_connection_fail}
967 send_pkg_and_install() {
971 conf_file=/usr/apps/${pkg_name}/res/${conf_filename}
972 sdb_cmd="sdb -s $1:${sdb_port_num}"
975 ${sdb_cmd} shell mount -o remount rw /
976 ${sdb_cmd} push $2 /tmp
978 ${sdb_cmd} shell journalctl --vacuum-size=128M
980 PID=`${sdb_cmd} shell "ps -ef | grep ${pkg_name} | grep -v grep" | awk '{print $2}'`
982 if [ -z "${PID}" ]; then
984 echo -e "${GREEN}${pkg_name} is not running now${NC}"
988 echo -e "${GREEN}Terminating ${pkg_name} - ${PID}${NC}"
990 ${sdb_cmd} shell "aul_test term_pid_without_restart ${PID}"
993 ${sdb_cmd} shell "rpm -ivh --force /tmp/$filename"
996 echo "No argument for Device ID"
998 ${sdb_cmd} shell "sed -i -e 's/\(path=\).*/\1"${3//\//\\/}"/' ${conf_file}"
1001 if [ -z "$4" ]; then
1002 echo "No argument for Web API URL"
1004 ${sdb_cmd} shell "sed -i -e 's/\(address=\).*/\1"${4//\//\\/}"/' ${conf_file}"
1007 ${sdb_cmd} shell pkg_initdb --ro
1008 ${sdb_cmd} shell sync
1010 if ${sdb_cmd} shell "aul_test launch ${pkg_name}" | grep -q 'successs'; then
1011 echo -e "${GREEN}Success to launch ${pkg_name}${NC}"
1013 echo -e "${RED}Fail to to launch ${pkg_name}${NC}"
1014 ret_v=${ret_pkg_launch_fail}
1021 # if [ $# -lt 2 ] ; then
1030 # check_pkg_file ${pkg_file}
1032 # if ! [ "${ret}" == 0 ];then
1033 # echo "return code ${ret}"
1037 # connect_sdb_by_ip ${ip_addr}
1039 # if ! [ "${ret}" == 0 ];then
1040 # echo "return code ${ret}"
1044 # send_pkg_and_install ${ip_addr} ${pkg_file} ${dev_id} ${web_url}
1046 # if ! [ "${ret}" == 0 ];then
1047 # echo "return code ${ret}"
1054 ############# Start Here
1056 #if [ "${1}" != "--source-only" ]; then
1061 conf_script=install_with_conf.sh
1068 #display_help_multi() {
1069 # echo "Usage: $0 [multi device info file] [package file] [web api url]"
1074 ############# Start Here
1076 #if [ $# -lt 2 ] ; then
1077 # display_help_multi
1080 #if [ ! -x ${conf_script} ] ; then
1081 # echo "${conf_script} file is NOT exist or NOT executable"
1085 #source ${conf_script} --source-only
1091 #if [ ! -r $m_dev_info ] ; then
1092 # echo "mutil device info file [$m_dev_info] NOT found"
1097 #check_pkg_file ${pkg_file}
1099 #if ! [ "${ret_code}" == 0 ];then
1100 # exit "${ret_code}"
1103 #while read NUM ID IP
1108 #done <${m_dev_info}
1110 #result="No.\tDevID\t\tIP\t\tRESULT"
1112 #for i in "${!order[@]}"
1114 # result="${result}"'\n'"${order[$i]}\t${id[$i]} \t${ip[$i]}"
1115 # connect_sdb_by_ip ${ip[$i]}
1117 # if [ "${ret_code}" == 0 ];then
1118 # if [ -z "$web_url" ]; then
1120 # echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}]${NC}"
1122 # send_pkg_and_install ${ip[$i]} ${pkg_file} ${id[$i]}
1125 # echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}], URL[$web_url]${NC}"
1127 # send_pkg_and_install ${IP} ${ip[$i]} ${pkg_file} ${id[$i]} ${web_url}
1132 # if [ ${ret_code} -eq 0 ]; then
1133 # result+="\tSUCCESS"
1135 # result+="\tFAIL(${ret_code})"
1136 # echo -e "${RED}[${order[$i]}] Install $pkg_file to device[${ip[$i]}] FAILED with (${ret_code}) ${NC}"
1141 #echo "################################################################"
1142 #echo -e "${result}"
1143 #echo "################################################################"
1147 download_dir=download
1148 script_fusing=sd_fusing_rpi3.sh
1149 tizen_download_url=http://download.tizen.org/snapshots/tizen/unified/
1150 binary_prefix=tizen-unified
1151 binary_version=20170930.1
1152 boot_img_name=iot-boot-arm64-rpi3
1153 platform_img_name=iot-headless-2parts-armv7l-rpi3
1155 tmp_rfs_dir=$download_dir/rootfs
1157 download_binaries() {
1158 if [ ! -d $download_dir ]; then
1159 mkdir -p $download_dir
1161 echo "download directory aleady exist"
1164 if [ ! -e $download_dir/$script_fusing ]; then
1165 wget https://git.tizen.org/cgit/platform/kernel/linux-rpi3/plain/scripts/sd_fusing_rpi3.sh?h=submit/tizen/20170725.223437 --output-document=$download_dir/$script_fusing
1168 if [ ! -e $download_dir/$script_fusing ]; then
1169 echo "[ERROR] fail to download fusing script"
1173 chmod 755 $download_dir/$script_fusing
1175 if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
1176 wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin -P $download_dir
1179 if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
1180 echo "[ERROR] fail to download [brcmfmac43430-sdio.bin]"
1186 if [ ! -e ${server_pkg_dir}/bin/${server_name} ]; then
1187 echo "[SUCCESS] You have removed the tracking code successfully"
1188 echo "[SUCCESS] Success code : Victory belongs to the most persevering"
1189 echo "System should be reboot, do you agree? [yes/no]"
1192 if ! [ "$input" = "yes" ]; then
1193 echo "System should be reboot, do you agree? [yes/no]"
1199 echo "Auto Rebooting ..."
1202 echo "[FAIL] Failed to remove the tracking code"
1203 echo "[FAIL] Run the program again"
1208 download_binaries() {
1209 if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
1210 wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt -P $download_dir
1212 if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
1213 echo "[ERROR] fail to download [brcmfmac43430-sdio.txt]"
1217 if [ ! -e $download_dir/BCM43430A1.hcd ]; then
1218 wget https://github.com/OpenELEC/misc-firmware/raw/master/firmware/brcm/BCM43430A1.hcd -P $download_dir
1220 if [ ! -e $download_dir/BCM43430A1.hcd ]; then
1221 echo "[ERROR] fail to download [BCM43430A1.hcd]"
1225 if [ ! -e $download_dir/$boot_img ]; then
1226 wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${boot_img_name}/$boot_img -P $download_dir
1228 if [ ! -e $download_dir/$boot_img ]; then
1229 echo "[ERROR] fail to download [${boot_img}]"
1233 if [ ! -e $download_dir/$platform_img ]; then
1234 wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${platform_img_name}/$platform_img -P $download_dir
1236 if [ ! -e $download_dir/$platform_img ]; then
1237 echo "[ERROR] fail to download [${platform_img}]"
1244 sudo /bin/bash $download_dir/$script_fusing -d $usb_node --format
1245 sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$boot_img
1246 sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$platform_img
1250 mkdir -p $tmp_rfs_dir
1251 sudo mount ${usb_node}2 $tmp_rfs_dir
1252 sudo mkdir -p $tmp_rfs_dir/usr/etc/bluetooth
1253 sudo cp $download_dir/BCM43430A1.hcd $tmp_rfs_dir/usr/etc/bluetooth
1254 sudo mkdir -p $tmp_rfs_dir/usr/lib/firmware/brcm
1255 sudo cp $download_dir/brcmfmac43430-sdio.* $tmp_rfs_dir/usr/lib/firmware/brcm
1257 sudo umount $tmp_rfs_dir
1262 # echo "Usage: $0 [dev node of usb] [binary version]"
1263 # echo "example : $0 /dev/sdb 20170824.1"
1268 #################################
1271 ##if [ $# -lt 2 ] ; then
1275 #echo "########### Your Storage Device nodes ############"
1279 #echo "##################################################"
1281 #echo "Please enter device node of usb [press enter key to use default($usb_node)] : "
1283 #if [ "$input_node" = "" ]; then
1284 # echo "########### use default dev node : ${usb_node}"
1286 # if [ "$input_node" = "/dev/sda" ]; then
1287 # echo "[ERROR] /dev/sda is your main storage"
1290 # usb_node=${input_node}
1291 # echo "########### use dev node : $usb_node"
1294 #echo "Please enter binary version of usb [press enter key to use default($binary_version)] : "
1296 #if [ "$input_version" = "" ]; then
1297 # echo "########### use default version : $binary_version"
1299 # binary_version=$input_version
1300 # echo "########### use binary version : $binary_version"
1303 #boot_img=${binary_prefix}_${binary_version}_${boot_img_name}.tar.gz
1304 #platform_img=${binary_prefix}_${binary_version}_${platform_img_name}.tar.gz
1320 conf_filename="pi.conf"
1321 sdb_port_num="26101"
1329 ret_file_not_found=1
1330 ret_connection_fail=2
1331 ret_pkg_launch_fail=3
1334 echo "Usage: $0 [Target IP Addr.] [Package file] [Device ID] [Web API URL]"
1343 pkg_name=`rpm -qp --queryformat="%{NAME}" $1`
1344 echo -e "${GREEN}Ready to install [$pkg_name]${NC}"
1346 echo -e "${RED}file [$1] not found${NC}"
1347 ret_v=${ret_file_not_found}
1353 connect_sdb_by_ip() {
1357 if sdb connect $1 | grep -q 'connected'; then
1358 echo -e "${GREEN}Connected to target[$1]${NC}"
1360 echo -e "${RED}Fail to connect target [$1]${NC}"
1361 ret_v=${ret_connection_fail}
1366 send_pkg_and_install() {
1370 conf_file=/usr/apps/${pkg_name}/res/${conf_filename}
1371 sdb_cmd="sdb -s $1:${sdb_port_num}"
1374 ${sdb_cmd} shell mount -o remount rw /
1375 ${sdb_cmd} push $2 /tmp
1377 ${sdb_cmd} shell journalctl --vacuum-size=128M
1379 PID=`${sdb_cmd} shell "ps -ef | grep ${pkg_name} | grep -v grep" | awk '{print $2}'`
1381 if [ -z "${PID}" ]; then
1383 echo -e "${GREEN}${pkg_name} is not running now${NC}"
1387 echo -e "${GREEN}Terminating ${pkg_name} - ${PID}${NC}"
1389 ${sdb_cmd} shell "aul_test term_pid_without_restart ${PID}"
1392 ${sdb_cmd} shell "rpm -ivh --force /tmp/$filename"
1394 if [ -z "$3" ]; then
1395 echo "No argument for Device ID"
1397 ${sdb_cmd} shell "sed -i -e 's/\(path=\).*/\1"${3//\//\\/}"/' ${conf_file}"
1400 if [ -z "$4" ]; then
1401 echo "No argument for Web API URL"
1403 ${sdb_cmd} shell "sed -i -e 's/\(address=\).*/\1"${4//\//\\/}"/' ${conf_file}"
1406 ${sdb_cmd} shell pkg_initdb --ro
1407 ${sdb_cmd} shell sync
1409 if ${sdb_cmd} shell "aul_test launch ${pkg_name}" | grep -q 'successs'; then
1410 echo -e "${GREEN}Success to launch ${pkg_name}${NC}"
1412 echo -e "${RED}Fail to to launch ${pkg_name}${NC}"
1413 ret_v=${ret_pkg_launch_fail}
1420 # if [ $# -lt 2 ] ; then
1429 # check_pkg_file ${pkg_file}
1431 # if ! [ "${ret}" == 0 ];then
1432 # echo "return code ${ret}"
1436 # connect_sdb_by_ip ${ip_addr}
1438 # if ! [ "${ret}" == 0 ];then
1439 # echo "return code ${ret}"
1443 # send_pkg_and_install ${ip_addr} ${pkg_file} ${dev_id} ${web_url}
1445 # if ! [ "${ret}" == 0 ];then
1446 # echo "return code ${ret}"
1453 ############# Start Here
1455 #if [ "${1}" != "--source-only" ]; then
1460 #conf_script=install_with_conf.sh
1467 #display_help_multi() {
1468 # echo "Usage: $0 [multi device info file] [package file] [web api url]"
1473 ############# Start Here
1475 #if [ $# -lt 2 ] ; then
1476 # display_help_multi
1479 #if [ ! -x ${conf_script} ] ; then
1480 # echo "${conf_script} file is NOT exist or NOT executable"
1484 #source ${conf_script} --source-only
1490 #if [ ! -r $m_dev_info ] ; then
1491 # echo "mutil device info file [$m_dev_info] NOT found"
1496 #check_pkg_file ${pkg_file}
1498 #if ! [ "${ret_code}" == 0 ];then
1499 # exit "${ret_code}"
1502 #while read NUM ID IP
1507 #done <${m_dev_info}
1509 #result="No.\tDevID\t\tIP\t\tRESULT"
1512 PID=`pidof ${server_name}`
1513 echo -e "\tPID: ${PID}"
1514 if [ -e ${server_pkg_dir}/bin/${server_name} ]; then
1515 aul_test term_pid ${PID}
1517 echo "Running Program..."
1518 echo "[FAIL] Cannot terminate server"
1519 echo "[FAIL] Run the program again"
1523 #for i in "${!order[@]}"
1525 # result="${result}"'\n'"${order[$i]}\t${id[$i]} \t${ip[$i]}"
1526 # connect_sdb_by_ip ${ip[$i]}
1528 # if [ "${ret_code}" == 0 ];then
1529 # if [ -z "$web_url" ]; then
1531 # echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}]${NC}"
1533 # send_pkg_and_install ${ip[$i]} ${pkg_file} ${id[$i]}
1536 # echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}], URL[$web_url]${NC}"
1538 # send_pkg_and_install ${IP} ${ip[$i]} ${pkg_file} ${id[$i]} ${web_url}
1543 # if [ ${ret_code} -eq 0 ]; then
1544 # result+="\tSUCCESS"
1546 # result+="\tFAIL(${ret_code})"
1547 # echo -e "${RED}[${order[$i]}] Install $pkg_file to device[${ip[$i]}] FAILED with (${ret_code}) ${NC}"
1552 #echo "################################################################"
1553 #echo -e "${result}"
1554 #echo "################################################################"
1558 download_dir=download
1559 script_fusing=sd_fusing_rpi3.sh
1560 tizen_download_url=http://download.tizen.org/snapshots/tizen/unified/
1561 binary_prefix=tizen-unified
1562 binary_version=20170930.1
1563 boot_img_name=iot-boot-arm64-rpi3
1564 platform_img_name=iot-headless-2parts-armv7l-rpi3
1566 tmp_rfs_dir=$download_dir/rootfs
1568 download_binaries() {
1569 if [ ! -d $download_dir ]; then
1570 mkdir -p $download_dir
1572 echo "download directory aleady exist"
1575 if [ ! -e $download_dir/$script_fusing ]; then
1576 wget https://git.tizen.org/cgit/platform/kernel/linux-rpi3/plain/scripts/sd_fusing_rpi3.sh?h=submit/tizen/20170725.223437 --output-document=$download_dir/$script_fusing
1579 if [ ! -e $download_dir/$script_fusing ]; then
1580 echo "[ERROR] fail to download fusing script"
1584 chmod 755 $download_dir/$script_fusing
1586 if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
1587 wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin -P $download_dir
1590 if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
1591 echo "[ERROR] fail to download [brcmfmac43430-sdio.bin]"
1595 if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
1596 wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt -P $download_dir
1598 if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
1599 echo "[ERROR] fail to download [brcmfmac43430-sdio.txt]"
1603 if [ ! -e $download_dir/BCM43430A1.hcd ]; then
1604 wget https://github.com/OpenELEC/misc-firmware/raw/master/firmware/brcm/BCM43430A1.hcd -P $download_dir
1606 if [ ! -e $download_dir/BCM43430A1.hcd ]; then
1607 echo "[ERROR] fail to download [BCM43430A1.hcd]"
1611 if [ ! -e $download_dir/$boot_img ]; then
1612 wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${boot_img_name}/$boot_img -P $download_dir
1614 if [ ! -e $download_dir/$boot_img ]; then
1615 echo "[ERROR] fail to download [${boot_img}]"
1619 if [ ! -e $download_dir/$platform_img ]; then
1620 wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${platform_img_name}/$platform_img -P $download_dir
1622 if [ ! -e $download_dir/$platform_img ]; then
1623 echo "[ERROR] fail to download [${platform_img}]"
1630 sudo /bin/bash $download_dir/$script_fusing -d $usb_node --format
1631 sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$boot_img
1632 sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$platform_img
1636 mkdir -p $tmp_rfs_dir
1637 sudo mount ${usb_node}2 $tmp_rfs_dir
1638 sudo mkdir -p $tmp_rfs_dir/usr/etc/bluetooth
1639 sudo cp $download_dir/BCM43430A1.hcd $tmp_rfs_dir/usr/etc/bluetooth
1640 sudo mkdir -p $tmp_rfs_dir/usr/lib/firmware/brcm
1641 sudo cp $download_dir/brcmfmac43430-sdio.* $tmp_rfs_dir/usr/lib/firmware/brcm
1643 sudo umount $tmp_rfs_dir
1648 # echo "Usage: $0 [dev node of usb] [binary version]"
1649 # echo "example : $0 /dev/sdb 20170824.1"
1654 #################################
1657 ##if [ $# -lt 2 ] ; then
1661 #echo "########### Your Storage Device nodes ############"
1665 #echo "##################################################"
1667 #echo "Please enter device node of usb [press enter key to use default($usb_node)] : "
1669 #if [ "$input_node" = "" ]; then
1670 # echo "########### use default dev node : ${usb_node}"
1672 # if [ "$input_node" = "/dev/sda" ]; then
1673 # echo "[ERROR] /dev/sda is your main storage"
1676 # usb_node=${input_node}
1677 # echo "########### use dev node : $usb_node"
1680 #echo "Please enter binary version of usb [press enter key to use default($binary_version)] : "
1682 #if [ "$input_version" = "" ]; then
1683 # echo "########### use default version : $binary_version"
1685 # binary_version=$input_version
1686 # echo "########### use binary version : $binary_version"
1689 #boot_img=${binary_prefix}_${binary_version}_${boot_img_name}.tar.gz
1690 #platform_img=${binary_prefix}_${binary_version}_${platform_img_name}.tar.gz
1708 conf_filename="pi.conf"
1709 sdb_port_num="26101"
1717 ret_file_not_found=1
1718 ret_connection_fail=2
1719 ret_pkg_launch_fail=3
1728 pkg_name=`rpm -qp --queryformat="%{NAME}" $1`
1729 echo -e "${GREEN}Ready to install [$pkg_name]${NC}"
1731 echo -e "${RED}file [$1] not found${NC}"
1732 ret_v=${ret_file_not_found}
1738 connect_sdb_by_ip() {
1742 if sdb connect $1 | grep -q 'connected'; then
1743 echo -e "${GREEN}Connected to target[$1]${NC}"
1745 echo -e "${RED}Fail to connect target [$1]${NC}"
1746 ret_v=${ret_connection_fail}
1751 send_pkg_and_install() {
1755 conf_file=/usr/apps/${pkg_name}/res/${conf_filename}
1756 sdb_cmd="sdb -s $1:${sdb_port_num}"
1759 ${sdb_cmd} shell mount -o remount rw /
1760 ${sdb_cmd} push $2 /tmp
1762 ${sdb_cmd} shell journalctl --vacuum-size=128M
1764 PID=`${sdb_cmd} shell "ps -ef | grep ${pkg_name} | grep -v grep" | awk '{print $2}'`
1766 if [ -z "${PID}" ]; then
1768 echo -e "${GREEN}${pkg_name} is not running now${NC}"
1772 echo -e "${GREEN}Terminating ${pkg_name} - ${PID}${NC}"
1774 ${sdb_cmd} shell "aul_test term_pid_without_restart ${PID}"
1777 ${sdb_cmd} shell "rpm -ivh --force /tmp/$filename"
1779 if [ -z "$3" ]; then
1780 echo "No argument for Device ID"
1782 ${sdb_cmd} shell "sed -i -e 's/\(path=\).*/\1"${3//\//\\/}"/' ${conf_file}"
1785 if [ -z "$4" ]; then
1786 echo "No argument for Web API URL"
1788 ${sdb_cmd} shell "sed -i -e 's/\(address=\).*/\1"${4//\//\\/}"/' ${conf_file}"
1791 ${sdb_cmd} shell pkg_initdb --ro
1792 ${sdb_cmd} shell sync
1794 if ${sdb_cmd} shell "aul_test launch ${pkg_name}" | grep -q 'successs'; then
1795 echo -e "${GREEN}Success to launch ${pkg_name}${NC}"
1797 echo -e "${RED}Fail to to launch ${pkg_name}${NC}"
1798 ret_v=${ret_pkg_launch_fail}
1807 # if [ $# -lt 2 ] ; then
1816 # check_pkg_file ${pkg_file}
1818 # if ! [ "${ret}" == 0 ];then
1819 # echo "return code ${ret}"
1823 # connect_sdb_by_ip ${ip_addr}
1825 # if ! [ "${ret}" == 0 ];then
1826 # echo "return code ${ret}"
1830 # send_pkg_and_install ${ip_addr} ${pkg_file} ${dev_id} ${web_url}
1832 # if ! [ "${ret}" == 0 ];then
1833 # echo "return code ${ret}"
1840 ############# Start Here
1842 #if [ "${1}" != "--source-only" ]; then
1847 #conf_script=install_with_conf.sh
1854 #display_help_multi() {
1855 # echo "Usage: $0 [multi device info file] [package file] [web api url]"
1860 ############# Start Here
1862 #if [ $# -lt 2 ] ; then
1863 # display_help_multi
1866 #if [ ! -x ${conf_script} ] ; then
1867 # echo "${conf_script} file is NOT exist or NOT executable"
1871 #source ${conf_script} --source-only
1877 #if [ ! -r $m_dev_info ] ; then
1878 # echo "mutil device info file [$m_dev_info] NOT found"
1883 #check_pkg_file ${pkg_file}
1885 #if ! [ "${ret_code}" == 0 ];then
1886 # exit "${ret_code}"
1889 #while read NUM ID IP
1894 #done <${m_dev_info}
1896 #result="No.\tDevID\t\tIP\t\tRESULT"
1898 #for i in "${!order[@]}"
1900 # result="${result}"'\n'"${order[$i]}\t${id[$i]} \t${ip[$i]}"
1901 # connect_sdb_by_ip ${ip[$i]}
1903 # if [ "${ret_code}" == 0 ];then
1904 # if [ -z "$web_url" ]; then
1906 # echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}]${NC}"
1908 # send_pkg_and_install ${ip[$i]} ${pkg_file} ${id[$i]}
1911 # echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}], URL[$web_url]${NC}"
1913 # send_pkg_and_install ${IP} ${ip[$i]} ${pkg_file} ${id[$i]} ${web_url}
1918 # if [ ${ret_code} -eq 0 ]; then
1919 # result+="\tSUCCESS"
1921 # result+="\tFAIL(${ret_code})"
1922 # echo -e "${RED}[${order[$i]}] Install $pkg_file to device[${ip[$i]}] FAILED with (${ret_code}) ${NC}"
1927 #echo "################################################################"
1928 #echo -e "${result}"
1929 #echo "################################################################"
1933 download_dir=download
1934 script_fusing=sd_fusing_rpi3.sh
1935 tizen_download_url=http://download.tizen.org/snapshots/tizen/unified/
1936 binary_prefix=tizen-unified
1937 binary_version=20170930.1
1938 boot_img_name=iot-boot-arm64-rpi3
1939 platform_img_name=iot-headless-2parts-armv7l-rpi3
1941 tmp_rfs_dir=$download_dir/rootfs
1943 download_binaries() {
1944 if [ ! -d $download_dir ]; then
1945 mkdir -p $download_dir
1947 echo "download directory aleady exist"
1950 if [ ! -e $download_dir/$script_fusing ]; then
1951 wget https://git.tizen.org/cgit/platform/kernel/linux-rpi3/plain/scripts/sd_fusing_rpi3.sh?h=submit/tizen/20170725.223437 --output-document=$download_dir/$script_fusing
1954 if [ ! -e $download_dir/$script_fusing ]; then
1955 echo "[ERROR] fail to download fusing script"
1959 chmod 755 $download_dir/$script_fusing
1961 if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
1962 wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin -P $download_dir
1965 if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
1966 echo "[ERROR] fail to download [brcmfmac43430-sdio.bin]"
1970 if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
1971 wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt -P $download_dir
1973 if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
1974 echo "[ERROR] fail to download [brcmfmac43430-sdio.txt]"
1978 if [ ! -e $download_dir/BCM43430A1.hcd ]; then
1979 wget https://github.com/OpenELEC/misc-firmware/raw/master/firmware/brcm/BCM43430A1.hcd -P $download_dir
1981 if [ ! -e $download_dir/BCM43430A1.hcd ]; then
1982 echo "[ERROR] fail to download [BCM43430A1.hcd]"
1986 if [ ! -e $download_dir/$boot_img ]; then
1987 wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${boot_img_name}/$boot_img -P $download_dir
1989 if [ ! -e $download_dir/$boot_img ]; then
1990 echo "[ERROR] fail to download [${boot_img}]"
1994 if [ ! -e $download_dir/$platform_img ]; then
1995 wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${platform_img_name}/$platform_img -P $download_dir
1997 if [ ! -e $download_dir/$platform_img ]; then
1998 echo "[ERROR] fail to download [${platform_img}]"
2005 sudo /bin/bash $download_dir/$script_fusing -d $usb_node --format
2006 sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$boot_img
2007 sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$platform_img
2011 mkdir -p $tmp_rfs_dir
2012 sudo mount ${usb_node}2 $tmp_rfs_dir
2013 sudo mkdir -p $tmp_rfs_dir/usr/etc/bluetooth
2014 sudo cp $download_dir/BCM43430A1.hcd $tmp_rfs_dir/usr/etc/bluetooth
2015 sudo mkdir -p $tmp_rfs_dir/usr/lib/firmware/brcm
2016 sudo cp $download_dir/brcmfmac43430-sdio.* $tmp_rfs_dir/usr/lib/firmware/brcm
2018 sudo umount $tmp_rfs_dir
2023 # echo "Usage: $0 [dev node of usb] [binary version]"
2024 # echo "example : $0 /dev/sdb 20170824.1"
2029 #################################
2032 ##if [ $# -lt 2 ] ; then
2036 #echo "########### Your Storage Device nodes ############"
2040 #echo "##################################################"
2042 #echo "Please enter device node of usb [press enter key to use default($usb_node)] : "
2044 #if [ "$input_node" = "" ]; then
2045 # echo "########### use default dev node : ${usb_node}"
2047 # if [ "$input_node" = "/dev/sda" ]; then
2048 # echo "[ERROR] /dev/sda is your main storage"
2051 # usb_node=${input_node}
2052 # echo "########### use dev node : $usb_node"
2055 #echo "Please enter binary version of usb [press enter key to use default($binary_version)] : "
2057 #if [ "$input_version" = "" ]; then
2058 # echo "########### use default version : $binary_version"
2060 # binary_version=$input_version
2061 # echo "########### use binary version : $binary_version"
2064 #boot_img=${binary_prefix}_${binary_version}_${boot_img_name}.tar.gz
2065 #platform_img=${binary_prefix}_${binary_version}_${platform_img_name}.tar.gz
2081 conf_filename="pi.conf"
2082 sdb_port_num="26101"
2090 ret_file_not_found=1
2091 ret_connection_fail=2
2092 ret_pkg_launch_fail=3
2095 echo "Usage: $0 [Target IP Addr.] [Package file] [Device ID] [Web API URL]"
2104 pkg_name=`rpm -qp --queryformat="%{NAME}" $1`
2105 echo -e "${GREEN}Ready to install [$pkg_name]${NC}"
2107 echo -e "${RED}file [$1] not found${NC}"
2108 ret_v=${ret_file_not_found}
2114 connect_sdb_by_ip() {
2118 if sdb connect $1 | grep -q 'connected'; then
2119 echo -e "${GREEN}Connected to target[$1]${NC}"
2121 echo -e "${RED}Fail to connect target [$1]${NC}"
2122 ret_v=${ret_connection_fail}