From 11e25956510fbe953a9ceeaddbaebd80334abf43 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Sun, 29 Jan 2012 16:17:09 -0500 Subject: [PATCH] rudimentary java library beginning. cleaned up scripts quite a bit more. --- kona/readme.txt | 4 ++ kona/src/org/feistymeow/process/ethread.java | 76 ++++++++++++++++++++ makefile | 2 +- scripts/buildor/stdbuild.sh | 2 - scripts/core/bootstrap_shells.sh | 4 +- scripts/core/common.alias | 2 +- scripts/core/create_tempdir.sh | 2 - scripts/core/functions.sh | 4 +- scripts/core/i.sh | 2 - scripts/database/backup_mysql_dbs.sh | 1 - scripts/files/find_bad_protection.sh | 2 - scripts/opensim/backup_opensim.sh | 2 - scripts/opensim/backup_osgrid.sh | 2 - scripts/system/osx_cd_mounter.sh | 2 - scripts/tty/keep_awake_process.sh | 2 - scripts/tty/lockup.sh | 2 - scripts/users/byejob.sh | 2 - 17 files changed, 88 insertions(+), 25 deletions(-) create mode 100644 kona/readme.txt create mode 100644 kona/src/org/feistymeow/process/ethread.java diff --git a/kona/readme.txt b/kona/readme.txt new file mode 100644 index 00000000..f41a4a65 --- /dev/null +++ b/kona/readme.txt @@ -0,0 +1,4 @@ + +"kona" is the feisty meow concerns ltd. name for our java components. + + diff --git a/kona/src/org/feistymeow/process/ethread.java b/kona/src/org/feistymeow/process/ethread.java new file mode 100644 index 00000000..0f2e860f --- /dev/null +++ b/kona/src/org/feistymeow/process/ethread.java @@ -0,0 +1,76 @@ + +package org.feistymeow.process; + +//still in progress... +// not compilable yet probably, +// plus missing the timed features of ethread. + + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * A simple java thread that hearkens back to the HOOPLE C++ ethread in features. + * + * @author Chris Koeritz + */ +class ethread implements Runnable +{ +//fix below to use better way to get class object. + private static Log c_logger = LogFactory.getLog(ethread.class); + + private volatile Thread c_RealThread = null; + + // the only variable on which both synchronize is the "thread finished" variable. + public ethread() + { + } + + /** + * Begins execution of the thread. + */ + public void start() + { + if( null == this.c_RealThread ) + { + this.c_RealThread = new Thread(this); + this.c_RealThread.start(); + } + } + + /** + * Stops execution of the thread, or at least attempts to. + */ + public void stop() + { + Thread goAway = c_RealThread; + c_RealThread = null; + if (null != goAway) { goAway.interrupt(); } + } + + /** + * Returns true if the thread isn't null. + */ + public boolean threadRunning() + { + return (null != this.c_RealThread); + } + + public void run() + { + if (false == threadRunning()) + { + return; // stopped before it ever started + } + + } + +} diff --git a/makefile b/makefile index f22e7a4e..72d5303e 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,7 @@ include variables.def PROJECT = feisty_meow_sources -BUILD_BEFORE = start_make nucleus scripts octopi graphiq webby production end_make +BUILD_BEFORE = start_make nucleus scripts octopi graphiq webby kona production end_make include rules.def diff --git a/scripts/buildor/stdbuild.sh b/scripts/buildor/stdbuild.sh index 7708469a..a9fb23cc 100644 --- a/scripts/buildor/stdbuild.sh +++ b/scripts/buildor/stdbuild.sh @@ -5,8 +5,6 @@ # # go to the main folder of the project you're building before you run this. -source $FEISTY_MEOW_SCRIPTS/core/date_stringer.sh - echo "$(date_stringer)" echo "Building application from $(\pwd)" echo " via standard 'configure;make;sudo make install' process..." diff --git a/scripts/core/bootstrap_shells.sh b/scripts/core/bootstrap_shells.sh index 5ce180c1..a1e3cabf 100644 --- a/scripts/core/bootstrap_shells.sh +++ b/scripts/core/bootstrap_shells.sh @@ -41,8 +41,10 @@ if [ ! -d "$FEISTY_MEOW_GENERATED" ]; then mkdir "$FEISTY_MEOW_GENERATED" fi +# just a variable we use in here to refer to the generated variables file. GENERATED_FEISTY_MEOW_VARIABLES="$FEISTY_MEOW_GENERATED/feisty_meow_variables.sh" -echo >"$GENERATED_FEISTY_MEOW_VARIABLES" +# create the alias file as totally blank. +echo -n >"$GENERATED_FEISTY_MEOW_VARIABLES" for i in FEISTY_MEOW_DIR FEISTY_MEOW_SCRIPTS FEISTY_MEOW_GENERATED; do echo "export $i=${!i}" >>"$GENERATED_FEISTY_MEOW_VARIABLES" done diff --git a/scripts/core/common.alias b/scripts/core/common.alias index 0c7efcc3..2b86df46 100644 --- a/scripts/core/common.alias +++ b/scripts/core/common.alias @@ -32,7 +32,7 @@ alias play='bash $FEISTY_MEOW_SCRIPTS/multimedia/sound_play.sh' alias rmdir='perl $FEISTY_MEOW_SCRIPTS/files/zapdirs.pl' alias rd='perl $FEISTY_MEOW_SCRIPTS/files/zapdirs.pl' #regen-- this might be better as a function. -alias regenerate='bash $FEISTY_MEOW_SCRIPTS/core/bootstrap_shells.sh ; perl $FEISTY_MEOW_SCRIPTS/core/generate_aliases.pl ; echo ; nechung' +alias regenerate='bash $FEISTY_MEOW_SCRIPTS/core/bootstrap_shells.sh ; echo ; nechung' alias reroot='chown -R root:root /root' alias rm='perl $FEISTY_MEOW_SCRIPTS/files/safedel.pl' alias ren='\mv -v -i ' diff --git a/scripts/core/create_tempdir.sh b/scripts/core/create_tempdir.sh index 07241b60..55899274 100644 --- a/scripts/core/create_tempdir.sh +++ b/scripts/core/create_tempdir.sh @@ -5,8 +5,6 @@ # This creates a temporary directory for transient files if such a directory # does not already exist. -source $FEISTY_MEOW_SCRIPTS/core/date_stringer.sh - if [ ! -z "$SHELL_DEBUG" ]; then echo creating temporary directory...; fi if [ -z "$TMP" ]; then diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index a8f570a0..31e94a04 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -8,7 +8,9 @@ fi # a handy little method that can be used for date strings. it was getting # really tiresome how many different ways the script did the date formatting. -function date_stringer() { date +"%Y_%m_%e_%H%M_%S" | tr -d '/\n/' } +function date_stringer() { + date +"%Y_%m_%e_%H%M_%S" | tr -d '/\n/' +} # makes a directory of the name specified and then tries to change the # current directory to that directory. diff --git a/scripts/core/i.sh b/scripts/core/i.sh index 90edb2a5..865c5b14 100644 --- a/scripts/core/i.sh +++ b/scripts/core/i.sh @@ -1,8 +1,6 @@ #!/bin/bash ( -source $FEISTY_MEOW_SCRIPTS/core/date_stringer.sh - echo '###############################################################################' echo echo Your user name is $USER on a computer named $(hostname). diff --git a/scripts/database/backup_mysql_dbs.sh b/scripts/database/backup_mysql_dbs.sh index 3b1888dc..551da0f7 100644 --- a/scripts/database/backup_mysql_dbs.sh +++ b/scripts/database/backup_mysql_dbs.sh @@ -1,5 +1,4 @@ #!/bin/bash -source $FEISTY_MEOW_SCRIPTS/core/date_stringer.sh temphost=$(hostname | sed -e 's/\([^.]*\)\..*/\1/') tar -czf /z/stuffing/archives/backup_dbs_${temphost}_$(date_stringer).tar.gz /home/archives/mysql_dbs/* diff --git a/scripts/files/find_bad_protection.sh b/scripts/files/find_bad_protection.sh index 761362f2..df9eb11d 100644 --- a/scripts/files/find_bad_protection.sh +++ b/scripts/files/find_bad_protection.sh @@ -1,7 +1,5 @@ #!/bin/bash -source $FEISTY_MEOW_SCRIPTS/core/date_stringer.sh - bad_file="$HOME/bad_protections.txt" if [ $# = 0 ]; then dirname=$HOME; export dirname; else dirname=$1; export dirname; fi diff --git a/scripts/opensim/backup_opensim.sh b/scripts/opensim/backup_opensim.sh index 5c18e55b..e431ade0 100644 --- a/scripts/opensim/backup_opensim.sh +++ b/scripts/opensim/backup_opensim.sh @@ -1,8 +1,6 @@ #!/bin/bash # a simple script that backs up the opensim database assets. -source $FEISTY_MEOW_SCRIPTS/core/date_stringer.sh - host=$(echo $(hostname) | sed -e 's/\([^.]*\)\..*/\1/') bkupname=opensim_bkup_${host}_$(date_stringer).mysql_bkup diff --git a/scripts/opensim/backup_osgrid.sh b/scripts/opensim/backup_osgrid.sh index 88d56526..4e14399a 100644 --- a/scripts/opensim/backup_osgrid.sh +++ b/scripts/opensim/backup_osgrid.sh @@ -1,8 +1,6 @@ #!/bin/bash # a simple script that backs up the opensim database assets. -source $FEISTY_MEOW_SCRIPTS/core/date_stringer.sh - host=$(echo $(hostname) | sed -e 's/\([^.]*\)\..*/\1/') bkupname=osgrid_bkup_${host}_$(date_stringer).mysql_bkup diff --git a/scripts/system/osx_cd_mounter.sh b/scripts/system/osx_cd_mounter.sh index a83aa871..531399bd 100644 --- a/scripts/system/osx_cd_mounter.sh +++ b/scripts/system/osx_cd_mounter.sh @@ -3,8 +3,6 @@ # keeps trying to mount the cd on a mac mini to overcome # a new bug in itunes seen as of osx leopard upgrade. -source $FEISTY_MEOW_SCRIPTS/core/date_stringer.sh - mountpoint=/Volumes/mounty_cd echo "$(date_stringer): starting cd mounter..." diff --git a/scripts/tty/keep_awake_process.sh b/scripts/tty/keep_awake_process.sh index 855423e5..4c31a2ab 100644 --- a/scripts/tty/keep_awake_process.sh +++ b/scripts/tty/keep_awake_process.sh @@ -2,8 +2,6 @@ # This program is meant to be started by the program keep_awake and has # the basic guts that are meant to execute inside of a semi-perpetual loop. -source $FEISTY_MEOW_SCRIPTS/core/date_stringer.sh - # save the process id for the goodbye program to deal with. #echo $$ >>$TMP/trash.last_keep_awake_process #don't let the shutdown guy know who we are; we want to keep running now. diff --git a/scripts/tty/lockup.sh b/scripts/tty/lockup.sh index e31357db..4ad330b3 100644 --- a/scripts/tty/lockup.sh +++ b/scripts/tty/lockup.sh @@ -2,8 +2,6 @@ # Thanks to Kevin Wika for this shell. -source $FEISTY_MEOW_SCRIPTS/core/date_stringer.sh - trap '' HUP trap '' INT trap '' QUIT diff --git a/scripts/users/byejob.sh b/scripts/users/byejob.sh index 05725447..196a3541 100644 --- a/scripts/users/byejob.sh +++ b/scripts/users/byejob.sh @@ -6,8 +6,6 @@ export LIGHTWEIGHT_INIT=true # make sure we just get our variables. source $HOME/yeti/scripts/launch_feisty_meow.sh export host=$(hostname) -source $FEISTY_MEOW_SCRIPTS/core/date_stringer.sh - # use this to always print the message. # export hostlist=$host -- 2.34.1