4/10/2015

Bash Shell 예제들

  
반드시 참조 아래사이트 
  https://wiki.kldp.org/HOWTO/html/Adv-Bash-Scr-HOWTO/
  https://ahyuo79.blogspot.com/2014/01/awk.html

$ cat reset_lte.sh
#!/bin/sh
#
# Usage examples:
#       ./reset_lte.sh stop
#       ./reset_lte.sh start



VER=1.6

LTE_PWR=160
LTE_EN=161

WAIT_100MS() {
    sleep 0.1
}

WAIT_10MS() {
    sleep 0.01
}

WAIT_1S() {
    sleep 1
}

enable_lte() {
    echo "ENABLE/RESET LTE  (LTE_PWR:$LTE_PWR, LTE_EN:$LTE_EN)"
    # write output (Power)
    echo "0" > /sys/class/gpio/gpio$LTE_EN/value; WAIT_100MS
    echo "1" > /sys/class/gpio/gpio$LTE_EN/value
    # Reset (LTE_IGT)
    echo "1" > /sys/class/gpio/gpio$LTE_PWR/value
}

disable_lte() {
    echo "DISABLE/RESET LTE  (LTE_PWR:$LTE_PWR, LTE_EN:$LTE_EN)"
    # write output (Power)
    echo "0" > /sys/class/gpio/gpio$LTE_EN/value; WAIT_100MS  
    # off (LTE_IGT) 
    echo "0" > /sys/class/gpio/gpio$LTE_PWR/value    
}

case "$1" in
    start)
    enable_lte
    ;;
    stop)    
    disable_lte
    ;;
    *)
    echo "Usage: $0 {start|stop} "
    exit 1
    ;;
esac

exit 0


$ cat reset_lte.sh
#!/bin/sh
# Setup LDO/RESET Service (systemd) 
# 


WAIT_100MS() {
    sleep 0.1
}

echo "   " | logger -t pwr_setup -p local0.notice
echo "   " | logger -t pwr_setup -p local0.notice
echo "   " | logger -t pwr_setup -p local0.notice
echo "Setup ALL POWER SYSTEM (LDO/RESET) Start !!!!! " | logger -t pwr_setup -p local0.notice

/usr/bin/setup_gpio.sh enable | logger -t pwr_setup -p local0.notice

if [ $? -eq 0 ]
then
  echo "Success: setup_gpio.sh enable (Setup GPIO about LDO/RESET)" | logger -t pwr_setup -p local0.notice
else
  echo "Failure: setup_gpio.sh enable (Setup GPIO about LDO/RESET)" >&2 | logger -t pwr_setup -p local0.notice
  exit 1
fi

/usr/bin/reset_gps.sh start | logger -t gps_reset -p local0.notice

if [ $? -eq 0 ]
then
  echo "Success: reset_gps.sh start (GPS RESET OK)" | logger -t gps_reset -p local0.notice
else
  echo "Failure: reset_gps.sh start (GPS RESET Failed) " >&2 | logger -t gps_reset -p local0.notice
  exit 1
fi


/usr/bin/reset_lte.sh start | logger -t lte_reset -p local0.notice

if [ $? -eq 0 ]
then
  echo "Success: reset_lte.sh start (LTE RESET OK)" | logger -t lte_reset -p local0.notice
else
  echo "Failure: reset_lte.sh start (LTE RESET Failed)" >&2 | logger -t lte_reset -p local0.notice
  exit 1
fi


exit 0


$ cat /etc/syslog.conf
#  /etc/syslog.conf     Configuration file for busybox's syslogd utility
#
#  Author: Jeonghun lee


local0.notice       /var/log/test1

local1.notice       /var/log/test2

# others  /var/log/message






댓글 없음 :