diff --git a/bin/monitor.php b/bin/monitor.php index 048a44032..b672d7ec9 100755 --- a/bin/monitor.php +++ b/bin/monitor.php @@ -38,6 +38,7 @@ $_binaries = getenv('BINARIES'); $_import = getenv('IMPORT'); $_cleanup = getenv('CLEANUP'); $_optimise = getenv('OPTIMISE'); +$_inno_test = shell_exec('svn info /var/www/newznab | grep inno'); $_innodb_path = getenv('INNODB_PATH'); $_admin_path = getenv('ADMIN_PATH'); @@ -117,15 +118,27 @@ while($i>0) $additional_releases_now = $releases_now - $book_releases_now - $console_releases_now - $movie_releases_now - $music_releases_now - $pc_releases_now - $tvrage_releases_now; $total_work_now = $work_remaining_now + $tvrage_releases_proc + $music_releases_proc + $movie_releases_proc + $console_releases_proc + $book_releases_proc; - passthru('clear'); - printf("\033[1;34mMonitor\033[0m has been running for: \033[38;5;160m$day\033[0m");printf(" days, "); - printf("\033[38;5;208m$hr\033[0m");printf(" hrs, "); - printf("\033[38;5;020m$min\033[0m");printf(" min\n"); - printf("The script updates every $sleeptime seconds.\n"); - printf("$releases_since_loop releases added since last update.\n\n"); + if ( $releases_since_start > 0 ) { $signed = "+"; } + else { $signed = ""; } - printf("$releases_now releases in your database.\n"); - printf("$releases_since_start releases have been added.\n\n"); + if ( $min != 1 ) { $string_min = "mins"; } + else { $string_min = "min"; } + + if ( $hr != 1 ) { $string_hr = "hrs"; } + else { $string_hr = "hr"; } + + if ( $day != 1 ) { $string_day = "days"; } + else { $string_day = "day"; } + + if ( $day > 0 ) { $time_string = "\033[38;5;160m$day\033[0m $string_day, \033[38;5;208m$hr\033[0m $string_hr, \033[38;5;020m$min\033[0m $string_min."; } + elseif ( $hr > 0 ) { $time_string = "\033[38;5;208m$hr\033[0m $string_hr, \033[38;5;020m$min\033[0m $string_min."; } + else { $time_string = "\033[38;5;020m$min\033[0m $string_min."; } + + + passthru('clear'); + printf("\033[1;34mMonitor\033[0m has been running for: $time_string\n"); + printf("$releases_since_loop releases added in the previous $sleeptime seconds.\n"); + printf("$releases_now($signed$releases_since_start) releases in your database.\n\n"); $mask = "%16s %10s %10s \n"; printf($mask, "Category", "In Process", "In Database"); @@ -186,42 +199,60 @@ while($i>0) } shell_exec("tmux respawnp -t Newznab-dev:0.10 'cd bin && $_php processOthers.php && date && echo \"$_string\"' 2>&1 1> /dev/null"); - if (( $_innodb == "true" ) && ( $_threads == "true" )) { - $_import_path = $_innodb_path; - $_update_path = $_innodb_path; - $_import_cmd = 'nzb-import.php'; - $_backfill_cmd = 'backfill_threaded.php'; - $_update_cmd = 'update_binaries_threaded.php'; - } elseif (( $_innodb == "true" ) && ( $_threads != "true" )) { - $_import_path = $_admin_path; - $_update_path = $_innodb_path; - $_import_cmd = 'nzb-importmodified.php'; - $_backfill_cmd = 'backfill.php'; - $_update_cmd = 'update_binaries.php'; - } elseif (( $_innodb != "true" ) && ( $_threads == "true" )) { - $_import_path = $_admin_path; - $_update_path = $_newznab_path; - $_import_cmd = 'nzb-importmodified.php'; - $_backfill_cmd = 'backfill_threaded.php'; - $_update_cmd = 'update_binaries_threaded.php'; - } else { - $_import_path = $_admin_path; - $_update_path = $_newznab_path; - $_import_cmd = 'nzb-importmodified.php'; - $_backfill_cmd = 'backfill.php'; - $_update_cmd = 'update_binaries.php'; - } +if ( ! $_inno_test ) { + if (( $_innodb == "true" ) && ( $_threads == "true" )) { + $_import_path = $_innodb_path; + $_update_path = $_innodb_path; + $_import_cmd = 'nzb-import.php'; + $_backfill_cmd = 'backfill_threaded.php'; + $_update_cmd = 'update_binaries_threaded.php'; + } elseif (( $_innodb == "true" ) && ( $_threads != "true" )) { + $_import_path = $_admin_path; + $_update_path = $_innodb_path; + $_import_cmd = 'nzb-importmodified.php'; + $_backfill_cmd = 'backfill.php'; + $_update_cmd = 'update_binaries.php'; + } elseif (( $_innodb != "true" ) && ( $_threads == "true" )) { + $_import_path = $_admin_path; + $_update_path = $_newznab_path; + $_import_cmd = 'nzb-importmodified.php'; + $_backfill_cmd = 'backfill_threaded.php'; + $_update_cmd = 'update_binaries_threaded.php'; + } else { + $_import_path = $_admin_path; + $_update_path = $_newznab_path; + $_import_cmd = 'nzb-importmodified.php'; + $_backfill_cmd = 'backfill.php'; + $_update_cmd = 'update_binaries.php'; + } +} else { + if ( $_threads == "true" ) { + $_import_path = $_newznab_path; + $_update_path = $_newznab_path; + $_import_cmd = 'nzb-import.php'; + $_backfill_cmd = 'backfill_threaded.php'; + $_update_cmd = 'update_binaries_threaded.php'; + } else { + $_import_path = $_newznab_path; + $_update_path = $_newznab_path; + $_import_cmd = 'nzb-import.php'; + $_backfill_cmd = 'backfill.php'; + $_update_cmd = 'update_binaries.php'; + } +} if (( $total_work_now < $_max_releases ) && ( $_binaries == "true" )) { - shell_exec("tmux respawnp -t Newznab-dev:0.11 'cd $_update_path && $_php $_update_cmd && date && sleep $_nntp && echo \"$_string\"' 2>&1 1> /dev/null"); + shell_exec("tmux respawnp -t Newznab-dev:0.11 'cd $_update_path && $_php $_update_cmd && date && echo \"sleeping $_nntp seconds...\" && sleep $_nntp && echo \"$_string\"' 2>&1 1> /dev/null"); } if (( $total_work_now < $_max_releases ) && ( $_backfill == "true" )) { - shell_exec("tmux respawnp -t Newznab-dev:0.12 '$_mysql -u$_DB_USER -h $_DB_HOST --password=$_DB_PASSWORD $_DB_NAME -e \"${backfill_increment}\"' 2>&1 1> /dev/null"); - shell_exec("tmux respawnp -t Newznab-dev:0.12 'cd $_update_path && $_php $_backfill_cmd && date && sleep $_nntp && echo \"$_string\"' 2>&1 1> /dev/null"); + //shell_exec("tmux respawnp -t Newznab-dev:0.12 '$_mysql -u$_DB_USER -h $_DB_HOST --password=$_DB_PASSWORD $_DB_NAME -e \"${backfill_increment}\"' 2>&1 1> /dev/null"); + shell_exec("tmux respawnp -t Newznab-dev:0.12 'cd $_update_path && $_php $_backfill_cmd && \ + $_mysql -u$_DB_USER -h $_DB_HOST --password=$_DB_PASSWORD $_DB_NAME -e \"${backfill_increment}\" && \ + date && echo \"sleeping $_nntp seconds...\" && sleep $_nntp && echo \"$_string\"' 2>&1 1> /dev/null"); } if (( $total_work_now < $_max_releases ) && ( $_import == "true" )) { - shell_exec("tmux respawnp -t Newznab-dev:0.13 'cd $_import_path && $_php $_import_cmd \"$_nzbs\" && date && echo \"$_string\"' 2>&1 1> /dev/null"); + shell_exec("tmux respawnp -t Newznab-dev:0.13 'cd $_import_path && $_php $_import_cmd \"$_nzbs\" true && date && echo \"$_string\"' 2>&1 1> /dev/null"); } shell_exec("tmux respawnp -t Newznab-dev:0.14 'cd $_newznab_path && $_php update_releases.php && date && echo \"$_string\"' 2>&1 1> /dev/null"); diff --git a/bin/post_complete.php b/bin/post_complete.php new file mode 100644 index 000000000..bfb35ca24 --- /dev/null +++ b/bin/post_complete.php @@ -0,0 +1,28 @@ +query($thequery); + if ($result[0]["thecount"] < 10 ) + { + $postprocess->processAll(); + echo "done...waiting"; + sleep(600); + } else { + for ($i = 0; $i < $result[0]["thecount"]; $i=$i+5) + { + echo "\n"; + echo $result[0]["thecount"] - $i. " more to go: \n"; + $postprocess->processAdditional(); + } + } +} +?> diff --git a/bin/processOthers.php b/bin/processOthers.php index f3b07f898..bb067147f 100755 --- a/bin/processOthers.php +++ b/bin/processOthers.php @@ -5,14 +5,8 @@ require_once(WWW_DIR."/lib/postprocess.php"); $postprocess = new PostProcess(true); $postprocess->processUnwanted(); - -$postprocess = new PostProcess(true); $postprocess->processMusicFromMediaInfo(); - -$postprocess = new PostProcess(true); $postprocess->processOtherMiscCategory(); - -$postprocess = new PostProcess(true); $postprocess->processUnknownCategory(); ?> diff --git a/conf/.gitignore b/conf/.gitignore new file mode 100644 index 000000000..17b3fff87 --- /dev/null +++ b/conf/.gitignore @@ -0,0 +1,2 @@ +tmux1.conf +tmux2.conf diff --git a/conf/.tmux.conf b/conf/tmux.conf similarity index 100% rename from conf/.tmux.conf rename to conf/tmux.conf diff --git a/conf/tmux_user.conf b/conf/tmux_user.conf new file mode 100755 index 000000000..1b5f21f52 --- /dev/null +++ b/conf/tmux_user.conf @@ -0,0 +1,50 @@ +# C-b is not acceptable -- Vim uses it +set-option -g prefix C-a +bind-key C-a last-window + +# Start numbering at 1 +#set -g base-index 1 + +# Allows for faster key repetition +set -s escape-time 0 + +# Set status bar +set -g status-bg black +set -g status-fg white +set -g status-left "" +set -g status-right "#[fg=green]#H" + +# Rather than constraining window size to the maximum size of any client +# connected to the *session*, constrain window size to the maximum size of any +# client connected to *that window*. Much more reasonable. +setw -g aggressive-resize on + +# Allows us to use C-a a to send commands to a TMUX session inside +# another TMUX session +bind-key a send-prefix + +# Activity monitoring +setw -g monitor-activity on +set -g visual-activity on + +# # Refresh the status bar every 30 seconds. Try to keep the nzb folder to a reasonable number +set-option -g status-interval 30 + +# Example of using a shell command in the status line +#set -g status-right "#[fg=yellow]#(uptime | cut -d ',' -f 2-)" +#set -g status-right "#[fg=red]#(ls -1 /storage/server/newznab/batch | wc -l) NZB's left to process #[fg=yellow]#(uptime | cut -d ',' -f 2-)" +set -g status-right "#[fg=red]#(ls -1 /storage/server/newznab/batch | wc -l) NZB's left to process #[fg=yellow]#(free -m | grep 'Mem' | awk '{ print \"Ram Used: \"$3\" MB\";}') #[fg=yellow]#(free -m | grep 'Mem' | awk '{ print \"Ram Free: \"$4\" MB\";}') #[fg=yellow]#(free -m | grep 'Swap' | awk '{ print \"Swap Used: \"$3\" MB\";}') #[fg=yellow]#(uptime | cut -d ',' -f 2-)" + +set-option -g status-right-length 200 +#set -g status-right '#[fg=green][#[fg=blue]%Y-%m-%d #[fg=white]%H:%M#[default] #($HOME/bin/battery)#[fg=green]]' + +# Highlight active window +set-window-option -g window-status-current-bg red + +#mouse - allows selct pane and resize with mouse +set -g mode-mouse on +set -g mouse-resize-pane on +set -g mouse-select-pane on +set -g mouse-select-window on + +set -g set-remain-on-exit on diff --git a/edit_these.sh b/edit_these.sh index 308e206f9..7c97a6b01 100755 --- a/edit_these.sh +++ b/edit_these.sh @@ -20,7 +20,7 @@ export TMUX_SESSION="Newznab-dev" export MONITOR_UPDATE="20" #Set, in seconds - how long the update_binaries and backfill should sleep between runs, 0 may cause errors -export NNTP_SLEEP="60" +export NNTP_SLEEP="10" #Set the maximum days tp backfill export MAXDAYS="210" diff --git a/set_perms.sh b/set_perms.sh index afb19d5cc..1fb0eb2a9 100755 --- a/set_perms.sh +++ b/set_perms.sh @@ -20,17 +20,6 @@ fi echo -e "\033[38;5;148mcp $TESTING_PATH/nzb-importmodified.php $NEWZPATH/www/admin/" cp $TESTING_PATH/nzb-importmodified.php $NEWZPATH/www/admin/ -if [ -d "/home/$USERNAME" ]; then - echo "cp conf/.tmux.conf /home/$USERNAME/.tmux.conf" - cp conf/.tmux.conf /home/$USERNAME/.tmux.conf - $SED -i 's,'changeme,"$NZBS"',' "/home/$USERNAME/.tmux.conf" -fi -if [ -d "$HOME" ]; then - echo "cp conf/.tmux.conf $HOME/.tmux.conf" - cp conf/.tmux.conf $HOME/.tmux.conf - $SED -i 's,'changeme,"$NZBS"',' "$HOME/.tmux.conf" -fi - echo "Editing $NEWZPATH/www/lib/postprocess.php" if [ ! -f $NEWZPATH/www/lib/postprocess.php.orig ]; then cp $NEWZPATH/www/lib/postprocess.php $NEWZPATH/www/lib/postprocess.php.orig diff --git a/start.sh b/start.sh index 860636ab6..c1674cdf9 100755 --- a/start.sh +++ b/start.sh @@ -17,35 +17,40 @@ if [[ $AGREED == "no" ]]; then echo "Please edit the edit_these.sh file" exit fi +TMPUNRAR_QUERY="SELECT value from site where ID = 66;" +TMPUNRAR_PATH=`$MYSQL -u$DB_USER -h $DB_HOST --password=$DB_PASSWORD $DB_NAME -s -N -e "${TMPUNRAR_PATH}"` +echo "$TMPUNRAR_PATH"; + +cp conf/tmux.conf conf/tmux_user.conf +$SED -i 's,'changeme,"$NZBS"',' "conf/tmux_user.conf" printf "\033]0; $TMUX_SESSION\007\003\n" -$TMUX -q -2 new-session -d -s $TMUX_SESSION -n NewzNab-dev 'cd bin && echo "monitor Working......" && nice -n 19 $PHP monitor.php -i' +$TMUX -f conf/tmux_user.conf new-session -d -s $TMUX_SESSION -n NewzNab-dev 'cd bin && echo "monitor Working......" && nice -n 19 $PHP monitor.php -i' $TMUX selectp -t 0 -$TMUX -q splitw -h -p 72 'echo "..."' -$TMUX -q splitw -h -p 50 'echo "..."' +$TMUX splitw -h -p 72 'echo "..."' +$TMUX splitw -h -p 50 'echo "..."' $TMUX selectp -t 0 -$TMUX -q splitw -v -p 65 'echo "..."' -$TMUX -q splitw -v -p 75 'echo "..."' -$TMUX -q splitw -v -p 67 'echo "..."' -$TMUX -q splitw -v -p 50 'echo "..."' +$TMUX splitw -v -p 65 'echo "..."' +$TMUX splitw -v -p 75 'echo "..."' +$TMUX splitw -v -p 67 'echo "..."' +$TMUX splitw -v -p 50 'echo "..."' $TMUX selectp -t 5 -$TMUX -q splitw -v -p 83 'echo "..."' -$TMUX -q splitw -v -p 80 'echo "..."' -$TMUX -q splitw -v -p 75 'echo "..."' -$TMUX -q splitw -v -p 67 'echo "..."' -$TMUX -q splitw -v -p 50 'echo "..."' +$TMUX splitw -v -p 83 'echo "..."' +$TMUX splitw -v -p 80 'echo "..."' +$TMUX splitw -v -p 75 'echo "..."' +$TMUX splitw -v -p 67 'echo "..."' +$TMUX splitw -v -p 50 'echo "..."' $TMUX selectp -t 11 -$TMUX -q splitw -v -p 75 'echo "..."' -$TMUX -q splitw -v -p 67 'echo "..."' -$TMUX -q splitw -v -p 50 'echo "..."' +$TMUX splitw -v -p 75 'echo "..."' +$TMUX splitw -v -p 67 'echo "..."' +$TMUX splitw -v -p 50 'echo "..."' $TMUX new-window -n cleanup 'echo "..."' $TMUX selectp -t 0 -$TMUX -q splitw -h -p 50 'echo "..."' +$TMUX splitw -h -p 50 'echo "..."' $TMUX selectp -t 0 -$TMUX -q splitw -v -p 50 'echo "..."' +$TMUX splitw -v -p 50 'echo "..."' $TMUX selectp -t 2 -$TMUX -q splitw -v -p 50 'echo "..."' - +$TMUX splitw -v -p 50 'echo "..."' if [[ $USE_HTOP == "true" ]]; then $TMUX new-window -n htop '$HTOP'