├── LGTV-RS232 ├── README.md ├── script_called_by_HDMI-CEC_plugin │ ├── TvOff.sh │ └── TvOn.sh └── script_called_by_Standby_mode │ ├── ATV │ ├── StandbyEnter.sh │ └── StandbyLeave.sh │ └── PLi │ ├── standby_enter.sh │ └── standby_leave.sh ├── README.md ├── _ipk_and_deb_maker_by_s3n0_for_ProjectXYZ.sh ├── backrest ├── bouquetx.sh ├── epg_download.sh ├── epg_refresh.py ├── epg_upload.sh ├── opkg-ext.py ├── oscam-idle-test.sh ├── oscam-new-version-updater.sh ├── oscam-picons-converter.py ├── oscam-picons-converter_OscamWebif_script.sh ├── oscam-srvid-generator-flysat.py ├── oscam-srvid-generator-kingofsat.sh ├── oscam-srvid-generator-lyngsat.sh ├── oscam-srvid-generator-satelitnatv.sh ├── oscam-srvid-generator-twojeip.sh ├── oscam_emm_refresh.sh ├── oscamrr ├── oscamrrf ├── remove_unused_languages.sh ├── softcam ├── softcam (+ bckgrnd script to checking the reader entitlements) ├── softcam (+ bckgrnd script to restart the softcam if it crashes) ├── softcam (+ bckgrnd script to zap the channel at the night) ├── softcam (+ delayed start if Linux is still booting) ├── softcam (+ zap channel each time when softcam was started) ├── softcam.service └── vhannibal-setting-download.sh /LGTV-RS232/README.md: -------------------------------------------------------------------------------- 1 | Switching on and off the LG TV via RS-232 serial interface 2 | ========================================================== 3 | 4 | The shell script can be called from within the HDMI-CEC plugin or it can be called directly from the Enigma source code - always when the standby is de/activated. Therefore, choose the right shell scripts, depending on whether you want to control LG-TV via the HDMI-CEC plugin or by invoking standby mode in Enigma (`..../python/Screens/Standby.py` file). 5 | 6 | - command to display basic serial interfaces under LINUX systems: 7 | - `setserial -g -a /dev/ttyS[0123]` 8 | 9 | - command for listing of all available serial interfaces and especially access rights to them: 10 | - `ls -l /dev/ttyS*` 11 | 12 | - there are two commands for LG-TV serial interface... so, as first, use the following commands to test the functionality of the RS-232 communication... after connecting the null-modem cable (without "hardware handshaking") between the set-top-box and the LG-TV ([OpenATV forum thread](https://www.opena.tv/english-section/32512-solution-standby-mode-lg-tv-hdmi-cec-simplink.html)): 13 | - turning off LG-TV: `echo "ka 01 00" > /dev/ttyS0` 14 | - turning on LG-TV: `echo "ka 01 01" > /dev/ttyS0` 15 | 16 | - if your LG-TV has not turned off via the serial interface with the help of an echo command, then it is possible that you do not have access rights to the serial interface (write)... so try setting up serial interface access rights if necessary: 17 | - `chmod o+rw /dev/ttyS0` 18 | 19 | - if the TV is still not communicating (TV turn off and on), it would have to try to configure the interface 20 | RS-232 to a slower speed, e.g. 9600 (for older LG TV) 21 | - display the current configuration of the "S0" interface: `stty -a -F /dev/ttyS0` 22 | - change the speed of the "S0" interface to 9600 bps: `stty -F /dev/ttyS0 9600` 23 | 24 | - for some linux distributions it seems to have a separate setup for output and input, as follows: 25 | - `stty -F /dev/ttyS0 ispeed 9600 ospeed 9600` 26 | 27 | - the `cat` command is normally used to display the contents of a file to standard output `stdout` but we can also display the serial interface input ... here's how to use it to extract content from input on the set-top-box: 28 | - `cat < /dev/ttyS0` 29 | - another example of reading a serial port input and displaying results on stdout (in hexadecimal, i.e. byte - one by one): 30 | - `od -x < /dev/ttyS0` 31 | 32 | Notes 33 | ===== 34 | 35 | After rebooting the set-top box, immediately after the first standby activation, the user's shell-script (via the "Standby.py" algorithm) will not be run for the purpose of switching LG TV on / off. I haven't found out yet why (tested on OpenATV/Enigma only). So don't worry if the TV doesn't turn off after the set-top box is restarted (first standby activation, after rebooting the set top box). Try it again and then it will still work. 36 | 37 | If you are using a USB <> RS232 adapter, you can also find the serial port here: `/dev/ttyUSB[0123]` 38 | 39 | If the serial interface is built into a set-top box with an ARM chipset, then you can find the serial port here: `/dev/ttyAMA[0123]` 40 | -------------------------------------------------------------------------------- /LGTV-RS232/script_called_by_HDMI-CEC_plugin/TvOff.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # if directory does not exist, must be created the new one /usr/script/ 4 | # bash-script files must be located at this place: /usr/script/*.sh 5 | # new script files in your Enigma2 must to have a execution rights: $ chmod 755 /usr/script/*.sh 6 | 7 | # https://github.com/openatv/enigma2/blob/DEV/lib/python/Components/HdmiCec.py 8 | # https://www.opena.tv/english-section/32512-solution-standby-mode-lg-tv-hdmi-cec-simplink.html 9 | 10 | # shell command to Turning Off the LG-TV through RS232 interface: 11 | 12 | echo "ka 01 00" > /dev/ttyS0 13 | -------------------------------------------------------------------------------- /LGTV-RS232/script_called_by_HDMI-CEC_plugin/TvOn.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # if directory does not exist, must be created the new one /usr/script/ 4 | # bash-script files must be located at this place: /usr/script/*.sh 5 | # new script files in your Enigma2 must to have a execution rights: $ chmod 755 /usr/script/*.sh 6 | 7 | # https://github.com/openatv/enigma2/blob/DEV/lib/python/Components/HdmiCec.py 8 | # https://www.opena.tv/english-section/32512-solution-standby-mode-lg-tv-hdmi-cec-simplink.html 9 | 10 | # shell command to Turning On the LG-TV through RS232 interface: 11 | 12 | echo "ka 01 01" > /dev/ttyS0 13 | -------------------------------------------------------------------------------- /LGTV-RS232/script_called_by_Standby_mode/ATV/StandbyEnter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # if directory does not exist, must be created the new one /usr/script/ 4 | # bash-script files must be located at this place: /usr/script/*.sh 5 | # new script files in your Enigma2 must to have a execution rights: $ chmod 755 /usr/script/*.sh 6 | 7 | # https://github.com/openatv/enigma2/blob/DEV/lib/python/Screens/Standby.py 8 | # https://www.opena.tv/english-section/32512-solution-standby-mode-lg-tv-hdmi-cec-simplink.html 9 | 10 | # shell command to Turning Off the LG-TV through RS232 interface: 11 | 12 | echo "ka 01 00" > /dev/ttyS0 13 | -------------------------------------------------------------------------------- /LGTV-RS232/script_called_by_Standby_mode/ATV/StandbyLeave.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # if directory does not exist, must be created the new one /usr/script/ 4 | # bash-script files must be located at this place: /usr/script/*.sh 5 | # new script files in your Enigma2 must to have a execution rights: $ chmod 755 /usr/script/*.sh 6 | 7 | # https://github.com/openatv/enigma2/blob/DEV/lib/python/Screens/Standby.py 8 | # https://www.opena.tv/english-section/32512-solution-standby-mode-lg-tv-hdmi-cec-simplink.html 9 | 10 | # shell command to Turning On the LG-TV through RS232 interface: 11 | 12 | echo "ka 01 01" > /dev/ttyS0 13 | -------------------------------------------------------------------------------- /LGTV-RS232/script_called_by_Standby_mode/PLi/standby_enter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # if directory does not exist, must be created the new one /usr/script/ 4 | # bash-script files must be located at this place: /usr/script/*.sh 5 | # new script files in your Enigma2 must to have a execution rights: $ chmod 755 /usr/script/*.sh 6 | 7 | # https://github.com/OpenPLi/enigma2/blob/develop/lib/python/Screens/Standby.py 8 | # https://www.opena.tv/english-section/32512-solution-standby-mode-lg-tv-hdmi-cec-simplink.html 9 | 10 | # shell command to Turning Off the LG-TV through RS232 interface: 11 | 12 | echo "ka 01 00" > /dev/ttyS0 13 | -------------------------------------------------------------------------------- /LGTV-RS232/script_called_by_Standby_mode/PLi/standby_leave.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # if directory does not exist, must be created the new one /usr/script/ 4 | # bash-script files must be located at this place: /usr/script/*.sh 5 | # new script files in your Enigma2 must to have a execution rights: $ chmod 755 /usr/script/*.sh 6 | 7 | # https://github.com/OpenPLi/enigma2/blob/develop/lib/python/Screens/Standby.py 8 | # https://www.opena.tv/english-section/32512-solution-standby-mode-lg-tv-hdmi-cec-simplink.html 9 | 10 | # shell command to Turning On the LG-TV through RS232 interface: 11 | 12 | echo "ka 01 01" > /dev/ttyS0 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Simple scripts for Enigma 2, focused on OpenATV and OpenPLi. 2 | 3 | + **LGTV-RS232 directory** 4 | > - switching On and Off the LG TV via RS-232 interface 5 | 6 | + **softcam** 7 | > - OSCam or CCcam startup shell-scripts (Bash) '/etc/init.d/softcam' for Enigma2 based set-top-box 8 | > - it also records its activity to a temporary LOG-file 9 | > - more info can be found in the script 10 | > - if you need to use this script for CCcam, please use the following 'sed' command: 11 | ``` 12 | sed -i -e 's/oscam/cccam/I' -e 's/OSCam/CCcam/I' -e 's/-b -r 2/-stl/I' /etc/init.d/softcam 13 | ``` 14 | + **make_ipk_by_s3n0_for_ProjectXYZ.py** 15 | > - IPK creation tool for Enigma2, debugged and tested on OpenATV 16 | 17 | + **oscam-picons-converter.py** 18 | > - simple script to convert PNG picons to TPL picons - for the needs of Oscam Webif (Oscam WebGUI) 19 | > - TPL picon names are determined by srvid or srvid2 databases 20 | 21 | + **epg_refresh.py** 22 | > - simple python script for Enigma2 based set-top-box, for refresh EPG data on all DVB channels 23 | > - the script will find all the necessary transponders what you need to zapping 24 | > - transponders are selected from the userbouquet and zap only once 25 | > - the best way to use EPG refresh is to add a new task to the CRON scheduler ... be sure to set the file attributes (`chmod 755 /usr/script/epg_refresh.py`) ... for example, to run the python script every 2th day at 03:00, as the background process, use the following line: 26 | 27 | ``` 28 | 00 03 */2 * * /usr/bin/python /usr/script/epg_refresh.py > /dev/null 2>&1 29 | ``` 30 | 31 | + **backrest** 32 | > - simple bash script for backing up and restoring user-defined settings + files + folders in Enigma2 33 | > - disadvantage is the need to manually edit this script after each new feature is added to your Enigma (plugins, binary files, scripts, etc.) for full backup or restore 34 | 35 | + **oscam-new-version-updater.sh** 36 | > - script checks if there is a newer version on the internet and if so, updates the binary file extracted from the downloaded IPK package 37 | > - 7zip-full archiver is required since 'ar' tool is a problematic... the "ar" tool is in most cases a light version as part of [BusyBox](https://busybox.net/)... and this light version is insufficient when splitting files from IPK / DEB packages 38 | 39 | + **bouquetx.sh** 40 | > - shell script to download userbouquet file from internet and overwrite local userbouquet file, but only if there is a change in the file (tested for file content differences) 41 | > - script is based on regular reloading of services using OpenWebif interface (i.e. mode 0 and also mode 4) 42 | 43 | ... etc. 44 | -------------------------------------------------------------------------------- /_ipk_and_deb_maker_by_s3n0_for_ProjectXYZ.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # sh script for Enigma2 - the IPK package creation tool 4 | # 2018-2023, by s3n0 5 | # 6 | # Simple creation of an IPK package without the use of OPKG-TOOLS. 7 | # It's just a simple archiving of files or folders and then merging the created files into one. 8 | # 9 | # A note: 10 | # 11 | # The version of the plugin is taken from the "version.txt" file, which must always be present 12 | # in the same folder where the plugin is located. I also use it in the plugin's own algorithm. 13 | # 14 | # It is also important to edit the created "control" file below - in this script, according to the needs of your project / plugin ! 15 | 16 | 17 | 18 | 19 | #### specify the plugin folder, the plugin version, the package output path + package filename, etc. : 20 | 21 | PLUGIN_NAME="Project XYZ" 22 | 23 | PLUGIN_DIR="/usr/lib/enigma2/python/Plugins/Extensions/"`echo "${PLUGIN_NAME}" | tr -d " -"` # PLUGIN_NAME: delete all " " and "-" characters 24 | PLUGIN_LANG_DIR="${PLUGIN_DIR}/locale" 25 | 26 | PROJECT_DIR="/tmp/${RANDOM}" 27 | BUILD_DIR="/tmp/${RANDOM}" 28 | 29 | VER=$(cat "$PLUGIN_DIR/version.txt") # VER="1.0.0" 30 | ARCH="all" # chipset / CPU architecture dependency: all, mips32el, mipsel, armv7ahf-neon, cortexa15hf-neon-vfpv4, aarch64, ...etc. 31 | 32 | IPK_PCKGNAME="enigma2-plugin-extensions-"`echo "${PLUGIN_NAME,,}" | tr " " "-"` # PLUGIN_NAME: lower case, replace all spaces with "-" 33 | IPK_FILENAME="${IPK_PCKGNAME}_${VER}_${ARCH}.ipk" 34 | IPK_FINISHED="/tmp/${IPK_FILENAME}" 35 | 36 | # the description of the plugin will be extracted from the file "plugin.py": 37 | #PLUGIN_DESCRIPTION=$(awk '/def Plugins/,/\]\s\n/' $PLUGIN_DIR/plugin.py | grep -E 'description.*=' | sed -e 's/.*description\s\=\s["'\'']//' -e 's/["'\''].*//') 38 | # Warning : most Enigma2 distributions usually compile the found "*.pyo" files into "*.py" format after a restart and thus the possibility of getting the description from the "plugin.py" file is also lost! 39 | # if you don't want or don't use the plugin definition in the "plugin.py" file, you can use your own definition here, for example: 40 | PLUGIN_DESCRIPTION="Plugin for the needs of the Project XYZ tests" 41 | 42 | 43 | 44 | 45 | # ==== preinst ========= (before installing a package) ===== 46 | # This script executes before that package will be unpacked from its Debian archive (".deb/.ipk") file. 47 | # Many 'preinst' scripts stop services for packages which are being upgraded until their installation or 48 | # upgrade is completed (following the successful execution of the 'postinst' script). 49 | # 50 | # ==== postinst ======== (after installing a package) ====== 51 | # This script typically completes any required configuration of the package foo once foo has been unpacked from its Debian archive (".deb/.ipk") file. 52 | # Often, 'postinst' scripts ask the user for input, and/or warn the user that if he accepts default values, he should remember to go back and re-configure that package 53 | # as the situation warrants. Many 'postinst' scripts then execute any commands necessary to start or restart a service once a new package has been installed or upgraded. 54 | # 55 | # ==== prerm =========== (before removing a package) ======= 56 | # This script typically stops any daemons which are associated with a package. It is executed before the removal of files associated with the package. 57 | # 58 | # ==== postrm ========== (after removing a package) ======== 59 | # This script typically modifies links or other files associated with foo, and/or removes files created by the package. 60 | 61 | 62 | 63 | 64 | 65 | #### prepare the CONTROL folder and all neccessary shell scripts inside of this folder: 66 | rm -rf ${PROJECT_DIR} 67 | mkdir -p ${PROJECT_DIR} ${PROJECT_DIR}/CONTROL 68 | 69 | 70 | 71 | cat > ${PROJECT_DIR}/CONTROL/control << EOF 72 | Package: ${IPK_PCKGNAME} 73 | Version: ${VER} 74 | Description: ${PLUGIN_DESCRIPTION} 75 | Architecture: ${ARCH} 76 | Section: extra 77 | Priority: optional 78 | Maintainer: MY_NICKNAME_AS_EXAMPLE 79 | License: GPLv2 80 | Homepage: https://MY_WEBPAGE.EXAMPLE.COM 81 | EOF 82 | # For more info about other fields, see here: https://www.debian.org/doc/debian-policy/ch-controlfields.html ; https://www.systutorials.com/docs/linux/man/5-deb-control/ ; https://linux.die.net/man/5/deb-control 83 | 84 | cat > ${PROJECT_DIR}/CONTROL/postinst << EOF 85 | #!/bin/sh 86 | echo "*********************************************************" 87 | echo " ${PLUGIN_NAME} ${VER} " 88 | echo " Enigma2 plugin/extension " 89 | echo "*********************************************************" 90 | echo " Successfully INSTALLED. You should restart Enigma2 now. " 91 | echo "*********************************************************" 92 | exit 0 93 | EOF 94 | 95 | cat > ${PROJECT_DIR}/CONTROL/postrm << EOF 96 | #!/bin/sh 97 | [ "\$1" != "upgrade" ] || exit 0 > /dev/null 2>&1 # prevent the OE2.5+ based Enigma2 for deleting files when the package is "upgrading" 98 | rm -rf ${PLUGIN_DIR} 99 | echo "*********************************************************" 100 | echo " ${PLUGIN_NAME} ${VER} " 101 | echo " Enigma2 plugin/extension " 102 | echo "*********************************************************" 103 | echo " Successfully REMOVED. You should restart Enigma2 now. " 104 | echo "*********************************************************" 105 | exit 0 106 | EOF 107 | 108 | 109 | chmod a+x ${PROJECT_DIR}/CONTROL/* 110 | 111 | 112 | 113 | 114 | 115 | #### remove all comments from the source code 116 | #if [ -f /usr/script/remove_comments.sh ]; then 117 | # /usr/script/remove_comments.sh $PLUGIN_DIR/plugin.py 118 | # init 4; sleep 5; init 3; sleep 20 # restart Enigma - for recompile the source code again - after removing all comments from the source code file 119 | #fi 120 | 121 | 122 | 123 | 124 | #### translate language files from .PO to .MO format (Machine Object) 125 | #### if necessary, install the language translation tools: opkg install gettext 126 | msgfmt --help > /dev/null 2>&1 || opkg install gettext # if the translation tool fails to start, an attempt is made to install it 127 | msgfmt --help > /dev/null 2>&1 \ 128 | && { for f in `find $PLUGIN_LANG_DIR -name *.po`; do msgfmt -o ${f%.po}.mo $f; rm -f $f; done; } \ 129 | || echo -e "--- Warning ! \n--- The 'msgfmt' tool or the 'gettext' package does not exist. \n--- Unable to translate language '.po' files to '.mo' format." 130 | 131 | 132 | 133 | 134 | #### prepare a copy of $PLUGIN_DIR to $PROJECT_DIR 135 | mkdir -p ${PROJECT_DIR}/${PLUGIN_DIR} 136 | cp -rp ${PLUGIN_DIR}/* ${PROJECT_DIR}/${PLUGIN_DIR} 137 | 138 | #### prepare a copy of $ANOTHER_DIR to $PROJECT_DIR 139 | # ANOTHER_DIR="/etc/iptv" 140 | # mkdir -p ${PROJECT_DIR}/${ANOTHER_DIR} 141 | # cp -rp ${ANOTHER_DIR}/* ${PROJECT_DIR}/${ANOTHER_DIR} 142 | 143 | #### remove unnecessary files and folders 144 | rm -rf ${PROJECT_DIR}/${PLUGIN_DIR}/*.py # remove all source-code python files 145 | #rm -rf ${PROJECT_DIR}/${PLUGIN_DIR}/*.pyo # remove all compiled python files (bytecode files - optimized) 146 | #rm -rf ${PROJECT_DIR}/${PLUGIN_DIR}/*.pyc # remove all compiled python files (bytceode files) 147 | #rm -rf ${PROJECT_DIR}/${PLUGIN_DIR}/__pycache__ 148 | 149 | #### create archive files "control.tar.gz" and "data.tar.gz" + create the text file "debian-binary" in $BUILD_DIR 150 | mkdir -p ${BUILD_DIR} 151 | tar -C ${PROJECT_DIR} --exclude='CONTROL' -czf ${BUILD_DIR}/data.tar.gz . 152 | tar -C ${PROJECT_DIR}/CONTROL -czf ${BUILD_DIR}/control.tar.gz . 153 | echo -e "2.0" > ${BUILD_DIR}/debian-binary 154 | 155 | #### combining all three files together (into IPK package) 156 | #### using the "ar" archiver to merge all 3 files in the following order: 1) debian-binary 2) control.tar.gz 3) data.tar.gz 157 | cd ${BUILD_DIR} 158 | rm -f ${IPK_FINISHED} 159 | ar -r ${IPK_FINISHED} ./debian-binary ./control.tar.gz ./data.tar.gz 160 | 161 | 162 | 163 | 164 | #### make a copy of the .ipk file, but with a .deb extension 165 | #### replace "/" by " " character from the end of filenames inside the "ar" archive 166 | cp -f ${IPK_FINISHED} ${IPK_FINISHED%.ipk}.deb 167 | sed -i 's/debian-binary\//debian-binary /g' ${IPK_FINISHED%.ipk}.deb 168 | sed -i 's/control.tar.gz\//control.tar.gz /g' ${IPK_FINISHED%.ipk}.deb 169 | sed -i 's/data.tar.gz\//data.tar.gz /g' ${IPK_FINISHED%.ipk}.deb 170 | #replaceByte() { 171 | # printf "$(printf '\\x%02X' $3)" | dd of="$1" bs=1 seek=$2 count=1 conv=notrunc &> /dev/null 172 | #} #### USAGE: replaceByte "filename" offset byte 173 | #replaceByte "${IPK_FINISHED%.ipk}.deb" 21 32 174 | #replaceByte "${IPK_FINISHED%.ipk}.deb" 86 32 175 | #sed -i 's/data.tar.gz\//data.tar.gz /g' ${IPK_FINISHED%.ipk}.deb 176 | 177 | 178 | 179 | #### remove all temporary directories 180 | rm -rf ${PROJECT_DIR} ${BUILD_DIR} 181 | 182 | 183 | 184 | exit 185 | -------------------------------------------------------------------------------- /backrest: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | #################################################### 5 | # Backup & Restore 6 | # by s3n0, 2019-2024 7 | #################################################### 8 | # shell script for backing up and restoring user-defined files and folders in the Enigma2 9 | #################################################### 10 | 11 | 12 | #BACKUP_DIR="" # leave blank, i.e. empty folder -> means the current directory (specified by Linux-Shell / terminal) 13 | #BACKUP_DIR="/media/hdd/backrest_folder/" 14 | #BACKUP_DIR="/home/root/backrest_folder/" 15 | #BACKUP_DIR="/media/mmc/backrest_folder/" 16 | #BACKUP_DIR="/hdd/backrest_folder/" 17 | BACKUP_DIR="/tmp/backrest_folder/" 18 | 19 | ##### * WARNING !!! if you use the "/tmp" folder to backup, keep in mind that this is a TEMPORARY folder, created in the RAM-disk, 20 | ##### * so after restarting Linux, its contents will be deleted... therefore after backup, please temporarily copy the archive-file to your PC, 21 | ##### * and before restoring the data, copy the archive-file back to the backup subfolder in "/tmp" 22 | 23 | 24 | FILE_PREFIX="e2-backup" # Note: The timestamp is automatically added at the end of the file name (as a file sufix) + the file extension will be set to ".tar.gz" 25 | 26 | 27 | LIST=" 28 | /etc/enigma2/ 29 | 30 | /usr/share/enigma2/picon/ 31 | /media/hdd/picon/ 32 | /media/usb/picon/ 33 | /media/mmc/picon/ 34 | /media/mmc/picon-tpl/ 35 | 36 | /usr/share/enigma2/MetrixHD/skinparts/MetrixHD-infobar-mod-by-s3n0/ 37 | 38 | /etc/tuxbox/*.xml 39 | /etc/auto.network 40 | /etc/cron/crontabs/root 41 | 42 | /usr/script/ 43 | 44 | /usr/bin/enigma2_pre_start.sh 45 | 46 | /usr/bin/*cam* 47 | /etc/init.d/softcam* 48 | /etc/rc?.d/*softcam* 49 | /etc/tuxbox/config/ 50 | /etc/CCcam.cfg 51 | /usr/keys/ 52 | 53 | /usr/bin/udpxy 54 | /etc/init.d/udpxy 55 | /etc/rc?.d/*udpxy 56 | 57 | /etc/init.d/iptv_* 58 | /etc/rc?.d/*iptv_* 59 | " 60 | 61 | 62 | PLUGINS_TO_RESTORE=" 63 | enigma2-plugin-extensions-chocholousek-picons 64 | enigma2-plugin-extensions-youtube 65 | enigma2-plugin-skins-metrix-atv-fhd-icons 66 | enigma2-plugin-systemplugins-fastscan 67 | enigma2-plugin-systemplugins-serviceapp 68 | exteplayer3 69 | zerotier 70 | curl 71 | curlftpfs 72 | htop 73 | " 74 | 75 | 76 | 77 | 78 | LIST=$(echo $LIST | tr "\n" " ") 79 | 80 | PLUGINS_TO_RESTORE=$(echo $PLUGINS_TO_RESTORE | tr "\n" " ") 81 | 82 | 83 | 84 | 85 | #################################################### 86 | #################################################### 87 | 88 | init_4_with_feedback() { 89 | echo "Stopping the Enigma..." 90 | init 4 91 | x=0 92 | while [ "$x" -le 15 ] && [ $(pidof enigma2) ] ; do 93 | x=$(( $x + 1 )) 94 | sleep 1 95 | echo "...$x seconds waiting" 96 | #echo "...Enigma state = "`ps --no-headers -o stat -C enigma2` # debugging output - for testing purpose only 97 | done 98 | if pidof enigma2 > /dev/null 2>&1 ; then 99 | echo "...stopping failed ! the 'backrest' script was aborted !" 100 | exit 1 101 | else 102 | echo "...successfully stopped after $x seconds." 103 | fi 104 | } 105 | 106 | init_3_with_feedback() { 107 | echo "Starting the Enigma..." 108 | init 3 109 | x=0 110 | while [ "$x" -le 120 ] && [ -z "$(timeout 1 wget -q -O - http://127.0.0.1/web/powerstate)" ] ; do 111 | x=$(( $x + 1 )) 112 | sleep 1 113 | echo "...$x seconds waiting" 114 | done 115 | echo "...+5 seconds of additional waiting (other Enigma2 modules such as OpenWebif take a long time to start)" 116 | sleep 5; x=$(( $x + 5 )) 117 | echo "...successfully started after $x seconds." 118 | } 119 | 120 | do_backup() { 121 | echo "-----------------------" 122 | if [ "$1" != "quickly" ]; then # ignoring the init command to start or stop the Enigma2, if the user choice was '--backup-quickly' argument 123 | # store the Standby power state when the script starts: 5 = to turn the Enigma2 into Standby , 4 = to wake-up the Enigma2 from Standby 124 | wget -q -O - http://127.0.0.1/api/powerstate | grep -iqE '"instandby"\s*:\s*true' && previous_power_state=5 || previous_power_state=4 125 | init_4_with_feedback 126 | echo "-----------------------" 127 | fi 128 | mkdir -p /tmp/backrest_temp 129 | BCKP_FILE_TMP="/tmp/backrest_temp/${FILE_PREFIX}_`date '+%Y-%m-%d_%H-%M-%S'`.tar.gz" 130 | BCKP_FILE_TARGET="${BACKUP_DIR}${FILE_PREFIX}_`date '+%Y-%m-%d_%H-%M-%S'`.tar.gz" 131 | echo "Output archive file name: " 132 | echo " TMP: ${BCKP_FILE_TMP} " 133 | echo " FINAL: ${BCKP_FILE_TARGET}" 134 | echo "-----------------------" 135 | echo "Files and folders to compress:" 136 | echo " LIST: ${LIST}" 137 | echo "-----------------------" 138 | echo "Starting compression..." 139 | [ -z "$BACKUP_DIR" ] || mkdir -p $BACKUP_DIR 140 | #tar --ignore-failed-read --exclude='/etc/enigma2/epg.dat' -czpf $BACKUP_FILENAME $LIST # --ignore-failed-read ...... is unfortunately a unknown argument in `tar` under OpenPLi 7.1 141 | tar --exclude='/etc/enigma2/epg.dat' --exclude='/hdd/epg.dat' --exclude='/media/hdd/epg.dat' -czpf $BCKP_FILE_TMP $LIST 142 | mv -f $BCKP_FILE_TMP $BCKP_FILE_TARGET 143 | echo "...compression done." # [ $? -eq 0 ] && echo "...done." || echo "...failed ! (exit code = $?)" 144 | echo "-----------------------" 145 | echo "List of files in the backup directory:" 146 | ls -l "${BACKUP_DIR}${FILE_PREFIX}"* 147 | echo "-----------------------" 148 | if [ "$1" != "quickly" ]; then # ignoring the init command to start or stop the Enigma2, if the user choice was '--backup-quickly' argument 149 | init_3_with_feedback 150 | echo "Force the Enigma power to its original state : $([ $previous_power_state = 5 ] && echo 'turn the Enigma2 into Standby' || echo 'wake-up the Enigma2 from Standby')" 151 | wget -q -O - http://127.0.0.1/api/powerstate?newstate=$previous_power_state > /dev/null 2>&1 152 | echo "-----------------------" 153 | fi 154 | rm -rf /tmp/backrest_temp 155 | } 156 | 157 | do_restore() { 158 | echo "-----------------------" 159 | if ls "${BACKUP_DIR}${FILE_PREFIX}"*.tar.gz > /dev/null 2>&1 ; then 160 | LATEST_FILE=$(ls -1 "${BACKUP_DIR}${FILE_PREFIX}"*.tar.gz | tail -n 1) 161 | init_4_with_feedback 162 | echo "-----------------------" 163 | echo "The latest archive file found in the directory:" 164 | echo " ${LATEST_FILE}" 165 | echo "-----------------------" 166 | echo "Installing required plugins..." 167 | opkg update > /dev/null 2>&1 168 | opkg install $PLUGINS_TO_RESTORE 169 | echo "...done." 170 | echo "-----------------------" 171 | echo "Starting decompression..." 172 | tar -C / --overwrite -xzphf $LATEST_FILE 173 | echo "...done." 174 | echo "-----------------------" 175 | if [ -d "/usr/script" ]; then 176 | echo "Setting the execution rights (attributes) on all files from the '/usr/script' folder." 177 | chmod a+x /usr/script/* 178 | echo "...done." 179 | echo "-----------------------" 180 | fi 181 | echo "Restarting the set-top box..." 182 | echo "(sending the 'init 6' command)" 183 | init 6 184 | echo "...done." 185 | echo "-----------------------" 186 | else 187 | echo "ERROR! No archive files ${FILE_PREFIX}*.tar.gz found in the ${BACKUP_DIR} directory!" 188 | echo "-----------------------" 189 | exit 1 190 | fi 191 | } 192 | 193 | 194 | 195 | #################################################### 196 | #################################################### 197 | 198 | 199 | 200 | case "$1" in 201 | b|backup|-b|--backup) 202 | do_backup "normal" 203 | ;; 204 | bq|backup-quickly|-bq|--backup-quickly) 205 | do_backup "quickly" 206 | ;; 207 | r|restore|-r|--restore) 208 | do_restore 209 | ;; 210 | *) 211 | echo -e "\nUSAGE:" 212 | echo -e "\t $0 " 213 | echo -e "ARGUMENT:" 214 | echo -e "\t b|backup|-b|--backup" 215 | echo -e "\t\t ...backup user-defined files & folders (Enigma will be stopped during the backup process)" 216 | echo -e "\t bq|backup-quickly|-bq|--backup-quickly" 217 | echo -e "\t\t ...backup user-defined files & folders (Enigma will not be stopped during the backup process)" 218 | echo -e "\t r|restore|-r|--restore" 219 | echo -e "\t\t ...restore user-defined files & folders - latest archive found in directory (set-top-box will restarted !!!)" 220 | echo -e "BACKUP DIR:" 221 | [ -z "$BACKUP_DIR" ] && echo -e "\t $(pwd) (as the current directory)" || echo -e "\t ${BACKUP_DIR}" 222 | ;; 223 | esac 224 | 225 | 226 | 227 | 228 | exit 0 229 | -------------------------------------------------------------------------------- /bouquetx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | #### shell-script to download userbouquet file from the internet, and then overwrite local userbouquet file - if both files are different (tested for file content differences) 5 | 6 | 7 | #### it isn't based on "init 4" and "init 3" commands to fast restart of Enigma2 (as the most reliable method for all Enigma distributions), 8 | #### but it is based on the OpenWebif reload services !!! 9 | 10 | 11 | #### CRON config example - check and download new userbouquet file - every day, at 05:15 : 12 | #### 15 05 * * * /bin/sh -c "/usr/script/bouquetx.sh download" 13 | 14 | 15 | 16 | 17 | fname="userbouquet.iptv-example.tv" 18 | bq_file_local="/etc/enigma2/${fname}" 19 | bq_file_online="http://example.com/iptv/${fname}" # bq_file_online="http://example.com/iptv/some.file.name.tv" 20 | tmp_file="/tmp/${fname}" # temporary file for downloading the online file and to compare with the local file 21 | log_file="/tmp/bouquetx.log" # log_file="/home/root/bouquetx.log" 22 | log_file_sizemax=65000 # max log_file size [Bytes] 23 | bq_entry="#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET \"$fname\" ORDER BY bouquet" 24 | 25 | 26 | help_msg=" 27 | USAGE: 28 | $0 install ......... to install the userbouquet file into the Enigma2 bouquet favorite list (/etc/enigma2/bouquets.tv) 29 | $0 uninstall ....... to uninstall the userbouquet file from the Enigma2 bouquet favorite list (/etc/enigma2/bouquets.tv) 30 | $0 download ........ to download the new userbouquet file + replace if there is a newer version online 31 | " 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | # function to logging 41 | fLog() 42 | { 43 | if [ "${1:0:3}" = "===" ]; then # if echo "$1" | grep -q "==="; then 44 | logmsg="$1" 45 | else 46 | logmsg=$(echo "$1" | sed "s/^/`date '+%Y-%m-%d %H:%M:%S'` /") # add a timestamp to each line of input argument (it can be a multiline string) 47 | fi 48 | 49 | #echo "$logmsg" > /dev/null ### null device <--- log will disabled (do nothing) 50 | #echo "$logmsg" >> $log_file ### file 51 | #echo "$logmsg" >> $log_file 2>&1 ### file + stderr 52 | #echo "$logmsg" | tee -a $log_file ### file + stdout(display) 53 | echo "$logmsg" 2>&1 | tee -a $log_file ### file + stdout(display) + stderr 54 | 55 | # reduction the log filesize, if neccessary (delete first 20 lines): 56 | if [ -f "$log_file" ] && [ $(wc -c <"$log_file") -gt $log_file_sizemax ]; then sed -i -e '1,20d' "$log_file"; fi 57 | } 58 | 59 | 60 | # function to detect the standby mode (e2/OpenWebif power-state) 61 | is_standby() { 62 | [ "$(wget -q -O - http://127.0.0.1/web/powerstate | grep '' | cut -f 1)" = "true" ] 63 | } 64 | 65 | 66 | # reload userbouquets, lamedb, blacklist in the Enigma2 (mode 0 as well as 4 - both modes are required for correct reload services !) 67 | services_reload() { 68 | wget -q -O - "http://127.0.0.1/web/servicelistreload?mode=0" > /dev/null 2>&1 # reloading: userbouquet.*.tv ; userbouquets.tv ; lamedb 69 | sleep 1 70 | wget -q -O - "http://127.0.0.1/web/servicelistreload?mode=4" > /dev/null 2>&1 # reloading: blacklist ; whitelist 71 | fLog "service lists was reloaded in your Enigma (userbouquet.*.tv / .radio , userbouquets.tv , lamedb)" 72 | } 73 | 74 | 75 | # download and replace the userbouquet file - only if there is a newer version online 76 | download_replace_userbouquet() { 77 | rm -f $tmp_file 78 | 79 | if wget -q -O $tmp_file "$bq_file_online" > /dev/null 2>&1; then 80 | fLog "$bq_file_online file was downloaded" 81 | else 82 | fLog "$bq_file_online file download failed !" 83 | fi 84 | 85 | if [ -f "$tmp_file" ] && diff -aw $tmp_file $bq_file_local > /dev/null 2>&1; then 86 | fLog "$bq_file_local file was not replaced (the content of the files is the same)" 87 | else 88 | mv -f $tmp_file $bq_file_local 89 | fLog "$bq_file_local file was replaced" 90 | fi 91 | } 92 | 93 | 94 | case "$1" in 95 | install) 96 | if ! cat /etc/enigma2/bouquets.tv | grep -w "$bq_entry" > /dev/null; then 97 | sed -i "1 a $bq_entry" /etc/enigma2/bouquets.tv 98 | [ -f $bq_file_local ] || touch $bq_file_local # create an empty userbouquet file - if the file does not exist 99 | download_replace_userbouquet 100 | services_reload 101 | fi 102 | ;; 103 | uninstall) 104 | sed -i "/$bq_entry/d" /etc/enigma2/bouquets.tv 105 | rm -f $bq_file_local 106 | services_reload 107 | ;; 108 | download) 109 | if is_standby; then # only if the Enigma is in standby, then... 110 | download_replace_userbouquet 111 | services_reload 112 | else 113 | fLog "Enigma2 is not in standby mode - download function was canceled" 114 | fi 115 | ;; 116 | *) 117 | echo "$help_msg" 118 | ;; 119 | esac 120 | 121 | 122 | rm -f $tmp_file 123 | fLog "===========================================" 124 | 125 | 126 | exit 0 127 | -------------------------------------------------------------------------------- /epg_download.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | #### CRON config example - download epg.dat file, every day, at 5:00 5 | #### 00 5 * * * /bin/sh /usr/script/epg_download.sh 6 | 7 | 8 | online_file="http://example.com/iptv/epg.dat" # online server with the "epg.dat" stored file 9 | local_file="/etc/enigma2/epg.dat" 10 | log_file="/tmp/epg_download.log" 11 | tmp_file="/tmp/e" 12 | 13 | 14 | #if [ "$(wget -q -O - http://127.0.0.1/web/powerstate | grep '' | cut -f 1)" == "false" ]; then 15 | # echo `date '+%Y-%m-%d %H:%M:%S'`": Enigma2 is not in Standby. EPG-file downloading script was canceled." >> $log_file 16 | # exit 0 17 | #fi 18 | 19 | 20 | if wget --spider ${online_file} 2>/dev/null; then # check the existence of an online file 21 | if wget -q -O $tmp_file "$online_file" > /dev/null 2>&1 && [ "$(wc -c < $tmp_file)" != "$(wc -c < $local_file)" ]; then 22 | mv -f $tmp_file $local_file 23 | wget -q -O - "http://127.0.0.1/web/loadepg" > /dev/null 2>&1 # reload epg.dat file - using the Enigma2 Open-Webif 24 | echo `date '+%Y-%m-%d %H:%M:%S'`": $online_file file was downloaded, replaced and reloaded in your Enigma2" >> $log_file 25 | else 26 | echo `date '+%Y-%m-%d %H:%M:%S'`": $online_file file was downloaded, but not replaced (it is the same file size as local file in Enigma2)" >> $log_file 27 | fi 28 | rm -f $tmp_file 29 | else 30 | echo `date '+%Y-%m-%d %H:%M:%S'`": $online_file file was not found !" >> $log_file 31 | fi 32 | 33 | 34 | exit 0 35 | -------------------------------------------------------------------------------- /epg_refresh.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | ############################################### 5 | # EPG Refresh - python script for Enigma2 6 | # written by s3n0, 2019-2023 7 | ############################################### 8 | # - simple python-script (Python 2.x.x / 3.x.x.) for Enigma2 based set-top-box, for refresh EPG data 9 | # - the script will find the necessary transponders depending on the available channels in the userbouquet files 10 | # - then the script gradually zaps these transponders (only some channels), to read EPG data from DVB stream 11 | ############################################### 12 | # - be sure to set the file attributes (chmod 755 /usr/script/epg_refresh.py) 13 | # - the best way to use EPG refresh is to add a new task to the CRON scheduler 14 | # - for example, to run the python script every 2nd day, at 03:00, as the background process, use the following crontab line: 15 | # 00 03 */2 * * /usr/bin/python /usr/script/epg_refresh.py > /dev/null 2>&1 16 | # - to verify the correct timing of the command in the CRON configuration, you can use the following website: https://crontab.guru/ 17 | ############################################### 18 | 19 | #### change the path to your own userbouquet file(s), containing the satellite channels, for which you want to refresh EPG data : 20 | BOUQUET_FILES = ['userbouquet.sat-skylink-sk-komplet-vcetne-cz.tv'] 21 | #BOUQUET_FILES = ['userbouquet.sat-skylink-sk-komplet-vcetne-cz.tv', 'userbouquet.sat-skylink-vhannibal.tv'] 22 | #BOUQUET_FILES = ['userbouquet.skylink.tv', 'userbouquet.freesat.tv', 'userbouquet.orange.tv'] 23 | 24 | LOG_FILE_PATH = '/tmp/epg_refresh.log' # epg_refresh log (path to directory + file name) 25 | 26 | DELAY_TIME = 15 # waiting time after zapping each channel (transponder) 27 | 28 | ############################################### 29 | 30 | from datetime import datetime 31 | from time import sleep 32 | from os.path import getsize as os_path_getsize 33 | 34 | from sys import version_info as py_version 35 | if py_version.major == 3: # data of this object type: sys.version_info(major=3, minor=8, micro=5, releaselevel='final', serial=0) 36 | import urllib.request as urllib2 37 | else: 38 | import urllib2 39 | 40 | ############################################### 41 | 42 | def writeLOG(msg): 43 | print(msg) 44 | with open(LOG_FILE_PATH, 'a') as f: 45 | f.write('[ %s ] %s\n' % (datetime.now().strftime("%Y-%m-%d %H:%M:%S"), msg)) 46 | if os_path_getsize(LOG_FILE_PATH) > 255000: # [Bytes] - maximum allowed file size 47 | with open(LOG_FILE_PATH, 'r') as f: 48 | cache = f.readlines() 49 | with open(LOG_FILE_PATH, 'w') as f: 50 | f.writelines( cache[ len(cache)/2 : ] ) 51 | 52 | def enigmaInStandby(): # checking standby mode (using the Enigma2 Open-Webif) 53 | response = urllib2.urlopen('http://127.0.0.1/web/powerstate') 54 | web_content = response.read() 55 | if isinstance(web_content, bytes): 56 | web_content = web_content.decode() 57 | if 'true' in web_content.lower(): 58 | return True 59 | else: 60 | writeLOG("Enigma2 is not switched to standby mode. The script 'epg_refresh.py' will be canceled.") 61 | return False 62 | 63 | def saveEPG(): # save EPG cache to disk - as the file "epg.dat" (using the Enigma2 Open-Webif) 64 | response = urllib2.urlopen('http://127.0.0.1/web/saveepg') 65 | web_content = response.read() 66 | if isinstance(web_content, bytes): 67 | web_content = web_content.decode() 68 | if 'true' in web_content.lower(): 69 | writeLOG("...saving the EPG file to disk was successful") 70 | else: 71 | writeLOG("...ERROR ! saving the EPG file to disk failed !") 72 | 73 | def zapChannel(src='0:0:0:0:0:0:0:0:0:0:'): # zap channel (using the Enigma2 Open-Webif) 74 | response = urllib2.urlopen('http://127.0.0.1/web/zap?sRef=' + src) 75 | web_content = response.read() 76 | # !!!! OpenWebif - usually returns "true" after any zapped SRC / channel (either if the channel does not exist !) !!!! 77 | 78 | def findChannelName(src='0:0:0:0:0:0:0:0:0:0:'): 79 | # index................... 0 1 2 3 4 5 6 7 8 9 80 | # userbouquet SRC ======= ServSource : 0 : ServType[hex] : SID : TID : NID : NameSpace : 0:0:0: ==> example for Markiza channel (2022-May) = 1:0:19:3731:C8E:3:EB0000:0:0:0: 81 | ch_name = "UNKNOWN!" 82 | src = src.split(":") 83 | # lameDB stream data === SID : NameSpace : TID : NID : ServType[dec] 84 | match = ":".join(( src[3].rjust(4,"0") , src[6].rjust(8,"0") , src[4].rjust(4,"0") , src[5].rjust(4,"0") , str(int(src[2],16)) )).upper() 85 | for i, line in enumerate(LAME_DB, 0): 86 | if line.upper().startswith(match): 87 | ch_name = LAME_DB[ i + 1 ] 88 | break 89 | return ch_name 90 | 91 | ############################################### 92 | ############################################### 93 | 94 | writeLOG(' ') 95 | writeLOG('==== BEGINNING OF THE SCRIPT ' + '=' * 44) 96 | 97 | if __name__ == "__main__" and enigmaInStandby(): 98 | 99 | with open('/etc/enigma2/lamedb', 'r') as f: 100 | LAME_DB = f.read().split('services')[2].splitlines() 101 | 102 | bouquet_SRC = [] 103 | for fname in BOUQUET_FILES: 104 | with open('/etc/enigma2/' + fname, 'r') as f: 105 | bouquet_data = f.read().upper().split('\n') 106 | # remove all lines startswith '#NAME', '#SERVICE 1:64', '#DESCRIPTION' 107 | # and take the values from index 9 to right side, i.e. lines without the prefix '#SERVICE ' and also without the URL link (http: ..... string) if does it exist 108 | refs = [':'.join(s[9:].split(':')[0:10]) + ':' for s in bouquet_data if not (s.startswith('#NAME') or s.startswith('#SERVICE 1:64') or s.startswith('#DESCR'))] 109 | bouquet_SRC += refs[:-1] # the last entry ':' in the list variable must to be removed (created in the for-loop before) 110 | 111 | with open('/etc/enigma2/blacklist', 'r') as f: 112 | blacklist_data = f.read().upper().split('\n') 113 | blacklist_SRC = [':'.join(k.split(':')[0:10]) + ':' for k in blacklist_data][:-1] # remove all http:// and other unwanted text from the end of lines 114 | 115 | needs_SRC = [] 116 | for SRC in bouquet_SRC: 117 | # --- bouquet format for ServRefCode = service_type : 0 : service_quality : ServiceID : TransponderID : NetworkID : Namespace : 0 : 0 : 0 : 118 | # --- index of the ServRefCode (fields) = 0 1 2 3 4 5 6 7 8 9 119 | # --- real example of the SRC variable = '1:0:16:3725:C8E:3:EB0000:0:0:0:' 120 | fields = SRC.split(':') 121 | if ':%s:%s:%s:' % tuple(fields[4:7]) not in ''.join(needs_SRC): # if *:TransponderID:NetworkID:NameSpace:* is not in the needs_SRC list, then add the item to needs_SRC list 122 | if SRC not in blacklist_SRC: 123 | needs_SRC.append(SRC) 124 | 125 | writeLOG('Number of transponders to tune: %s' % len(needs_SRC)) 126 | writeLOG('Zapping the neccessary transponders...') 127 | 128 | i = 0 129 | imax = len(needs_SRC) 130 | while enigmaInStandby() and i < imax: # if enigma2 is lasting at the standby mode, the tuner zapping will continue... (otherwise the while-loop will be aborted) 131 | zapChannel(needs_SRC[i]) 132 | writeLOG('{:03d} / {:03d} | {} | {}'.format(i + 1, imax, needs_SRC[i], findChannelName(needs_SRC[i]))) 133 | sleep(DELAY_TIME) # waiting a few of seconds - for receiving and retrieving all EPG data from the stream (from the currently tuned transponder) 134 | i += 1 135 | 136 | if i == imax: # if enigma2 was not interrupted from standby, the script will be completed and the DVB tuner will be turned off 137 | zapChannel() # shut down the tuner (stopping the received DVB signal) 138 | saveEPG() # save EPG cache to disk, if we need to upload the file "epg.dat" to another set-top box or to some server on the internet 139 | else: 140 | writeLOG('...Enigma2 is no longer in standby... script execution was interrupted') 141 | 142 | writeLOG('...done.') 143 | 144 | writeLOG('==== END OF THE SCRIPT ' + '=' * 50) 145 | -------------------------------------------------------------------------------- /epg_upload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | #### CRON config example - upload epg.dat file via the script, every 2nd day, at 03:00 5 | #### 00 03 */2 * * /bin/sh /usr/script/epg_upload.sh 6 | 7 | 8 | 9 | # enigma2 folders: 10 | log_file="/tmp/epg_upload.log" 11 | local_file="/etc/enigma2/epg.dat" 12 | 13 | # online web-server (ftp connection) to store the epg.dat file: 14 | online_file="ftp://example.com/folder/epg.dat" 15 | xuser="user_login" 16 | xpass="user_password" 17 | 18 | 19 | 20 | # for sure I will test the functionality and presence of the necessary "curl" in the system! 21 | if [ ! "$(curl --version)" ] 22 | then 23 | echo `date '+%Y-%m-%d %H:%M:%S'`": curl command NOT found (NOT installed)... please install it first: opkg update && opkg install curl" >> $log_file 24 | exit 0 25 | fi 26 | 27 | 28 | 29 | # I will only upload the $local_file (EPG data) only if exists and is greater than 65 kB 30 | #wget -q -O - "http://127.0.0.1/web/saveepg" > /dev/null 2>&1 # save epg.dat file to disk - using the Enigma2 Open-Webif 31 | if [ -f "$local_file" ] && [ $(wc -c < "$local_file") -gt 65000 ]; then # -gt = GreaterThan # -lt = LesserThan 32 | curl --insecure --ftp-ssl -u $xuser:$xpass -T $local_file $online_file 33 | echo `date '+%Y-%m-%d %H:%M:%S'`": $local_file file was uploaded" >> $log_file 34 | else 35 | echo `date '+%Y-%m-%d %H:%M:%S'`": $local_file file to upload is too small or not found" >> $log_file 36 | fi 37 | 38 | 39 | exit 0 40 | -------------------------------------------------------------------------------- /opkg-ext.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | 4 | ############################################################################################## 5 | #### - python script is intended for easier search of installation packages, on feed servers from specific Enigma2 distributions 6 | #### - therefore, it is also necessary to occasionally update the source URLs in this script, i.e. according to the currently released firmware version - for a specific Enigma2 7 | #### - this python script is compatible with both PY2 and PY3 8 | #### - written by s3n0, 2019-2025 9 | ############################################################################################## 10 | 11 | 12 | from __future__ import print_function 13 | 14 | import os 15 | import sys 16 | if sys.version_info.major == 3: # data of this object type, as example: sys.version_info(major=3, minor=10, micro=1, releaselevel='final', serial=0) 17 | import urllib.request as urllib2 18 | else: 19 | import urllib2 20 | import ssl # I use the SSL module for unverified connections with the urllib2 module, due to problems with SSL certificates 21 | ssl._create_default_https_context = ssl._create_unverified_context # this will ensure downloading from the Internet without SSL-key verification as default, for all open HTTPS websites 22 | 23 | 24 | ################################# FEEDS variable format: ##################################### 25 | #### 26 | #### ----atv # Enigma2 distribution shortcut for your database (4 x minus/dash character + the Enigma2 distribution shortcut) 27 | #### 28 | #### 29 | #### http.......Packages.gz # if the line starts with "http" and ends with "Packages.gz" - it means to download + browse the only one package-list (directly) 30 | #### 31 | #### 32 | #### # blank lines are also allowed ! they will ignored :-) 33 | #### 34 | #### 35 | #### http.........../ # if the line starts with "http" and ends with the "/" (slash character), then the following additional sub-directories (sub-feeds) are assumed... 36 | #### # ...and the following assumed sub-feeds (sub-folders) will be added after the previous URL (source feed URL) 37 | #### # ...and also then the string "/Packages.gz" will be added at the end of the whole URL (whole line) 38 | #### armv7ahf-neon # example 1 - of assumed sub-directory (sub-feed) 39 | #### mips32el # example 2 - of assumed sub-directory (sub-feed) 40 | #### vusolo # example 3 - of assumed sub-directory (sub-feed) 41 | #### 42 | #### 43 | #### 44 | #### ----END # end of your database (4 x minus/dash character + the string END) 45 | #### 46 | ############################################################################################## 47 | 48 | 49 | 50 | FEEDS = """ 51 | 52 | 53 | 54 | ----pli 55 | 56 | 57 | http://taapat.ho.ua/openpli/openpli-5/sh4/Packages.gz 58 | 59 | 60 | 61 | http://downloads.openpli.org/feeds/openpli-8-release/ 62 | 63 | all 64 | 65 | mips32el 66 | 3rd-party-mips32el 67 | 68 | vusolose 69 | 3rd-party-vusolose 70 | 71 | et8000 72 | 3rd-party-et8000 73 | 74 | et6x00 75 | 3rd-party-et6x00 76 | 77 | armv7ahf-neon 78 | 3rd-party-armv7ahf-neon 79 | 80 | armv7vehf-neon-vfpv4 81 | cortexa7hf-vfp 82 | 83 | cortexa15hf-neon-vfpv4 84 | 3rd-party-cortexa15hf-neon-vfpv4 85 | 86 | aarch64 87 | 3rd-party-aarch64 88 | 89 | 90 | 91 | 92 | http://downloads.openpli.org/feeds/openpli-9-release/ 93 | 94 | all 95 | 96 | mips32el 97 | 3rd-party-mips32el 98 | 99 | vusolose 100 | 3rd-party-vusolose 101 | 102 | et8000 103 | 3rd-party-et8000 104 | 105 | et6x00 106 | 3rd-party-et6x00 107 | 108 | armv7ahf-neon 109 | 3rd-party-armv7ahf-neon 110 | 111 | armv7vehf-neon-vfpv4 112 | cortexa7hf-vfp 113 | 114 | cortexa15hf-neon-vfpv4 115 | 3rd-party-cortexa15hf-neon-vfpv4 116 | 117 | aarch64 118 | 3rd-party-aarch64 119 | 120 | 121 | 122 | 123 | 124 | ----atv 125 | 126 | http://feeds2.mynonpublic.com/7.5.1/ 127 | formuler4turbo/mips32el 128 | formuler4turbo/all 129 | formuler4turbo/3rdparty 130 | formuler4turbo/formuler4turbo_3rdparty 131 | formuler4turbo/formuler4turbo 132 | 133 | vuzero4k/cortexa15hf-neon-vfpv4 134 | vuzero4k/all 135 | vuzero4k/3rdparty 136 | vuzero4k/vuzero4k_3rdparty 137 | vuzero4k/vuzero4k 138 | 139 | http://feeds2.mynonpublic.com/7.4/ 140 | formuler4turbo/mips32el 141 | formuler4turbo/all 142 | formuler4turbo/3rdparty 143 | formuler4turbo/formuler4turbo_3rdparty 144 | formuler4turbo/formuler4turbo 145 | 146 | vuzero4k/cortexa15hf-neon-vfpv4 147 | vuzero4k/all 148 | vuzero4k/3rdparty 149 | vuzero4k/vuzero4k_3rdparty 150 | vuzero4k/vuzero4k 151 | 152 | http://feeds2.mynonpublic.com/6.4/ 153 | spark/sh4 154 | spark/spark 155 | spark/spark_3rdparty 156 | 157 | http://updates.mynonpublic.com/oea/4.4/ 158 | mips32el 159 | cortexa15hf-neon-vfpv4 160 | sh4 161 | 162 | http://updates.mynonpublic.com/oea/4.3/aarch64/Packages.gz 163 | 164 | 165 | 166 | 167 | 168 | ----pure2 169 | 170 | http://pur-e2.club/OU/ 171 | 6.2/3rdparty 172 | 6.3/extra-aarch64 173 | 6.5/3rdparty 174 | 175 | 6.5/vusolo/vusolo 176 | 6.5/vusolo/all 177 | 6.5/vusolo/mips32el 178 | 179 | 6.5/vuzero4k/vuzero4k 180 | 6.5/vuzero4k/all 181 | 6.5/vuzero4k/cortexa15hf-neon-vfpv4 182 | 183 | 6.5/amikoalien/amikoalien 184 | 6.5/amikoalien/all 185 | 6.5/amikoalien/sh4 186 | 187 | http://pur-e2.club/cam/6.2/aarch64/Packages.gz 188 | 189 | 190 | 191 | 192 | ----nn2 193 | 194 | https://feed.newnigma2.to/weekly/oe2.0/ipk/ 195 | mips32el 196 | mips32el-nf 197 | 198 | 199 | 200 | 201 | ----openeight-arm 202 | 203 | http://feed.openeight.de/6.8/ 204 | sf8008/all 205 | sf8008/cortexa15hf-neon-vfpv4 206 | sf8008/sf8008 207 | sf8008/3rdparty 208 | sf8008/sf8008_3rdparty 209 | http://openeight.dyndns.tv/armv7/Packages.gz 210 | 211 | 212 | 213 | 214 | ----entware 215 | 216 | http://bin.entware.net/ 217 | armv7sf-k2.6 218 | armv7sf-k3.2 219 | mipselsf-k3.4 220 | 221 | 222 | 223 | 224 | ----satdreamgr 225 | 226 | http://188.165.252.42/feeds/satdreamgr-10/ 227 | mips32el 228 | armv7ahf-neon 229 | all 230 | vusolo2 231 | sf4008 232 | sf8008 233 | vuzero4k 234 | 235 | http://188.165.252.42/feeds/ 236 | satdreamgr-extra 237 | satdreamgr-extra-aarch64 238 | satdreamgr-extra-vuzero4k 239 | satdreamgr-extra-osmio4k 240 | 241 | http://188.165.252.42/feeds/3rd-party/Packages.gz 242 | 243 | 244 | 245 | ----END 246 | """ 247 | 248 | 249 | FEEDS = FEEDS.splitlines() 250 | 251 | FEEDS = [s.strip() for s in FEEDS if s.strip() != ''] 252 | 253 | ############################################################################################### 254 | 255 | def downloadFile(url, targetfile): 256 | header = { 'User-Agent' : 'Mozilla/5.0 (X11; Linux i686; rv:110.0) Gecko/20100101 Firefox/110.0' } # pre stiahnutie obrazkovych suborov z internetu musim zmenit UserAgent-a v requestovacej hlavicke, nakolko niektore webstranky nedovoluju stahovat obrazky urllib2 klientovi, ktory sa pouziva v module Python jazyka 257 | try: 258 | req = urllib2.Request(url, None, header) 259 | content = urllib2.urlopen(req).read() 260 | with open(targetfile, 'wb') as f: 261 | f.write(content) 262 | print('%s - DOWNLOADED' % (url,)) 263 | except urllib2.HTTPError as e: 264 | print("HTTP Error: ", e, url) 265 | return False 266 | except urllib2.URLError as e: 267 | print("URL Error: ", e, url) 268 | return False 269 | except IOError as e: 270 | print("I/O Error: ", e, targetfile) 271 | return False 272 | except Exception as e: 273 | print("Another error: ", e, targetfile, url) 274 | return False 275 | 276 | return True 277 | 278 | def findPackages(distr, ipkname): 279 | global FEEDS 280 | print('-' * 20 + ' FEED LISTs DOWNLOADing: ' + '-' * 20) 281 | 282 | URL_LIST = [] 283 | i = FEEDS.index('----%s' % distr) + 1 284 | 285 | while not FEEDS[i].startswith('----'): 286 | 287 | if FEEDS[i].startswith('http'): 288 | 289 | if FEEDS[i].endswith('Packages.gz'): 290 | URL_LIST.append(FEEDS[i]) 291 | i += 1 292 | 293 | elif FEEDS[i].endswith('/'): 294 | url_template = FEEDS[i] + '%s/Packages.gz' 295 | i += 1 296 | 297 | while not FEEDS[i].startswith('----') and not FEEDS[i].startswith('http'): 298 | URL_LIST.append(url_template % FEEDS[i]) 299 | i += 1 300 | 301 | db = [] 302 | for feed_url in URL_LIST: 303 | if downloadFile(feed_url, '/tmp/Packages.gz'): # from downloaded package will be extracted a text file named as "Package" 304 | os.system('cd /tmp && gunzip -f /tmp/Packages.gz') # the one exactly file will be gunzipped, with the same name as the package name (without extension) 305 | with open('/tmp/Packages', 'r') as f: 306 | tmp = f.readlines() 307 | db.append('@@@' + feed_url + '\n') 308 | db += tmp 309 | os.remove('/tmp/Packages') 310 | 311 | #with open('/tmp/' + sys.argv[0].split(".")[0] + '.tmp', 'w') as f: 312 | # f.writelines(db) 313 | 314 | index_list = [i for i, val in enumerate(db) if val.startswith('Filename:') and (ipkname in val)] 315 | if index_list: 316 | print('-' * 23 + ' PACKAGES FOUND: ' + '-' * 23) 317 | for idx in index_list: 318 | url_dir = next(db[i] for i in reversed(range(idx)) if db[i].startswith('@@@')) # '@@@http://feeds2.mynonpublic.com/6.2/vusolose/mips32el/Packages.gz' 319 | url_dir = '/'.join(url_dir.split('/')[:-1]) # '@@@http://feeds2.mynonpublic.com/6.2/vusolose/mips32el' 320 | url_dir = url_dir[3:] + '/' + db[idx].split(':')[1].strip() # 'http://feeds2.mynonpublic.com/6.2/vusolose/mips32el/7zip-full_16.02-r0_mips32el.ipk' 321 | print('index = %s, url = %s' % (idx, url_dir)) 322 | else: 323 | print('The package "%s" was not found.' % ipkname) 324 | 325 | def availableDistros(): 326 | global FEEDS 327 | lst = [] 328 | for line in FEEDS: 329 | if line.startswith('----') and not line.endswith('END'): 330 | lst.append(line[4:].strip()) 331 | return lst 332 | 333 | ############################################################################################### 334 | 335 | if __name__ == '__main__': 336 | 337 | if len(sys.argv) == 3: # 1 + 2 arguments are neccessary ! the sum of: [0] script file name (default built-in argument) [1] Enigma feed atv/pli [2] package name to find 338 | 339 | scriptname, distro, ipkmatchname = sys.argv 340 | 341 | if distro in availableDistros(): 342 | findPackages(distro, ipkmatchname) 343 | 344 | else: 345 | print('USAGE: python %s <%s> \n' % ( sys.argv[0] , '|'.join(availableDistros()) ) + 346 | 'Examples: python %s pli youtube \n' % sys.argv[0] + 347 | ' python %s pure2 oscam \n' % sys.argv[0] + 348 | ' python %s atv 7zip' % sys.argv[0] 349 | ) 350 | 351 | 352 | 353 | # Note: 354 | # - list of all feed URLs, currently for the installed local Enigma2 distribution or in the current set-top box: /etc/opkg/*.conf 355 | # - list of all available .ipk packages, already in the form of a database downloaded to the local disk, for the currently installed Enigma2 distribution: /var/lib/opkg/lists 356 | -------------------------------------------------------------------------------- /oscam-idle-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | USR="oscam" 4 | PAS="xxxxxxxxxxxx" 5 | 6 | ### the script first finds out, and reads from OscamApi all the clients, then... 7 | ### if some connected clients have been found, it finds out how long the idle lasted in hours+minutes+seconds 8 | ### and compares it with the value of 20 (seconds), but this is only valid for IRDETO, in which the key is refreshed every 10 seconds 9 | 10 | oscam_is_busy() { 11 | # CHAN_REQ_LIST=$(wget -q -O - "http://${USR}:${PAS}@127.0.0.1:8888/oscamapi.html?part=status" | sed -rn '// {s/.*srvid="([0-9]*)".*/\1/p}') ## a functional "oscamapi.html" is required, which is unfortunately not included in every Oscam build 12 | # TOTAL=0; for CHAN in $CHAN_REQ_LIST; do (( TOTAL += CHAN )); done 13 | # [ $TOTAL -gt 0 ] # the function returns a boolean (according to the sum of all ServiceIDs watching) 14 | 15 | # DELAY_CLIENT_LIST=$(wget -q -O - --no-check-certificate --no-cache --no-cookies "http://${USR}:${PAS}@127.0.0.1:8888/oscamapi.html?part=status" | awk '/type="c"/,/client>/' | sed -rn 's/.*idle="([0-9]*)".*/\1/p') ## a functional "oscamapi.html" is required, which is unfortunately not included in every Oscam build 16 | # DELAY_CLIENT_LIST=$(wget -q -O - --no-check-certificate --no-cache --no-cookies "http://${USR}:${PAS}@127.0.0.1:8888/oscamapi.html?part=status" | sed -rn '/type="c"/,/client>/ {s/.*idle="([0-9]*)".*/\1/p}') ## a functional "oscamapi.html" is required, which is unfortunately not included in every Oscam build 17 | DELAY_CLIENT_LIST=$(wget -q -O - --no-check-certificate --no-cache --no-cookies "http://${USR}:${PAS}@127.0.0.1:8888" | sed -rn '/CLASS="c"/,/TR>/ {s/.*IDLE:\s*([0-9:]*)".*/\1/p}' | tr -d ':') ## read all idle time from all active clients, but without a colon signs, for example: 000355 000002 000007 18 | for DELAY in $DELAY_CLIENT_LIST; do [ $DELAY -lt 20 ] && break; done ## if at least one client accesses Oscam within 20 seconds, the function returns the value "0", otherwise the function returns "1" 19 | } 20 | 21 | if oscam_is_busy; then 22 | echo "Oscam is busy (decoding channels)." 23 | else 24 | echo "Oscam is idle (sleeping)." 25 | fi 26 | -------------------------------------------------------------------------------- /oscam-new-version-updater.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | ####################################### 6 | # Oscam new version updater 7 | ####################################### 8 | # 9 | # 2019/10/21 - shell script written by s3n0 10 | # 11 | # This script checks if there is a newer version of Oscam on the internet and if so, 12 | # then downloads and overwrites the found Oscam binary file on the local disk. 13 | # 14 | # This script is designed to avoid having to add another 'feed/source' to your Enigma. 15 | # 16 | # Unfortunately the '7zip' archiver is required since the 'ar' tool is problematic when splitting files (inside the IPK package). 17 | # 18 | # To run my script on your set-top box, directly from the github, use the following command: 19 | # wget -qO- --no-check-certificate "https://github.com/s3n0/e2scripts/raw/master/oscam-new-version-updater.sh" | bash 20 | # 21 | ####################################### 22 | # 23 | # This script uses "updates.mynonpublic.com" as an update source and also uses the Python source code, 24 | # from the script by @SpaceRat: 25 | # http://updates.mynonpublic.com/oea/feed 26 | # 27 | # The original 'feed' script was developed by @SpaceRat for the purpose of installing softcam-feed into Enigma/OpenATV, 28 | # but it also works in other Enigmas. Use the following command to install the feed: 29 | # wget -O - -q http://updates.mynonpublic.com/oea/feed | bash 30 | # 31 | ####################################### 32 | 33 | 34 | 35 | 36 | 37 | 38 | ## OSCAM_LOCAL_PATH="/usr/bin/oscam" 39 | ## [ -f $OSCAM_LOCAL_PATH ] || { echo "ERROR ! User-configured binary file $OSCAM_LOCAL_PATH not found !"; exit 1; } 40 | 41 | OSCAM_LOCAL_PATH=$(find /usr/bin -iname 'oscam*' | head -n 1) 42 | [ -z "$OSCAM_LOCAL_PATH" ] && { OSCAM_LOCAL_PATH="/usr/bin/oscam"; echo "Oscam binary file was not found in folder '/usr/bin'. The default path and filename $OSCAM_LOCAL_PATH will be used to download and to add a new Oscam binary file."; } || echo "Recognized binary file: $OSCAM_LOCAL_PATH" 43 | 44 | ## OSCAM_LOCAL_PATH=$(ps --no-headers -f -C oscam | sed 's@.*\s\([\-\_\/a-zA-Z]*\)\s.*@\1@' | head -n 1) 45 | ## [ -z "$OSCAM_LOCAL_PATH" ] && { OSCAM_LOCAL_PATH="/usr/bin/oscam"; echo "No Oscam process name found. The default file name $OSCAM_LOCAL_PATH will be used to download and add a new Oscam."; } || echo "Oscam process $OSCAM_LOCAL_PATH found." 46 | 47 | 48 | 49 | 50 | 51 | 52 | REQUESTED_BUILD="oscam-trunk" 53 | #REQUESTED_BUILD="oscam-emu" 54 | 55 | # - some examples of Oscam builds included on the feed server, there is possible to change one of them: 56 | # 57 | # oscam-trunk !!!! does not work ???? 58 | # oscam-trunk-ipv4only !!!! does not work ???? 59 | # 60 | # oscam-stable 61 | # oscam-stable-ipv4only 62 | # 63 | # oscam-emu 64 | # oscam-emu-ipv4only 65 | 66 | 67 | 68 | 69 | 70 | IRDETO_ENTITLEMENTS="no" # please choice your option "no" or "yes", for IRDETO satellite cards, due to necessary "entitlements" (receipt of first EMMs) - the waiting time in the script is set to 30 seconds 71 | IRDETO_CHANNEL="1:0:19:3731:C8E:3:EB0000:0:0:0:" 72 | 73 | 74 | 75 | 76 | 77 | # A temporary directory 78 | TMP_DIR="/tmp/oscam_binary_update" 79 | 80 | 81 | 82 | HR_LINE="----------------------------------" 83 | 84 | 85 | 86 | 87 | 88 | ####################################### 89 | ####################################### 90 | ####################################### 91 | 92 | 93 | 94 | #### Auto-configuring the Enigma version and the chipset / CPU architecture (with the help of Python): 95 | 96 | # OEVER="4.3" # this value is determined automatically using the Python script below - a note: OEVER here means the OE-Alliance version ! not the OE-core version (by Dreambox) ! 97 | # ARCH="mips32el" # this value is determined automatically using the Python script below 98 | # BASE_FEED="http://updates.mynonpublic.com/oea" # feed server with all Oscam packages (for OpenATV of course) 99 | # Wget example: wget -O /tmp/Packages.gz "$BASE_FEED/$OEVER/$ARCH/Packages.gz" 100 | # Specific URL example: "http://updates.mynonpublic.com/oea/4.3/{mips32el,cortexa15hf-neon-vfpv4,cortexa9hf-neon,armv7ahf-neon,aarch64,sh4}/Packages.gz" 101 | 102 | [ -e /usr/bin/python3 ] && PY="python3" || PY="python" 103 | 104 | BASE_FEED="http://updates.mynonpublic.com/oea" 105 | 106 | 107 | 108 | 109 | get_oever() { 110 | OEVER=$($PY - < /dev/null 2>&1 && echo "OK" || { echo "FAILED!"; exit 1; } 275 | } 276 | echo "$HR_LINE" 277 | echo "Extracting the IPK package:" 278 | extractor $IPK_FILENAME # 1. splitting linked files ("ar" archive) - since "ar" separates files from the archive with difficulty, so I will use "7-zip" archiver 279 | extractor data.tar.?z # 2. unpacking the ".gz" OR ".xz" archive 280 | extractor data.tar ./usr/bin/$REQUESTED_BUILD # 3. unpacking ".tar" archive, but only one file - i.e. an oscam binary file, for example as "oscam-trunk" 281 | echo -n "The Oscam binary file has " 282 | [ -f $TMP_DIR/$REQUESTED_BUILD ] && echo "been successfully extracted." || { echo "not been extracted! Please check the folder '$TMP_DIR'."; exit 1; } 283 | chmod a+x $TMP_DIR/$REQUESTED_BUILD 284 | echo "$HR_LINE" 285 | 286 | #### Check the availability of some dependent libraries: 287 | if $TMP_DIR/$REQUESTED_BUILD --build-info 2>&1 | grep -q 'required by'; then 288 | echo "Unfortunately, some dependent libraries are missed for the Oscam binary file." 289 | echo "You can try to install / to update them manually ... for example:" 290 | echo " opkg update" # opkg update > /dev/null 2>&1 291 | echo " opkg install libc6 libcrypto1.0.2 libssl1.0.2 libusb-1.0-0" 292 | echo "$HR_LINE" 293 | $TMP_DIR/$REQUESTED_BUILD --build-info 294 | exit 1 295 | fi 296 | 297 | #### Check the availability of some sym-links to libraries: 298 | if $TMP_DIR/$REQUESTED_BUILD --build-info 2>&1 | grep -q 'shared libraries'; then 299 | echo "Unfortunately, some libraries have missed symbolic-links." 300 | echo "You can try to assign them manually (ln -s file symlink) ... for example:" 301 | echo " ln -s /usr/lib/libssl.so.1.0.2 /usr/lib/libssl.so.1.0.0" 302 | echo " ln -s /usr/lib/libcrypto.so.1.0.2 /usr/lib/libcrypto.so.1.0.0" 303 | echo "$HR_LINE" 304 | $TMP_DIR/$REQUESTED_BUILD --build-info 305 | exit 1 306 | fi 307 | 308 | #### Function to check the Enigma2 Standby 309 | is_standby() { 310 | #[ "$(wget -qO- http://127.0.0.1/web/powerstate | grep -i '' | cut -f 1)" = "true" ] 311 | #[ "$(wget -qO- http://127.0.0.1/web/powerstate | grep -i '' | awk '{print $1}')" = "true" ] 312 | #wget -qO- "http://127.0.0.1/api/powerstate" | grep -iqE '"instandby"\s*:\s*true' 313 | #wget -qO- http://127.0.0.1/web/powerstate | grep -qi 'true' 314 | wget -qO- http://127.0.0.1/api/powerstate | grep -qi 'instandby.*true' 315 | } 316 | 317 | #### Retrieve Oscam online version (from downloaded binary file) 318 | OSCAM_ONLINE_VERSION=$( $TMP_DIR/$REQUESTED_BUILD --build-info | grep -i 'version:' | grep -o '[0-9]\{5\}' ) # output result is, as example: 11552 319 | #OSCAM_ONLINE_VERSION=$( echo $IPK_FILENAME | sed -e 's/.*svn\([0-9]*\)-.*/\1/' ) # old method to retrieve online Oscam version 320 | [ -z "$OSCAM_ONLINE_VERSION" ] && { echo "Error! The online version cannot be recognized! Script canceled!"; exit 1; } 321 | 322 | #### Retrieve Oscam local version (from current binary file placed in the /usr/bin folder) 323 | OSCAM_LOCAL_VERSION=$( $OSCAM_LOCAL_PATH --build-info | grep -i 'version:' | grep -o '[0-9]\{5\}' ) # output result is, as example: 11546 324 | [ -z "$OSCAM_LOCAL_VERSION" ] && OSCAM_LOCAL_VERSION="11000" # sets the null version as a precaution if there is no Oscam binary file on the local harddisk yet 325 | 326 | #### Compare Oscam local version VS. online version 327 | echo -e "Oscam version on internet:\t$OSCAM_ONLINE_VERSION\nOscam version on local drive:\t$OSCAM_LOCAL_VERSION" 328 | if [ "$OSCAM_ONLINE_VERSION" -gt "$OSCAM_LOCAL_VERSION" ] 329 | then 330 | 331 | echo "A new version of Oscam has been found and will be updated." 332 | # wget -qO- "http://127.0.0.1/web/message?type=1&timeout=10&text=New+Oscam+version+found+($OSCAM_ONLINE_VERSION)%0ANew+version+will+updated+now." > /dev/null 2>&1 # show WebGUI info message 333 | #### Replace the oscam binary file with new one 334 | OSCAM_BIN_FNAME=${OSCAM_LOCAL_PATH##*/} 335 | if ps --version 2>&1 | grep -q -i "busybox"; then 336 | OSCAM_CMD=$(ps | grep $OSCAM_BIN_FNAME | grep -v grep | head -n 1 | grep -o '/.*$') # feature-poor `ps` command from BusyBox (for example in OpenPLi image) 337 | else 338 | OSCAM_CMD=$(ps -f --no-headers -C $OSCAM_BIN_FNAME | head -n 1 | grep -o '/.*$') # full-featured `ps` command from Linux OS (for example in OpenATV image) 339 | fi 340 | 341 | [ -z "$OSCAM_CMD" ] || { killall -9 $OSCAM_BIN_FNAME ; echo "Recognized Oscam command-line: $OSCAM_CMD" ; } 342 | mv -f $TMP_DIR/$REQUESTED_BUILD $OSCAM_LOCAL_PATH 343 | chmod a+x $OSCAM_LOCAL_PATH 344 | 345 | [ -z "$OSCAM_CMD" ] || 346 | { 347 | $OSCAM_CMD 348 | sleep 1 349 | if pidof $OSCAM_BIN_FNAME > /dev/null 2>&1; then 350 | echo "The new Oscam is ready to use !" 351 | #### helping for IRDETO cards to receive any EMMs --- it is to neccessary, to receive some entitlements after each Oscam restart 352 | if is_standby && [ "$IRDETO_ENTITLEMENTS" = "yes" ]; then 353 | echo "$HR_LINE" 354 | echo "Turning on the tuner..." 355 | echo "...zapping the user specified channel - $IRDETO_CHANNEL" 356 | wget -qO- "http://127.0.0.1/api/zap?sRef=${IRDETO_CHANNEL}" > /dev/null 2>&1 357 | echo "...waiting for a while, to receive any entitlements on your IRDETO satellite card" 358 | sleep 40 # waiting 20 secs for card initialization + 20 secs to receive any EMM 359 | echo "...turning off the tuner (Enigma still in standby)" 360 | wget -qO- "http://127.0.0.1/api/zap?sRef=0" > /dev/null 2>&1 361 | echo "...done !" 362 | fi 363 | else 364 | echo "The new Oscam failed to start ! Exiting the update script !" 365 | exit 1 366 | fi 367 | } 368 | 369 | else 370 | 371 | echo "Installed Oscam version is current. No need to update." 372 | # wget -qO- "http://127.0.0.1/web/message?type=1&timeout=10&text=Installed+Oscam+version+($OSCAM_LOCAL_VERSION)+is+current.%0ANo+need+to+update." > /dev/null 2>&1 # show WebGUI info message 373 | 374 | fi 375 | 376 | #### Remove all temporary files (sub-directory) 377 | rm -rf $TMP_DIR 378 | 379 | 380 | 381 | 382 | echo "$HR_LINE" 383 | 384 | exit 0 385 | -------------------------------------------------------------------------------- /oscam-picons-converter_OscamWebif_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # First you need to add to the 'oscam.conf' file, an entry to specify the shell script directory ... for example: 4 | # httpscript = /usr/script 5 | # Then you need to place the shell script in this folder, including the python script for converting to Oscam-Webif picon format. 6 | # Both script files must have an execution attribute set. For example, set this via an FTP connection as attributes to 755, or use the Shell command: 7 | # chmod a+x /usr/script/oscam-picons* 8 | # You can set the parameters for picon conversion according to yourself, i.e. $SCR_PARAMS variable. 9 | # This script can then be started in Oscam-Webif, via the "Script" MENU. 10 | 11 | SCR_NAME="oscam-picons-converter.py" 12 | #SCR_PARAMS="-d -q -1 -c 0624,0D96,FFFE" 13 | SCR_PARAMS="-d -q -a -c 0624,0D96,FFFE" # 0624,0D96 = Skylink sat-provider, FFFE = Free-To-Air channels (for dvbapi user in OscamWebif) 14 | SCR_PATH="/usr/script" 15 | LOG_FILE="/tmp/${SCR_NAME%.*}.log" 16 | 17 | [ -f "${SCR_PATH}/${SCR_NAME}" ] || { echo "Error ! The script-file '${SCR_PATH}/${SCR_NAME}' was not found !"; exit 1; } 18 | 19 | [ -e /usr/bin/python3 ] && PY="python3" || PY="python" 20 | 21 | opkg list-installed | grep -q "${PY}-pillow" || { opkg update; opkg install $PY-pillow; } # it is neccessary package, to use the python-module named as PIL 22 | 23 | /usr/bin/$PY $SCR_PATH/$SCR_NAME $SCR_PARAMS > $LOG_FILE 2>&1 & 24 | 25 | echo "The python script '${SCR_NAME}' has been started - it will run in the background." 26 | echo "To verify that the script is working properly, you can check the '${LOG_FILE}' file," 27 | echo "after a few minutes or seconds (depending on the picons generation speed)." 28 | echo "Bye." 29 | 30 | exit 0 31 | -------------------------------------------------------------------------------- /oscam-srvid-generator-flysat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | header = """ 4 | ####################################################################### 5 | ### Simple python-script for create the 'oscam.srvid' file ### 6 | ### by parsing the https://www.FLYSAT.com web page. ### 7 | ####################################################################### 8 | ### Script written by s3n0, 2021-03-03, https://github.com/s3n0 ### 9 | ####################################################################### 10 | """ 11 | 12 | output_file = '/tmp/oscam.srvid' 13 | 14 | packages = { 15 | 'https://flysat.com/en/package/skylink-1/astra-3b' : '0D96,0624' , 16 | 'https://flysat.com/en/package/sky-deutschland-2/astra-19' : '1833,1834,1702,1722,09C4,09AF' , 17 | # 'https://flysat.com/en/package/antiksat-1/eutelsat-16a' : '0B00' , 18 | # 'https://flysat.com/en/package/maxtv-sat-1/eutelsat-16a' : '1830' , 19 | } 20 | 21 | # packages = { 22 | # 'FlySat_package_name' : 'list_of_CAIDs_what_you_need_-_separated_by_comma,0001,0001,0003' , 23 | # ... 24 | # } 25 | 26 | # # # # # The right provider packages you can find here: 27 | # # # # # https://www.flysat.com/en/packagelist 28 | # # # # # -- find the URL there by mouse over - under the "Package" columns 29 | # # # # # -- after that, copy the URL and then add your required CAIDs 30 | 31 | ############################################################################# 32 | 33 | from sys import version_info as py_version 34 | if py_version.major == 3: # data of this object type: sys.version_info(major=3, minor=8, micro=5, releaselevel='final', serial=0) 35 | import urllib.request as urllib2 36 | import html 37 | htmlParser = html 38 | else: 39 | import urllib2 40 | from HTMLParser import HTMLParser 41 | htmlParser = HTMLParser() 42 | 43 | ########## 44 | 45 | import ssl 46 | try: 47 | _create_unverified_https_context = ssl._create_unverified_context 48 | except AttributeError: 49 | pass # Legacy Python versions (for example v2.7.2) that doesn't verify HTTPS certificates by default 50 | else: 51 | ssl._create_default_https_context = _create_unverified_https_context # Handle target environment that doesn't support HTTPS verification --- https://www.python.org/dev/peps/pep-0476/ 52 | 53 | ########## 54 | 55 | from datetime import datetime 56 | 57 | ############################################################################# 58 | 59 | def htmlContent(url): 60 | print('Downloading web page: %s' % pckg) 61 | headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0'} 62 | try: 63 | req = urllib2.Request(url, data=None, headers=headers) 64 | handler = urllib2.urlopen(req, timeout=15) 65 | data = handler.read().decode('utf-8') 66 | except: 67 | print('ERROR ! Failed to request and download the web-site: %s' % url) 68 | data = '' 69 | print('...done.') 70 | return data 71 | 72 | ############################################################################# 73 | 74 | if __name__ == '__main__': 75 | 76 | result = [] 77 | for pckg in packages: 78 | 79 | webpage = htmlContent(pckg) 80 | 81 | if webpage: 82 | pckg_name = pckg.split('/')[5] # - output example: ['https:', '', 'www.flysat.com', 'en', 'package', 'skylink-1', 'astra-3b'] 83 | if pckg_name[-2:] in ('-1', '-2', '-3', '-4'): 84 | pckg_name = pckg_name[:-2] 85 | 86 | print('Processing "%s" package, please wait...' % pckg_name) 87 | 88 | #bkp_file = '/tmp/FlySat_-_%s.html' % pckg_name 89 | #with open(bkp_file, 'w') as f: 90 | # f.write(webpage) 91 | # print('Web page was stored in a file: %s' % bkp_file) 92 | 93 | i = 2000 94 | 95 | while i < len(webpage) - 1000: 96 | 97 | # retrieve the channel name 98 | i = webpage.find('30px', i) # '30px' / 'height:30px' / 'height: 30px' / 'flysat.com/en/channel/' 99 | if i == -1: 100 | break # to break the while loop 101 | i = webpage.find('', i) + 3 102 | CHN = webpage[ i : webpage.find('', i) ].strip() 103 | CHN = htmlParser.unescape(CHN) # CHN = CHN.replace('&', '&') 104 | 105 | # if the channel name is censored, then retrieve the inner string part between + delete blank characters at the begin/end of string 106 | #if '') ].strip() 108 | # !!! !!! !!! unfortunately, the FlySat database no longer contains the original channel name, which is included in the blacklist (18+), but only contains the censored name - as an asterisk ("*"), i.e. without TAGs "" 109 | if CHN == '*': 110 | CHN = '**CENSORED**' 111 | 112 | # retrieve all SIDs - next from the channel name 113 | for x in range(4): 114 | i = webpage.find('', i) + 9 116 | SIDS = webpage[ i : webpage.find('', i) ] # read the all data in the XML field (table column) 117 | SIDS = SIDS.replace('\n','').replace('\t','') 118 | # all possible SIDs are separated in the html table TAG... so... there is '
' or '')) == 2: # if there is only one SID number, then SIDS str variable was not splitted, and we need to split it again - but now via the '<' delimiter 120 | SIDS = [ SIDS.split('<')[0] ,] # convert to list type (for SIDS it is neccessary to use just the list data type) 121 | else: 122 | SIDS = SIDS.split('
') 123 | SIDS = [ "%04X" % int(s) for s in SIDS if s.isdigit() ] # remove all non-numeric (also for a string type) entries from the list + converting decimal to hexadecimal (4-digits) string-numeric values 124 | 125 | # a small step to forward 126 | i += 20 127 | 128 | #print('MYDEBUGLOGLINE --- CHN=%s ; SIDS=%s ; i=%s ; pckg=%s' % (CHN, SIDS, i, pckg_name) ) 129 | 130 | # add the otput to the 'result' variable 131 | for SID in SIDS: # if some more SIDs were found... 132 | # # # # # # # CAID(s) : SID | PROVIDER NAME | CHANNEL NAME 133 | result.append(packages[pckg] + ':' + SID + '|' + pckg_name.upper() + '|' + CHN) 134 | 135 | print('...done.') 136 | else: 137 | print('Web page download FAILED !!! - package: %s' % pckg) 138 | 139 | if result: 140 | data = header + '\n### File creation date: ' + datetime.now().strftime('%Y-%m-%d %H:%M:%S') + '\n\n' + '\n'.join(result) 141 | # delete (rewrite) a file / save the 'result' variable into a file 142 | with open(output_file, 'w') as f: 143 | f.write(data) 144 | print('File "%s" was stored.' % output_file) 145 | 146 | print('Good bye.') 147 | 148 | ############################################################################# 149 | ### EoF 150 | -------------------------------------------------------------------------------- /oscam-srvid-generator-kingofsat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HEADER=" 4 | ################################################################################# 5 | ### - the script serves as a generator of the 'oscam.srvid' file 6 | ### - based on data parsing from website: http://en.KingOfSat.net/pack-XXXXXX.php 7 | ### - script written by s3n0, 2021-03-02: https://github.com/s3n0 8 | ################################################################################# 9 | " 10 | 11 | ################################################################################# 12 | 13 | find_oscam_cfg_dir() 14 | { 15 | RET_VAL="" 16 | DIR_LIST="/etc /var /usr /config" 17 | for FOLDER in $DIR_LIST; do 18 | FILEPATH=$(find "${FOLDER}" -iname "oscam.conf" | head -n 1) 19 | [ -f "$FILEPATH" ] && { RET_VAL="${FILEPATH%/*.conf}"; break; } 20 | done 21 | 22 | if [ -z "$RET_VAL" ]; then 23 | OSCAM_BIN=$(find /usr/bin -iname 'oscam*' | head -n 1) 24 | if [ -z "$OSCAM_BIN" ]; then 25 | echo -e "ERROR !\nOscam binary file was not found in folder '/usr/bin'.\nAlso, do not find the Oscam configuration directory.\nThe script will be terminated." 26 | exit 1 27 | else 28 | RET_VAL="$($OSCAM_BIN -V | grep -i 'configdir' | awk '{print substr($2,0,length($2)-1)}')" 29 | fi 30 | fi 31 | 32 | [ -z "$RET_VAL" ] && echo "WARNING ! Oscam configuration directory not found !" 33 | echo "$RET_VAL" 34 | } 35 | 36 | ################################################################################# 37 | 38 | create_srvid_file() 39 | { 40 | # INPUT ARGUMENTS: 41 | # $1 = the URL of the package list of channels with their data, on a specific http://en.KingOfSat.net/pack-XXXXX.php website (see below) 42 | # $2 = CAIDs (separated by comma) what is necessary for the provider 43 | # 44 | # EXAMPLE: create_srvid_file "skylink" "0D96,0624" 45 | # 46 | # NOTE: "${1^}" provides the first-character-upper string = "Provider" "${1^^}" provides the upper-case string = "PROVIDER" "${1}" provides the string = "provider" "${1,,}" provides the lower-case string = "provider" 47 | 48 | URL="http://en.kingofsat.net/pack-${1,,}.php" 49 | 50 | if wget -q -O /tmp/kos.html --no-check-certificate "$URL" > /dev/null 2>&1; then 51 | echo "URL download successful: ${URL}" 52 | 53 | awk -F '>' -v CAIDS="${2}" -v PROVIDER="${1^^}" -e ' 54 | BEGIN { CHNAME = "invalid" } 55 | /|class="A3"/ { CHNAME = substr($2,1,length($2) - 3) } 56 | /class="s">[0-9]+/ { 57 | SID = substr($2,1,length($2) - 4) 58 | if (CHNAME == "invalid") next 59 | printf "%s:%04X|%s|%s\n", CAIDS, SID, PROVIDER, CHNAME 60 | CHNAME = "invalid" 61 | }' /tmp/kos.html > "/tmp/oscam__${1,,}.srvid" 62 | 63 | echo -e "The new file was created: /tmp/oscam__${1,,}.srvid\n" 64 | rm -f /tmp/kos.html 65 | else 66 | echo "URL download failed !!! URL: ${URL}" 67 | fi 68 | } 69 | 70 | ################################################################################# 71 | 72 | echo "$HEADER" 73 | 74 | ### if the oscam config directory is not found, then use the "/tmp" directory, to avoid a possible error in the variable below: 75 | OSCAM_CFGDIR=$(find_oscam_cfg_dir) 76 | [ -z "$OSCAM_CFGDIR" ] && { echo "WARNING ! The output directory for the 'oscam.srvid' file was changed to '/tmp' !"; OSCAM_CFGDIR="/tmp"; } 77 | 78 | #OSCAM_SRVID="/tmp/oscam_-_merged-kingofsat.srvid" 79 | OSCAM_SRVID="${OSCAM_CFGDIR}/oscam.srvid" 80 | 81 | 82 | 83 | ### create temporary ".srvid" files: 84 | create_srvid_file "skylink" "0D96,0624,FFFE" 85 | create_srvid_file "antiksat" "0B00" 86 | create_srvid_file "orangesk" "0B00,0609" # some channels are shared to the AntikSat provider (package), so this one "orangesk" package is also needed for "antiksat" (as the CAID=0B00) 87 | create_srvid_file "upc" "0D02,0D97,0B02,1815" 88 | create_srvid_file "skygermany" "1833,1834,1702,1722,09C4,09AF" 89 | 90 | #create_srvid_file "focussat" "0B02" 91 | #create_srvid_file "digitv" "1802,1880" 92 | #create_srvid_file "mtv" "0B00,0D00" 93 | #create_srvid_file "canaldigitalnordic" "0B00" 94 | #create_srvid_file "bbc" "0B00" 95 | #create_srvid_file "skydigital" "0963" 96 | #create_srvid_file "skyitalia" "0919,093B,09CD" 97 | #create_srvid_file "dolcetv" "092F" 98 | #create_srvid_file "hellohd" "0BAA,0000" 99 | 100 | 101 | 102 | ### backup the original file "oscam.srvid" to the "/tmp" dir: 103 | fileSRC="${OSCAM_CFGDIR}/oscam.srvid" 104 | fileDST="/tmp/oscam_-_backup_$(date '+%Y-%m-%d_%H-%M-%S').srvid" 105 | [ -f "$fileSRC" ] && { mv "$fileSRC" "$fileDST"; echo -e "The original file was backed up: ${fileSRC} >>> ${fileDST}\n"; } # backup the old 'oscam.srvid' file 106 | 107 | ### merge all generated ".srvid" files into one file + move this new file to the Oscam config-dir: 108 | echo "$HEADER" > $OSCAM_SRVID 109 | echo -e "### File creation date: $(date '+%Y-%m-%d %H:%M:%S')\n" >> $OSCAM_SRVID 110 | cat /tmp/oscam__* >> $OSCAM_SRVID 111 | rm -f /tmp/oscam__* 112 | [ -f "$OSCAM_SRVID" ] && echo "All generated '.srvid' files have been merged into one and moved to the directory: ${OSCAM_SRVID}" 113 | 114 | 115 | 116 | 117 | exit 0 118 | 119 | ################################################################################# 120 | ################################################################################# 121 | -------------------------------------------------------------------------------- /oscam-srvid-generator-lyngsat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HEADER=" 4 | ###################################################################################### 5 | ### - the script serves as a generator of the 'oscam.srvid' file 6 | ### - based on data parsing from website: https://www.lyngsat.com/packages/XXXXXX.html 7 | ### - script written by s3n0, 2021-03-13: https://github.com/s3n0 8 | ###################################################################################### 9 | " 10 | 11 | ###################################################################################### 12 | ###################################################################################### 13 | 14 | find_oscam_cfg_dir() 15 | { 16 | RET_VAL="" 17 | DIR_LIST="/etc /var /usr /config" 18 | for FOLDER in $DIR_LIST; do 19 | FILEPATH=$(find "${FOLDER}" -iname "oscam.conf" | head -n 1) 20 | [ -f "$FILEPATH" ] && { RET_VAL="${FILEPATH%/*.conf}"; break; } 21 | done 22 | 23 | if [ -z "$RET_VAL" ]; then 24 | OSCAM_BIN=$(find /usr/bin -iname 'oscam*' | head -n 1) 25 | if [ -z "$OSCAM_BIN" ]; then 26 | echo -e "ERROR !\nOscam binary file was not found in folder '/usr/bin'.\nAlso, do not find the Oscam configuration directory.\nThe script will be terminated." 27 | exit 1 28 | else 29 | RET_VAL="$($OSCAM_BIN -V | grep -i 'configdir' | awk '{print substr($2,0,length($2)-1)}')" 30 | fi 31 | fi 32 | 33 | [ -z "$RET_VAL" ] && echo "WARNING ! Oscam configuration directory not found !" 34 | echo "$RET_VAL" 35 | } 36 | 37 | ###################################################################################### 38 | 39 | create_srvid_file() 40 | { 41 | # INPUT ARGUMENTS: 42 | # $1 = the package name, on a specific https://www.lyngsat.com/packages/XXXXXX.html website (see below) 43 | # $2 = CAIDs (separated by comma) what is necessary for the provider 44 | # $3 = DVB provider name 45 | # 46 | # EXAMPLE: create_srvid_file "Sky-Deutschland" "1833,1834,1702,1722,09C4,09AF" "SKY DE" 47 | # 48 | # NOTE: "${1^}" provides the string with only first upper character = "Provider" "${1^^}" provides the upper-case string = "PROVIDER" "${1}" provides the string = "provider" "${1,,}" provides the lower-case string = "provider" 49 | 50 | URL="https://www.lyngsat.com/packages/${1}.html" 51 | 52 | if wget -q -O /tmp/los.html --no-check-certificate "${URL}" > /dev/null 2>&1; then 53 | echo "URL download successful: ${URL}" 54 | else 55 | echo "URL download FAILED: ${URL}" 56 | exit 1 57 | fi 58 | 59 | CHN_MATCH='[0-9 ]+' 61 | 62 | LIST=$(cat /tmp/los.html | grep -E -e "${CHN_MATCH}" -e "${SID_MATCH}") 63 | rm -f /tmp/los.html 64 | 65 | LIST_LEN=$(printf "%s" "$LIST" | grep -c "^") 66 | if (( $LIST_LEN % 2 )); then # testing whether the number of lines in the $LIST variable is even (must be even) 67 | echo -e "ERROR !\nThe SID + CAID list from the web page is not complete (number of lines is odd, but an even number is required).\nThe script will be aborted !" 68 | exit 1 69 | fi 70 | 71 | # Example of the $LIST variable content: 72 | # 73 | # 2417 74 | # Porto Canal 75 | # 2418 76 | # ESPN 2 Africa 77 | # 2420 78 | # Blast 79 | # .... 80 | 81 | RESULT="" 82 | 83 | while IFS= read -r LINE; do 84 | SIDHEX="" 85 | CHN="" 86 | # ServiceID at the odd $LINE: 87 | SID=$(echo $LINE | cut -d '>' -f 3 | cut -d '<' -f 1) 88 | SIDHEX=$(printf "%04X" $SID) # converting a decimal value to hexadecimal 89 | # CHANNEL-name at the even $LINE: 90 | IFS= read -r LINE 91 | CHN=$(echo $LINE | grep -oE 'html">.*' | cut -d '>' -f 2 | cut -d '<' -f 1) 92 | # write a new entry - if both variables are not empty: 93 | [ -n "$SIDHEX" -a -n "$CHN" ] && RESULT="${RESULT}${2}:${SIDHEX}|${3}|${CHN}\n" # [ -n "$SIDHEX" -a -n "$CHN" ] && RESULT="${RESULT}CAID1,CAID2:${SIDHEX}|PROVIDER|${CHN}\n" 94 | done <<< "$LIST" # the '.srvid' file format is, for example : "CAID1,CAID2,CAID3:SID|PROVIDER-NAME|CHANNEL-NAME" 95 | 96 | # write $RESULT to a temporary file (also taking into account newline codes) 97 | echo -e "$RESULT" > "/tmp/oscam__${1}.srvid" 98 | } 99 | 100 | ###################################################################################### 101 | ###################################################################################### 102 | ###################################################################################### 103 | 104 | echo "$HEADER" 105 | 106 | ### if the oscam config directory is not found, then use the "/tmp" directory, to avoid a possible error in the variable below: 107 | OSCAM_CFGDIR=$(find_oscam_cfg_dir) 108 | [ -z "$OSCAM_CFGDIR" ] && { echo "WARNING ! The output directory for the 'oscam.srvid' file was changed to '/tmp' !"; OSCAM_CFGDIR="/tmp"; } 109 | 110 | #OSCAM_SRVID="/tmp/oscam_-_merged-kingofsat.srvid" 111 | OSCAM_SRVID="${OSCAM_CFGDIR}/oscam.srvid" 112 | 113 | ### create temporary ".srvid" files: 114 | create_srvid_file "Skylink" "0D96,0624" "Skylink" 115 | create_srvid_file "Antik-Sat" "0B00" "AntikSAT" 116 | create_srvid_file "Orange-Slovensko" "0B00,0609" "Orange SK" # some channels are shared to the AntikSat provider (package), so this one "orangesk" package is also needed for "antiksat" (as the CAID=0B00) 117 | create_srvid_file "Sky-Deutschland" "1833,1834,1702,1722,09C4,09AF" "SKY DE" 118 | 119 | ### backup the original file "oscam.srvid" to the "/tmp" dir 120 | [ -n "$OSCAM_CFGDIR" -a -f "${OSCAM_CFGDIR}/oscam.srvid" ] && mv "${OSCAM_CFGDIR}/oscam.srvid" "/tmp/oscam_-_backup_$(date '+%Y-%m-%d_%H-%M-%S').srvid" 121 | 122 | ### merge all generated ".srvid" files into one file + write this new file to the Oscam config-dir: 123 | echo "$HEADER" > $OSCAM_SRVID 124 | echo -e "### File creation date: $(date '+%Y-%m-%d %H:%M:%S')\n" >> $OSCAM_SRVID 125 | cat /tmp/oscam__* >> $OSCAM_SRVID 126 | rm -f /tmp/oscam__* 127 | [ -f "$OSCAM_SRVID" ] && echo "Path to the generated 'oscam.srvid' file: ${OSCAM_SRVID}" 128 | 129 | 130 | exit 0 131 | 132 | 133 | -------------------------------------------------------------------------------- /oscam-srvid-generator-satelitnatv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HEADER=" 4 | ################################################################################# 5 | ### shell-script written by s3n0, 2021-03-02, https://github.com/s3n0 ### 6 | ################################################################################# 7 | ### shell-script to parse data from the web page https://www.satelitnatv.sk ### 8 | ### and then generate the 'oscam.srvid' file from parsed data ### 9 | ################################################################################# 10 | ### !!! the mentioned web-site www.satelitnatv.sk unfortunately provides !!! ### 11 | ### !!! only DVB-services from Slovakia and the Czech Republic !!! ### 12 | ################################################################################# 13 | " 14 | 15 | ################################################################################# 16 | 17 | find_oscam_cfg_dir() 18 | { 19 | RET_VAL="" 20 | DIR_LIST="/etc /var /usr /config" 21 | for FOLDER in $DIR_LIST; do 22 | FILEPATH=$(find "${FOLDER}" -iname "oscam.conf" | head -n 1) 23 | [ -f "$FILEPATH" ] && { RET_VAL="${FILEPATH%/*.conf}"; break; } 24 | done 25 | 26 | if [ -z "$RET_VAL" ]; then 27 | OSCAM_BIN=$(find /usr/bin -iname 'oscam*' | head -n 1) 28 | if [ -z "$OSCAM_BIN" ]; then 29 | echo -e "ERROR !\nOscam binary file was not found in folder '/usr/bin'.\nAlso, do not find the Oscam configuration directory.\nThe script will be terminated." 30 | exit 1 31 | else 32 | RET_VAL="$($OSCAM_BIN -V | grep -i 'configdir' | awk '{print substr($2,0,length($2)-1)}')" 33 | fi 34 | fi 35 | 36 | [ -z "$RET_VAL" ] && echo "WARNING ! Oscam configuration directory not found !" 37 | echo "$RET_VAL" 38 | } 39 | 40 | ################################################################################# 41 | 42 | create_srvid_file() 43 | { 44 | # INPUT ARGUMENTS: 45 | # $1 = the URL of the package list of channels with their data, on a specific website (http://www.satelitnatv.sk/PROVIDER-NAME) 46 | # $2 = provider name (that exact name will be inserted into the '.srvid' output file) 47 | # $3 = CAIDs (separated by comma) what is necessary for the provider 48 | 49 | if wget -q -O /tmp/satelitnatv.html --no-check-certificate "${1}" > /dev/null 2>&1; then 50 | echo "URL download successful: ${1}" 51 | else 52 | echo "URL download FAILED: ${1}" 53 | exit 1 54 | fi 55 | 56 | sed -i 's//\n/g' /tmp/satelitnatv.html # change all "" TAGs to new-line characters 57 | LIST=$(sed -n 's/.*\(.*\)<\/a><\/strong>.*/\1 \2/p' /tmp/satelitnatv.html) # one line example, from the $LIST variable: 14129 Markiza HD 58 | 59 | FILE_NAME=`echo "${1##*.sk}" | tr -d "/"` # FILE_NAME=`echo "${1}" | cut -d "/" -f 4` 60 | FILE_OUTPUT="/tmp/oscam__${FILE_NAME}.srvid" 61 | rm -f $FILE_OUTPUT 62 | 63 | while IFS= read -r LINE; do 64 | SRN=$(echo "$LINE" | cut -d " " -f 2-) 65 | SID=$(echo "$LINE" | cut -d " " -f -1 | awk '{print $1 + 0}') # awk '{print $1 + 0}' ---- removing the zeros at the beginning (on the left) of the string variable 66 | SIDHEX=$(printf "%04X" $SID) # converting a decimal value to hexadecimal 67 | echo "${3}:${SIDHEX}|${2}|${SRN}" >> $FILE_OUTPUT 68 | done <<< "$LIST" 69 | 70 | if [ -f "$FILE_OUTPUT" ]; then 71 | echo -e "The new file was created: ${FILE_OUTPUT}\n" 72 | rm -f /tmp/satelitnatv.html 73 | else 74 | echo "ERROR ! File was not created: ${FILE_OUTPUT}" 75 | echo -e "Function arguments:\n${1} ${2} ${3}\n" 76 | fi 77 | } 78 | 79 | ################################################################################# 80 | 81 | echo "$HEADER" 82 | 83 | ### if the oscam config directory is not found, then use the "/tmp" directory, to avoid a possible error in the variable below: 84 | OSCAM_CFGDIR=$(find_oscam_cfg_dir) 85 | [ -z "$OSCAM_CFGDIR" ] && { echo "WARNING ! The output directory for the 'oscam.srvid' file was changed to '/tmp' !"; OSCAM_CFGDIR="/tmp"; } 86 | 87 | #OSCAM_SRVID="/tmp/oscam_-_merged-kingofsat.srvid" 88 | OSCAM_SRVID="${OSCAM_CFGDIR}/oscam.srvid" 89 | 90 | ### create temporary ".srvid" files 91 | 92 | create_srvid_file "https://www.satelitnatv.sk/frekvencie/skylink-sk-19e/" "Skylink" "0D96,0624,FFFE" 93 | create_srvid_file "https://www.satelitnatv.sk/frekvencie/freesat-sk/" "FreeSAT" "0D97,0653,0B02" 94 | create_srvid_file "https://www.satelitnatv.sk/frekvencie/antik-sat-sk/" "AntikSAT" "0B00" 95 | 96 | #create_srvid_file "https://www.satelitnatv.sk/skylink-programy-frekvencie-parametre/" "Skylink" "0D96,0624" 97 | #create_srvid_file "https://www.satelitnatv.sk/antik-sat/" "Antiksat" "0B00" 98 | #create_srvid_file "https://www.satelitnatv.sk/freesat-by-upc-direct/" "FreeSAT" "0D97,0653,0B02" 99 | 100 | 101 | 102 | ### backup the original file "oscam.srvid" to the "/tmp" dir: 103 | fileSRC="${OSCAM_CFGDIR}/oscam.srvid" 104 | fileDST="/tmp/oscam_-_backup_$(date '+%Y-%m-%d_%H-%M-%S').srvid" 105 | [ -f "$fileSRC" ] && { mv "$fileSRC" "$fileDST"; echo -e "The original file was backed up: ${fileSRC} >>> ${fileDST}\n"; } # backup the old 'oscam.srvid' file 106 | 107 | ### merge all generated ".srvid" files into one file + write this new file to the Oscam config-dir: 108 | echo "$HEADER" > $OSCAM_SRVID 109 | echo -e "### File creation date: $(date '+%Y-%m-%d %H:%M:%S')\n" >> $OSCAM_SRVID 110 | cat /tmp/oscam__* >> $OSCAM_SRVID 111 | rm -f /tmp/oscam__* 112 | [ -f "$OSCAM_SRVID" ] && echo "All generated '.srvid' files have been merged into one and moved to the directory: ${OSCAM_SRVID}" 113 | 114 | 115 | 116 | exit 0 117 | 118 | ################################################################################# 119 | ################################################################################# 120 | -------------------------------------------------------------------------------- /oscam-srvid-generator-twojeip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HEADER=" 4 | ################################################################################# 5 | ### script is designed to download and replace the 'oscam.srvid' file 6 | ### as the '.srvid' generator is used the online web-page: HTTP://KOS.TWOJEIP.NET 7 | ### script written by s3n0, 2021-02-17: https://github.com/s3n0 8 | ################################################################################# 9 | " 10 | 11 | ################################################################################# 12 | 13 | find_oscam_cfg_dir() 14 | { 15 | RET_VAL="" 16 | DIR_LIST="/etc /var /usr /config" 17 | for FOLDER in $DIR_LIST; do 18 | FILEPATH=$(find "${FOLDER}" -iname "oscam.conf" | head -n 1) 19 | [ -f "$FILEPATH" ] && { RET_VAL="${FILEPATH%/*.conf}"; break; } 20 | done 21 | 22 | if [ -z "$RET_VAL" ]; then 23 | OSCAM_BIN=$(find /usr/bin -iname 'oscam*' | head -n 1) 24 | if [ -z "$OSCAM_BIN" ]; then 25 | echo -e "ERROR !\nOscam binary file was not found in folder '/usr/bin'.\nAlso, do not find the Oscam configuration directory.\nThe script will be terminated." 26 | exit 1 27 | else 28 | RET_VAL="$($OSCAM_BIN -V | grep -i 'configdir' | awk '{print substr($2,0,length($2)-1)}')" 29 | fi 30 | fi 31 | 32 | [ -z "$RET_VAL" ] && echo "WARNING ! Oscam configuration directory not found !" 33 | echo "$RET_VAL" 34 | } 35 | 36 | ################################################################################# 37 | 38 | echo "$HEADER" 39 | 40 | URL="http://kos.twojeip.net/download.php?download[]=pack-hdplus&download[]=pack-mtv&download[]=pack-skylink&download[]=pack-austriasat&download[]=pack-orfdigital&download[]=pack-skygermany" 41 | #### # # # # # # # # # # # # # downloading : pack-hdplus + pack-mtv + pack-skylink + pack-austriasat + pack-orfdigital + pack-skygermany 42 | #### You must to find the correct package names (or full URL) directly on the website HTTP://KOS.TWOJEIP.NET - in the URL address of the downloaded file 43 | #### !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 44 | 45 | OSCAM_CFGDIR=$(find_oscam_cfg_dir) 46 | 47 | [ -z "$OSCAM_CFGDIR" ] && { echo "ERROR ! Oscam cfg-directory not found !"; exit 1; } 48 | 49 | cp -f "${OSCAM_CFGDIR}/oscam.srvid" "/tmp/oscam.srvid_backup" 50 | 51 | echo -e "Downloading file...\n- from: ${URL}\n- to: ${OSCAM_CFGDIR}/oscam.srvid" 52 | if wget --spider "${URL}" 2>/dev/null; then # check the existence of an online file or web-page 53 | wget -q -O "${OSCAM_CFGDIR}/oscam.srvid" "${URL}" 54 | echo "...done !" 55 | else 56 | echo "...ERROR - online URL ${URL} does not exist !" 57 | exit 1 58 | fi 59 | 60 | exit 0 61 | -------------------------------------------------------------------------------- /oscam_emm_refresh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #### The problem with some firmware on IRDETO cards is that after an 1 hour in idle time, "Entitlements" are lost. 4 | #### Then they have to be reloaded through EMMs, which sometimes takes up to 5 - 20 seconds. 5 | 6 | #### This script is designed to re-wake the DVB tuner once per hour and wait for 1 minute to receive EMMs. 7 | #### These EMMs are then automatically sent to the decoder card. 8 | 9 | #### The script is activated every 10 minutes and does the following: 10 | #### 11 | #### The Standby mode is tested first, and then the length of time the Oscam is idle is tested. 12 | #### If the Enigma is in Standby and the Oscam idle time is longer than 3600 seconds (1 hour), the satellite tuner will turn on and wait for EMM reception for 1 minute. 13 | 14 | #### 1) for OpenATV / OpenPLi Enigma please copy the script file into the directory "/usr/script" (create the directory if does not exist) 15 | #### in the case of other Enigma, copy the script where you see fit (!!! but not to the directory "/tmp" !!!) 16 | #### 17 | #### 2) assign the execution attributes to the script file: 18 | #### chmod a+x /usr/script/oscam_emm_refresh.sh 19 | #### 20 | #### 3) to start the script between 06:00 and 23:00, every 10 minutes, add the following line into the CRON configuration file: 21 | #### */10 6-23 * * * sh /usr/script/oscam_emm_refresh.sh 22 | #### 23 | #### Note: 24 | #### During editing the CRON config file (/etc/cron/crontabs/root), the CRON daemon must be stopped (as prevention), 25 | #### so, use the following command-line (OpenATV Enigma): 26 | #### /etc/init.d/crond {start|stop|restart} # use the stop argument before edit and when all will done, then use the start argument to start daemon again 27 | 28 | #### Version history: 29 | #### 04.10.2018 - script proposed by s3n0 30 | #### 30.01.2019 - minor repairs 31 | 32 | #### For a testing purpose: 33 | #### wget -q -O /tmp/test-oscam-api.xml $WEBIF_OSCAM/oscamapi.html?part=status 34 | #### cat /tmp/test-oscam-api.xml | sed -rn '/name="'$READER_LABEL'"/,/times/p' 35 | #### cat /tmp/test-oscam-api.xml | sed -rn '/name="'$READER_LABEL'"/,/times/ {s/.*idle="([0-9]+)".*/\1/p}' 36 | 37 | #### USER CONFIGURATION: 38 | WEBIF_ENIGMA="http://127.0.0.1:80" # use "http://LOGIN:PASSWORD@127.0.0.1:PORT" if you also use a password for Enigma-Webif 39 | WEBIF_OSCAM="http://127.0.0.1:8888" # use "http://LOGIN:PASSWORD@127.0.0.1:PORT" if you also use a password for Oscam-Webif 40 | READER_LABEL="reader_sci0" # card-reader name 41 | IDLE_TIME=3600 # the time interval [sec.] to retreive a new EMMs (only when Enigma is standby) 42 | EMM_AWAITING="1m" # awaiting to EMM arrival (1m = meaning 1 min. waiting time, 30s = meaning 30 secs, ... etc.) 43 | SRC="1:0:19:3731:C8E:3:EB0000:0:0:0:" # channel used for receive some EMMs - in this case as a SAT-channel Markiza-HD on the satellite Astra-3B / 23.5E => Service Reference Code = 1:0:19:3731:C8E:3:EB0000:0:0:0: 44 | LOG_FILE="/tmp/oscam_emm_refresh.log" # use "/dev/null" to disable the .log file 45 | LOG_MAXSIZE=25000 # max. file size [Bytes] 46 | 47 | #### function to check the Standby (e2/OpenWebif power-state) 48 | is_standby(){ 49 | [ "$(wget -q -O - $WEBIF_ENIGMA/web/powerstate | grep '' | cut -f 1)" = "true" ] 50 | } 51 | 52 | #### reduction the log file size, if neccessary (delete first 20 lines) 53 | if [ -f "$LOG_FILE" ] && [ $(wc -c < "$LOG_FILE") -gt $LOG_MAXSIZE ]; then sed -i -e 1,20d "$LOG_FILE"; fi 54 | 55 | #### if Enigma is not in standby, exit the script 56 | if ! is_standby; then echo `date '+%Y-%m-%d %H:%M:%S'`": Enigma2 is not in Standby. Script canceled." >> $LOG_FILE; exit 0; fi 57 | 58 | #### in another step will check the card-reader idle time... 59 | #### if the idle time of the specific card $READER_LABEL in Oscam is greater than $IDLE_TIME, then EMM refresh begins (zap to the satellite channel for a short time period), otherwise exiting script 60 | if [ $(wget -q -O - $WEBIF_OSCAM/oscamapi.html?part=status | sed -rn '/name="'$READER_LABEL'"/,/times/ {s/.*idle="([0-9]+)".*/\1/p}') -gt $IDLE_TIME ] 61 | then 62 | wget -q -O - "$WEBIF_ENIGMA/web/zap?sRef=$SRC" > /dev/null 2>&1 63 | echo `date '+%Y-%m-%d %H:%M:%S'`": Start channel descrambling - $SRC + waiting for EMM arrival (for $EMM_AWAITING time)." >> $LOG_FILE 64 | sleep $EMM_AWAITING # sleep 30s # sleep 2m 65 | else 66 | echo `date '+%Y-%m-%d %H:%M:%S'`": The $READER_LABEL reader idle time is not greater than the configured $IDLE_TIME secs. Script canceled." >> $LOG_FILE 67 | exit 0 68 | fi 69 | 70 | #### at the end of script execution we have to recheck the standby mode 71 | #### if a user has accidentally switched on a satellite receiver until the script was waiting for EMMs write 72 | if ! is_standby 73 | then 74 | echo `date '+%Y-%m-%d %H:%M:%S'`": Enigma2 has been awakened (by user's intervention ? using the remote control ?). Script canceled." >> $LOG_FILE 75 | exit 0 76 | else 77 | wget -q -O - "$WEBIF_ENIGMA/web/zap?sRef=-1" > /dev/null 2>&1 78 | echo `date '+%Y-%m-%d %H:%M:%S'`": Stop channel descrambling." >> $LOG_FILE 79 | #wget -q -O - "$WEBIF_ENIGMA/web/powerstate?newstate=5" > /dev/null 2>&1 80 | #echo `date '+%Y-%m-%d %H:%M:%S'`": Set-top-box has been switched to Standby" >> $LOG_FILE 81 | fi 82 | 83 | 84 | exit 0 85 | 86 | -------------------------------------------------------------------------------- /oscamrr: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | USER_NAME="a" 6 | USER_PASS="b" 7 | PORT="8888" 8 | OSCAM_READER="reader_sci0" 9 | 10 | 11 | OSCAM_WEBIF="http://${USER_NAME}:${USER_PASS}@127.0.0.1:${PORT}" # if the oscam password is not used: OSCAM_WEBIF="http://127.0.0.1:${PORT}" 12 | 13 | 14 | 15 | ################################### 16 | #### 17 | #### OSCAM-Reader-Restarts 18 | #### 19 | #### A simple endless shell-script that restarts the Oscam reader - in case if there are no "Tiers" / "Entitlements" 20 | #### 21 | ################################### 22 | #### 23 | #### Shell script designed by s3n0 (2022-03-20): 24 | #### https://github.com/s3n0 25 | #### https://www.linuxsat-support.com/cms/user/347246-s3n0/ 26 | #### 27 | #### Example of use: 28 | #### /etc/init.d/oscamrr 29 | #### 30 | #### Original shell script: 31 | #### https://www.linuxsat-support.com/thread/115614-script-to-restart-1-of-2-readers-on-no-entitelments/ 32 | #### 33 | ################################### 34 | #### 35 | #### How to install: 36 | #### wget -O /etc/init.d/oscamrr --no-check-certificate "https://github.com/s3n0/e2scripts/raw/master/oscamrr" # download and place the script into the "/etc/inid.d" folder 37 | #### chmod a+x /etc/init.d/oscamrr # and set the file execution rights 38 | #### ln -sf /etc/init.d/oscamrr /etc/rc3.d/S90oscamrr # link the script file under the Run-Level-3 (for auto-start during system boot) 39 | #### /etc/init.d/oscamrr start # start it manually (only as first time) 40 | #### 41 | #### How to uninstall: 42 | #### /etc/init.d/oscamrr stop 43 | #### rm -f /etc/rc3.d/S90oscamrr /etc/init.d/oscamrr 44 | #### 45 | ################################### 46 | 47 | 48 | 49 | TMP_SCRIPT_NAME="oscam_entitlements_checking" 50 | 51 | 52 | 53 | ################################### 54 | 55 | fStart() { 56 | cat << NEWSCRIPT > /tmp/$TMP_SCRIPT_NAME 57 | #!/bin/bash 58 | 59 | trap 'exit' INT TERM ERR 60 | trap 'kill 0' EXIT 61 | 62 | while true; do 63 | # [ \$(wget -qO- "${OSCAM_WEBIF}/entitlements.html?label=${OSCAM_READER}" | grep -c "tier") -gt 0 ] && wget -qO- "${OSCAM_WEBIF}/status.html?action=restart&label=${OSCAM_READER}" > /dev/null 2>&1 64 | [ \$(wget -qO- "${OSCAM_WEBIF}/entitlements.html?label=${OSCAM_READER}" | grep -c "e_expired") -gt 2 ] && wget -qO- "${OSCAM_WEBIF}/status.html?action=restart&label=${OSCAM_READER}" > /dev/null 2>&1 65 | sleep 65 66 | done 67 | 68 | exit 69 | NEWSCRIPT 70 | chmod a+x /tmp/$TMP_SCRIPT_NAME 71 | nohup /tmp/$TMP_SCRIPT_NAME &>/dev/null & 72 | } 73 | 74 | ################################### 75 | 76 | fStop() { 77 | if [ -e "/tmp/$TMP_SCRIPT_NAME" ]; then 78 | if killall --help > /dev/null 2>&1; then # use the `killall` command 79 | killall -9 $TMP_SCRIPT_NAME 80 | else # use the `kill` command 81 | if ps --version 2>&1 | grep -q -i "busybox"; then # ...then... use the feature-poor `ps` command from BusyBox (for example in OpenPLi image) 82 | PID=$(ps | grep $TMP_SCRIPT_NAME | grep -v 'grep' | awk '{ printf $1 }') 83 | else # ...else... use the full-featured `ps` command from Linux OS (for example in OpenATV image) 84 | PID=$(ps -ef | grep $TMP_SCRIPT_NAME | grep -v 'grep' | awk '{ printf $2 }') 85 | #PID=$(ps -aux | grep $TMP_SCRIPT_NAME | grep -v 'grep' | cut -d ' ' -f 6) 86 | fi 87 | kill -n 9 $PID 88 | fi 89 | sleep 1 90 | rm -f /tmp/$TMP_SCRIPT_NAME 91 | fi 92 | } 93 | 94 | ################################### 95 | 96 | case "$1" in 97 | start) 98 | fStart 99 | ;; 100 | stop) 101 | fStop 102 | ;; 103 | restart) 104 | fStop 105 | fStart 106 | ;; 107 | status) 108 | [ -e "/tmp/$TMP_SCRIPT_NAME" ] && { echo "service is running"; exit 0; } || { echo "service is stopped"; exit 3; } 109 | ;; 110 | *) 111 | echo "ERROR ! Wrong argument ! The correct usage syntax is:" 112 | echo " $0 " 113 | exit 2 # invalid or excess argument(s) 114 | ;; 115 | esac 116 | 117 | ################################### 118 | 119 | exit 0 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | #### ---- to restart the specific card reader : 128 | #### [ $(wget -qO- "${OSCAM_WEBIF}/entitlements.html?label=${OSCAM_READER}" | grep -c "tier") -gt 0 ] && wget -qO- "${OSCAM_WEBIF}/status.html?action=restart&label=${OSCAM_READER}" > /dev/null 2>&1 129 | #### ---- to re-read entitlements : 130 | #### # # # # # # # # # # # # # # # # # # # # # # # # # /readers.html?action=reread&label=${OSCAM_READER}" > /dev/null 2>&1 131 | -------------------------------------------------------------------------------- /oscamrrf: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | USER_NAME="a" 6 | USER_PASS="b" 7 | PORT="8888" 8 | OSCAM_READER_0="reader_sci0" 9 | OSCAM_READER_1="reader_sci1" 10 | 11 | OSCAM_WEBIF="http://${USER_NAME}:${USER_PASS}@127.0.0.1:${PORT}" # if the oscam password is not used: OSCAM_WEBIF="http://127.0.0.1:${PORT}" 12 | 13 | 14 | 15 | ################################### 16 | #### 17 | #### OSCAM-Reader-Restarts-as-Force 18 | #### 19 | #### A simple endless shell-script that restarts the Oscam readers - both internal card readers ! as FORCE ! every 2 mins (60 sec. + 60 sec.) ! 20 | #### The script will restart the first reader in 60 seconds and then restart the second reader - in another 60 seconds. 21 | ################################### 22 | #### 23 | #### Shell script designed by s3n0 (2022-03-21): 24 | #### https://github.com/s3n0 25 | #### https://www.linuxsat-support.com/cms/user/347246-s3n0/ 26 | #### 27 | #### Example of use: 28 | #### /etc/init.d/oscamrrf 29 | #### 30 | #### Original shell script: 31 | #### https://www.linuxsat-support.com/thread/115614-script-to-restart-1-of-2-readers-on-no-entitelments/ 32 | #### 33 | ################################### 34 | #### 35 | #### How to install: 36 | #### wget -O /etc/init.d/oscamrrf --no-check-certificate "https://github.com/s3n0/e2scripts/raw/master/oscamrrf" # download and place the script into the "/etc/inid.d" folder 37 | #### chmod a+x /etc/init.d/oscamrrf # and set the file execution rights 38 | #### ln -sf /etc/init.d/oscamrrf /etc/rc3.d/S90oscamrrf # link the script file under the Run-Level-3 (for auto-start during system boot) 39 | #### /etc/init.d/oscamrrf start # start it manually (only as first time) 40 | #### 41 | #### How to uninstall: 42 | #### /etc/init.d/oscamrrf stop 43 | #### rm -f /etc/rc3.d/S90oscamrrf /etc/init.d/oscamrrf 44 | #### 45 | ################################### 46 | 47 | 48 | 49 | TMP_SCRIPT_NAME="oscam_readers_force_restart" 50 | 51 | 52 | 53 | ################################### 54 | 55 | fStart() { 56 | 57 | cat << NEWSCRIPT > /tmp/$TMP_SCRIPT_NAME 58 | #!/bin/bash 59 | 60 | trap 'exit' INT TERM ERR 61 | trap 'kill 0' EXIT 62 | 63 | while true; do 64 | wget -qO- "${OSCAM_WEBIF}/status.html?action=restart&label=${OSCAM_READER_0}" > /dev/null 2>&1 65 | sleep 60 66 | wget -qO- "${OSCAM_WEBIF}/status.html?action=restart&label=${OSCAM_READER_1}" > /dev/null 2>&1 67 | sleep 60 68 | done 69 | 70 | exit 71 | NEWSCRIPT 72 | 73 | #sed '/sleep[[:space:]]120/d' /tmp/$TMP_SCRIPT_NAME 74 | #sed -i '7 a sleep 120' /tmp/$TMP_SCRIPT_NAME # sed for in-place editing (-i) of the file: 'LINE_NUMBER a-ppend TEXT_TO_ADD' 75 | 76 | chmod a+x /tmp/$TMP_SCRIPT_NAME 77 | nohup /tmp/$TMP_SCRIPT_NAME &>/dev/null & 78 | } 79 | 80 | ################################### 81 | 82 | fStop() { 83 | if [ -e "/tmp/$TMP_SCRIPT_NAME" ]; then 84 | if killall --help > /dev/null 2>&1; then # use the `killall` command 85 | killall -9 $TMP_SCRIPT_NAME 86 | else # use the `kill` command 87 | if ps --version 2>&1 | grep -q -i "busybox"; then # ...then... use the feature-poor `ps` command from BusyBox (for example in OpenPLi image) 88 | PID=$(ps | grep $TMP_SCRIPT_NAME | grep -v 'grep' | awk '{ printf $1 }') 89 | else # ...else... use the full-featured `ps` command from Linux OS (for example in OpenATV image) 90 | PID=$(ps -ef | grep $TMP_SCRIPT_NAME | grep -v 'grep' | awk '{ printf $2 }') 91 | #PID=$(ps -aux | grep $TMP_SCRIPT_NAME | grep -v 'grep' | cut -d ' ' -f 6) 92 | fi 93 | kill -n 9 $PID 94 | fi 95 | sleep 1 96 | rm -f /tmp/$TMP_SCRIPT_NAME 97 | fi 98 | } 99 | 100 | ################################### 101 | 102 | case "$1" in 103 | start) 104 | fStart 105 | ;; 106 | stop) 107 | fStop 108 | ;; 109 | restart) 110 | fStop 111 | fStart 112 | ;; 113 | status) 114 | [ -e "/tmp/$TMP_SCRIPT_NAME" ] && { echo "service is running"; exit 0; } || { echo "service is stopped"; exit 3; } 115 | ;; 116 | *) 117 | echo "ERROR ! Wrong argument ! The correct usage syntax is:" 118 | echo " $0 " 119 | exit 2 # invalid or excess argument(s) 120 | ;; 121 | esac 122 | 123 | ################################### 124 | 125 | exit 0 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | #### ---- to restart the specific card reader : 134 | #### [ $(wget -qO- "${OSCAM_WEBIF}/entitlements.html?label=${OSCAM_READER}" | grep -c "tier") -gt 0 ] && wget -qO- "${OSCAM_WEBIF}/status.html?action=restart&label=${OSCAM_READER}" > /dev/null 2>&1 135 | #### ---- to re-read entitlements : 136 | #### # # # # # # # # # # # # # # # # # # # # # # # # # /readers.html?action=reread&label=${OSCAM_READER}" > /dev/null 2>&1 137 | -------------------------------------------------------------------------------- /remove_unused_languages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ################################################################################# 4 | #### a simple command-line to remove unnecessary language packs from OpenATV #### 5 | ################################################################################# 6 | 7 | #### HOW TO CHECK INSTALLED LANG. PACKAGES: 8 | #opkg update && opkg list-installed | grep enigma2-locale 9 | 10 | #### HOW TO REMOVE LANGUAGE PACKAGES: 11 | #opkg remove --force-depends enigma2-locale-{ar,bg,ca,cs,da,el,en-gb,es,et,fa,fi,fr,fy,he,hr,hu,id,is,it,ku,lt,lv,nb,nl,no,pl,pt,pt-br,ro,ru,sk,sl,sr,sv,th,tr,uk,vi,zh-cn,zh-hk} # remove all except EN,DE 12 | #opkg remove --force-depends enigma2-locale-{ar,bg,ca,cs,da,el,en-gb,es,et,fa,fi,fr,fy,he,hr,hu,id,is,it,ku,lt,lv,nb,nl,no,pl,pt,pt-br,ro,ru,sl,sr,sv,th,tr,uk,vi,zh-cn,zh-hk} # remove all except EN,DE,SK 13 | 14 | #### HOW TO REMOVE LANGUAGE PACKAGES (WITH THE HELPING OF THE DIR-LIST, BY S3N0) --- ONLY WORKS IN OpenATV AND SOME Enigma2 DERIVATIVES ! 15 | PKGS=$(ls /usr/share/enigma2/po/ | grep -vwE 'en|de|sk' | awk '{gsub("_","-"); print "enigma2-locale-" tolower($0)}' | tr '\n' ' '); [ -z "$PKGS" ] && echo "No packages to remove." || opkg remove --force-depends $PKGS # to remove all except EN,DE,SK 16 | 17 | #### HOW TO REMOVE LANGUAGE PACKAGES (WITH THE HELPING OF LOOP-FOR AND DIR-LIST, BY OpenATV FORUM -> https://www.opena.tv/howtos/41966-howto-sprachen-deinstallieren-nachdem-die-box-online-geflasht-wurde-post360880.html#post360880 ): 18 | #for LANG in `ls /usr/share/enigma2/po/ | grep -v -E 'de|en|sk'`; do opkg remove --force-depends enigma2-locale-$LANG; done; # remove all except EN,DE,SK 19 | 20 | #### HOW TO INSTALL LANGUAGE PACKAGES: 21 | #opkg install enigma2-locale-{ar,bg,ca,cs,da,el,en-gb,es,et,fa,fi,fr,fy,he,hr,hu,id,is,it,ku,lt,lv,nb,nl,no,pl,pt,pt-br,ro,ru,sk,sl,sr,sv,th,tr,uk,vi,zh-cn,zh-hk} 22 | #opkg install enigma2-locale-{en,de,sk} 23 | 24 | #### A NOTE: 25 | ###Please do not remove the English language (en) and the German language (de). These are the default languages that will be used when other languages do not exist. It also has a lot of plugins for OpenATV (as the default localization language in case of emergency). 26 | 27 | #### FOLDERS USED IN ENIGMA2 FOR LANG. PACKAGES: 28 | #rm /usr/share/enigma2/countries/*.png 29 | #rm -r /usr/share/enigma2/po/* 30 | -------------------------------------------------------------------------------- /softcam: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | 6 | # HISTORY OF CHANGES: 7 | # 8 | # 2018/07/16 - created shell-script: /etc/init.d/softcam 9 | # 2019/06/15 - remake the logging concept (logging output via function) 10 | # - some cosmetic improvements 11 | # 2019/06/23 - some changes in start/stop/restart functions 12 | # 2020/02/19 - improved and complete instructions how-to install the Softcam 13 | # 2020/08/30 - no longer use the SIGTERM (No.15) signal, but only SIGKILL (No.9), as some OSCam builds ignore the regular stop by the SIGTERM (No.15) signal 14 | # - removed 'stdout' redirection to 'null' device at softcam execution/starting command-line 15 | # 2020/11/10 - improved installation instructions (OSCam / CCcam) 16 | # 2021/03/24 - simplified (abbreviated) script source code 17 | # 2021/04/07 - updated return error codes for "argument status" as well as for "exit status" 18 | # 2022/03/12 - improved installation instructions (clarity) 19 | 20 | 21 | 22 | 23 | 24 | # ####################### HOW-TO ######################### 25 | # 26 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 27 | # Enigma2 distributions with built-in SoftCAM support : (OpenATV 6.x and OpenPLi 7.x) 28 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 29 | # 30 | # 1) Download the "softcam" script file directly from my github + ADD the ".oscam" file extension + SET the execution rights/attributes: 31 | # wget -O /etc/init.d/softcam.oscam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam.oscam 32 | # 33 | # If you plan to modify and use this script for CCcam, then the correct file extension is ".cccam" or ".CCcam": 34 | # wget -O /etc/init.d/softcam.CCcam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam.CCcam 35 | # 36 | # 2) If your Enigma2 distribution has built-in softcam support, then there is no need to create any symbolic link at this point. 37 | # I mean the "/etc/init.d/softcam.*" script auto-start feature, which is implemented in many new Enigma2 distributions (based on OE2.0 core), directly in the Enigma2 source code. 38 | # 39 | # 3) Copy your configuration files (using the FTP connection) into the particular folder: 40 | # For the OSCam: "/etc/tuxbox/config/oscam" 41 | # For the CCcam: "/etc" - where the main configuration file is "/etc/CCcam.cfg" !!! 42 | # 43 | # 4) Download a specific softcam binary file and upload it to the set-top box - usually to the "/usr/bin" folder. 44 | # Set its executable attributes: 45 | # chmod a+x /usr/bin/softcam-name 46 | # You can also use the following online shell script to download the OSCam binary file (I recommend it only for OpenATV): 47 | # wget -q -O - --no-check-certificate "https://github.com/s3n0/e2scripts/raw/master/oscam-new-version-updater.sh" | bash 48 | # 49 | # 5) Restart the set-top box via the GUI-MENU or via the Shell: 50 | # reboot 51 | # 52 | # 6) Select and activate the particular softcam via the GUI-MENU: 53 | # MENU -> Info Panel -> Softcam Panel -> select your softcam (OSCam or CCcam) by pressing the left/right buttons and then activate it with the green button 54 | # 55 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 56 | # All other or unknown Enigma2 distributions - without built-in SoftCAM support : 57 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 58 | # 59 | # 1) Download the "softcam" script file directly from my github + SET the execution rights/attributes: 60 | # wget -O /etc/init.d/softcam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam 61 | # 62 | # 2) Probably, the "/etc/init.d/softcam" script auto-start feature is not implemented in your Enigma2 distribution (in Python algorithm), 63 | # so you must additionally create a symbolic link, and thus you have two options to choose from: 64 | # 65 | # A) You can use the automated system tool: 66 | # For add (install) the startup sym-links to all default run-levels: 67 | # update-rc.d softcam defaults 90 68 | # For remove (uninstall) startup sym-links from all run-levels use the following command: 69 | # update-rc.d -f softcam remove 70 | # 71 | # B) If the automated system tool does not work or is not installed, use the manual creation of a symbolic link: 72 | # For add (install) the startup sym-links to run-level No.3 (Enigma2 default run-level): 73 | # ln -sf /etc/init.d/softcam /etc/rc3.d/S90softcam 74 | # For remove (uninstall) the symbolic link you can simply delete this link: 75 | # rm -f /etc/rc3.d/S90softcam # or the same way with "unlink" command: unlink /etc/rc3.d/S90softcam 76 | # 77 | # 3) Copy your configuration files (using the FTP connection) into the particular folder: 78 | # For the OSCam: "/etc/tuxbox/config/oscam" 79 | # For the CCcam: "/etc" - where the main configuration file is "/etc/CCcam.cfg" !!! 80 | # 81 | # 4) Download a specific softcam binary file and upload it to the set-top box - usually to the "/usr/bin" folder. 82 | # Set its executable attributes: 83 | # chmod a+x /usr/bin/softcam-name 84 | # You can also use the following online shell script to download the OSCam binary file (I recommend it only for OpenATV): 85 | # wget -q -O - --no-check-certificate "https://github.com/s3n0/e2scripts/raw/master/oscam-new-version-updater.sh" | bash 86 | # 87 | # 5) Then restart the set-top box via the GUI-MENU or via the Shell: 88 | # reboot 89 | # 90 | # ########################################################## 91 | 92 | 93 | 94 | 95 | # ###################### USER SETUP ###################### 96 | # 97 | # SOFTCAM BINARY DIRECTORY: 98 | BINDIR="/usr/bin" 99 | # 100 | # SOFTCAM PROCESS NAME (BINARY FILE NAME): 101 | BINFILENAME="oscam" # for CCcam: BINFILENAME="CCcam" 102 | # 103 | # SOFTCAM ARGUMENTS: 104 | BINARGS="-b -r 2" # for CCcam: BINARGS="-stl" 105 | # 106 | # SOFTCAM EXECUTION COMMAND LINE: 107 | CMDEXEC="${BINDIR}/${BINFILENAME} ${BINARGS}" # for CCcam: CMDEXEC="${BINDIR}/${BINFILENAME} ${BINARGS} > /dev/null 2>&1 &" 108 | # 109 | # LOG FILE FOR THE SOFTCAM HANDLING: 110 | LOGFILE="/tmp/${BINFILENAME}_handling.log" 111 | LOGSIZE=45000 # limit maximum file size [Bytes] 112 | # 113 | # AUXILIARY SCRIPT VARIABLES: 114 | HRLINE="--------------------------------------------------------------------------" 115 | MANPAGE="PROPER USE OF THE SCRIPT: 116 | ${0} 117 | POSSIBLE ARGUMENTS: 118 | $(cat ${0} | grep -wE '^[[:space:]]+[a-z\|\-]+\)$' | tr -d ')')" 119 | # 120 | # ############### END OF THE USER SETUP ################## 121 | 122 | 123 | 124 | 125 | # ##################### FUNCTIONS ######################## 126 | 127 | fLog() 128 | { 129 | if [ "$1" = "$HRLINE" ]; then 130 | MSG="$1" 131 | else 132 | MSG="$(date '+%Y-%m-%d %H:%M:%S') $1" # add a timestamp if it's not a separator line (header line) 133 | fi 134 | 135 | #echo "$MSG" > /dev/null ### null device <--- log will disabled (do nothing) 136 | #echo "$MSG" >> $LOGFILE ### file 137 | #echo "$MSG" >> $LOGFILE 2>&1 ### file + stderr 138 | #echo "$MSG" | tee -a $LOGFILE ### file + stdout(display) 139 | echo "$MSG" 2>&1 | tee -a $LOGFILE ### file + stdout(display) + stderr 140 | 141 | #### reduction the log filesize, if neccessary (delete first 50 lines): 142 | if [ -f "$LOGFILE" ] && [ $(wc -c <"$LOGFILE") -gt $LOGSIZE ]; then sed -i -e 1,50d "$LOGFILE"; fi 143 | } 144 | 145 | fStop() 146 | { 147 | fLog "Stopping '$1'..." 148 | if ! pidof $1 > /dev/null; then 149 | fLog "...no '$1' process is running." 150 | fLog "$HRLINE" 151 | exit 7 # 1=generic or unspecified error ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example, "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 152 | else 153 | fLog "...sending the SIGKILL signal to the service '$1' / PID '$(pidof $1)'" 154 | killall -9 $1 > /dev/null 155 | sleep 0.5s # changed from 1s to 0.5s, as the '/lib/python/Screens/SoftcamSetup.py' (OpenATV github) restarts the softcam script too quickly with the 'stop' argument and 1 sec. later it immediately starts the script again with the argument 'start' i.e. without using the 'restart' argument ! unfortunately my softcam script is testing as the first normal softcam stopping, which can take about 0.3 - 0.7 secs 156 | if pidof $1 > /dev/null; then 157 | fLog "...'$1' was not killed by the SIGKILL signal. The process is still running. Probably a system error ?!" 158 | fLog "$HRLINE" 159 | exit 1 160 | else 161 | fLog "...'$1' was successfully killed." 162 | fi 163 | fi 164 | } 165 | 166 | fStart() 167 | { 168 | fLog "Starting '$1'..." 169 | if pidof $1 > /dev/null; then 170 | fLog "...'$1' process has already started and is still running." 171 | else 172 | fLog "...command-line used to start the process: ${CMDEXEC}" 173 | $CMDEXEC 174 | sleep 0.8s 175 | if pidof $1 > /dev/null; then 176 | fLog "...'$1' was successfully started." 177 | else 178 | fLog "ERROR! '$1' start failed!" 179 | fLog "$HRLINE" 180 | exit 1 181 | fi 182 | fi 183 | } 184 | 185 | fRestart() 186 | { 187 | if pidof $1 > /dev/null; then fStop $1; fi # the process will be stopped / killed only if it's running 188 | fStart $1 189 | } 190 | 191 | fGetVer() 192 | { 193 | case `echo "$BINFILENAME" | tr '[:upper:]' '[:lower:]'` in # `echo "$BINFILENAME" | awk '{print tolower($0)}'` 194 | "oscam"*|"ncam"*) VER=$($BINDIR/$BINFILENAME -V | grep 'Version\|IPv6' | sed 's/Version:[ ]*//' | sed 's/IPv6.*yes/with IPv6/g' | sed 's/IPv6.*no/IPv4-only/g' | sed ':a;N;$!ba;s/\n/ /g') ;; 195 | "cccam"*) VER=$(strings $BINDIR/$BINFILENAME | grep -E 'CCcam[[:space:]][0-9/./-]+') ;; # it is not completely regular to get the CCcam version, but it works :) 196 | *) VER="ERROR! version/info detection for '${BINFILENAME}' has not yet been implemented in the script algorithm" ;; 197 | esac 198 | [ -z "$VER" ] && VER="ERROR! failed to get version/info of softcam '${BINFILENAME}'" 199 | echo "$VER" 200 | } 201 | 202 | 203 | # ########################################################## 204 | # ########################################################## 205 | # ########################################################## 206 | 207 | 208 | # CHECKING THE EXISTENCE OF THE BINARY/EXEC FILE 209 | 210 | if [ ! -x "$BINDIR/$BINFILENAME" ]; then 211 | fLog "ERROR! Executable binary file '$BINDIR/$BINFILENAME' does not exist!" 212 | fLog "$HRLINE" 213 | exit 5 # 1=generic or unspecified error (current practice) ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 214 | fi 215 | 216 | 217 | # CALL FUNCTIONS ACCORDING TO INPUT ARGUMENTS OF THE SHELL SCRIPT ************************** 218 | 219 | case "$1" in 220 | start) 221 | fStart "$BINFILENAME" 222 | fLog "$HRLINE" 223 | ;; 224 | stop) 225 | fStop "$BINFILENAME" 226 | fLog "$HRLINE" 227 | ;; 228 | restart|reload|force-reload) 229 | fRestart "$BINFILENAME" 230 | fLog "$HRLINE" 231 | ;; 232 | status) 233 | echo -n "$BINFILENAME " 234 | if pidof $BINFILENAME > /dev/null # RETURNED STATUS: 235 | then echo "running"; exit 0 # 0 = program is running -or- service is OK ; 1 = program is dead with "/var/run" pid-file exists ; 2 = program is dead with "/var/lock" lock-file exists ; 236 | else echo "stopped"; exit 3 # 3 = program is not running ; 4 = status is unknown ; 5-99 = reserved for future LSB use ; 100-254 = reserved 237 | fi 238 | ;; 239 | version|info) 240 | fGetVer 241 | ;; 242 | *) 243 | fLog "Unknown or missing arguments !" 244 | echo "$MANPAGE" >$(tty) 245 | fLog "$HRLINE" 246 | exit 2 # 1=generic or unspecified error ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example, "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 247 | ;; 248 | esac 249 | 250 | 251 | exit 0 252 | 253 | -------------------------------------------------------------------------------- /softcam (+ bckgrnd script to checking the reader entitlements): -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | 6 | # HISTORY OF CHANGES: 7 | # 8 | # 2018/07/16 - created shell-script: /etc/init.d/softcam 9 | # 2019/06/15 - remake the logging concept (logging output via function) 10 | # - some cosmetic improvements 11 | # 2019/06/23 - some changes in start/stop/restart functions 12 | # 2020/02/19 - improved and complete instructions how-to install the Softcam 13 | # 2020/08/30 - no longer use the SIGTERM (No.15) signal, but only SIGKILL (No.9), as some OSCam builds ignore the regular stop by the SIGTERM (No.15) signal 14 | # - removed 'stdout' redirection to 'null' device at softcam execution/starting command-line 15 | # 2020/11/10 - improved installation instructions (OSCam / CCcam) 16 | # 2021/03/24 - simplified (abbreviated) script source code 17 | # 2021/04/07 - updated return error codes for "argument status" as well as for "exit status" 18 | # 2021/09/26 - some improvements of the script function for Auto-Updating (AU) of "Entitlements" on a decoding card (IRDETO mode), which are updated via EMMs 19 | # 2022/03/12 - improved installation instructions (clarity) 20 | 21 | 22 | 23 | 24 | # ####################### HOW-TO ######################### 25 | # 26 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 27 | # Enigma2 distributions with built-in SoftCAM support : (OpenATV 6.x and OpenPLi 7.x) 28 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 29 | # 30 | # 1) Download the "softcam" script file directly from my github + ADD the ".oscam" file extension + SET the execution rights/attributes: 31 | # wget -O /etc/init.d/softcam.oscam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam.oscam 32 | # 33 | # If you plan to modify and use this script for CCcam, then the correct file extension is ".cccam" or ".CCcam": 34 | # wget -O /etc/init.d/softcam.CCcam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam.CCcam 35 | # 36 | # 2) If your Enigma2 distribution has built-in softcam support, then there is no need to create any symbolic link at this point. 37 | # I mean the "/etc/init.d/softcam.*" script auto-start feature, which is implemented in many new Enigma2 distributions (based on OE2.0 core), directly in the Enigma2 source code. 38 | # 39 | # 3) Copy your configuration files (using the FTP connection) into the particular folder: 40 | # For the OSCam: "/etc/tuxbox/config/oscam" 41 | # For the CCcam: "/etc" - where the main configuration file is "/etc/CCcam.cfg" !!! 42 | # 43 | # 4) Download a specific softcam binary file and upload it to the set-top box - usually to the "/usr/bin" folder. 44 | # Set its executable attributes: 45 | # chmod a+x /usr/bin/softcam-name 46 | # You can also use the following online shell script to download the OSCam binary file (I recommend it only for OpenATV): 47 | # wget -q -O - --no-check-certificate "https://github.com/s3n0/e2scripts/raw/master/oscam-new-version-updater.sh" | bash 48 | # 49 | # 5) Restart the set-top box via the GUI-MENU or via the Shell: 50 | # reboot 51 | # 52 | # 6) Select and activate the particular softcam via the GUI-MENU: 53 | # MENU -> Info Panel -> Softcam Panel -> select your softcam (OSCam or CCcam) by pressing the left/right buttons and then activate it with the green button 54 | # 55 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 56 | # All other or unknown Enigma2 distributions - without built-in SoftCAM support : 57 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 58 | # 59 | # 1) Download the "softcam" script file directly from my github + SET the execution rights/attributes: 60 | # wget -O /etc/init.d/softcam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam 61 | # 62 | # 2) Probably, the "/etc/init.d/softcam" script auto-start feature is not implemented in your Enigma2 distribution (in Python algorithm), 63 | # so you must additionally create a symbolic link, and thus you have two options to choose from: 64 | # 65 | # A) You can use the automated system tool: 66 | # For add (install) the startup sym-links to all default run-levels: 67 | # update-rc.d softcam defaults 90 68 | # For remove (uninstall) startup sym-links from all run-levels use the following command: 69 | # update-rc.d -f softcam remove 70 | # 71 | # B) If the automated system tool does not work or is not installed, use the manual creation of a symbolic link: 72 | # For add (install) the startup sym-links to run-level No.3 (Enigma2 default run-level): 73 | # ln -sf /etc/init.d/softcam /etc/rc3.d/S90softcam 74 | # For remove (uninstall) the symbolic link you can simply delete this link: 75 | # rm -f /etc/rc3.d/S90softcam # or the same way with "unlink" command: unlink /etc/rc3.d/S90softcam 76 | # 77 | # 3) Copy your configuration files (using the FTP connection) into the particular folder: 78 | # For the OSCam: "/etc/tuxbox/config/oscam" 79 | # For the CCcam: "/etc" - where the main configuration file is "/etc/CCcam.cfg" !!! 80 | # 81 | # 4) Download a specific softcam binary file and upload it to the set-top box - usually to the "/usr/bin" folder. 82 | # Set its executable attributes: 83 | # chmod a+x /usr/bin/softcam-name 84 | # You can also use the following online shell script to download the OSCam binary file (I recommend it only for OpenATV): 85 | # wget -q -O - --no-check-certificate "https://github.com/s3n0/e2scripts/raw/master/oscam-new-version-updater.sh" | bash 86 | # 87 | # 5) Then restart the set-top box via the GUI-MENU or via the Shell: 88 | # reboot 89 | # 90 | # ########################################################## 91 | 92 | 93 | 94 | 95 | # ###################### USER SETUP ###################### 96 | # 97 | # SOFTCAM BINARY DIRECTORY: 98 | BINDIR="/usr/bin" 99 | # 100 | # SOFTCAM PROCESS NAME (BINARY FILE NAME): 101 | BINFILENAME="oscam" # for CCcam: BINFILENAME="CCcam" 102 | # 103 | # SOFTCAM ARGUMENTS: 104 | BINARGS="-b -r 2" # for CCcam: BINARGS="-stl" 105 | # 106 | # SOFTCAM EXECUTION COMMAND LINE: 107 | CMDEXEC="${BINDIR}/${BINFILENAME} ${BINARGS}" # for CCcam: CMDEXEC="${BINDIR}/${BINFILENAME} ${BINARGS} > /dev/null 2>&1 &" 108 | # 109 | # LOG FILE FOR THE SOFTCAM HANDLING: 110 | LOGFILE="/tmp/${BINFILENAME}_handling.log" 111 | LOGSIZE=45000 # limit maximum file size [Bytes] 112 | # 113 | # CHANNEL (SERVICE REFERENCE CODE) FOR AUTO-UPDATE OF PREPAID TV-PACKAGES (ENTITLEMENTS) + WAITING AUTO-UPDATE TIME (SECONDS): 114 | # A NOTE: Auto-Updating via EMM packets is required after a Softcam start/restart, for some encryption cards, for example when the card is operating in IRDETO mode. 115 | ZAPCHANNEL="1:0:19:3731:C8E:3:EB0000:0:0:0:" 116 | ZAPDELAY=30 117 | AUENABLED="yes" # "no" / "yes" - run the AutoUpdate script-function in the background permanently, with Entitlements checking 118 | OSCAMWEBIF="http://YOUR-USERNAME:YOUR-PASSWORD@127.0.0.1:8888" # if you do not use the password for Oscam-Webif: OSCAMWEBIF="http://127.0.0.1:8888" 119 | OSCAMREADER="READER_LABEL" 120 | # 121 | # AUXILIARY SCRIPT VARIABLES: 122 | HRLINE="--------------------------------------------------------------------------" 123 | MANPAGE="PROPER USE OF THE SCRIPT: 124 | ${0} 125 | POSSIBLE ARGUMENTS: 126 | $(cat ${0} | grep -wE '^[[:space:]]+[a-z\|\-]+\)$' | tr -d ')')" 127 | # 128 | # ############### END OF THE USER SETUP ################## 129 | 130 | 131 | 132 | 133 | # ##################### FUNCTIONS ######################## 134 | 135 | fLog() 136 | { 137 | if [ "$1" = "$HRLINE" ]; then 138 | MSG="$1" 139 | else 140 | MSG="$(date '+%Y-%m-%d %H:%M:%S') $1" # add a timestamp if it's not a separator line (header line) 141 | fi 142 | 143 | #echo "$MSG" > /dev/null ### null device <--- log will disabled (do nothing) 144 | #echo "$MSG" >> $LOGFILE ### file 145 | #echo "$MSG" >> $LOGFILE 2>&1 ### file + stderr 146 | #echo "$MSG" | tee -a $LOGFILE ### file + stdout(display) 147 | echo "$MSG" 2>&1 | tee -a $LOGFILE ### file + stdout(display) + stderr 148 | 149 | #### reduction the log filesize, if neccessary (delete first 50 lines): 150 | if [ -f "$LOGFILE" ] && [ $(wc -c <"$LOGFILE") -gt $LOGSIZE ]; then sed -i -e 1,50d "$LOGFILE"; fi 151 | } 152 | 153 | fStop() 154 | { 155 | fLog "Stopping '$1'..." 156 | if ! pidof $1 > /dev/null; then 157 | fLog "...no '$1' process is running." 158 | fLog "$HRLINE" 159 | exit 7 # 1=generic or unspecified error ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example, "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 160 | else 161 | [ "$AUENABLED" = "yes" ] && fBackgroundScript stop 162 | fLog "...sending the SIGKILL signal to the service '$1' / PID '$(pidof $1)'" 163 | killall -9 $1 > /dev/null 164 | sleep 0.5s # changed from 1s to 0.5s, as the '/lib/python/Screens/SoftcamSetup.py' (OpenATV github) restarts the softcam script too quickly with the 'stop' argument and 1 sec. later it immediately starts the script again with the argument 'start' i.e. without using the 'restart' argument ! unfortunately my softcam script is testing as the first normal softcam stopping, which can take about 0.3 - 0.7 secs 165 | if pidof $1 > /dev/null; then 166 | fLog "...'$1' was not killed by the SIGKILL signal. The process is still running. Probably a system error ?!" 167 | fLog "$HRLINE" 168 | exit 1 169 | else 170 | fLog "...'$1' was successfully killed." 171 | fi 172 | fi 173 | } 174 | 175 | fStart() 176 | { 177 | fLog "Starting '$1'..." 178 | if pidof $1 > /dev/null; then 179 | fLog "...'$1' process has already started and is still running." 180 | else 181 | fLog "...command-line used to start the process: ${CMDEXEC}" 182 | $CMDEXEC 183 | sleep 0.8s 184 | if pidof $1 > /dev/null; then 185 | fLog "...'$1' was successfully started." 186 | [ "$AUENABLED" = "yes" ] && fBackgroundScript start 187 | else 188 | fLog "ERROR! '$1' start failed!" 189 | fLog "$HRLINE" 190 | exit 1 191 | fi 192 | fi 193 | } 194 | 195 | fRestart() 196 | { 197 | if pidof $1 > /dev/null; then fStop $1; fi # the process will be stopped / killed only if it's running 198 | fStart $1 199 | } 200 | 201 | fGetVer() 202 | { 203 | case `echo "$BINFILENAME" | tr '[:upper:]' '[:lower:]'` in # `echo "$BINFILENAME" | awk '{print tolower($0)}'` 204 | "oscam"*|"ncam"*) VER=$($BINDIR/$BINFILENAME -V | grep 'Version\|IPv6' | sed 's/Version:[ ]*//' | sed 's/IPv6.*yes/with IPv6/g' | sed 's/IPv6.*no/IPv4-only/g' | sed ':a;N;$!ba;s/\n/ /g') ;; 205 | "cccam"*) VER=$(strings $BINDIR/$BINFILENAME | grep -E 'CCcam[[:space:]][0-9/./-]+') ;; # it is not completely regular to get the CCcam version, but it works :) 206 | *) VER="ERROR! version/info detection for '${BINFILENAME}' has not yet been implemented in the script algorithm" ;; 207 | esac 208 | [ -z "$VER" ] && VER="ERROR! failed to get version/info of softcam '${BINFILENAME}'" 209 | echo "$VER" 210 | } 211 | 212 | E2inStandby() 213 | { 214 | wget -q -O - http://127.0.0.1/api/powerstate | grep -qi 'instandby.*true' # check if Enigma2 is in standby mode 215 | } 216 | 217 | fBackgroundScript() 218 | { 219 | case "$1" in # start | stop the background shell-script 220 | start) 221 | # prepare the background shell-script (in '/tmp' folder) 222 | if [ ! -f "/tmp/softcam_AU_on_background.sh" ]; then 223 | CMD="#!/bin/bash 224 | trap 'exit' INT TERM ERR 225 | trap 'kill 0' EXIT 226 | while true 227 | do 228 | if wget -qO- 'http://127.0.0.1:80/api/powerstate' | grep -qi 'instandby.*true' && wget -qO- '${OSCAMWEBIF}/status.html' | grep '${OSCAMREADER}' | grep -qiE 'no[[:space:]]entitlements'; then 229 | wget -qO- 'http://127.0.0.1:80/api/zap?sRef=${ZAPCHANNEL}' > /dev/null 2>&1 230 | date '+%Y-%m-%d %H:%M:%S' | tr -d '\n' >> ${LOGFILE}; echo -e ' Zap the tuner to the '${ZAPCHANNEL}' channel/SRC. The tuner will turn off automatically after '${ZAPDELAY}' seconds.' >> ${LOGFILE} 231 | sleep ${ZAPDELAY} 232 | wget -qO- 'http://127.0.0.1:80/api/zap?sRef=0' > /dev/null 2>&1 233 | date '+%Y-%m-%d %H:%M:%S' | tr -d '\n' >> ${LOGFILE}; echo -e ' The tuner has been turned off (zapped to the null channel/SRC).\n'${HRLINE}' ' >> ${LOGFILE} 234 | fi 235 | sleep 600 # 600 sec. = 10 min. 236 | done 237 | exit 0 238 | " 239 | echo "${CMD}" > /tmp/softcam_AU_on_background.sh 240 | chmod a+x /tmp/softcam_AU_on_background.sh 241 | fi 242 | /bin/bash "/tmp/softcam_AU_on_background.sh" &>/dev/null & disown 243 | fLog "...the '/tmp/softcam_AU_on_background.sh' script was started" 244 | ;; 245 | stop) 246 | PID_SCRIPT=$(ps aux | grep 'softcam_AU_on_background.sh' | grep -v 'grep' | awk '{print $2}') 247 | #PID_CHILDS=$(pgrep -P $PID_SCRIPT) 248 | #kill $PID_SCRIPT $PID_CHILDS 249 | pkill -P $PID_SCRIPT 250 | rm -f "/tmp/softcam_AU_on_background.sh" 251 | fLog "...the '/tmp/softcam_AU_on_background.sh' script was stopped" 252 | ;; 253 | esac 254 | } 255 | 256 | # ########################################################## 257 | # ########################################################## 258 | # ########################################################## 259 | 260 | 261 | # CHECKING THE EXISTENCE OF THE BINARY/EXEC FILE 262 | 263 | if [ ! -x "$BINDIR/$BINFILENAME" ]; then 264 | fLog "ERROR! Executable binary file '$BINDIR/$BINFILENAME' does not exist!" 265 | fLog "$HRLINE" 266 | exit 5 # 1=generic or unspecified error (current practice) ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 267 | fi 268 | 269 | 270 | # CALL FUNCTIONS ACCORDING TO INPUT ARGUMENTS OF THE SHELL SCRIPT ************************** 271 | 272 | case "$1" in 273 | start) 274 | fStart "$BINFILENAME" 275 | fLog "$HRLINE" 276 | ;; 277 | stop) 278 | fStop "$BINFILENAME" 279 | fLog "$HRLINE" 280 | ;; 281 | restart|reload|force-reload) 282 | fRestart "$BINFILENAME" 283 | fLog "$HRLINE" 284 | ;; 285 | status) 286 | echo -n "$BINFILENAME " 287 | if pidof $BINFILENAME > /dev/null # RETURNED STATUS: 288 | then echo "running"; exit 0 # 0 = program is running -or- service is OK ; 1 = program is dead with "/var/run" pid-file exists ; 2 = program is dead with "/var/lock" lock-file exists ; 289 | else echo "stopped"; exit 3 # 3 = program is not running ; 4 = status is unknown ; 5-99 = reserved for future LSB use ; 100-254 = reserved 290 | fi 291 | ;; 292 | version|info) 293 | fGetVer 294 | ;; 295 | *) 296 | fLog "Unknown or missing arguments !" 297 | echo "$MANPAGE" >$(tty) 298 | fLog "$HRLINE" 299 | exit 2 # 1=generic or unspecified error ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example, "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 300 | ;; 301 | esac 302 | 303 | 304 | exit 0 305 | 306 | -------------------------------------------------------------------------------- /softcam (+ bckgrnd script to restart the softcam if it crashes): -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | 6 | # HISTORY OF CHANGES: 7 | # 8 | # 2018/07/16 - created shell-script: /etc/init.d/softcam 9 | # 2019/06/15 - remake the logging concept (logging output via function) 10 | # - some cosmetic improvements 11 | # 2019/06/23 - some changes in start/stop/restart functions 12 | # 2020/02/19 - improved and complete instructions how-to install the Softcam 13 | # 2020/08/30 - no longer use the SIGTERM (No.15) signal, but only SIGKILL (No.9), as some OSCam builds ignore the regular stop by the SIGTERM (No.15) signal 14 | # - removed 'stdout' redirection to 'null' device at softcam execution/starting command-line 15 | # 2020/11/10 - improved installation instructions (OSCam / CCcam) 16 | # 2021/03/24 - simplified (abbreviated) script source code 17 | # 2021/04/07 - updated return error codes for "argument status" as well as for "exit status" 18 | # 2021/09/26 - some improvements of the script function for Auto-Updating (AU) of "Entitlements" on a decoding card (IRDETO mode), which are updated via EMMs 19 | # 2022/03/12 - improved installation instructions (clarity) 20 | 21 | 22 | 23 | 24 | # ####################### HOW-TO ######################### 25 | # 26 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 27 | # Enigma2 distributions with built-in SoftCAM support : (OpenATV 6.x and OpenPLi 7.x) 28 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 29 | # 30 | # 1) Download the "softcam" script file directly from my github + ADD the ".oscam" file extension + SET the execution rights/attributes: 31 | # wget -O /etc/init.d/softcam.oscam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam.oscam 32 | # 33 | # If you plan to modify and use this script for CCcam, then the correct file extension is ".cccam" or ".CCcam": 34 | # wget -O /etc/init.d/softcam.CCcam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam.CCcam 35 | # 36 | # 2) If your Enigma2 distribution has built-in softcam support, then there is no need to create any symbolic link at this point. 37 | # I mean the "/etc/init.d/softcam.*" script auto-start feature, which is implemented in many new Enigma2 distributions (based on OE2.0 core), directly in the Enigma2 source code. 38 | # 39 | # 3) Copy your configuration files (using the FTP connection) into the particular folder: 40 | # For the OSCam: "/etc/tuxbox/config/oscam" 41 | # For the CCcam: "/etc" - where the main configuration file is "/etc/CCcam.cfg" !!! 42 | # 43 | # 4) Download a specific softcam binary file and upload it to the set-top box - usually to the "/usr/bin" folder. 44 | # Set its executable attributes: 45 | # chmod a+x /usr/bin/softcam-name 46 | # You can also use the following online shell script to download the OSCam binary file (I recommend it only for OpenATV): 47 | # wget -q -O - --no-check-certificate "https://github.com/s3n0/e2scripts/raw/master/oscam-new-version-updater.sh" | bash 48 | # 49 | # 5) Restart the set-top box via the GUI-MENU or via the Shell: 50 | # reboot 51 | # 52 | # 6) Select and activate the particular softcam via the GUI-MENU: 53 | # MENU -> Info Panel -> Softcam Panel -> select your softcam (OSCam or CCcam) by pressing the left/right buttons and then activate it with the green button 54 | # 55 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 56 | # All other or unknown Enigma2 distributions - without built-in SoftCAM support : 57 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 58 | # 59 | # 1) Download the "softcam" script file directly from my github + SET the execution rights/attributes: 60 | # wget -O /etc/init.d/softcam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam 61 | # 62 | # 2) Probably, the "/etc/init.d/softcam" script auto-start feature is not implemented in your Enigma2 distribution (in Python algorithm), 63 | # so you must additionally create a symbolic link, and thus you have two options to choose from: 64 | # 65 | # A) You can use the automated system tool: 66 | # For add (install) the startup sym-links to all default run-levels: 67 | # update-rc.d softcam defaults 90 68 | # For remove (uninstall) startup sym-links from all run-levels use the following command: 69 | # update-rc.d -f softcam remove 70 | # 71 | # B) If the automated system tool does not work or is not installed, use the manual creation of a symbolic link: 72 | # For add (install) the startup sym-links to run-level No.3 (Enigma2 default run-level): 73 | # ln -sf /etc/init.d/softcam /etc/rc3.d/S90softcam 74 | # For remove (uninstall) the symbolic link you can simply delete this link: 75 | # rm -f /etc/rc3.d/S90softcam # or the same way with "unlink" command: unlink /etc/rc3.d/S90softcam 76 | # 77 | # 3) Copy your configuration files (using the FTP connection) into the particular folder: 78 | # For the OSCam: "/etc/tuxbox/config/oscam" 79 | # For the CCcam: "/etc" - where the main configuration file is "/etc/CCcam.cfg" !!! 80 | # 81 | # 4) Download a specific softcam binary file and upload it to the set-top box - usually to the "/usr/bin" folder. 82 | # Set its executable attributes: 83 | # chmod a+x /usr/bin/softcam-name 84 | # You can also use the following online shell script to download the OSCam binary file (I recommend it only for OpenATV): 85 | # wget -q -O - --no-check-certificate "https://github.com/s3n0/e2scripts/raw/master/oscam-new-version-updater.sh" | bash 86 | # 87 | # 5) Then restart the set-top box via the GUI-MENU or via the Shell: 88 | # reboot 89 | # 90 | # ########################################################## 91 | 92 | 93 | 94 | 95 | # ###################### USER SETUP ###################### 96 | # 97 | # SOFTCAM BINARY DIRECTORY: 98 | BINDIR="/usr/bin" 99 | # 100 | # SOFTCAM PROCESS NAME (BINARY FILE NAME): 101 | BINFILENAME="oscam" # for CCcam: BINFILENAME="CCcam" 102 | # 103 | # SOFTCAM ARGUMENTS: 104 | BINARGS="-b -r 2" # for CCcam: BINARGS="-stl" 105 | # 106 | # SOFTCAM EXECUTION COMMAND LINE: 107 | CMDEXEC="${BINDIR}/${BINFILENAME} ${BINARGS}" # for CCcam: CMDEXEC="${BINDIR}/${BINFILENAME} ${BINARGS} > /dev/null 2>&1 &" 108 | # 109 | # LOG FILE FOR THE SOFTCAM HANDLING: 110 | LOGFILE="/tmp/${BINFILENAME}_handling.log" 111 | LOGSIZE=45000 # limit maximum file size [Bytes] 112 | # 113 | # AUTO-RESTART FUNCTION, IF THE SOFTCAM SERVICE CRASH: 114 | DELAYCHECK=30 # [seconds] 115 | AUTORESTARTENABLED="yes" # "no" / "yes" - run the AUTORESTARTENABLED script function in the background permanently, detecting the running Softcam process 116 | # 117 | # AUXILIARY SCRIPT VARIABLES: 118 | HRLINE="--------------------------------------------------------------------------" 119 | MANPAGE="PROPER USE OF THE SCRIPT: 120 | ${0} 121 | POSSIBLE ARGUMENTS: 122 | $(cat ${0} | grep -wE '^[[:space:]]+[a-z\|\-]+\)$' | tr -d ')')" 123 | # 124 | # ############### END OF THE USER SETUP ################## 125 | 126 | 127 | 128 | 129 | # ##################### FUNCTIONS ######################## 130 | 131 | fLog() 132 | { 133 | if [ "$1" = "$HRLINE" ]; then 134 | MSG="$1" 135 | else 136 | MSG="$(date '+%Y-%m-%d %H:%M:%S') $1" # add a timestamp if it's not a separator line (header line) 137 | fi 138 | 139 | #echo "$MSG" > /dev/null ### null device <--- log will disabled (do nothing) 140 | #echo "$MSG" >> $LOGFILE ### file 141 | #echo "$MSG" >> $LOGFILE 2>&1 ### file + stderr 142 | #echo "$MSG" | tee -a $LOGFILE ### file + stdout(display) 143 | echo "$MSG" 2>&1 | tee -a $LOGFILE ### file + stdout(display) + stderr 144 | 145 | #### reduction the log filesize, if neccessary (delete first 50 lines): 146 | if [ -f "$LOGFILE" ] && [ $(wc -c <"$LOGFILE") -gt $LOGSIZE ]; then sed -i -e 1,50d "$LOGFILE"; fi 147 | } 148 | 149 | fStop() 150 | { 151 | fLog "Stopping '$1'..." 152 | if ! pidof $1 > /dev/null; then 153 | fLog "...no '$1' process is running." 154 | fLog "$HRLINE" 155 | exit 7 # 1=generic or unspecified error ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example, "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 156 | else 157 | [ "$AUTORESTARTENABLED" = "yes" ] && fBackgroundScript stop 158 | fLog "...sending the SIGKILL signal to the service '$1' / PID '$(pidof $1)'" 159 | killall -9 $1 > /dev/null 160 | sleep 0.5s # changed from 1s to 0.5s, as the '/lib/python/Screens/SoftcamSetup.py' (OpenATV github) restarts the softcam script too quickly with the 'stop' argument and 1 sec. later it immediately starts the script again with the argument 'start' i.e. without using the 'restart' argument ! unfortunately my softcam script is testing as the first normal softcam stopping, which can take about 0.3 - 0.7 secs 161 | if pidof $1 > /dev/null; then 162 | fLog "...'$1' was not killed by the SIGKILL signal. The process is still running. Probably a system error ?!" 163 | fLog "$HRLINE" 164 | exit 1 165 | else 166 | fLog "...'$1' was successfully killed." 167 | fi 168 | fi 169 | } 170 | 171 | fStart() 172 | { 173 | fLog "Starting '$1'..." 174 | if pidof $1 > /dev/null; then 175 | fLog "...'$1' process has already started and is still running." 176 | else 177 | fLog "...command-line used to start the process: ${CMDEXEC}" 178 | $CMDEXEC 179 | sleep 0.8s 180 | if pidof $1 > /dev/null; then 181 | fLog "...'$1' was successfully started." 182 | [ "$AUTORESTARTENABLED" = "yes" ] && fBackgroundScript start 183 | else 184 | fLog "ERROR! '$1' start failed!" 185 | fLog "$HRLINE" 186 | exit 1 187 | fi 188 | fi 189 | } 190 | 191 | fRestart() 192 | { 193 | if pidof $1 > /dev/null; then fStop $1; fi # the process will be stopped / killed only if it's running 194 | fStart $1 195 | } 196 | 197 | fGetVer() 198 | { 199 | case `echo "$BINFILENAME" | tr '[:upper:]' '[:lower:]'` in # `echo "$BINFILENAME" | awk '{print tolower($0)}'` 200 | "oscam"*|"ncam"*) VER=$($BINDIR/$BINFILENAME -V | grep 'Version\|IPv6' | sed 's/Version:[ ]*//' | sed 's/IPv6.*yes/with IPv6/g' | sed 's/IPv6.*no/IPv4-only/g' | sed ':a;N;$!ba;s/\n/ /g') ;; 201 | "cccam"*) VER=$(strings $BINDIR/$BINFILENAME | grep -E 'CCcam[[:space:]][0-9/./-]+') ;; # it is not completely regular to get the CCcam version, but it works :) 202 | *) VER="ERROR! version/info detection for '${BINFILENAME}' has not yet been implemented in the script algorithm" ;; 203 | esac 204 | [ -z "$VER" ] && VER="ERROR! failed to get version/info of softcam '${BINFILENAME}'" 205 | echo "$VER" 206 | } 207 | 208 | E2inStandby() 209 | { 210 | wget -q -O - http://127.0.0.1/api/powerstate | grep -qi 'instandby.*true' # check if Enigma2 is in standby mode 211 | } 212 | 213 | fBackgroundScript() 214 | { 215 | case "$1" in # start | stop the background shell-script 216 | start) 217 | # prepare the background shell-script (in '/tmp' folder) 218 | if [ ! -f "/tmp/softcam_AutoRestart_on_background.sh" ]; then 219 | CMD="#!/bin/bash 220 | trap 'exit' INT TERM ERR 221 | trap 'kill 0' EXIT 222 | while true; do 223 | if ! pidof ${BINFILENAME} > /dev/null; then 224 | echo \"\$(date '+%Y-%m-%d %H:%M:%S') The '${BINFILENAME}' is dropped (crashed)! Trying to restart!\" > ${LOGFILE} 225 | /etc/init.d/softcam restart 226 | # else 227 | # echo \"The '${BINFILENAME}' is running - nothing to do.\" > ${LOGFILE} 228 | fi 229 | sleep ${DELAYCHECK} 230 | done 231 | exit 0 232 | " 233 | echo "${CMD}" > /tmp/softcam_AutoRestart_on_background.sh 234 | chmod a+x /tmp/softcam_AutoRestart_on_background.sh 235 | fi 236 | /bin/bash "/tmp/softcam_AutoRestart_on_background.sh" &>/dev/null & disown 237 | fLog "...the '/tmp/softcam_AutoRestart_on_background.sh' script was started" 238 | ;; 239 | stop) 240 | PID_SCRIPT=$(ps aux | grep 'softcam_AutoRestart_on_background.sh' | grep -v 'grep' | awk '{print $2}') 241 | #PID_CHILDS=$(pgrep -P $PID_SCRIPT) 242 | #kill $PID_SCRIPT $PID_CHILDS 243 | pkill -P $PID_SCRIPT 244 | rm -f "/tmp/softcam_AutoRestart_on_background.sh" 245 | fLog "...the '/tmp/softcam_AutoRestart_on_background.sh' script was stopped" 246 | ;; 247 | esac 248 | } 249 | 250 | # ########################################################## 251 | # ########################################################## 252 | # ########################################################## 253 | 254 | 255 | # CHECKING THE EXISTENCE OF THE BINARY/EXEC FILE 256 | 257 | if [ ! -x "$BINDIR/$BINFILENAME" ]; then 258 | fLog "ERROR! Executable binary file '$BINDIR/$BINFILENAME' does not exist!" 259 | fLog "$HRLINE" 260 | exit 5 # 1=generic or unspecified error (current practice) ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 261 | fi 262 | 263 | 264 | # CALL FUNCTIONS ACCORDING TO INPUT ARGUMENTS OF THE SHELL SCRIPT ************************** 265 | 266 | case "$1" in 267 | start) 268 | fStart "$BINFILENAME" 269 | fLog "$HRLINE" 270 | ;; 271 | stop) 272 | fStop "$BINFILENAME" 273 | fLog "$HRLINE" 274 | ;; 275 | restart|reload|force-reload) 276 | fRestart "$BINFILENAME" 277 | fLog "$HRLINE" 278 | ;; 279 | status) 280 | echo -n "$BINFILENAME " 281 | if pidof $BINFILENAME > /dev/null # RETURNED STATUS: 282 | then echo "running"; exit 0 # 0 = program is running -or- service is OK ; 1 = program is dead with "/var/run" pid-file exists ; 2 = program is dead with "/var/lock" lock-file exists ; 283 | else echo "stopped"; exit 3 # 3 = program is not running ; 4 = status is unknown ; 5-99 = reserved for future LSB use ; 100-254 = reserved 284 | fi 285 | ;; 286 | version|info) 287 | fGetVer 288 | ;; 289 | *) 290 | fLog "Unknown or missing arguments !" 291 | echo "$MANPAGE" >$(tty) 292 | fLog "$HRLINE" 293 | exit 2 # 1=generic or unspecified error ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example, "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 294 | ;; 295 | esac 296 | 297 | 298 | exit 0 299 | 300 | -------------------------------------------------------------------------------- /softcam (+ bckgrnd script to zap the channel at the night): -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | 6 | # HISTORY OF CHANGES: 7 | # 8 | # 2018/07/16 - created shell-script: /etc/init.d/softcam 9 | # 2019/06/15 - remake the logging concept (logging output via function) 10 | # - some cosmetic improvements 11 | # 2019/06/23 - some changes in start/stop/restart functions 12 | # 2020/02/19 - improved and complete instructions how-to install the Softcam 13 | # 2020/08/30 - no longer use the SIGTERM (No.15) signal, but only SIGKILL (No.9), as some OSCam builds ignore the regular stop by the SIGTERM (No.15) signal 14 | # - removed 'stdout' redirection to 'null' device at softcam execution/starting command-line 15 | # 2020/11/10 - improved installation instructions (OSCam / CCcam) 16 | # 2021/03/24 - simplified (abbreviated) script source code 17 | # 2021/04/07 - updated return error codes for "argument status" as well as for "exit status" 18 | # 2021/09/26 - some improvements of the script function for Auto-Updating (AU) of "Entitlements" on a decoding card (IRDETO mode), which are updated via EMMs 19 | # 2022/03/12 - improved installation instructions (clarity) 20 | 21 | 22 | 23 | 24 | # ####################### HOW-TO ######################### 25 | # 26 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 27 | # Enigma2 distributions with built-in SoftCAM support : (OpenATV 6.x and OpenPLi 7.x) 28 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 29 | # 30 | # 1) Download the "softcam" script file directly from my github + ADD the ".oscam" file extension + SET the execution rights/attributes: 31 | # wget -O /etc/init.d/softcam.oscam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam.oscam 32 | # 33 | # If you plan to modify and use this script for CCcam, then the correct file extension is ".cccam" or ".CCcam": 34 | # wget -O /etc/init.d/softcam.CCcam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam.CCcam 35 | # 36 | # 2) If your Enigma2 distribution has built-in softcam support, then there is no need to create any symbolic link at this point. 37 | # I mean the "/etc/init.d/softcam.*" script auto-start feature, which is implemented in many new Enigma2 distributions (based on OE2.0 core), directly in the Enigma2 source code. 38 | # 39 | # 3) Copy your configuration files (using the FTP connection) into the particular folder: 40 | # For the OSCam: "/etc/tuxbox/config/oscam" 41 | # For the CCcam: "/etc" - where the main configuration file is "/etc/CCcam.cfg" !!! 42 | # 43 | # 4) Download a specific softcam binary file and upload it to the set-top box - usually to the "/usr/bin" folder. 44 | # Set its executable attributes: 45 | # chmod a+x /usr/bin/softcam-name 46 | # You can also use the following online shell script to download the OSCam binary file (I recommend it only for OpenATV): 47 | # wget -q -O - --no-check-certificate "https://github.com/s3n0/e2scripts/raw/master/oscam-new-version-updater.sh" | bash 48 | # 49 | # 5) Restart the set-top box via the GUI-MENU or via the Shell: 50 | # reboot 51 | # 52 | # 6) Select and activate the particular softcam via the GUI-MENU: 53 | # MENU -> Info Panel -> Softcam Panel -> select your softcam (OSCam or CCcam) by pressing the left/right buttons and then activate it with the green button 54 | # 55 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 56 | # All other or unknown Enigma2 distributions - without built-in SoftCAM support : 57 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 58 | # 59 | # 1) Download the "softcam" script file directly from my github + SET the execution rights/attributes: 60 | # wget -O /etc/init.d/softcam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam 61 | # 62 | # 2) Probably, the "/etc/init.d/softcam" script auto-start feature is not implemented in your Enigma2 distribution (in Python algorithm), 63 | # so you must additionally create a symbolic link, and thus you have two options to choose from: 64 | # 65 | # A) You can use the automated system tool: 66 | # For add (install) the startup sym-links to all default run-levels: 67 | # update-rc.d softcam defaults 90 68 | # For remove (uninstall) startup sym-links from all run-levels use the following command: 69 | # update-rc.d -f softcam remove 70 | # 71 | # B) If the automated system tool does not work or is not installed, use the manual creation of a symbolic link: 72 | # For add (install) the startup sym-links to run-level No.3 (Enigma2 default run-level): 73 | # ln -sf /etc/init.d/softcam /etc/rc3.d/S90softcam 74 | # For remove (uninstall) the symbolic link you can simply delete this link: 75 | # rm -f /etc/rc3.d/S90softcam # or the same way with "unlink" command: unlink /etc/rc3.d/S90softcam 76 | # 77 | # 3) Copy your configuration files (using the FTP connection) into the particular folder: 78 | # For the OSCam: "/etc/tuxbox/config/oscam" 79 | # For the CCcam: "/etc" - where the main configuration file is "/etc/CCcam.cfg" !!! 80 | # 81 | # 4) Download a specific softcam binary file and upload it to the set-top box - usually to the "/usr/bin" folder. 82 | # Set its executable attributes: 83 | # chmod a+x /usr/bin/softcam-name 84 | # You can also use the following online shell script to download the OSCam binary file (I recommend it only for OpenATV): 85 | # wget -q -O - --no-check-certificate "https://github.com/s3n0/e2scripts/raw/master/oscam-new-version-updater.sh" | bash 86 | # 87 | # 5) Then restart the set-top box via the GUI-MENU or via the Shell: 88 | # reboot 89 | # 90 | # ########################################################## 91 | 92 | 93 | 94 | 95 | # ###################### USER SETUP ###################### 96 | # 97 | # SOFTCAM BINARY DIRECTORY: 98 | BINDIR="/usr/bin" 99 | # 100 | # SOFTCAM PROCESS NAME (BINARY FILE NAME): 101 | BINFILENAME="oscam" # for CCcam: BINFILENAME="CCcam" 102 | # 103 | # SOFTCAM ARGUMENTS: 104 | BINARGS="-b -r 2" # for CCcam: BINARGS="-stl" 105 | # 106 | # SOFTCAM EXECUTION COMMAND LINE: 107 | CMDEXEC="${BINDIR}/${BINFILENAME} ${BINARGS}" # for CCcam: CMDEXEC="${BINDIR}/${BINFILENAME} ${BINARGS} > /dev/null 2>&1 &" 108 | # 109 | # LOG FILE FOR THE SOFTCAM HANDLING: 110 | LOGFILE="/tmp/${BINFILENAME}_handling.log" 111 | LOGSIZE=45000 # limit maximum file size [Bytes] 112 | # 113 | # CHANNEL (SERVICE REFERENCE CODE) FOR AUTO-UPDATE OF PREPAID TV-PACKAGES (ENTITLEMENTS) + WAITING AUTO-UPDATE TIME: 114 | # A NOTE: Auto-Updating via EMM packets is required after a Softcam start/restart, for some encryption cards, for example when the card is operating in IRDETO mode. 115 | ZAPENABLED="yes" # "no" / "yes" - run the AutoUpdate script-function in the background permanently, with Entitlements checking 116 | ZAPTIME="05:45" # "hour:minute" - when the satellite tuner will zapped to the desired channel 117 | ZAPDELAY="30m" # 1800s = 30m ; 3600s = 60m ; etc. ; for older versions of Shell, use the value in seconds, for example for 30 min., use the value 1800 without 's' 118 | ZAPCHANNEL="1:0:19:3731:C8E:3:EB0000:0:0:0:" 119 | # 120 | # AUXILIARY SCRIPT VARIABLES: 121 | HRLINE="--------------------------------------------------------------------------" 122 | MANPAGE="PROPER USE OF THE SCRIPT: 123 | ${0} 124 | POSSIBLE ARGUMENTS: 125 | $(cat ${0} | grep -wE '^[[:space:]]+[a-z\|\-]+\)$' | tr -d ')')" 126 | # 127 | # ############### END OF THE USER SETUP ################## 128 | 129 | 130 | 131 | 132 | # ##################### FUNCTIONS ######################## 133 | 134 | fLog() 135 | { 136 | if [ "$1" = "$HRLINE" ]; then 137 | MSG="$1" 138 | else 139 | MSG="$(date '+%Y-%m-%d %H:%M:%S') $1" # add a timestamp if it's not a separator line (header line) 140 | fi 141 | 142 | #echo "$MSG" > /dev/null ### null device <--- log will disabled (do nothing) 143 | #echo "$MSG" >> $LOGFILE ### file 144 | #echo "$MSG" >> $LOGFILE 2>&1 ### file + stderr 145 | #echo "$MSG" | tee -a $LOGFILE ### file + stdout(display) 146 | echo "$MSG" 2>&1 | tee -a $LOGFILE ### file + stdout(display) + stderr 147 | 148 | #### reduction the log filesize, if neccessary (delete first 50 lines): 149 | if [ -f "$LOGFILE" ] && [ $(wc -c <"$LOGFILE") -gt $LOGSIZE ]; then sed -i -e 1,50d "$LOGFILE"; fi 150 | } 151 | 152 | fStop() 153 | { 154 | fLog "Stopping '$1'..." 155 | if ! pidof $1 > /dev/null; then 156 | fLog "...no '$1' process is running." 157 | fLog "$HRLINE" 158 | exit 7 # 1=generic or unspecified error (current practice) ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example, "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 159 | else 160 | [ "$ZAPENABLED" = "yes" ] && fBackgroundScript stop 161 | fLog "...sending the SIGKILL signal to the service '$1' / PID '$(pidof $1)'" 162 | killall -9 $1 > /dev/null 163 | sleep 0.5s # changed from 1s to 0.5s, as the '/lib/python/Screens/SoftcamSetup.py' (OpenATV github) restarts the softcam script too quickly with the 'stop' argument and 1 sec. later it immediately starts the script again with the argument 'start' i.e. without using the 'restart' argument ! unfortunately my softcam script is testing as the first normal softcam stopping, which can take about 0.3 - 0.7 secs 164 | if pidof $1 > /dev/null; then 165 | fLog "...'$1' was not killed by the SIGKILL signal. The process is still running. Probably a system error ?!" 166 | fLog "$HRLINE" 167 | exit 1 168 | else 169 | fLog "...'$1' was successfully killed." 170 | fi 171 | fi 172 | } 173 | 174 | fStart() 175 | { 176 | fLog "Starting '$1'..." 177 | if pidof $1 > /dev/null; then 178 | fLog "...'$1' process has already started and is still running." 179 | else 180 | fLog "...command-line used to start the process: ${CMDEXEC}" 181 | $CMDEXEC 182 | sleep 0.8s 183 | if pidof $1 > /dev/null; then 184 | fLog "...'$1' was successfully started." 185 | [ "$ZAPENABLED" = "yes" ] && fBackgroundScript start 186 | else 187 | fLog "ERROR! '$1' start failed!" 188 | fLog "$HRLINE" 189 | exit 1 190 | fi 191 | fi 192 | } 193 | 194 | fRestart() 195 | { 196 | if pidof $1 > /dev/null; then fStop $1; fi # the process will be stopped / killed only if it's running 197 | fStart $1 198 | } 199 | 200 | fGetVer() 201 | { 202 | case `echo "$BINFILENAME" | tr '[:upper:]' '[:lower:]'` in # `echo "$BINFILENAME" | awk '{print tolower($0)}'` 203 | "oscam"*|"ncam"*) VER=$($BINDIR/$BINFILENAME -V | grep 'Version\|IPv6' | sed 's/Version:[ ]*//' | sed 's/IPv6.*yes/with IPv6/g' | sed 's/IPv6.*no/IPv4-only/g' | sed ':a;N;$!ba;s/\n/ /g') ;; 204 | "cccam"*) VER=$(strings $BINDIR/$BINFILENAME | grep -E 'CCcam[[:space:]][0-9/./-]+') ;; # it is not completely regular to get the CCcam version, but it works :) 205 | *) VER="ERROR! version/info detection for '${BINFILENAME}' has not yet been implemented in the script algorithm" ;; 206 | esac 207 | [ -z "$VER" ] && VER="ERROR! failed to get version/info of softcam '${BINFILENAME}'" 208 | echo "$VER" 209 | } 210 | 211 | E2inStandby() 212 | { 213 | wget -q -O - http://127.0.0.1/api/powerstate | grep -qi 'instandby.*true' # check if Enigma2 is in standby mode 214 | } 215 | 216 | fBackgroundScript() 217 | { 218 | case "$1" in # start | stop the background shell-script 219 | start) 220 | # prepare the background shell-script (in '/tmp' folder) 221 | if [ ! -f "/tmp/softcam_AU_on_background.sh" ]; then 222 | CMD="#!/bin/bash 223 | trap 'exit' INT TERM ERR 224 | trap 'kill 0' EXIT 225 | while true 226 | do 227 | if [ \"\$(date +'%H:%M')\" = \"${ZAPTIME}\" ] && wget -qO- 'http://127.0.0.1:80/api/powerstate' | grep -qi 'instandby.*true'; then 228 | wget -qO- 'http://127.0.0.1:80/api/zap?sRef=${ZAPCHANNEL}' > /dev/null 2>&1 229 | date '+%Y-%m-%d %H:%M:%S' | tr -d '\n' >> ${LOGFILE}; echo -e ' Zap the tuner to the '${ZAPCHANNEL}' channel/SRC. The tuner will turn off automatically after '${ZAPDELAY}' seconds.' >> ${LOGFILE} 230 | sleep ${ZAPDELAY} 231 | if wget -qO- 'http://127.0.0.1:80/api/powerstate' | grep -qi 'instandby.*true'; then 232 | wget -qO- 'http://127.0.0.1:80/api/zap?sRef=0' > /dev/null 2>&1 233 | date '+%Y-%m-%d %H:%M:%S' | tr -d '\n' >> ${LOGFILE}; echo -e ' The tuner has been turned off (zapped to the null channel/SRC).\n'${HRLINE}' ' >> ${LOGFILE} 234 | else 235 | date '+%Y-%m-%d %H:%M:%S' | tr -d '\n' >> ${LOGFILE}; echo -e ' The tuner was not turned off because Enigma2 was already woken up (no longer in standby).\n'${HRLINE}' ' >> ${LOGFILE} 236 | fi 237 | fi 238 | sleep 60 239 | done 240 | exit 0 241 | " 242 | echo "${CMD}" > /tmp/softcam_AU_on_background.sh 243 | chmod a+x /tmp/softcam_AU_on_background.sh 244 | fi 245 | /bin/bash "/tmp/softcam_AU_on_background.sh" &>/dev/null & disown 246 | ;; 247 | stop) 248 | PID_SCRIPT=$(ps aux | grep 'softcam_AU_on_background.sh' | grep -v 'grep' | awk '{print $2}') 249 | #PID_CHILDS=$(pgrep -P $PID_SCRIPT) 250 | #kill $PID_SCRIPT $PID_CHILDS 251 | pkill -P $PID_SCRIPT 252 | rm -f "/tmp/softcam_AU_on_background.sh" 253 | ;; 254 | esac 255 | } 256 | 257 | # ########################################################## 258 | # ########################################################## 259 | # ########################################################## 260 | 261 | 262 | # CHECKING THE EXISTENCE OF THE BINARY/EXEC FILE 263 | 264 | if [ ! -x "$BINDIR/$BINFILENAME" ]; then 265 | fLog "ERROR! Executable binary file '$BINDIR/$BINFILENAME' does not exist!" 266 | fLog "$HRLINE" 267 | exit 5 # 1=generic or unspecified error (current practice) ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 268 | fi 269 | 270 | 271 | # CALL FUNCTIONS ACCORDING TO INPUT ARGUMENTS OF THE SHELL SCRIPT ************************** 272 | 273 | case "$1" in 274 | start) 275 | fStart "$BINFILENAME" 276 | fLog "$HRLINE" 277 | ;; 278 | stop) 279 | fStop "$BINFILENAME" 280 | fLog "$HRLINE" 281 | ;; 282 | restart|reload|force-reload) 283 | fRestart "$BINFILENAME" 284 | fLog "$HRLINE" 285 | ;; 286 | status) 287 | echo -n "$BINFILENAME " 288 | if pidof $BINFILENAME > /dev/null # RETURNED STATUS: 289 | then echo "running"; exit 0 # 0 = program is running -or- service is OK ; 1 = program is dead with "/var/run" pid-file exists ; 2 = program is dead with "/var/lock" lock-file exists ; 290 | else echo "stopped"; exit 3 # 3 = program is not running ; 4 = status is unknown ; 5-99 = reserved for future LSB use ; 100-254 = reserved 291 | fi 292 | ;; 293 | version|info) 294 | fGetVer 295 | ;; 296 | *) 297 | fLog "Unknown or missing arguments !" 298 | echo "$MANPAGE" >$(tty) 299 | fLog "$HRLINE" 300 | exit 2 # 1=generic or unspecified error ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example, "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 301 | ;; 302 | esac 303 | 304 | 305 | exit 0 306 | 307 | -------------------------------------------------------------------------------- /softcam (+ delayed start if Linux is still booting): -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | 6 | # HISTORY OF CHANGES: 7 | # 8 | # 2018/07/16 - created shell-script: /etc/init.d/softcam 9 | # 2019/06/15 - remake the logging concept (logging output via function) 10 | # - some cosmetic improvements 11 | # 2019/06/23 - some changes in start/stop/restart functions 12 | # 2020/02/19 - improved and complete instructions how-to install the Softcam 13 | # 2020/08/30 - no longer use the SIGTERM (No.15) signal, but only SIGKILL (No.9), as some OSCam builds ignore the regular stop by the SIGTERM (No.15) signal 14 | # - removed 'stdout' redirection to 'null' device at softcam execution/starting command-line 15 | # 2020/11/10 - improved installation instructions (OSCam / CCcam) 16 | # 2021/03/24 - simplified (abbreviated) script source code 17 | # 2021/04/07 - updated return error codes for "argument status" as well as for "exit status" 18 | # 2022/03/12 - improved installation instructions (clarity) 19 | 20 | 21 | 22 | 23 | 24 | # ####################### HOW-TO ######################### 25 | # 26 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 27 | # Enigma2 distributions with built-in SoftCAM support : (OpenATV 6.x and OpenPLi 7.x) 28 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 29 | # 30 | # 1) Download the "softcam" script file directly from my github + ADD the ".oscam" file extension + SET the execution rights/attributes: 31 | # wget -O /etc/init.d/softcam.oscam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam.oscam 32 | # 33 | # If you plan to modify and use this script for CCcam, then the correct file extension is ".cccam" or ".CCcam": 34 | # wget -O /etc/init.d/softcam.CCcam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam.CCcam 35 | # 36 | # 2) If your Enigma2 distribution has built-in softcam support, then there is no need to create any symbolic link at this point. 37 | # I mean the "/etc/init.d/softcam.*" script auto-start feature, which is implemented in many new Enigma2 distributions (based on OE2.0 core), directly in the Enigma2 source code. 38 | # 39 | # 3) Copy your configuration files (using the FTP connection) into the particular folder: 40 | # For the OSCam: "/etc/tuxbox/config/oscam" 41 | # For the CCcam: "/etc" - where the main configuration file is "/etc/CCcam.cfg" !!! 42 | # 43 | # 4) Download a specific softcam binary file and upload it to the set-top box - usually to the "/usr/bin" folder. 44 | # Set its executable attributes: 45 | # chmod a+x /usr/bin/softcam-name 46 | # You can also use the following online shell script to download the OSCam binary file (I recommend it only for OpenATV): 47 | # wget -q -O - --no-check-certificate "https://github.com/s3n0/e2scripts/raw/master/oscam-new-version-updater.sh" | bash 48 | # 49 | # 5) Restart the set-top box via the GUI-MENU or via the Shell: 50 | # reboot 51 | # 52 | # 6) Select and activate the particular softcam via the GUI-MENU: 53 | # MENU -> Info Panel -> Softcam Panel -> select your softcam (OSCam or CCcam) by pressing the left/right buttons and then activate it with the green button 54 | # 55 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 56 | # All other or unknown Enigma2 distributions - without built-in SoftCAM support : 57 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 58 | # 59 | # 1) Download the "softcam" script file directly from my github + SET the execution rights/attributes: 60 | # wget -O /etc/init.d/softcam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam 61 | # 62 | # 2) Probably, the "/etc/init.d/softcam" script auto-start feature is not implemented in your Enigma2 distribution (in Python algorithm), 63 | # so you must additionally create a symbolic link, and thus you have two options to choose from: 64 | # 65 | # A) You can use the automated system tool: 66 | # For add (install) the startup sym-links to all default run-levels: 67 | # update-rc.d softcam defaults 90 68 | # For remove (uninstall) startup sym-links from all run-levels use the following command: 69 | # update-rc.d -f softcam remove 70 | # 71 | # B) If the automated system tool does not work or is not installed, use the manual creation of a symbolic link: 72 | # For add (install) the startup sym-links to run-level No.3 (Enigma2 default run-level): 73 | # ln -sf /etc/init.d/softcam /etc/rc3.d/S90softcam 74 | # For remove (uninstall) the symbolic link you can simply delete this link: 75 | # rm -f /etc/rc3.d/S90softcam # or the same way with "unlink" command: unlink /etc/rc3.d/S90softcam 76 | # 77 | # 3) Copy your configuration files (using the FTP connection) into the particular folder: 78 | # For the OSCam: "/etc/tuxbox/config/oscam" 79 | # For the CCcam: "/etc" - where the main configuration file is "/etc/CCcam.cfg" !!! 80 | # 81 | # 4) Download a specific softcam binary file and upload it to the set-top box - usually to the "/usr/bin" folder. 82 | # Set its executable attributes: 83 | # chmod a+x /usr/bin/softcam-name 84 | # You can also use the following online shell script to download the OSCam binary file (I recommend it only for OpenATV): 85 | # wget -q -O - --no-check-certificate "https://github.com/s3n0/e2scripts/raw/master/oscam-new-version-updater.sh" | bash 86 | # 87 | # 5) Then restart the set-top box via the GUI-MENU or via the Shell: 88 | # reboot 89 | # 90 | # ########################################################## 91 | 92 | 93 | 94 | 95 | # ###################### USER SETUP ###################### 96 | # 97 | # SOFTCAM BINARY DIRECTORY: 98 | BINDIR="/usr/bin" 99 | # 100 | # SOFTCAM PROCESS NAME (BINARY FILE NAME): 101 | BINFILENAME="oscam" # for CCcam: BINFILENAME="CCcam" 102 | # 103 | # SOFTCAM ARGUMENTS: 104 | BINARGS="-b -r 2" # for CCcam: BINARGS="-stl" 105 | # 106 | # SOFTCAM EXECUTION COMMAND LINE: 107 | CMDEXEC="${BINDIR}/${BINFILENAME} ${BINARGS}" # for CCcam: CMDEXEC="${BINDIR}/${BINFILENAME} ${BINARGS} > /dev/null 2>&1 &" 108 | # 109 | # IF THE LINUX SYSTEM IS IN THE BOOT PROCESS, THE START OF THE SOFTCAM WILL BE DELAYED BY A FEW SECONDS: 110 | BOOTDELAY=15 111 | # 112 | # LOG FILE FOR THE SOFTCAM HANDLING: 113 | LOGFILE="/tmp/${BINFILENAME}_handling.log" 114 | LOGSIZE=45000 # limit maximum file size [Bytes] 115 | # 116 | # AUXILIARY SCRIPT VARIABLES: 117 | HRLINE="--------------------------------------------------------------------------" 118 | MANPAGE="PROPER USE OF THE SCRIPT: 119 | ${0} 120 | POSSIBLE ARGUMENTS: 121 | $(cat ${0} | grep -wE '^[[:space:]]+[a-z\|\-]+\)$' | tr -d ')')" 122 | # 123 | # ############### END OF THE USER SETUP ################## 124 | 125 | 126 | 127 | 128 | # ##################### FUNCTIONS ######################## 129 | 130 | fLog() 131 | { 132 | if [ "$1" = "$HRLINE" ]; then 133 | MSG="$1" 134 | else 135 | MSG="$(date '+%Y-%m-%d %H:%M:%S') $1" # add a timestamp if it's not a separator line (header line) 136 | fi 137 | 138 | #echo "$MSG" > /dev/null ### null device <--- log will disabled (do nothing) 139 | #echo "$MSG" >> $LOGFILE ### file 140 | #echo "$MSG" >> $LOGFILE 2>&1 ### file + stderr 141 | #echo "$MSG" | tee -a $LOGFILE ### file + stdout(display) 142 | echo "$MSG" 2>&1 | tee -a $LOGFILE ### file + stdout(display) + stderr 143 | 144 | #### reduction the log filesize, if neccessary (delete first 50 lines): 145 | if [ -f "$LOGFILE" ] && [ $(wc -c <"$LOGFILE") -gt $LOGSIZE ]; then sed -i -e 1,50d "$LOGFILE"; fi 146 | } 147 | 148 | fStop() 149 | { 150 | fLog "Stopping '$1'..." 151 | if ! pidof $1 > /dev/null; then 152 | fLog "...no '$1' process is running." 153 | fLog "$HRLINE" 154 | exit 7 # 1=generic or unspecified error ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example, "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 155 | else 156 | fLog "...sending the SIGKILL signal to the service '$1' / PID '$(pidof $1)'" 157 | killall -9 $1 > /dev/null 158 | sleep 0.5s # changed from 1s to 0.5s, as the '/lib/python/Screens/SoftcamSetup.py' (OpenATV github) restarts the softcam script too quickly with the 'stop' argument and 1 sec. later it immediately starts the script again with the argument 'start' i.e. without using the 'restart' argument ! unfortunately my softcam script is testing as the first normal softcam stopping, which can take about 0.3 - 0.7 secs 159 | if pidof $1 > /dev/null; then 160 | fLog "...'$1' was not killed by the SIGKILL signal. The process is still running. Probably a system error ?!" 161 | fLog "$HRLINE" 162 | exit 1 163 | else 164 | fLog "...'$1' was successfully killed." 165 | fi 166 | fi 167 | } 168 | 169 | fStart() 170 | { 171 | fLog "Starting '$1'..." 172 | if pidof $1 > /dev/null; then 173 | fLog "...'$1' process has already started and is still running." 174 | else 175 | if wget --spider "http://127.0.0.1" 2>/dev/null; then # finding out if the softcam script is run during Linux booting 176 | # normal start of softcam (Linux is not in boot state): 177 | fLog "...command-line used to start the process: ${CMDEXEC}" 178 | $CMDEXEC 179 | sleep 0.8s 180 | if pidof $1 > /dev/null; then 181 | fLog "...'$1' was successfully started." 182 | else 183 | fLog "ERROR! '$1' start failed!" 184 | fLog "$HRLINE" 185 | exit 1 186 | fi 187 | else 188 | # delayed start of softcam (Linux is in boot state): 189 | CMDEXEC="sleep ${BOOTDELAY}; ${CMDEXEC}" 190 | fLog "...command-line used to start the process: ${CMDEXEC}" 191 | fLog "...'$1' will start with a delay of a ${BOOTDELAY} seconds in the background (Linux is in boot state)." 192 | eval "${CMDEXEC}" &>/dev/null & disown; 193 | fi 194 | fi 195 | } 196 | 197 | fRestart() 198 | { 199 | if pidof $1 > /dev/null; then fStop $1; fi # the process will be stopped / killed only if it's running 200 | fStart $1 201 | } 202 | 203 | fGetVer() 204 | { 205 | case `echo "$BINFILENAME" | tr '[:upper:]' '[:lower:]'` in # `echo "$BINFILENAME" | awk '{print tolower($0)}'` 206 | "oscam"*|"ncam"*) VER=$($BINDIR/$BINFILENAME -V | grep 'Version\|IPv6' | sed 's/Version:[ ]*//' | sed 's/IPv6.*yes/with IPv6/g' | sed 's/IPv6.*no/IPv4-only/g' | sed ':a;N;$!ba;s/\n/ /g') ;; 207 | "cccam"*) VER=$(strings $BINDIR/$BINFILENAME | grep -E 'CCcam[[:space:]][0-9/./-]+') ;; # it is not completely regular to get the CCcam version, but it works :) 208 | *) VER="ERROR! version/info detection for '${BINFILENAME}' has not yet been implemented in the script algorithm" ;; 209 | esac 210 | [ -z "$VER" ] && VER="ERROR! failed to get version/info of softcam '${BINFILENAME}'" 211 | echo "$VER" 212 | } 213 | 214 | 215 | # ########################################################## 216 | # ########################################################## 217 | # ########################################################## 218 | 219 | 220 | # CHECKING THE EXISTENCE OF THE BINARY/EXEC FILE 221 | 222 | if [ ! -x "$BINDIR/$BINFILENAME" ]; then 223 | fLog "ERROR! Executable binary file '$BINDIR/$BINFILENAME' does not exist!" 224 | fLog "$HRLINE" 225 | exit 5 # 1=generic or unspecified error (current practice) ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 226 | fi 227 | 228 | 229 | # CALL FUNCTIONS ACCORDING TO INPUT ARGUMENTS OF THE SHELL SCRIPT ************************** 230 | 231 | case "$1" in 232 | start) 233 | fStart "$BINFILENAME" 234 | fLog "$HRLINE" 235 | ;; 236 | stop) 237 | fStop "$BINFILENAME" 238 | fLog "$HRLINE" 239 | ;; 240 | restart|reload|force-reload) 241 | fRestart "$BINFILENAME" 242 | fLog "$HRLINE" 243 | ;; 244 | status) 245 | echo -n "$BINFILENAME " 246 | if pidof $BINFILENAME > /dev/null # RETURNED STATUS: 247 | then echo "running"; exit 0 # 0 = program is running -or- service is OK ; 1 = program is dead with "/var/run" pid-file exists ; 2 = program is dead with "/var/lock" lock-file exists ; 248 | else echo "stopped"; exit 3 # 3 = program is not running ; 4 = status is unknown ; 5-99 = reserved for future LSB use ; 100-254 = reserved 249 | fi 250 | ;; 251 | version|info) 252 | fGetVer 253 | ;; 254 | *) 255 | fLog "Unknown or missing arguments !" 256 | echo "$MANPAGE" >$(tty) 257 | fLog "$HRLINE" 258 | exit 2 # 1=generic or unspecified error ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example, "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 259 | ;; 260 | esac 261 | 262 | 263 | exit 0 264 | 265 | -------------------------------------------------------------------------------- /softcam (+ zap channel each time when softcam was started): -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | 6 | # HISTORY OF CHANGES: 7 | # 8 | # 2018/07/16 - created shell-script: /etc/init.d/softcam 9 | # 2019/06/15 - remake the logging concept (logging output via function) 10 | # - some cosmetic improvements 11 | # 2019/06/23 - some changes in start/stop/restart functions 12 | # 2020/02/19 - improved and complete instructions how-to install the Softcam 13 | # 2020/08/30 - no longer use the SIGTERM (No.15) signal, but only SIGKILL (No.9), as some OSCam builds ignore the regular stop by the SIGTERM (No.15) signal 14 | # - removed 'stdout' redirection to 'null' device at softcam execution/starting command-line 15 | # 2020/11/10 - improved installation instructions (OSCam / CCcam) 16 | # 2021/03/24 - simplified (abbreviated) script source code 17 | # 2021/04/07 - updated return error codes for "argument status" as well as for "exit status" 18 | # 2021/09/26 - some improvements of the script function for Auto-Updating (AU) of "Entitlements" on a decoding card (IRDETO mode), which are updated via EMMs 19 | # 2022/03/12 - improved installation instructions (clarity) 20 | 21 | 22 | 23 | 24 | # ####################### HOW-TO ######################### 25 | # 26 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 27 | # Enigma2 distributions with built-in SoftCAM support : (OpenATV 6.x and OpenPLi 7.x) 28 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 29 | # 30 | # 1) Download the "softcam" script file directly from my github + ADD the ".oscam" file extension + SET the execution rights/attributes: 31 | # wget -O /etc/init.d/softcam.oscam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam.oscam 32 | # 33 | # If you plan to modify and use this script for CCcam, then the correct file extension is ".cccam" or ".CCcam": 34 | # wget -O /etc/init.d/softcam.CCcam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam.CCcam 35 | # 36 | # 2) If your Enigma2 distribution has built-in softcam support, then there is no need to create any symbolic link at this point. 37 | # I mean the "/etc/init.d/softcam.*" script auto-start feature, which is implemented in many new Enigma2 distributions (based on OE2.0 core), directly in the Enigma2 source code. 38 | # 39 | # 3) Copy your configuration files (using the FTP connection) into the particular folder: 40 | # For the OSCam: "/etc/tuxbox/config/oscam" 41 | # For the CCcam: "/etc" - where the main configuration file is "/etc/CCcam.cfg" !!! 42 | # 43 | # 4) Download a specific softcam binary file and upload it to the set-top box - usually to the "/usr/bin" folder. 44 | # Set its executable attributes: 45 | # chmod a+x /usr/bin/softcam-name 46 | # You can also use the following online shell script to download the OSCam binary file (I recommend it only for OpenATV): 47 | # wget -q -O - --no-check-certificate "https://github.com/s3n0/e2scripts/raw/master/oscam-new-version-updater.sh" | bash 48 | # 49 | # 5) Restart the set-top box via the GUI-MENU or via the Shell: 50 | # reboot 51 | # 52 | # 6) Select and activate the particular softcam via the GUI-MENU: 53 | # MENU -> Info Panel -> Softcam Panel -> select your softcam (OSCam or CCcam) by pressing the left/right buttons and then activate it with the green button 54 | # 55 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 56 | # All other or unknown Enigma2 distributions - without built-in SoftCAM support : 57 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 58 | # 59 | # 1) Download the "softcam" script file directly from my github + SET the execution rights/attributes: 60 | # wget -O /etc/init.d/softcam --no-check-certificate https://github.com/s3n0/e2scripts/raw/master/softcam && chmod a+x /etc/init.d/softcam 61 | # 62 | # 2) Probably, the "/etc/init.d/softcam" script auto-start feature is not implemented in your Enigma2 distribution (in Python algorithm), 63 | # so you must additionally create a symbolic link, and thus you have two options to choose from: 64 | # 65 | # A) You can use the automated system tool: 66 | # For add (install) the startup sym-links to all default run-levels: 67 | # update-rc.d softcam defaults 90 68 | # For remove (uninstall) startup sym-links from all run-levels use the following command: 69 | # update-rc.d -f softcam remove 70 | # 71 | # B) If the automated system tool does not work or is not installed, use the manual creation of a symbolic link: 72 | # For add (install) the startup sym-links to run-level No.3 (Enigma2 default run-level): 73 | # ln -sf /etc/init.d/softcam /etc/rc3.d/S90softcam 74 | # For remove (uninstall) the symbolic link you can simply delete this link: 75 | # rm -f /etc/rc3.d/S90softcam # or the same way with "unlink" command: unlink /etc/rc3.d/S90softcam 76 | # 77 | # 3) Copy your configuration files (using the FTP connection) into the particular folder: 78 | # For the OSCam: "/etc/tuxbox/config/oscam" 79 | # For the CCcam: "/etc" - where the main configuration file is "/etc/CCcam.cfg" !!! 80 | # 81 | # 4) Download a specific softcam binary file and upload it to the set-top box - usually to the "/usr/bin" folder. 82 | # Set its executable attributes: 83 | # chmod a+x /usr/bin/softcam-name 84 | # You can also use the following online shell script to download the OSCam binary file (I recommend it only for OpenATV): 85 | # wget -q -O - --no-check-certificate "https://github.com/s3n0/e2scripts/raw/master/oscam-new-version-updater.sh" | bash 86 | # 87 | # 5) Then restart the set-top box via the GUI-MENU or via the Shell: 88 | # reboot 89 | # 90 | # ########################################################## 91 | 92 | 93 | 94 | 95 | # ###################### USER SETUP ###################### 96 | # 97 | # SOFTCAM BINARY DIRECTORY: 98 | BINDIR="/usr/bin" 99 | # 100 | # SOFTCAM PROCESS NAME (BINARY FILE NAME): 101 | BINFILENAME="oscam" # for CCcam: BINFILENAME="CCcam" 102 | # 103 | # SOFTCAM ARGUMENTS: 104 | BINARGS="-b -r 2" # for CCcam: BINARGS="-stl" 105 | # 106 | # SOFTCAM EXECUTION COMMAND LINE: 107 | CMDEXEC="${BINDIR}/${BINFILENAME} ${BINARGS}" # for CCcam: CMDEXEC="${BINDIR}/${BINFILENAME} ${BINARGS} > /dev/null 2>&1 &" 108 | # 109 | # LOG FILE FOR THE SOFTCAM HANDLING: 110 | LOGFILE="/tmp/${BINFILENAME}_handling.log" 111 | LOGSIZE=45000 # limit maximum file size [Bytes] 112 | # 113 | # CHANNEL (SERVICE REFERENCE CODE) FOR AUTO-UPDATE OF PREPAID TV-PACKAGES (ENTITLEMENTS) + WAITING TO AUTO-UPDATE (DELAY IN SECONDS): 114 | # A NOTE: Auto-Updating via EMM packets is required after a Softcam start/restart, for some encryption cards, for example when the card is operating in IRDETO mode. 115 | ZAPCHANNEL="1:0:19:3731:C8E:3:EB0000:0:0:0:" # Service-Reference-Code of the satellite channel - for invoke the ZAP function, via Enigma2 / Open-Webif 116 | ZAPDELAY=50 117 | ZAPONSTART="yes" # "no" / "yes" - run the AutoUpdate script-function after every daemon/softcam start 118 | # 119 | # AUXILIARY SCRIPT VARIABLES: 120 | HRLINE="--------------------------------------------------------------------------" 121 | MANPAGE="PROPER USE OF THE SCRIPT: 122 | ${0} 123 | POSSIBLE ARGUMENTS: 124 | $(cat ${0} | grep -wE '^[[:space:]]+[a-z\|\-]+\)$' | tr -d ')')" 125 | # 126 | # ############### END OF THE USER SETUP ################## 127 | 128 | 129 | 130 | 131 | # ##################### FUNCTIONS ######################## 132 | 133 | fLog() 134 | { 135 | if [ "$1" = "$HRLINE" ]; then 136 | MSG="$1" 137 | else 138 | MSG="$(date '+%Y-%m-%d %H:%M:%S') $1" # add a timestamp if it's not a separator line (header line) 139 | fi 140 | 141 | #echo "$MSG" > /dev/null ### null device <--- log will disabled (do nothing) 142 | #echo "$MSG" >> $LOGFILE ### file 143 | #echo "$MSG" >> $LOGFILE 2>&1 ### file + stderr 144 | #echo "$MSG" | tee -a $LOGFILE ### file + stdout(display) 145 | echo "$MSG" 2>&1 | tee -a $LOGFILE ### file + stdout(display) + stderr 146 | 147 | #### reduction the log filesize, if neccessary (delete first 50 lines): 148 | if [ -f "$LOGFILE" ] && [ $(wc -c <"$LOGFILE") -gt $LOGSIZE ]; then sed -i -e 1,50d "$LOGFILE"; fi 149 | } 150 | 151 | fStop() 152 | { 153 | fLog "Stopping '$1'..." 154 | if ! pidof $1 > /dev/null; then 155 | fLog "...no '$1' process is running." 156 | fLog "$HRLINE" 157 | exit 7 # 1=generic or unspecified error ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example, "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 158 | else 159 | fLog "...sending the SIGKILL signal to the service '$1' / PID '$(pidof $1)'" 160 | killall -9 $1 > /dev/null 161 | sleep 0.5s # changed from 1s to 0.5s, as the '/lib/python/Screens/SoftcamSetup.py' (OpenATV github) restarts the softcam script too quickly with the 'stop' argument and 1 sec. later it immediately starts the script again with the argument 'start' i.e. without using the 'restart' argument ! unfortunately my softcam script is testing as the first normal softcam stopping, which can take about 0.3 - 0.7 secs 162 | if pidof $1 > /dev/null; then 163 | fLog "...'$1' was not killed by the SIGKILL signal. The process is still running. Probably a system error ?!" 164 | fLog "$HRLINE" 165 | exit 1 166 | else 167 | fLog "...'$1' was successfully killed." 168 | fi 169 | fi 170 | } 171 | 172 | fStart() 173 | { 174 | fLog "Starting '$1'..." 175 | if pidof $1 > /dev/null; then 176 | fLog "...'$1' process has already started and is still running." 177 | else 178 | fLog "...command-line used to start the process: ${CMDEXEC}" 179 | $CMDEXEC 180 | sleep 0.8s 181 | if pidof $1 > /dev/null; then 182 | fLog "...'$1' was successfully started." 183 | [ "$ZAPONSTART" == "yes" ] && $0 au 184 | else 185 | fLog "ERROR! '$1' start failed!" 186 | fLog "$HRLINE" 187 | exit 1 188 | fi 189 | fi 190 | } 191 | 192 | fRestart() 193 | { 194 | if pidof $1 > /dev/null; then fStop $1; fi # the process will be stopped / killed only if it's running 195 | fStart $1 196 | } 197 | 198 | fGetVer() 199 | { 200 | case `echo "$BINFILENAME" | tr '[:upper:]' '[:lower:]'` in # `echo "$BINFILENAME" | awk '{print tolower($0)}'` 201 | "oscam"*|"ncam"*) VER=$($BINDIR/$BINFILENAME -V | grep 'Version\|IPv6' | sed 's/Version:[ ]*//' | sed 's/IPv6.*yes/with IPv6/g' | sed 's/IPv6.*no/IPv4-only/g' | sed ':a;N;$!ba;s/\n/ /g') ;; 202 | "cccam"*) VER=$(strings $BINDIR/$BINFILENAME | grep -E 'CCcam[[:space:]][0-9/./-]+') ;; # it is not completely regular to get the CCcam version, but it works :) 203 | *) VER="ERROR! version/info detection for '${BINFILENAME}' has not yet been implemented in the script algorithm" ;; 204 | esac 205 | [ -z "$VER" ] && VER="ERROR! failed to get version/info of softcam '${BINFILENAME}'" 206 | echo "$VER" 207 | } 208 | 209 | E2inStandby() 210 | { 211 | wget -q -O - http://127.0.0.1/api/powerstate | grep -qi 'instandby.*true' # check if Enigma2 is in standby mode 212 | } 213 | 214 | 215 | # ########################################################## 216 | # ########################################################## 217 | # ########################################################## 218 | 219 | 220 | # CHECKING THE EXISTENCE OF THE BINARY/EXEC FILE 221 | 222 | if [ ! -x "$BINDIR/$BINFILENAME" ]; then 223 | fLog "ERROR! Executable binary file '$BINDIR/$BINFILENAME' does not exist!" 224 | fLog "$HRLINE" 225 | exit 5 # 1=generic or unspecified error (current practice) ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 226 | fi 227 | 228 | 229 | # CALL FUNCTIONS ACCORDING TO INPUT ARGUMENTS OF THE SHELL SCRIPT ************************** 230 | 231 | case "$1" in 232 | start) 233 | fStart "$BINFILENAME" 234 | fLog "$HRLINE" 235 | ;; 236 | stop) 237 | fStop "$BINFILENAME" 238 | fLog "$HRLINE" 239 | ;; 240 | restart|reload|force-reload) 241 | fRestart "$BINFILENAME" 242 | fLog "$HRLINE" 243 | ;; 244 | status) 245 | echo -n "$BINFILENAME " 246 | if pidof $BINFILENAME > /dev/null # RETURNED STATUS: 247 | then echo "running"; exit 0 # 0 = program is running -or- service is OK ; 1 = program is dead with "/var/run" pid-file exists ; 2 = program is dead with "/var/lock" lock-file exists ; 248 | else echo "stopped"; exit 3 # 3 = program is not running ; 4 = status is unknown ; 5-99 = reserved for future LSB use ; 100-254 = reserved 249 | fi 250 | ;; 251 | version|info) 252 | fGetVer 253 | ;; 254 | au|autoupdate) 255 | if E2inStandby; then 256 | wget -qO- "http://127.0.0.1/api/zap?sRef=${ZAPCHANNEL}" > /dev/null 2>&1 257 | fLog "Zap the tuner to the '${ZAPCHANNEL}' channel/SRC. The tuner will turn off automatically after ${ZAPDELAY} seconds." 258 | # CMD="sleep ${ZAPDELAY}; /usr/bin/wget -qO- 'http://127.0.0.1/api/zap?sRef=0' > /dev/null 2>&1; printf '%(%Y-%m-%d %H:%M:%S)T The tuner has been turned off (zapped to the null channel/SRC).\n' >> ${LOGFILE}; echo '${HRLINE}' >> ${LOGFILE};" 259 | CMD="sleep ${ZAPDELAY}; /usr/bin/wget -qO- 'http://127.0.0.1/api/zap?sRef=0' > /dev/null 2>&1; date '+%Y-%m-%d %H:%M:%S' | tr -d '\n' >> ${LOGFILE}; echo -e ' The tuner has been turned off (zapped to the null channel/SRC).\n${HRLINE}' >> ${LOGFILE};" 260 | eval "${CMD}" &>/dev/null & disown; 261 | else 262 | TMPMSG="$(date '+%Y-%m-%d %H:%M:%S') The AutoUpdate/AU script function cannot be performed. Enigma2 is not in standby mode or Enigma2 is still not running (when the Linux system is just booting)." 263 | fLog "$TMPMSG" 264 | fLog "$HRLINE" 265 | fi 266 | ;; 267 | *) 268 | fLog "Unknown or missing arguments !" 269 | echo "$MANPAGE" >$(tty) 270 | fLog "$HRLINE" 271 | exit 2 # 1=generic or unspecified error ; 2=invalid or excess argument(s) ; 3=unimplemented feature (for example, "reload") ; 4=user had insufficient privilege ; 5=program is not installed ; 6=program is not configured ; 7=program is not running 272 | ;; 273 | esac 274 | 275 | 276 | exit 0 277 | 278 | -------------------------------------------------------------------------------- /softcam.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Softcam 3 | After=dev-dvb-adapter0-ca0.device 4 | After=dev-dvb-adapter0-demux0.device 5 | After=dev-sci0.device 6 | 7 | [Service] 8 | Type=forking 9 | ExecStart=/usr/bin/oscam -b -r 2 10 | # for CCcam, use the following startup command: ExecStart=/usr/bin/CCcam & 11 | Restart=on-failure 12 | NotifyAccess=main 13 | NonBlocking=true 14 | 15 | [Install] 16 | WantedBy=multi-user.target 17 | 18 | # A NOTE: This file belongs to the directory '/lib/systemd/system' 19 | -------------------------------------------------------------------------------- /vhannibal-setting-download.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | # Shell script was created by s3n0, 02.2021 5 | # - shell script was intended for downloading the patricular zip-package / "setting" package 6 | # - after download the zip-package, it is unpacked in a temporary folder 7 | # - next, at least two strings are searched in all "*.tv" files to identify a specific one file - specific SAT provider 8 | # - the userbouquet file is renamed and copied to the "/etc/enigma2" folder 9 | # - userbouquet files are then reloaded via OpenWebif 10 | # Of course, it is necessary to modify the search strings and also the ID number of the downloaded zip-file, according to your own needs 11 | 12 | 13 | HR="#####################################################" 14 | echo "$HR" 15 | TMP_DIR="/tmp/vhannibal_settings" 16 | rm -rf $TMP_DIR 17 | mkdir -p $TMP_DIR 18 | cd $TMP_DIR 19 | 20 | 21 | #### Notice: Find your own setting zip-package on the Vhannibal web-site https://www.vhannibal.net/enigma2.php 22 | #### and edit the required "id=??" number, according to your downloaded zip-file. 23 | ID_NUMBER=13 24 | echo "- downloading and extracting the main Vhannibal enigma2 settings file, with ID number ${ID_NUMBER}" 25 | wget -O "${TMP_DIR}/setting.zip" --no-check-certificate "https://www.vhannibal.net/download_setting.php?id=${ID_NUMBER}&action=download" > /dev/null 2>&1 26 | [ "$?" -ne "0" ] && { echo "! ERROR ! The main Vhannibal enigma2 settings file, with ID number ${ID_NUMBER} - download failed !"; exit 1; } 27 | unzip -qj "${TMP_DIR}/setting.zip" -d $TMP_DIR 28 | 29 | 30 | BOUQUET2SAVE=/etc/enigma2/userbouquet.sat-skylink-vhannibal.tv 31 | echo "- search for 'Skylink' userbouquet file (with 'Movies' category)" 32 | BOUQUET2FIND=$(grep -l "Movies" `grep -l "Skylink" $TMP_DIR/*.tv`) 33 | if [ -z "$BOUQUET2FIND" ]; then 34 | echo "! 'Skylink' userbouquet file was NOT found !" 35 | else 36 | echo "- 'Skylink' userbouquet file found: ${BOUQUET2FIND}" 37 | sed -i -e 's/NAME Skylink/NAME SAT Skylink SK \& CZ (Vhannibal '$(date "+%Y-%m")')/I' $BOUQUET2FIND 38 | echo "- copying: ${BOUQUET2FIND} ----> ${BOUQUET2SAVE}" 39 | cp -f $BOUQUET2FIND $BOUQUET2SAVE 40 | fi 41 | 42 | 43 | BOUQUET2SAVE=/etc/enigma2/userbouquet.sat-deutschland-vhannibal.tv 44 | echo "- search for 'Deutschland' userbouquet file (with 'Regionalen' category)" 45 | BOUQUET2FIND=$(grep -l "Regionalen" `grep -l "Deutschland" $TMP_DIR/*.tv`) 46 | if [ -z "$BOUQUET2FIND" ]; then 47 | echo "! 'Deutschland' userbouquet file was NOT found !" 48 | else 49 | echo "- 'Deutschland' userbouquet file found: ${BOUQUET2FIND}" 50 | sed -i -e 's/NAME HD+ Deutschland/NAME SAT Deutschland (Vhannibal '$(date "+%Y-%m")')/I' $BOUQUET2FIND 51 | echo "- copying: ${BOUQUET2FIND} ----> ${BOUQUET2SAVE}" 52 | cp -f $BOUQUET2FIND $BOUQUET2SAVE 53 | fi 54 | 55 | 56 | echo "* reloading all services in Enigma2 (reloading list of favorite channels)" 57 | wget -qO- "http://127.0.0.1/web/servicelistreload?mode=0" > /dev/null 2>&1 58 | sleep 2 59 | wget -qO- "http://127.0.0.1/web/servicelistreload?mode=4" > /dev/null 2>&1 60 | 61 | 62 | rm -rf $TMP_DIR 63 | echo "$HR" 64 | 65 | 66 | exit 0 67 | --------------------------------------------------------------------------------