################################# ###################
# Description:
#
# This Script is written by buyukbang and inspired from the script made By MalMen.
# Special thanks to Smudger for all tests for the all information, tests and power measurements!
#
# 1. S99PriorityManager automatically changes the priorities of the processes to give optimal performance for the menu being used. I tested
# all processes one by one, decided their effects on the performance of all modules and wrote a bug-free (hopefully) script.
#
# 2. S99PriorityManager provides power saving ! Smudger's power measurements show that S99PriorityManager decrease power consumption of the
# box from 25W to 23W while watching an SD channel and from 28W to 24W while watching an HD channel.
#
#
################################# ###################
# User Defined Parameters :
#
# MODE : IF YOU WANT TO RUN THIS SCRIPT ON A BOX BEING USED AS A CAM SERVER CHANGE BELOW LINE TO MODE=SERVER THEN SAVE THE SCRIPT.
MODE=CLIENT
#
################################# ###################
# History:
#
# v1.2
# -----
# Fixed : Sometimes CRTVCore collects all CPU power and this slows down everything. So I decreased priority of CRTVCore.
# Fixed : Fixed a bug in restart command ( /DISK2/etc/start.d/S99PriorityManager.sh restart )
# Improved : All process priorities fine tuned.
# Improved : Better menu detection.
# Improved : Better sleep mode detection.
# Modified : Loop sleep time decreased from 60 seconds to 30 seconds.
# Added : azepgmgr support to protect TV/Media applications from the glitches caused by its initial process. (Thanks to Smudger!)
# Added : Client/Server mode switch parameter for those who want to this script on a box being used as a CAM server.
# Added : Audio menu prioritization.
# Added : Settings menu prioritization.
# Added : Plugins menu prioritization.
# Added : Cheops EMU prioritization.
# Added : SBox EMU prioritization.
#
# v1.1
# -----
# Added : RSS and Browser components stay in memory after first usage. Added support for automatically killing RSS and Browser
# components when using other menu.
#
# v1.0
# -----
# Fixed : All process priorities updated according to the results of my long tests. Mediaplayer performance, IP TV, Recording,
# ECM Time (for EMUs) are optimized.
# Fixed : Old scripts use "snice +XX" command to give processes positive nice values (lower priority). But this command does
# not guarantee to decrease the priority and system sometimes ignore this command. You can check old scripts by top command
# while changing menu modes. "<" sign means negative nice value and high priority, "N" sign means positive nice value and
# low priority. After a few times changing the menu modes everything has "<" sign and this is really nonfunctional situation.
# To fix this problem I used "snice STOP" which cannot be ignored by the system.
# Fixed : massimo1167's script is not compatible with the option "Always Start in TV Mode" and this causes totally wrong
# prioritization. This is fixed.
# Fixed : Old scripts block firmware upgrades and upgrade process sticks at "Extracting". S99PriorityManager fixes this issue and
# fully compatible Opensat upgrades. Just wait 45 seconds at "Extracting", then upgrade process will continue.
# Added : ftp,samba,telnet prioritization in sleep mode. I suggest you to transfer your files with FTP during sleep mode prioritization.
# This is the fasted method.
# Added : Photo menu prioritization.
# Added : Browser menu prioritization.
# Added : RSS menu prioritization.
# Added : Use this command to stop the script (does not work in old scripts) : /DISK2/etc/start.d/S99PriorityManager.sh stop
# Added : Use this command to restart the script (does not work in old scripts) : /DISK2/etc/start.d/S99PriorityManager.sh restart
# Added : Logging. Use this command to see log file : tail -f /tmp/S99PriorityManager_IsRunning
#
################################# ###################
# Intallation:
#
# 1. Check "User Defined Parameters" and if needed edit parameters then save the scipt.
# 2. Put this script under "/DISK2/etc/start.d", use following commands in TELNET with below order.
# 3. chmod 755 /DISK2/etc/start.d/S99PriorityManager.sh
# 4. If you edited and saved the script use this command: dos2unix /DISK2/etc/start.d/S99PriorityManager.sh
# 5. After the first run of the script standby.sh and wakeup.sh scripts will be created under /DISK2/etc . These scripts will help to main
# script for the decision of the sleep mode by creating and deleting a file ( /tmp/S99PriorityManager_Sleep ) If you have already
# standby.sh and wakeup.sh in /DISK2/etc you must manually add below commands to scripts before running S99PriorityManager.sh :
# echo 0 > /tmp/S99PriorityManager_Sleep ==> to standby.sh
# rm /tmp/S99PriorityManager_Sleep ==> to wakeup.sh
# 6. /DISK2/etc/start.d/S99PriorityManager.sh start (After this command standby.sh and wakeup.sh will be created under /DISK2/etc)
# 7. Restart the box. 30 seconds after restarting use below command to check if the script is working.
# 8. tail -f /tmp/S99PriorityManager_IsRunning
#
################################# ###################
# Important Notes:
#
# - Scripts works in a loop with 30 seconds sleep times. So wait max 30 seconds for prioritization. You can decrease this to 15-20 seconds
# if you want, but values below 10 may cause a small performance loss.
#
# - A looped script in /DISK2/etc/start.d/ will block the other scripts with a higher heading value. So use only one looped script (and
# this is it). This is the reason why I used "99" in the script name. This will not block any script with two digit but will block scripts
# with higher values as heading value.
COMMENTA