diff --git a/.gitignore b/.gitignore index 255751113..602b7ca97 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ fix.sh defaults.sh +combined.sh diff --git a/bin/monitor.php b/bin/monitor.php index 3f35894fb..1946f9f65 100644 --- a/bin/monitor.php +++ b/bin/monitor.php @@ -12,8 +12,8 @@ $qry="SELECT COUNT( releases.categoryID ) AS cnt, parentID FROM releases RIGHT J $proc="SELECT ( SELECT COUNT( groupID ) AS cnt from releases where consoleinfoID IS NULL and categoryID BETWEEN 1000 AND 1999 ) AS console, ( SELECT COUNT( groupID ) AS cnt from releases where imdbID IS NULL and categoryID BETWEEN 2000 AND 2999 ) AS movies, ( SELECT COUNT( groupID ) AS cnt from releases where musicinfoID IS NULL and categoryID BETWEEN 3000 AND 3999 ) AS audio, ( SELECT COUNT( groupID ) AS cnt from releases r left join category c on c.ID = r.categoryID where (categoryID BETWEEN 4000 AND 4999 and ((r.passwordstatus between -6 and -1) or (r.haspreview = -1 and c.disablepreview = 0)))) AS pc, ( SELECT COUNT( groupID ) AS cnt from releases where rageID = -1 and categoryID BETWEEN 5000 AND 5999 ) AS tv, ( SELECT COUNT( groupID ) AS cnt from releases where bookinfoID IS NULL and categoryID = 7020 ) AS book, ( SELECT COUNT( groupID ) AS cnt from releases r left join category c on c.ID = r.categoryID where (r.passwordstatus between -6 and -1) or (r.haspreview = -1 and c.disablepreview = 0)) AS work, ( SELECT COUNT( groupID ) AS cnt from releases) AS releases, ( SELECT COUNT( groupID ) AS cnt FROM releases r WHERE r.releasenfoID = 0) AS nforemains, ( SELECT COUNT( groupID ) AS cnt FROM releases WHERE releasenfoID not in (0, -1)) AS nfo, ( SELECT table_rows AS cnt FROM information_schema.TABLES where table_name = 'parts' AND TABLE_SCHEMA = '".DB_NAME."' ) AS parts, ( SELECT concat(round((data_length+index_length)/(1024*1024*1024),2),'GB') AS cnt FROM information_schema.tables where table_name = 'parts' AND TABLE_SCHEMA = '".DB_NAME."' ) AS partsize;"; //get variables from defaults.sh -$varnames = shell_exec("cat ../defaults.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); -$vardata = shell_exec('cat ../defaults.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); +$varnames = shell_exec("cat ../combined.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); +$vardata = shell_exec('cat ../combined.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); $varnames = explode("\n", $varnames); $vardata = explode("\n", $vardata); $array = array_combine($varnames, $vardata); @@ -90,9 +90,12 @@ while($i>0) //get microtime at start of loop $time_loop_start = microtime_float(); + //recreate the combined.sh + shell_exec("cat ../config.sh ../defaults.sh > ../combined.sh"); + //chack variables again during loop - $varnames = shell_exec("cat ../defaults.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); - $vardata = shell_exec('cat ../defaults.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); + $varnames = shell_exec("cat ../combined.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); + $vardata = shell_exec('cat ../combined.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); $varnames = explode("\n", $varnames); $vardata = explode("\n", $vardata); $array = array_combine($varnames, $vardata); @@ -101,6 +104,14 @@ while($i>0) //get microtime to at start of queries $query_timer_start=microtime_float(); + //kill panes if user changed to/from nzb import threaded + if ( $_imports != $array['NZB_THREADS'] ) { + shell_exec("$_tmux respawnp -k -t {$array['TMUX_SESSION']}:0.11"); + shell_exec("$_tmux respawnp -k -t {$array['TMUX_SESSION']}:0.1"); + shell_exec("$_tmux respawnp -k -t {$array['TMUX_SESSION']}:0.11"); + $_imports = $array['NZB_THREADS']; + } + //run queries $result = @$db->query($qry); $initquery = array(); @@ -344,13 +355,6 @@ while($i>0) $_backfill_cmd = 'backfill.php'; } - //kill panes if user changed - if ( $_imports != $array['NZB_THREADS'] ) { - shell_exec("$_tmux respawnp -k -t {$array['TMUX_SESSION']}:0.11"); - shell_exec("$_tmux respawnp -k -t {$array['TMUX_SESSION']}:0.1"); - $_imports = $array['NZB_THREADS']; - } - //set command for nzb-import if ( $array['NZB_THREADS'] == "true" ) { $nzb_cmd = "$_php nzb-import-sub.php \"{$array['NZBS']}\""; diff --git a/bin/nzb-import-sub.php b/bin/nzb-import-sub.php index 996e20f44..95d141d72 100644 --- a/bin/nzb-import-sub.php +++ b/bin/nzb-import-sub.php @@ -18,8 +18,8 @@ if($subdir_count == 0){ die(); } -$varnames = shell_exec("cat ../defaults.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); -$vardata = shell_exec('cat ../defaults.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); +$varnames = shell_exec("cat ../combined.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); +$vardata = shell_exec('cat ../combined.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); $varnames = explode("\n", $varnames); $vardata = explode("\n", $vardata); $array = array_combine($varnames, $vardata); diff --git a/bin/nzb-import.php b/bin/nzb-import.php index 7760ca790..3ec745dd3 100644 --- a/bin/nzb-import.php +++ b/bin/nzb-import.php @@ -132,8 +132,8 @@ if (!isset($groups) || count($groups) == 0) { flush(); } - $varnames = shell_exec("cat ../defaults.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); - $vardata = shell_exec('cat ../defaults.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); + $varnames = shell_exec("cat ../combined.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); + $vardata = shell_exec('cat ../combined.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); $varnames = explode("\n", $varnames); $vardata = explode("\n", $vardata); $array = array_combine($varnames, $vardata); diff --git a/bin/nzb-importonenzb.php b/bin/nzb-importonenzb.php index 8d1359dec..9dee049b8 100644 --- a/bin/nzb-importonenzb.php +++ b/bin/nzb-importonenzb.php @@ -191,8 +191,8 @@ if ($using_cli || $page->isPostBack() ) } - $varnames = shell_exec("cat ../defaults.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); - $vardata = shell_exec('cat ../defaults.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); + $varnames = shell_exec("cat ../combined.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); + $vardata = shell_exec('cat ../combined.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); $varnames = explode("\n", $varnames); $vardata = explode("\n", $vardata); $array = array_combine($varnames, $vardata); diff --git a/bin/nzbcount.php b/bin/nzbcount.php index ed629c82c..d24cf15ee 100644 --- a/bin/nzbcount.php +++ b/bin/nzbcount.php @@ -4,8 +4,8 @@ $subdir_count_now = 0; $filecount=0; //get variables from defaults.sh -$varnames = shell_exec("cat ../defaults.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); -$vardata = shell_exec('cat ../defaults.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); +$varnames = shell_exec("cat ../combined.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); +$vardata = shell_exec('cat ../combined.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); $varnames = explode("\n", $varnames); $vardata = explode("\n", $vardata); $array = array_combine($varnames, $vardata); @@ -34,8 +34,8 @@ while ($i==0) { } //get variables from defaults.sh - $varnames = shell_exec("cat ../defaults.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); - $vardata = shell_exec('cat ../defaults.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); + $varnames = shell_exec("cat ../combined.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); + $vardata = shell_exec('cat ../combined.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); $varnames = explode("\n", $varnames); $vardata = explode("\n", $vardata); $array = array_combine($varnames, $vardata); diff --git a/bin/test_defaults.sh b/bin/test_defaults.sh deleted file mode 100644 index c6b0b4da0..000000000 --- a/bin/test_defaults.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash -export ALLOW_START="true" -if [ -z "$RUNNING" ]; then export ALLOW_START="false"; fi -if [ -z "$IMPORT" ]; then export ALLOW_START="false"; fi -if [ -z "$NZB_THREADS" ]; then export ALLOW_START="false"; fi -if [ -z "$NZBCOUNT" ]; then export ALLOW_START="false"; fi -if [ -z "$IMPORT_SLEEP" ]; then export ALLOW_START="false"; fi -if [ -z "$IMPORT_MAX_RELEASES" ]; then export ALLOW_START="false"; fi -if [ -z "$RELEASES" ]; then export ALLOW_START="false"; fi -if [ -z "$RELEASES_SLEEP" ]; then export ALLOW_START="false"; fi -if [ -z "$OPTIMIZE" ]; then export ALLOW_START="false"; fi -if [ -z "$MYISAM_SMALL" ]; then export ALLOW_START="false"; fi -if [ -z "$MYISAM_LARGE" ]; then export ALLOW_START="false"; fi -if [ -z "$INNODB_SMALL" ]; then export ALLOW_START="false"; fi -if [ -z "$INNODB_LARGE" ]; then export ALLOW_START="false"; fi -if [ -z "$INNODB" ]; then export ALLOW_START="false"; fi -if [ -z "$CLEANUP" ]; then export ALLOW_START="false"; fi -if [ -z "$CLEANUP_TIMER" ]; then export ALLOW_START="false"; fi -if [ -z "$PARSING" ]; then export ALLOW_START="false"; fi -if [ -z "$PARSING_TIMER" ]; then export ALLOW_START="false"; fi -if [ -z "$PREDB_TIMER" ]; then export ALLOW_START="false"; fi -if [ -z "$TVRAGE_TIMER" ]; then export ALLOW_START="false"; fi -if [ -z "$SPHINX" ]; then export ALLOW_START="false"; fi -if [ -z "$SPHINX_TIMER" ]; then export ALLOW_START="false"; fi -if [ -z "$SED" ]; then export ALLOW_START="false"; fi -if [ -z "$USE_HTOP" ]; then export ALLOW_START="false"; fi -if [ -z "$USE_NMON" ]; then export ALLOW_START="false"; fi -if [ -z "$USE_BWMNG" ]; then export ALLOW_START="false"; fi -if [ -z "$USE_IOTOP" ]; then export ALLOW_START="false"; fi -if [ -z "$USE_MYTOP" ]; then export ALLOW_START="false"; fi -if [ -z "$USE_VNSTAT" ]; then export ALLOW_START="false"; fi -if [ -z "$USE_IFTOP" ]; then export ALLOW_START="false"; fi -if [ -z "$POWERLINE" ]; then export ALLOW_START="false"; fi -if [ -z "$RAMDISK" ]; then export ALLOW_START="false"; fi -if [ -z "$AGREED" ]; then export ALLOW_START="false"; fi -if [ -z "$MYSQL" ]; then export ALLOW_START="false"; fi -if [ -z "$PHP" ]; then export ALLOW_START="false"; fi -if [ -z "$TMUXCMD" ]; then export ALLOW_START="false"; fi -if [ -z "$NICE" ]; then export ALLOW_START="false"; fi -if [ -z "$TMUX_CONF" ]; then export ALLOW_START="false"; fi -if [ -z "$RUNNING" ]; then export ALLOW_START="false"; fi -if [ -z "$NEWZPATH" ]; then export ALLOW_START="false"; fi -if [ -z "$NEWZNAB_PATH" ]; then export ALLOW_START="false"; fi -if [ -z "$TESTING_PATH" ]; then export ALLOW_START="false"; fi -if [ -z "$ADMIN_PATH" ]; then export ALLOW_START="false"; fi -if [ -z "$POST_TO_RUN" ]; then export ALLOW_START="false"; fi -if [ -z "$TMUX_SESSION" ]; then export ALLOW_START="false"; fi -if [ -z "$MONITOR_UPDATE" ]; then export ALLOW_START="false"; fi -if [ -z "$BINARIES" ]; then export ALLOW_START="false"; fi -if [ -z "$BINARIES_THREADS" ]; then export ALLOW_START="false"; fi -if [ -z "$BINARIES_SLEEP" ]; then export ALLOW_START="false"; fi -if [ -z "$MAX_RELEASES" ]; then export ALLOW_START="false"; fi -if [ -z "$BACKFILL" ]; then export ALLOW_START="false"; fi -if [ -z "$BACKFILL_THREADS" ]; then export ALLOW_START="false"; fi -if [ -z "$BACKFILL_SLEEP" ]; then export ALLOW_START="false"; fi -if [ -z "$BACKFILL_MAX_RELEASES" ]; then export ALLOW_START="false"; fi -if [ -z "$MAXDAYS" ]; then export ALLOW_START="false"; fi -if [ -z "$NZBS" ]; then export ALLOW_START="false"; fi -if [ -z "$IMPORT_MAX_ROWS" ]; then export ALLOW_START="false"; fi -if [ -z "$BINARIES_MAX_ROWS" ]; then export ALLOW_START="false"; fi -if [ -z "$BACKFILL_MAX_ROWS" ]; then export ALLOW_START="false"; fi -if [ -z "$KILL_PROCESS" ]; then export ALLOW_START="false"; fi -if [ -z "NZB_FOLDER_COUNT" ]; then export ALLOW_START="false"; fi -if [ -z "DELETE_PARTS" ]; then export ALLOW_START="false"; fi -if [ -z "IMPORT_TRUE" ]; then export ALLOW_START="false"; fi - - diff --git a/config.sh b/config.sh index b90c1c7fe..15ebcb14f 100644 --- a/config.sh +++ b/config.sh @@ -204,7 +204,7 @@ export KILL_PROCESS="0" #Delete parts and binaries older than retention days, which is set in edit - site #NOT IMPLEMENTED YET -export DELETE_PARTS="true" +export DELETE_PARTS="false" ############################################################ diff --git a/start.sh b/start.sh index 1a4246116..e115dc1b8 100755 --- a/start.sh +++ b/start.sh @@ -22,15 +22,8 @@ if [[ $EUID -ne 0 ]]; then #exit 1 fi -source defaults.sh - -#verify all variables exist -source bin/test_defaults.sh -if [[ $ALLOW_START == "false" ]]; then - clear - echo "Please copy config.sh to defaults.sh, your current copy is outdated." - exit -fi +cat config.sh defaults.sh > combined.sh +source combined.sh eval $( $SED -n "/^define/ { s/.*('\([^']*\)', '*\([^']*\)'*);/export \1=\"\2\"/; p }" "$NEWZPATH"/www/config.php )