and_cesbo

MAG-250 action.sh with set_key

May 30th, 2013
640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.37 KB | None | 0 0
  1. # cat /home/default/action.sh
  2. #!/bin/sh
  3. #$1 - path; $2 - return value
  4. check_file_path()
  5. {
  6.     DIR1="/ram/media"
  7.     DIR2="/ram/mnt"
  8.     fpath="$1"
  9.     fpath=${fpath%/*}
  10.     rpath=`realpath "$fpath/" 2>/dev/null`
  11.     dir1=${rpath#${DIR1}*}
  12.     dir2=${rpath#${DIR2}*}
  13.  
  14.     if [ "$rpath" == "" ] ; then
  15.     export $2="Error"
  16.     return;
  17.     fi
  18.     if [ "$dir1" == "$rpath" ] ; then
  19.     if [ "$dir2" == "$rpath" ] ; then
  20.         export $2="Error"
  21.         return;
  22.     fi
  23.     fi
  24.     export $2="Ok"
  25. }
  26.  
  27. PATH=$PATH:/home/default
  28. case "$1" in
  29.     reboot)
  30.     reboot
  31.     ;;
  32.     bright)
  33.         ;;
  34.     mount_dir)
  35.     check_file_path "$3" ret
  36.     if [ "$ret" == "Error" ]; then
  37.         echo -ne "Error: wrong mount point"
  38.         exit 2;
  39.     fi
  40.         mount -t nfs -o ro,rsize=4096,wsize=4096,nolock,udp "$2" "$3"
  41.         ;;
  42.                            
  43.     umount_dir)
  44.     umount "$2"
  45.         ;;
  46.     make_dir)
  47.         mkdir "$2"
  48.         ;;
  49.     SetVideoOut)
  50.     ;;
  51.     RebootDHCP)
  52.     rebootmng.sh dhcp
  53.     ;;
  54.     UpdateSW)
  55.     # $2  -  upgrade mode
  56.     #   up_ip_tftp
  57.     #   up_dhcp_tftp
  58.     #   up_mc
  59.     rebootmng.sh $2
  60.     ;;
  61.     front_panel)
  62.     /home/default/setFpanel.sh "$2" "$3"
  63.     ;;
  64.     tvsystem)
  65.     mode=""
  66.     case "$2" in
  67.         PAL|576p-50|720p-50|1080i-50|NTSC|576p-60|720p-60|1080i-60|1080p-50|1080p-60)
  68.             mode="$2"
  69.         ;;
  70.         576i)
  71.         mode="PAL"
  72.         ;;
  73.         480i)
  74.         mode="NTSC"
  75.         ;;
  76.     esac
  77.     if [ -n "$mode" ] ; then
  78.         fw_setenv tvsystem $mode
  79.     fi
  80.     ;;
  81.     graphicres)
  82.     case "$2" in
  83.         1920|1280|720|tvsystem_res)
  84.         fw_setenv graphicres $2
  85.         ;;
  86.     esac
  87.     ;;
  88.     timezone)
  89.     TZCONF="/ram/timezone"
  90.     LTCONF="/ram/localtime"
  91.     timezone=$2
  92.  
  93.         tzconf=`fw_printenv timezone_conf 2>/dev/null`
  94.         tzconf=${tzconf#timezone_conf=}
  95.         if [ "$tzconf" != "$timezone" ]; then
  96.         fw_setenv timezone_conf $timezone  
  97.         fi
  98.  
  99.     if [ -n "$timezone" ]; then
  100.             echo "$timezone" > $TZCONF
  101.             rm $LTCONF
  102.             ln -s /usr/share/zoneinfo/$timezone $LTCONF
  103.     else
  104.             echo "Europe/Kiev" > $TZCONF
  105.             rm $LTCONF
  106.         ln -s /usr/share/zoneinfo/Europe/Kiev $LTCONF
  107.     fi
  108.     ;;
  109.     set_key)
  110.     echo "$2" >/tmp/key
  111.     ;;
  112.     *)  echo Bad Action code.
  113.     ;;  
  114. esac
Advertisement
Add Comment
Please, Sign In to add comment