Advertisement
Guest User

onPowerOn.sh

a guest
Oct 22nd, 2016
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.86 KB | None | 0 0
  1. #!/mnt/bin/sh
  2.  
  3. . /dtv/SGO.env
  4.  
  5. #log power on event
  6.  
  7. #if the date/time is right, inject libPinCode
  8. DAYOFWEEK=`date '+%u'`;
  9. HOUR=`TZ='GMT-3' date '+%H'`;
  10. SODIR=$SYSROOT/opt/privateer/usr/libso
  11. OPTIONS="TIMEOUT:100 TRIES:3"
  12. LOG=/dtv/onPowerOn.log
  13.  
  14. #from monday-friday (1-5)
  15. if [ "$DAYOFWEEK" -lt 8 ]; then
  16.         #from 8-18
  17.         if [ "$HOUR" -gt 7 -a "$HOUR" -lt 19 ]; then
  18.  
  19.                 #is the pin code already injected? If yes, it's possible it is disabled and we
  20.                 #need to restart the TV
  21.                 INJECTED=`cat /dtv/LockTV.log | grep "Locking TV, pincode requested" | wc -l`;
  22.                 if [ "$INJECTED" -eq "1" ]; then
  23.                         logger -s -t $0 "libPinCode is already injected. We can't reinject" 2>&1| tee -a $LOG
  24.                         samyGOso -d -A -B -l /mnt/opt/privateer/usr/libso/libText.so TEXT:'libPinCode is already injected. Reboot forced' FONT:2 CENTER:7 TIMEOUT:5
  25.                         sync
  26.                         sync
  27.                         sleep 3
  28.                         /sbin/micom reboot
  29.                 else
  30.  
  31.                         logger -s -t $0 "Injecting libPinCode because we are on a weekday before 18" 2>&1 | tee -a $LOG
  32.                         USER=`id`
  33.                         logger -s -t $0 "Running as $USER" 2>&1 | tee -a $LOG
  34.                         samyGOso -d -A -B -l /mnt/opt/privateer/usr/libso/libText.so TEXT:'injecting libPinCode to enforce time' FONT:2 CENTER:7 TIMEOUT:5
  35.                         logger -s -t $0 "Text injection error code:$?" 2>&1 | tee -a $LOG
  36.                         sync
  37.                         sync
  38.                         sleep 3
  39.                         samyGOso -A -B -r -l $SODIR/libLockTV.so $OPTIONS
  40.                         logger -s -t $0 "Lock TV injection error code:$?" 2>&1 | tee -a $LOG
  41.  
  42.                 fi
  43.  
  44.         fi
  45.  
  46. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement