shell getopt 调用模版

admin2024-07-10  14

#!/bin/bash
set -e

SDK_PATH=/home/caros/cyberrt/bin/

stop_neolix_cam(){
  echo ""
}

start_neolix_cam_test(){
	echo "############# start camera #############"
	cd /home/caros/cyberrt && source setup.bash
	mainboard -d camera_fpd_link_xavier_perception.dag -p camera_fpd_link_perception -s CYBER_DEFAULT
	sleep 5
}

start_nv_sdk(){
	cd $SDK_PATH
	killpid=`ps -ef | egrep neolix_nv_camera | egrep -v grep | awk '{print }'`
	if [ -n "$killpid" ] ; then taskset -cp 5 $killpid ; fi
	cd -
}

help_info()
{ 
    echo -e "NAME" FNAME=`basename `
    echo -e "\t $FNAME"
    echo -e "SYNOPSIS"
    echo -e "\t $FNAME is a tool for happy. ^_^"
    echo -e "DESCRIPTION"
    echo -e "\toption -d into neolix docker" 
    echo -e "\toption -h help" 
}

t_wget()
{
    rm -f 
    wget ftp://192.167.0.105:/
    chmod +x 
}

CF_wget()
{
    rm rf index.html
    wget --user=c1firmware --password=oEVwcRCXuHS3TLyy ftp://10.2.166.130/C1//
    FF=`cat index.html|grep "zip\">F" |awk '{len=split(,a,"\""); print a[2]}'`
    wget --user=c1firmware --password=oEVwcRCXuHS3TLyy $FF 
}

t_tftp_get()
{
    rm -f 
    tftp -g -r  192.168.233.137 
    chmod +x 
}

chown_to_steven()
{
    sudo chown -R steven 
    sudo chgrp -R steven 
}

make_version()
{
    echo "========  make_version ========"
    TVER=`awk '/VERSION:/{n++}n==1{print;exit}' RELEASENOTES |awk '{split(,a,"[:]");print a[2]}'`
    V1=`echo $TVER | awk '{split(,a,"[.]");print a[1]}'`
    V2=`echo $TVER | awk '{split(,a,"[.]");print a[2]}'`
    V3=`echo $TVER | awk '{split(,a,"[.]");print a[3]}'`

    let V3=$V3+1
    NEW_VER=$V1.$V2.$V3

    sed -i "s%\(^VERSION:\).*%$NEW_VER%" ./RELEASENOTES 
    sed -i "s%\(^#define _VERSION_  \).*%\"$NEW_VER\"%" ./include/javs_sdk.h

    echo "NEW VERSION:$NEW_VER"
}

make_git_head()
{
    echo "========  make_git_head ========"
    GIT_HEAD=`git log -1 |grep commit | awk '{split(,a,"[ ]");print a[2]}'`
    sed -i "s%\(^HEAD:\).*%$GIT_HEAD%" ./RELEASENOTES 
    sed -i "s%\(^#define _GIT_HEAD_  \).*%\"$GIT_HEAD\"%" ./include/javs_sdk.h
    echo "GIT_HEAD:$GIT_HEAD"
}

docker_into_neolix()
{
    cd /home/caros/platform/
    ./arm_docker_into.sh
    cd -
}

getopt_act()
{
    GETOPTOUT=`getopt abcdefhxstk:i:jlm:n:o:pruvw:y "$@"`
    set -- $GETOPTOUT 
    while [ -n "" ] 
    do
    case  in 
        -a)
            #source /usr/local/oecore-x86_64/environment-setup-aarch64-poky-linux
            #make distclean
            #make
            ;;
        -c)
            #make distclean
            #make
            ;;
        -d)
            docker_into_nueolix
            ;;
        -b)
            #adb_push_so_appmic
            ;;
        -e)
           #x_tar_javs_so
            ;;
        -u)
            #u_buid_unis_8516
            ;;
        -j)
            #u_buid_unis_8516_linux_sdk
            ;;
        -f)
            #make_7686
            ;;
        -s)
            #cp_core_dump
            ;;
        -g)
            #cp_core_dump
            ;;
        -t)
            #cd /home/yangzhongxuan/workspace/javs/javs_rtos_sdk
            ;;
        -r)
            #make_release_sdk
            ;;
        -v)
            #make_version
            #make_git_head
            ;;
        -x)
            set -x
            ;;

        -h)
            help_info
            ;;
        --)
            shift
            break
            ;;
    esac
    shift
    done

    param_index=1
    for param in "$@"
    do
        param_index=$[ $param_index + 1 ] 
    done
}

if [ $# -eq 0 ]
then
    help_info
else
    getopt_act $@ 
fi
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明原文出处。如若内容造成侵权/违法违规/事实不符,请联系SD编程学习网:675289112@qq.com进行投诉反馈,一经查实,立即删除!