From 05c57aa798f97beecc08414df3659365d3a4918f Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Tue, 5 Jul 2022 12:58:30 -0500 Subject: [PATCH] Initial commit --- Java/scripts/build.sh | 9 + Java/scripts/clean.sh | 4 + Java/scripts/commit.sh | 20 ++ Java/scripts/filelist | 7 + Java/scripts/jar.sh | 17 ++ Java/scripts/md5 | 6 + Java/scripts/release.sh | 14 ++ Java/scripts/update.sh | 3 + Java/scripts/version_info | 3 + README.md | 27 +++ bin/JavaProjectTemplate.jar | Bin 0 -> 8133 bytes sig | 11 ++ src/sig/JavaProjectTemplate.java | 21 +++ src/sig/engine/Color.java | 38 ++++ src/sig/engine/Edge.java | 33 ++++ src/sig/engine/Panel.java | 314 +++++++++++++++++++++++++++++++ src/sig/engine/Point.java | 32 ++++ tmp | 11 ++ utils/.coauthors | 1 + utils/.updateDirectories | 3 + utils/define.sh | 26 +++ utils/filelist | 5 + utils/main.sh | 28 +++ utils/md5 | 4 + utils/search.sh | 103 ++++++++++ 25 files changed, 740 insertions(+) create mode 100755 Java/scripts/build.sh create mode 100755 Java/scripts/clean.sh create mode 100755 Java/scripts/commit.sh create mode 100644 Java/scripts/filelist create mode 100755 Java/scripts/jar.sh create mode 100644 Java/scripts/md5 create mode 100644 Java/scripts/release.sh create mode 100755 Java/scripts/update.sh create mode 100644 Java/scripts/version_info create mode 100644 README.md create mode 100644 bin/JavaProjectTemplate.jar create mode 100755 sig create mode 100644 src/sig/JavaProjectTemplate.java create mode 100644 src/sig/engine/Color.java create mode 100644 src/sig/engine/Edge.java create mode 100644 src/sig/engine/Panel.java create mode 100644 src/sig/engine/Point.java create mode 100644 tmp create mode 100644 utils/.coauthors create mode 100644 utils/.updateDirectories create mode 100755 utils/define.sh create mode 100644 utils/filelist create mode 100644 utils/main.sh create mode 100644 utils/md5 create mode 100644 utils/search.sh diff --git a/Java/scripts/build.sh b/Java/scripts/build.sh new file mode 100755 index 0000000..613d20e --- /dev/null +++ b/Java/scripts/build.sh @@ -0,0 +1,9 @@ +#Builds and runs the project. +#Java +source ${LANGUAGE}/scripts/version_info +javac -source ${SOURCE_VERSION} -target ${TARGET_VERSION} -Xlint:unchecked -cp ${CLASS_PATH} -d ${OUT_DIR} ${PROJECT_DIR}/*.java +printf "\n\n\nRunning Program...\n\n" +ORIGINAL_LOC=$(pwd) +cd $OUT_DIR +java -cp .:../lib/bin -Djava.library.path="${LIBRARY_PATH}" ${MAIN_CLASS} "$@" +${ORIGINAL_LOC}/${LANGUAGE}/scripts/clean.sh \ No newline at end of file diff --git a/Java/scripts/clean.sh b/Java/scripts/clean.sh new file mode 100755 index 0000000..0963522 --- /dev/null +++ b/Java/scripts/clean.sh @@ -0,0 +1,4 @@ +#Cleans up and removes unused files. +#Java +find -type f -name *.class -delete +find -type f -name manifest -delete \ No newline at end of file diff --git a/Java/scripts/commit.sh b/Java/scripts/commit.sh new file mode 100755 index 0000000..36b45b5 --- /dev/null +++ b/Java/scripts/commit.sh @@ -0,0 +1,20 @@ +#Adds a commit message and pushes project to github repository. +#Java +COMMIT_MESSAGE="$*" +FIRST_LINE=true +while IFS= read -r line +do +if [ "$FIRST_LINE" = true ]; then + COMMIT_MESSAGE+=" + +Co-authored-by: $line" +FIRST_LINE=false +else + COMMIT_MESSAGE+=" +Co-authored-by: $line" +fi +done < utils/.coauthors +git add -u +git add * +git commit -m "$COMMIT_MESSAGE" +git push \ No newline at end of file diff --git a/Java/scripts/filelist b/Java/scripts/filelist new file mode 100644 index 0000000..455d98e --- /dev/null +++ b/Java/scripts/filelist @@ -0,0 +1,7 @@ +build.sh +clean.sh +commit.sh +jar.sh +release.sh +update.sh +version_info diff --git a/Java/scripts/jar.sh b/Java/scripts/jar.sh new file mode 100755 index 0000000..d201c59 --- /dev/null +++ b/Java/scripts/jar.sh @@ -0,0 +1,17 @@ +#Builds a runnable jar file using ${MAIN_CLASS} as an entry point and then runs the newly generated jar. +#Java +source ${LANGUAGE}/scripts/version_info +rm -Rf bin/* +javac -source ${SOURCE_VERSION} -target ${TARGET_VERSION} -Xlint:unchecked -cp ${CLASS_PATH} -d ${OUT_DIR} ${PROJECT_DIR}/${PROJECT_NAME}.java +printf "\n\n\nGenerating Manifest...\n\n" +touch manifest +echo "Main-Class: ${MAIN_CLASS}" >> manifest +printf "\n\n\nCreating Jar...\n\n" +ORIGINAL_LOC=$(pwd) +cd ${OUT_DIR} +jar cfm ${PROJECT_NAME}.jar ${ORIGINAL_LOC}/manifest sig +jar uf ${PROJECT_NAME}.jar -C ../lib/bin/ . +printf "\n\n\nRunning Program...\n\n" +java -cp .:../lib/bin -Djava.library.path="${LIBRARY_PATH}" -jar ${PROJECT_NAME}.jar "$@" +../${LANGUAGE}/scripts/clean.sh +cd .. diff --git a/Java/scripts/md5 b/Java/scripts/md5 new file mode 100644 index 0000000..6ae0752 --- /dev/null +++ b/Java/scripts/md5 @@ -0,0 +1,6 @@ +build.sh:22308eae5fd9c88aa16fef54cf03ae21 - +clean.sh:668a2f9b568c55f6a044a509315032f6 - +commit.sh:5e4448db9ad48e72ec3a1ff4f5763b41 - +jar.sh:343cf505530401fb696296bc25a9b090 - +release.sh:b1b62203411b18d0fec1db3dc2e5a061 - +update.sh:3be721658983183efa395984acd96b03 - diff --git a/Java/scripts/release.sh b/Java/scripts/release.sh new file mode 100644 index 0000000..0f7389c --- /dev/null +++ b/Java/scripts/release.sh @@ -0,0 +1,14 @@ +#Creates a zip file containing all project contents. +#Java +source ${LANGUAGE}/scripts/version_info +TARGET_FILE="${PROJECT_NAME}_${RELEASE_VERSION}.zip" +FILES=$(cat ${LANGUAGE}/scripts/.package.files) +echo "Creating Package $TARGET_FILE..." +for f in $FILES +do + zip -ur $TARGET_FILE $f +done +echo "Complete!" +echo "" +echo "" +echo "" \ No newline at end of file diff --git a/Java/scripts/update.sh b/Java/scripts/update.sh new file mode 100755 index 0000000..517be05 --- /dev/null +++ b/Java/scripts/update.sh @@ -0,0 +1,3 @@ +#Pulls the latest version of the repository. +#Java +git pull \ No newline at end of file diff --git a/Java/scripts/version_info b/Java/scripts/version_info new file mode 100644 index 0000000..719f74f --- /dev/null +++ b/Java/scripts/version_info @@ -0,0 +1,3 @@ +export SOURCE_VERSION="8" +export TARGET_VERSION="8" +export RELEASE_VERSION="0.0a" \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5421753 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# JavaProjectTemplate +Provides a Java pipeline for building applications and deploying a JAR with ease. Providing a base graphical engine (fast pixel blitting) with support for input should be enough to get any project going. + +The system will also use the SigScript updating system to keep files up-to-date. + +## Usage: +**./sig** - Shows a menu with all scripts. Example output: +``` + gitpod /workspace/JavaProjectTemplate (main) $ ./sig + + Usage: ./sig {args} + + ==== Current Configuration ===================== + PROJECT_NAME JavaProjectTemplate + PROJECT_DIR src/sig + MAIN_CLASS sig.JavaProjectTemplate + OUT_DIR bin + ===================================================== + + Command List: + + build Builds and runs the project. + clean Cleans up and removes unused files. + commit Adds a commit message and pushes project to github repository. + jar Builds a runnable jar file using ${MAIN_CLASS} as an entry point and then runs the newly generated jar. +``` +Configuration is modified at the top of the script file while the command list includes all included modules inside of `scripts`. diff --git a/bin/JavaProjectTemplate.jar b/bin/JavaProjectTemplate.jar new file mode 100644 index 0000000000000000000000000000000000000000..37133e2c71f4be13a732f86dd70340dc9c36b8e0 GIT binary patch literal 8133 zcmb7J1yCK^vc-bCI{|__1a}DT?j#52;I6@f1b3GNJ2(V)3GVLh?jAV6Pu{)%-P~LM zy{g|+Q#Do7-MeQ`ckiyXl;xmdup!{#;USWu>eV5B69fnt2n7jsQ6?EhNtWk92nc8h zWjQ$bUm8$mtmCI*>Pl+eKkqfq?jmTAY$Vg z+>1yUrIF8z_&u?Qs;IGt4>8MQz%#8yzeWFFabnPX;Whgig~iYNSDc6t5I~UZza+9y#dede$G7*p7fho=FATTx z@2xuB4re~y?DZ)@uv`px3)m89v)OyWmQZ6h7_XNjkVxRnVmm4YJ<JK+sVZ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YZ7W(yst zxP%qTqIXP)C85k{ie1(pLZmK;gPoku8_mE-g156)Bi+;2<7oTuuceA>QA6HVf}oGu zZktY@PWqB7Aj;QO;9GgH-oeC2lV$^Azk-}*sy;Y1dx&an} z-#+t0Me`2KS7qRYR#H&9u`zcYSy>Uzs$*2UyqEPRTH7Oc_{MwhmsKO)XygDO%68E%0+3cO`iLetBqF8asi<{XWwcF zswLKy6((>`=u1V+%AU$r>ucP;JNi&u9nntWU8SM+*ub)PTh5Aegd7_?16;Mo=KP_& ze(gI$Z4X}axz3}!2Kz%muIQi7ovAccF_T>H$4G?;$|ld|=Q5uJe1)@*ICqF^%Y_rl zso47RdQ(loxd%((ep8KXBJ=fqL>4u;`CVBkM7SvCr*h63xi?3Uw~@YqFH98Wrp*XX zB-iepTfWW7^-F-EB~7diG+P%M_%RWh(p(|{j6;kMMsWik!l9sq!CLO>7uB^mPs99Y zLltx5(|1iiagzn)Ie?630apKbo}Jos$sw+7P%z{H&@glC_;%ozI5{~CegepXTKznV296gI@)Yw3Tv z)L(S#-{s%@=`ZqCS?=$qztfw)$kx9^@aN;dO@E_ae|bQJ_|G)xUmkXTKK?<9{(a5g z>8)S1=wAW{`G>`SBuW3<;=lN?zeMNfUj179-|X1mWB7fh{53iLB?131{EIF7=idE( ze*WEu#m}w$ZSmh`(SQ2*y+QunM+e^DeEfFq{?o_rsqw3o{w0)zfAjHIV^x-W1^Y`4 P;pZjxGj(kK^&kERZcKWB literal 0 HcmV?d00001 diff --git a/sig b/sig new file mode 100755 index 0000000..e4830e8 --- /dev/null +++ b/sig @@ -0,0 +1,11 @@ +export AUTO_UPDATE=true + +source utils/define.sh + +define PROJECT_NAME "JavaProjectTemplate" +define PROJECT_DIR "src/sig" +define MAIN_CLASS "sig.${PROJECT_NAME}" +define OUT_DIR "bin" +define LANGUAGE "Java" + +source utils/main.sh \ No newline at end of file diff --git a/src/sig/JavaProjectTemplate.java b/src/sig/JavaProjectTemplate.java new file mode 100644 index 0000000..ac5ae34 --- /dev/null +++ b/src/sig/JavaProjectTemplate.java @@ -0,0 +1,21 @@ +package sig; + +import javax.swing.JFrame; +import sig.engine.Panel; + +public class JavaProjectTemplate { + public static final String PROGRAM_NAME="Sig's Java Project Template"; + public static void main(String[] args) { + JFrame f = new JFrame(PROGRAM_NAME); + Panel p = new Panel(f); + + p.init(); + + f.add(p); + f.setSize(1280,720); + f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + f.setVisible(true); + + p.render(); + } +} diff --git a/src/sig/engine/Color.java b/src/sig/engine/Color.java new file mode 100644 index 0000000..3a6bde7 --- /dev/null +++ b/src/sig/engine/Color.java @@ -0,0 +1,38 @@ +package sig.engine; + +public class Color { + int r,g,b,a; + + final static public Color BLACK = new Color(0,0,0); + final static public Color RED = new Color(204,0,0); + final static public Color GREEN = new Color(78,154,6); + final static public Color YELLOW = new Color(196,160,0); + final static public Color BLUE = new Color(114,159,207); + final static public Color MAGENTA = new Color(117,80,123); + final static public Color CYAN = new Color(6,152,154); + final static public Color WHITE = new Color(211,215,207); + final static public Color BRIGHT_BLACK = new Color(85,87,83); + final static public Color BRIGHT_RED = new Color(239,41,41); + final static public Color BRIGHT_GREEN = new Color(138,226,52); + final static public Color BRIGHT_YELLOW = new Color(252,233,79); + final static public Color BRIGHT_BLUE = new Color(50,175,255); + final static public Color BRIGHT_MAGENTA = new Color(173,127,168); + final static public Color BRIGHT_CYAN = new Color(52,226,226); + final static public Color BRIGHT_WHITE = new Color(255,255,255); + + public Color(int r, int g, int b) { + this(r,g,b,255); + } + + public Color(int r, int g, int b,int a) { + super(); + this.r = r; + this.g = g; + this.b = b; + this.a = a; + } + + public int getColor() { + return (a<<24)+(r<<16)+(g<<8)+b; + } +} diff --git a/src/sig/engine/Edge.java b/src/sig/engine/Edge.java new file mode 100644 index 0000000..867937e --- /dev/null +++ b/src/sig/engine/Edge.java @@ -0,0 +1,33 @@ +package sig.engine; + +public class Edge { + Point a,b; + int min_y; + int max_y; + int min_x; + int max_x; + double x_of_min_y; + double inverse_slope; + public Edge(Point a, Point b) { + super(); + this.a = a; + this.b = b; + min_y=Math.min(a.y, b.y); + max_y=Math.max(a.y, b.y); + min_x=Math.min(a.x, b.x); + max_x=Math.max(a.x, b.x); + if (a.y==min_y) { + x_of_min_y=a.x; + } else { + x_of_min_y=b.x; + } + + inverse_slope=(double)(a.x-b.x)/(a.y-b.y); + } + @Override + public String toString() { + return "Edge [a=" + a + ", b=" + b + ", min_y=" + min_y + ", max_y=" + max_y + ", min_x=" + min_x + ", max_x=" + + max_x + ", x_of_min_y=" + x_of_min_y + ", inverse_slope=" + inverse_slope + "]"; + } + +} diff --git a/src/sig/engine/Panel.java b/src/sig/engine/Panel.java new file mode 100644 index 0000000..2f558f7 --- /dev/null +++ b/src/sig/engine/Panel.java @@ -0,0 +1,314 @@ +package sig.engine; +import java.awt.Graphics; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.Image; +import java.awt.Toolkit; +import java.awt.image.ColorModel; +import java.awt.image.MemoryImageSource; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JFrame; +import javax.swing.JPanel; + +import sig.JavaProjectTemplate; + +public class Panel extends JPanel implements Runnable { + JFrame window; + public int pixel[]; + public int width=1280; + public int height=720; + final int CIRCLE_PRECISION=32; + final int OUTLINE_COL=Color.BRIGHT_WHITE.getColor(); + private Thread thread; + private Image imageBuffer; + private MemoryImageSource mImageProducer; + private ColorModel cm; + int scanLine=0; + int nextScanLine=0; + double x_offset=0; + double y_offset=0; + int frameCount=0; + long lastSecond=0; + int lastFrameCount=0; + + public Panel(JFrame f) { + super(true); + this.window=f; + thread = new Thread(this, "MyPanel Thread"); + } + + /** + * Get Best Color model available for current screen. + * @return color model + */ + protected static ColorModel getCompatibleColorModel(){ + GraphicsConfiguration gfx_config = GraphicsEnvironment. + getLocalGraphicsEnvironment().getDefaultScreenDevice(). + getDefaultConfiguration(); + return gfx_config.getColorModel(); + } + + /** + * Call it after been visible and after resizes. + */ + public void init(){ + cm = getCompatibleColorModel(); + int screenSize = width * height; + if(pixel == null || pixel.length < screenSize){ + pixel = new int[screenSize]; + } + if(thread.isInterrupted() || !thread.isAlive()){ + thread.start(); + } + mImageProducer = new MemoryImageSource(width, height, cm, pixel,0, width); + mImageProducer.setAnimated(true); + mImageProducer.setFullBufferUpdates(true); + imageBuffer = Toolkit.getDefaultToolkit().createImage(mImageProducer); + } + + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + // perform draws on pixels + render(); + // ask ImageProducer to update image + mImageProducer.newPixels(); + // draw it on panel + g.drawImage(this.imageBuffer, 0, 0, this); + + + if (window!=null&&System.currentTimeMillis()-lastSecond>=1000) { + window.setTitle(JavaProjectTemplate.PROGRAM_NAME+" - FPS: "+(frameCount-lastFrameCount)); + lastFrameCount=frameCount; + lastSecond=System.currentTimeMillis(); + } + frameCount++; + } + + /** + * Overrides ImageObserver.imageUpdate. + * Always return true, assuming that imageBuffer is ready to go when called + */ + @Override + public boolean imageUpdate(Image image, int a, int b, int c, int d, int e) { + return true; + } + /** + * Do your draws in here !! + * pixel is your canvas! + */ + public /* abstract */ void render(){ + int[] p = pixel; // this avoid crash when resizing + //a=h/w + + for (int x=0;x edges_sorted = new ArrayList(); + for (int i=0;i=edges[i].min_y) { + edges_sorted.add(j,edges[i]); + inserted=true; + break; + } + } + if (!inserted) { + edges_sorted.add(edges[i]); + } + } + } + } + //System.out.println(edges_sorted); + List active_edges = new ArrayList(); + scanLine = edges_sorted.get(0).min_y-1; + nextScanLine = scanLine+1; + do { + for (int i=0;i=0) { + Draw(p,index,col.getColor()); + } + } + } + List new_active_edges = new ArrayList(); + for (int i=0;ie.x_of_min_y) { + new_active_edges.add(j,e); + inserted=true; + break; + } + } + if (!inserted) { + new_active_edges.add(e); + } + } + active_edges=new_active_edges; + GetNextScanLineEdges(edges_sorted, active_edges); + } + while (active_edges.size()>0); + } + + private void GetNextScanLineEdges(List edges_sorted, List active_edges) { + if (scanLine==nextScanLine) { + for (int i=0;iscanLine) { + nextScanLine=e.min_y; + break; + } + } + } + } + + public void Draw(int[] canvas,int index, int col) { + int alpha = col>>>24; + if (alpha==0) { + return;} + else + if (alpha==255) { + canvas[index]=col; + } else { + float ratio=alpha/255f; + int prev_col=canvas[index]; + int prev_r=(prev_col&0xFF); + int prev_g=(prev_col&0xFF00)>>>8; + int prev_b=(prev_col&0xFF0000)>>>16; + int r=(col&0xFF); + int g=(col&0xFF00)>>>8; + int b=(col&0xFF0000)>>>16; + + int new_r=(int)(ratio*r+(1-ratio)*prev_r); + int new_g=(int)(ratio*g+(1-ratio)*prev_g); + int new_b=(int)(ratio*b+(1-ratio)*prev_b); + + canvas[index]=new_r+(new_g<<8)+(new_b<<16)+(col&0xFF000000); + } + } + + @Override + public void run() { + while (true) { + // request a JPanel re-drawing + repaint(); + //System.out.println("Repaint "+frameCount++); + //try {Thread.sleep(1);} catch (InterruptedException e) {} + } + } +} \ No newline at end of file diff --git a/src/sig/engine/Point.java b/src/sig/engine/Point.java new file mode 100644 index 0000000..b848018 --- /dev/null +++ b/src/sig/engine/Point.java @@ -0,0 +1,32 @@ +package sig.engine; + +public class Point { + int x,y; + + public Point(int x, int y) { + super(); + this.x = x; + this.y = y; + } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + @Override + public String toString() { + return "Point(" + x + "," + y + ")"; + } +} diff --git a/tmp b/tmp new file mode 100644 index 0000000..b81d66d --- /dev/null +++ b/tmp @@ -0,0 +1,11 @@ +.coauthors:3785ad38663e5fc43e574914ad067294 - +define.sh:d6b20a25a04a60d94f466e48fa60ac69 - +main.sh:32a1f953ffca8584d1eb57c0ecd8a582 - +search.sh:3321258db3b59d8e4cfe04c472516e45 - +.updateDirectories:0ede00461e947494545e694040787b3f - +commit.sh:9c342703d765cad7ea296f16d68f29f4 - +.coauthors:3785ad38663e5fc43e574914ad067294 - +define.sh:d6b20a25a04a60d94f466e48fa60ac69 - +main.sh:32a1f953ffca8584d1eb57c0ecd8a582 - +search.sh:3321258db3b59d8e4cfe04c472516e45 - +.updateDirectories:0ede00461e947494545e694040787b3f - diff --git a/utils/.coauthors b/utils/.coauthors new file mode 100644 index 0000000..b904d0f --- /dev/null +++ b/utils/.coauthors @@ -0,0 +1 @@ +sigonasr2 diff --git a/utils/.updateDirectories b/utils/.updateDirectories new file mode 100644 index 0000000..e4dde11 --- /dev/null +++ b/utils/.updateDirectories @@ -0,0 +1,3 @@ +Java/ +scripts/ +utils/ \ No newline at end of file diff --git a/utils/define.sh b/utils/define.sh new file mode 100755 index 0000000..214fc50 --- /dev/null +++ b/utils/define.sh @@ -0,0 +1,26 @@ +export VARS=("") + +export LANGUAGE="" + +function define() { + VARS+=("$1") + value="${*:2}" + eval export "$1"='$value' +} + +if [[ $(pwd) != *"SigScript" && $AUTO_UPDATE = "true" && $1 != "update" ]]; then + source utils/search.sh + + find . -type f -name md5 -delete + find . -type f -name filelist -delete + + #Check for hashes + FILES=$(cat utils/.updateDirectories) + for f in $FILES + do + search $f + check $f + done +else + echo "Dev build, no checks required." +fi \ No newline at end of file diff --git a/utils/filelist b/utils/filelist new file mode 100644 index 0000000..95ad5ff --- /dev/null +++ b/utils/filelist @@ -0,0 +1,5 @@ +.coauthors +define.sh +main.sh +search.sh +.updateDirectories diff --git a/utils/main.sh b/utils/main.sh new file mode 100644 index 0000000..d299d6b --- /dev/null +++ b/utils/main.sh @@ -0,0 +1,28 @@ +if [ -z "$1" ] + then + echo "" + echo " Usage: ./sig {args}" + echo "" + printf "====\tCurrent Configuration" + printf "\t=====================" + for t in ${VARS[@]} + do + printf "\n\t%-15s%20s" $t ${!t} + done + printf "\n=====================================================" + echo "" + echo "" + echo " Command List:" + FILES=$(ls -1A ./$LANGUAGE/scripts 2>/dev/null | sed -e 's/\.sh$//' | sed -e 's/^/ /') + for f in $FILES + do + if [ -f "./$LANGUAGE/scripts/$f.sh" ]; then + DESC="$(head -n1 ./$LANGUAGE/scripts/$f.sh)" + printf "\n\t%-15s%-65s" $f "${DESC:1}" + fi + done + echo "" + exit +fi + +./$LANGUAGE/scripts/$1.sh "${*:2}" \ No newline at end of file diff --git a/utils/md5 b/utils/md5 new file mode 100644 index 0000000..baa339d --- /dev/null +++ b/utils/md5 @@ -0,0 +1,4 @@ +define.sh:3ecab0dffe2adfb950f3eb7c7061b750 - +main.sh:d3d1bd0b56d8114eb7479964227f8576 - +search.sh:81d08f5ff48e8a44b5f68387d426da05 - +.updateDirectories:0ede00461e947494545e694040787b3f - diff --git a/utils/search.sh b/utils/search.sh new file mode 100644 index 0000000..99a69b3 --- /dev/null +++ b/utils/search.sh @@ -0,0 +1,103 @@ +function search() { + FILES2=$(ls -A $1 2>/dev/null) + for g in $FILES2 + do + if [ -d $1$g ]; + then + echo "$1$g is a directory" + search $1$g/ + else + echo "$1$g is a file" + if [ $g != "md5" ] && [ $g != "filelist" ] && [ $g != ".package.files" ]; then + if [ $g != ".coauthors" ] && [ $g != "version_info" ]; then + SUM=$(md5sum < $1$g) + echo "$g:$SUM" >> $1md5 + fi + echo "$g" >> $1filelist + else + echo " ignoring $g..." + fi + fi + done +} + +function check() { + echo "Check $1" + FILES2=$(ls -A $1 2>/dev/null) + if [ -f "$1/md5" ]; + then + echo " md5: https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1md5" + curl -H 'Cache-Control: no-cache, no-store' -s "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1md5" --output /tmp/out + cmp -s $1/md5 /tmp/out + if [ "$?" -ne 0 ] + then + echo " Differences detected!" + cat /tmp/out + while IFS= read -r line + do + IFS=':' read -ra split <<< $line + g="${split[0]}" + echo "LINE -- $g" + if [ "$g" != "md5" ] && [ "$g" != "filelist" ] && [ "$g" != ".package.files" ]; then + if [ -f $1$g ]; + then + if [ "$g" != ".coauthors" ] && [ "$g" != "version_info" ]; then + echo "++Redownload $1$g..." + if [ -f "$1$g" ]; then + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g + else + echo "===Could not find directory, assuming regular scripts directory exists." + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $LANGUAGE/scripts/$g + fi + fi + else + echo "++==Downloading $1$g..." + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g + fi + fi + done < /tmp/out + fi + fi + if [ -f "$1/filelist" ]; + then + echo " filelist: https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1filelist" + curl -H 'Cache-Control: no-cache, no-store' -s "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1filelist" --output /tmp/out + cmp -s $1/filelist /tmp/out + if [ "$?" -ne 0 ] + then + echo " Differences detected!" + cat /tmp/out + while IFS= read -r line + do + IFS=':' read -ra split <<< $line + g="${split[0]}" + echo "LINE -- $g" + if [ "$g" != "md5" ] && [ "$g" != "filelist" ] && [ "$g" != ".package.files" ]; then + if [ -f $1$g ]; + then + if [ "$g" != ".coauthors" ] && [ "$g" != "version_info" ]; then + echo "++Redownload $1$g..." + if [ -f "$1$g" ]; then + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g + else + echo "===Could not find directory, assuming regular scripts directory exists." + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $LANGUAGE/scripts/$g + fi + fi + else + echo "++==Downloading $1$g..." + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g + fi + fi + done < /tmp/out + fi + fi + for g in $FILES2 + do + if [ -d $1$g ]; + then + echo "$1$g is a directory" + check $1$g/ + fi + done +}