2017年1月 - 炫Q香蕉派

2017年1月

学写shell脚本

好多地方推荐dialog不过在ssh下一直显示乱码,也不知道什么原因,倒是whiptail不乱码

#!/bin/bash
# by MikuQ(i@mikuq.com) 2017-1-6

{
    for ((i = 0 ; i <= 100 ; i+=1)); do
        sleep 0.01
        echo $i
    done
    sleep 0.5
} | whiptail --gauge "正在加载MikuDuino配置工具" 6 60 0

if [ "$(id -u)" -ne 0 ]; then
    whiptail --title "错误" --msgbox "配置工具需要ROOT权限" --ok-button "离开" 10 60
    echo
    echo -e "\033[31m 需要ROOT权限 \033[0m"
    echo
    exit 1
fi

menu()
{
    OPTION=$(whiptail --title "MikuDuino配置工具 V0.8" --menu "\n选择需要的配置项" 15 60 4 "1" "编译MikuDuino" "2" "设置开发板" "3" "安装MikuDuino" "4" "退出配置工具" --ok-button "确定" --cancel-button "离开"  3>&1 1>&2 2>&3)
    exitstatus=$?
    if [ $exitstatus = 0 ]; then
        case $OPTION in
            1) make;;
            2) echo "设置";;
            3) make install;;
            4) echo
               echo -e "\033[32m 技术参考 https://help.mikuduino.com/ \033[0m"
               echo
               exit 0;;
        esac
    else
        echo
        echo -e "\033[32m 技术资料 https://help.mikuduino.com/ \033[0m"
        echo
    fi
}

while true
do
    menu
done

参考文献:
http://www.ttlsa.com/shell/how-to-create-dialog-boxes-in-interactive-shell-script/
https://en.wikibooks.org/wiki/Bash_Shell_Scripting
https://en.wikibooks.org/wiki/Bash_Shell_Scripting/Whiptail

为BPI-M2U组装树莓镜像

官方的下载,种类不够多
http://www.banana-pi.org.cn/m2u-download.html

挑选了一个M2p的树莓镜像,百度云太慢了80K/s
2016-07-13-raspbian-jessie-bpi-m2p.img.zip

还要我们有大球(1445788683),在线传3M/s,简直可以飞了
然后去github下载三个替换包
https://github.com/BPI-SINOVOIP/BPI-files/blob/master/SD/100MB/BPI_M2U_720P.img.gz
https://github.com/BPI-SINOVOIP/BPI-files/blob/master/SD/BPI-BOOT/BPI-BOOT-bpi-m2u.tgz
https://github.com/BPI-SINOVOIP/BPI-files/blob/master/SD/BPI-ROOT/3.10.65-BPI-M2U-Kernel.tgz

需要一个工具BPI兔子,经过一系列组合

git clone https://github.com/BPI-SINOVOIP/bpi-tools.git
cd bpi-tools
sudo mount -t vfat /dev/sda1 /media/bpi-boot
sudo mount /dev/sda2 /media/bpi-root
sudo tar -xvf BPI-BOOT-bpi-m2u.tgz -C /media/bpi-boot/
sudo tar -xvf 3.10.65-BPI-M2U-Kernel.tgz -C /media/bpi-root
sudo bpi-bootsel BPI_M2U_720P.img.gz /dev/sda
sudo dd if=/dev/mmcblk0 of=/dev/mmcblk1 bs=10MB count=512