From a2eccdc41be3e50985060307d004d915429f6797 Mon Sep 17 00:00:00 2001 From: jonnyboy Date: Mon, 31 Dec 2012 19:15:59 -0500 Subject: [PATCH] lots of small tweaks --- README.md | 10 +-- bin/innodb_import_full_threaded.sh | 34 --------- bin/innodb_import_threaded.sh | 34 --------- bin/monitor.php | 10 ++- bin/myisam_import_full_threaded.sh | 34 --------- bin/myisam_import_threaded.sh | 34 --------- bin/workhorse.sh | 114 +++++++++++++++++++++++++++++ conf/.tmux.conf | 9 ++- edit_these.sh | 12 ++- set_perms.sh | 1 - start.sh | 25 +++---- 11 files changed, 153 insertions(+), 164 deletions(-) delete mode 100755 bin/innodb_import_full_threaded.sh delete mode 100755 bin/innodb_import_threaded.sh delete mode 100755 bin/myisam_import_full_threaded.sh delete mode 100755 bin/myisam_import_threaded.sh create mode 100755 bin/workhorse.sh diff --git a/README.md b/README.md index a087c59d4..f98798667 100644 --- a/README.md +++ b/README.md @@ -39,15 +39,15 @@ * update_cleanup needs to be uncommented to actually do something, and update_parsing is good for fixing a few releases everytime it runs, not a silver bullet though - * If you notice that the pane middle right is empty, that is intentional. I have bwm-ng ready to go into that spot, if you have it installed. Once it is installed run these commands as root from the nix_scripts/tmux folder: - - `sed -i -e "s/$TMUX splitw -h -p 50 '$BWMNG'/$TMUX splitw -h -p 50 '$BWMNG'/" start.sh` - - `sed -i -e 's/#command/command/' edit_these.sh` + * You have two choices for monitoring activity. Mytop monitors the sctivity of you mysql database and bwm-ng monitors your current traffic. Theses are selected in the edit_these.sh file. Only one can be selected at a time. + + * If you are running this on an OVH or kimsufi server, you may need to run sudo ./start.sh because they built grsecurity into the kernel. * Now all panes should be running smoothly. + +
Click here to lend your support to: Newznab-tmux and make a donation at www.pledgie.com ! diff --git a/bin/innodb_import_full_threaded.sh b/bin/innodb_import_full_threaded.sh deleted file mode 100755 index aedc5a8ea..000000000 --- a/bin/innodb_import_full_threaded.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -set -e - -source ../edit_these.sh -eval $( sed -n "/^define/ { s/.*('\([^']*\)', '*\([^']*\)'*);/export \1=\"\2\"/; p }" ../../../../www/config.php ) - -export MYSQL_CMD="UPDATE groups set backfill_target=backfill_target+1 where active=1 and backfill_target<$MAXDAYS;" - -while : - do - - #import nzb's - cd $INNODB_PATH - [ -f $INNODB_PATH/nzb-import.php ] && $PHP $INNODB_PATH/nzb-import.php ${NZBS} & - - #make active groups current - cd $NEWZNAB_PATH - [ -f $NEWZNAB_PATH/update_binaries_threaded.php ] && $PHP $NEWZNAB_PATH/update_binaries_threaded.php & - - #get backfill for all active groups - cd $NEWZNAB_PATH - [ -f $NEWZNAB_PATH/backfill_threaded.php ] && $PHP $NEWZNAB_PATH/backfill_threaded.php & - - wait - - #increment backfill days - $MYSQL -u$DB_USER -h $DB_HOST --password=$DB_PASSWORD $DB_NAME -e "${MYSQL_CMD}" - - echo "imports waiting $NEWZNAB_IMPORT_SLEEP_TIME seconds..." - sleep $NEWZNAB_IMPORT_SLEEP_TIME - -done - diff --git a/bin/innodb_import_threaded.sh b/bin/innodb_import_threaded.sh deleted file mode 100755 index d9201e839..000000000 --- a/bin/innodb_import_threaded.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -set -e - -source ../edit_these.sh -eval $( sed -n "/^define/ { s/.*('\([^']*\)', '*\([^']*\)'*);/export \1=\"\2\"/; p }" ../../../../www/config.php ) - -export MYSQL_CMD="UPDATE groups set backfill_target=backfill_target+1 where active=1 and backfill_target<$MAXDAYS;" - -while : - do - - #import nzb's - cd $INNODB_PATH - [ -f $INNODB_PATH/nzb-import.php ] && $PHP $INNODB_PATH/nzb-import.php ${NZBS} & - - #make active groups current - cd $INNODB_PATH - [ -f $INNODB_PATH/update_binaries.php ] && $PHP $INNODB_PATH/update_binaries.php & - - #get backfill for all active groups - cd $INNODB_PATH - [ -f $INNODB_PATH/backfill.php ] && $PHP $INNODB_PATH/backfill.php & - - wait - - #increment backfill days - $MYSQL -u$DB_USER -h $DB_HOST --password=$DB_PASSWORD $DB_NAME -e "${MYSQL_CMD}" - - echo "imports waiting $NEWZNAB_IMPORT_SLEEP_TIME seconds..." - sleep $NEWZNAB_IMPORT_SLEEP_TIME - -done - diff --git a/bin/monitor.php b/bin/monitor.php index 985ab7003..b4009c523 100755 --- a/bin/monitor.php +++ b/bin/monitor.php @@ -19,10 +19,14 @@ while ($row = mysql_fetch_assoc($result_begin)) { } $i=1; -while($i=1) +while($i>0) { $result_inner_loop = mysql_query($query); - sleep(60); + + if ($i>1) { + sleep(60); + } + $result_loop = mysql_query($query); if (!$result_inner_loop) { @@ -54,6 +58,8 @@ while($i=1) printf("$count_loop releases currently in your database\n\n"); printf("***Info***\n"); printf("Above left shows the current NFO's being analyzed. Above middle shows the the processing for. Above right show the lookups for TVRage, music, etc. Below left shows the activity of imports - it is looping nzb import, backfill and current fill. Below right shows the activity of applying regex's and creating releases.\n"); + + $i++; } mysql_free_result($result_begin); diff --git a/bin/myisam_import_full_threaded.sh b/bin/myisam_import_full_threaded.sh deleted file mode 100755 index bb97c713f..000000000 --- a/bin/myisam_import_full_threaded.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -set -e - -source ../edit_these.sh -eval $( sed -n "/^define/ { s/.*('\([^']*\)', '*\([^']*\)'*);/export \1=\"\2\"/; p }" ../../../../www/config.php ) - -export MYSQL_CMD="UPDATE groups set backfill_target=backfill_target+1 where active=1 and backfill_target<$MAXDAYS;" - -while : - do - - #import nzb's - cd $ADMIN_PATH - [ -f $ADMIN_PATH/nzb-importmodified.php ] && $PHP $ADMIN_PATH/nzb-importmodified.php ${NZBS} & - - #make active groups current - cd $NEWZNAB_PATH - [ -f $NEWZNAB_PATH/update_binaries_threaded.php ] && $PHP $NEWZNAB_PATH/update_binaries_threaded.php & - - #get backfill for all active groups - cd $NEWZNAB_PATH - [ -f $NEWZNAB_PATH/backfill_threaded.php ] && $PHP $NEWZNAB_PATH/backfill_threaded.php & - - wait - - #increment backfill days - #$MYSQL -u$DB_USER -h $DB_HOST --password=$DB_PASSWORD $DB_NAME -e "${MYSQL_CMD}" - - echo "imports waiting $NEWZNAB_IMPORT_SLEEP_TIME seconds..." - sleep $NEWZNAB_IMPORT_SLEEP_TIME - -done - diff --git a/bin/myisam_import_threaded.sh b/bin/myisam_import_threaded.sh deleted file mode 100755 index 5bb166352..000000000 --- a/bin/myisam_import_threaded.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -set -e - -source ../edit_these.sh -eval $( sed -n "/^define/ { s/.*('\([^']*\)', '*\([^']*\)'*);/export \1=\"\2\"/; p }" ../../../../www/config.php ) - -export MYSQL_CMD="UPDATE groups set backfill_target=backfill_target+1 where active=1 and backfill_target<$MAXDAYS;" - -while : - do - - #import nzb's - cd $ADMIN_PATH - [ -f $ADMIN_PATH/nzb-importmodified.php ] && $PHP $ADMIN_PATH/nzb-importmodified.php ${NZBS} & - - #make active groups current - cd $NEWZNAB_PATH - [ -f $NEWZNAB_PATH/update_binaries.php ] && $PHP $NEWZNAB_PATH/update_binaries.php & - - #get backfill for all active groups - cd $NEWZNAB_PATH - [ -f $NEWZNAB_PATH/backfill.php ] && $PHP $NEWZNAB_PATH/backfill.php & - - wait - - #increment backfill days - $MYSQL -u$DB_USER -h $DB_HOST --password=$DB_PASSWORD $DB_NAME -e "${MYSQL_CMD}" - - echo "imports waiting $NEWZNAB_IMPORT_SLEEP_TIME seconds..." - sleep $NEWZNAB_IMPORT_SLEEP_TIME - -done - diff --git a/bin/workhorse.sh b/bin/workhorse.sh new file mode 100755 index 000000000..9d3027272 --- /dev/null +++ b/bin/workhorse.sh @@ -0,0 +1,114 @@ +#!/bin/bash + +set -e + +source ../edit_these.sh +eval $( sed -n "/^define/ { s/.*('\([^']*\)', '*\([^']*\)'*);/export \1=\"\2\"/; p }" ../../../../../www/config.php ) + +export MYSQL_CMD="UPDATE groups set backfill_target=backfill_target+1 where active=1 and backfill_target<$MAXDAYS;" + +if [ "$THREADS" == "true" -a "$INNODB" == "true" ]; then + while : + do + + #import nzb's + cd $INNODB_PATH + [ -f $INNODB_PATH/nzb-import.php ] && $PHP $INNODB_PATH/nzb-import.php ${NZBS} & + + #make active groups current + cd $NEWZNAB_PATH + [ -f $NEWZNAB_PATH/update_binaries_threaded.php ] && $PHP $NEWZNAB_PATH/update_binaries_threaded.php & + + #get backfill for all active groups + cd $NEWZNAB_PATH + [ -f $NEWZNAB_PATH/backfill_threaded.php ] && $PHP $NEWZNAB_PATH/backfill_threaded.php & + + wait + + #increment backfill days + $MYSQL -u$DB_USER -h $DB_HOST --password=$DB_PASSWORD $DB_NAME -e "${MYSQL_CMD}" + + echo "imports waiting $NEWZNAB_IMPORT_SLEEP_TIME seconds..." + sleep $NEWZNAB_IMPORT_SLEEP_TIME + + done + +elif [ "$THREADS" != "true" -a "$INNODB" == "true" ]; then + while : + do + + #import nzb's + cd $INNODB_PATH + [ -f $INNODB_PATH/nzb-import.php ] && $PHP $INNODB_PATH/nzb-import.php ${NZBS} & + + #make active groups current + cd $INNODB_PATH + [ -f $INNODB_PATH/update_binaries.php ] && $PHP $INNODB_PATH/update_binaries.php & + + #get backfill for all active groups + cd $INNODB_PATH + [ -f $INNODB_PATH/backfill.php ] && $PHP $INNODB_PATH/backfill.php & + + wait + + #increment backfill days + $MYSQL -u$DB_USER -h $DB_HOST --password=$DB_PASSWORD $DB_NAME -e "${MYSQL_CMD}" + + echo "imports waiting $NEWZNAB_IMPORT_SLEEP_TIME seconds..." + sleep $NEWZNAB_IMPORT_SLEEP_TIME + + done + +elif [ "$THREADS" == "true" -a "$INNODB" != "true" ]; then + while : + do + + #import nzb's + cd $ADMIN_PATH + [ -f $ADMIN_PATH/nzb-importmodified.php ] && $PHP $ADMIN_PATH/nzb-importmodified.php ${NZBS} & + + #make active groups current + cd $NEWZNAB_PATH + [ -f $NEWZNAB_PATH/update_binaries_threaded.php ] && $PHP $NEWZNAB_PATH/update_binaries_threaded.php & + + #get backfill for all active groups + cd $NEWZNAB_PATH + [ -f $NEWZNAB_PATH/backfill_threaded.php ] && $PHP $NEWZNAB_PATH/backfill_threaded.php & + + wait + + #increment backfill days + #$MYSQL -u$DB_USER -h $DB_HOST --password=$DB_PASSWORD $DB_NAME -e "${MYSQL_CMD}" + + echo "imports waiting $NEWZNAB_IMPORT_SLEEP_TIME seconds..." + sleep $NEWZNAB_IMPORT_SLEEP_TIME + + done +else + while : + do + + #import nzb's + cd $ADMIN_PATH + [ -f $ADMIN_PATH/nzb-importmodified.php ] && $PHP $ADMIN_PATH/nzb-importmodified.php ${NZBS} & + + #make active groups current + cd $NEWZNAB_PATH + [ -f $NEWZNAB_PATH/update_binaries.php ] && $PHP $NEWZNAB_PATH/update_binaries.php & + + #get backfill for all active groups + cd $NEWZNAB_PATH + [ -f $NEWZNAB_PATH/backfill.php ] && $PHP $NEWZNAB_PATH/backfill.php & + + wait + + #increment backfill days + $MYSQL -u$DB_USER -h $DB_HOST --password=$DB_PASSWORD $DB_NAME -e "${MYSQL_CMD}" + + echo "imports waiting $NEWZNAB_IMPORT_SLEEP_TIME seconds..." + sleep $NEWZNAB_IMPORT_SLEEP_TIME + + done + +fi + diff --git a/conf/.tmux.conf b/conf/.tmux.conf index 63991b3c1..3241ed9c9 100644 --- a/conf/.tmux.conf +++ b/conf/.tmux.conf @@ -32,7 +32,14 @@ set-option -g status-interval 10 # 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 changeme | wc -l) NZB's left to process #[fg=yellow]#(uptime | cut -d ',' -f 2-)" +#set -g status-right "#[fg=red]#(ls -1 changeme | wc -l) NZB's left to process #[fg=yellow]#(uptime | cut -d ',' -f 2-)" +set -g status-right \ + "#[fg=red]#(ls -1 /home/jonnyboy/nzbs/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]]' diff --git a/edit_these.sh b/edit_these.sh index 35ca28054..500a5770a 100755 --- a/edit_these.sh +++ b/edit_these.sh @@ -22,6 +22,12 @@ export THREADS='true' #Choose your database, comment the one true/false export INNODB='true' +#Choose which app to run in the middle right pane, of course it must be installed. Your choices are mytop and bwm-ng. +#Only have 1 uncommented at a time. + +export CHOICE_APP='bwm-ng' +#export CHOICE_APP='mytop' + #By using this script you understand that the programmer is not responsible for any loss of data, users, or sanity. #You also agree that you were smart enough to make a backup of your database and files. Do you agree? yes/no @@ -33,6 +39,6 @@ export AGREED='no' export MYSQL=`which mysql` export SED=`which sed` command -v php5 >/dev/null && export PHP=`which php5` || { export PHP=`which php`; } -command -v tmux >/dev/null && export TMUX=`which tmux` || { echo tmux command not found.\n apt-get install tmux\n or if on a real server yum install tmux; exit 1; } -#command -v bwm-ng >/dev/null && export BWMNG=`which bwm-ng` || { echo bwm-ng command not found.\n apt-get install bwm-ng; exit 1; } - +command -v tmux >/dev/null && export TMUX=`which tmux` +command -v bwm-ng >/dev/null && export BWMNG=`which bwm-ng` +command -v mytop >/dev/null && export MYTOP=`which mytop` diff --git a/set_perms.sh b/set_perms.sh index 552fe21c6..e57ea9b27 100755 --- a/set_perms.sh +++ b/set_perms.sh @@ -30,5 +30,4 @@ chmod -R 777 $NEWZPATH/www/covers chmod 777 $NEWZPATH/www chmod 777 $NEWZPATH/www/install chmod -R 777 $NEWZPATH/nzbfiles -#chown -R www-data:www-data /var/www/ chmod 777 $NEWZPATH/nzbfiles/tmpunrar/ diff --git a/start.sh b/start.sh index 2679d99ed..93ff2c797 100755 --- a/start.sh +++ b/start.sh @@ -7,26 +7,19 @@ if [[ $AGREED == "no" ]]; then exit fi -$TMUX new-session -d -s NewzNab -n NewzNab 'echo "processNfos Working......" && sleep 30 && $PHP bin/postprocess_nfo.php' +$TMUX new-session -d -s NewzNab -n NewzNab 'echo "processNfos Working......" && $PHP bin/postprocess_nfo.php' $TMUX selectp -t 0 $TMUX splitw -v -p 82 'echo "monitor Working......" && $PHP bin/monitor.php' - - -if [ "$THREADS" == "true" -a "$INNODB" == "true" ]; then - $TMUX splitw -v -p 66 'cd bin && echo "imports Working......" && sleep 45 && ./innodb_import_full_threaded.sh' -elif [ "$THREADS" != "true" -a "$INNODB" == "true" ]; then - $TMUX splitw -v -p 66 'cd bin && echo "imports Working......" && sleep 45 && ./innodb_import_threaded.sh' -elif [ "$THREADS" == "true" -a "$INNODB" != "true" ]; then - $TMUX splitw -v -p 66 'cd bin && echo "imports Working......" && sleep 45 && ./myisam_import_full_threaded.sh' -else - $TMUX splitw -v -p 66 'cd bin && echo "imports Working......" && sleep 45 && ./myisam_import_threaded.sh' -fi - +$TMUX splitw -v -p 66 'cd bin && echo "imports Working......" && ./workhorse.sh' $TMUX selectp -t 0 -$TMUX splitw -h -p 66 'echo "processAdditional Working......" && sleep 35 && $PHP bin/processAlternate.php' -$TMUX splitw -h -p 50 'echo "postProcessing Working......" && sleep 40 && $PHP bin/postprocessing.php' +$TMUX splitw -h -p 66 'echo "processAdditional Working......" && $PHP bin/processAlternate.php' +$TMUX splitw -h -p 50 'echo "postProcessing Working......" && $PHP bin/postprocessing.php' $TMUX selectp -t 3 -$TMUX splitw -h -p 50 #'$BWMNG' +if [[ $CHOICE_APP == "mytop" ]]; then + $TMUX splitw -h -p 50 '$MYTOP -u $DB_USER -p $DB_PASSWORD -d $DB_NAME -h $DB_HOST' +else + $TMUX splitw -h -p 50 '$BWMNG' +fi $TMUX selectp -t 5 $TMUX splitw -h -p 50 'cd bin && echo "create Releases Working......" && ./cleanup_scripts.sh'