#!/bin/bash echo "test 1" DEBUG=1 GIT_DIR_STORE=/gitduino/git GIT_DATA=/gitduino/data povray_template=/home/gitduino/tempname/tn_web/renderbot/gitduino.tmpl.pov #/srv/cache/gitduino/username/reponame/images/ #/srv/gitduino/data/username/reponame/images/ #/srv/gitduino/data/username/repo #GIT_DIR: /srv/gitduino/git/kanzure/reprap.git #repo_path: /srv/git/gitduino/kanzure/reprap.git repo_path=`realpath $GIT_DIR/` #repo_name: reprap repo_name=`basename $repo_path | sed s/\\.git//` lusrname1=`dirname $repo_path` username=`basename $lusrname1` cache_path=$GIT_DATA/$username/$repo_name echo "cache_path: $cache_path" echo "username: $username" echo "repo_name: $repo_name" echo "repo_path: $repo_path" echo "GIT_DATA: $GIT_DATA" echo "GIT_DIR_STORE: $GIT_DIR_STORE" echo "test 2" while read oldrev newrev refname; do refname=${1#refs/heads/} [ "$refname" = "master" ] && refname= for commit in $(git rev-list $oldrev..$newrev | tac); do if [ $DEBUG -eq 1 ]; then echo "processing commit $commit"; fi; mkdir -p $cache_path/$commit for file in `git show --pretty="format:" --name-only $commit | grep ".scad"`; do if [ $DEBUG -eq 1 ]; then echo "\nprocessing file $file"; fi; temp_token=`date | md5sum | cut -d " " -f 1 | head -c 10` if [ $DEBUG -eq 1 ]; then echo "\n\ntemp_token: $temp_token"; fi; file_contents=`git show $commit:$file` output_stl_path=$cache_path/$commit/$file-$temp_token.stl output_png_path=$cache_path/$commit/$file-$temp_token.png input_scad_file_path=$cache_path/$commit/$file-$temp_token.scad scad_error_log=$input_scad_file_path.log model_pov_file_path=$cache_path/$commit/$file-$temp_token-model.pov pov_file_path=$cache_path/$commit/$file-$temp_token.pov if [ $DEBUG -eq 1 ]; then y="\n\n" echo "" #echo "$yfile_contents=$file_contents" echo "$y output_stl_path=$output_stl_path" echo "$y output_png_path=$output_png_path" echo "$y input_scad_file_path=$input_scad_file_path" echo "$y scad_error_log=$scad_error_log" echo "$y model_pov_file_path=$model_pov_file_path" echo "$y pov_file_path=$pov_file_path" echo "" fi; #put the .scad file somewhere echo "$file_contents" > $input_scad_file_path if [ $DEBUG -eq 1 ]; then echo "\n\n..Starting openscad"; fi; #generate .stl of .scad (this might take a while) openscad -s "$output_stl_path" "$input_scad_file_path" &> $scad_error_log if [ $DEBUG -eq 1 ]; then echo "\n\n..openscad done"; fi; #ain't no fun when we know the future #model_name=`grep "#declare" "${input_scad_file_path}" | cut -d\ -f2` model_name="OpenSCAD_Model" if [ $DEBUG -eq 1 ]; then echo "\n\n..running stl2pov"; fi; #generate .pov of stl model model_pov=`./hooks/stl2pov -s "$output_stl_path"` echo "$model_pov" > $model_pov_file_path if [ $DEBUG -eq 1 ]; then echo "\n\n..stl2pov done"; fi; model_pov_file_path=$file-$temp_token-model.pov #fill out the povray template cat $povray_template | sed -e "s@{{INCLUDE_FILE}}@${model_pov_file_path}@g" -e "s@{{MODELNAME}}@${model_name}@g" > "${pov_file_path}" if [ $DEBUG -eq 1 ]; then echo "\n\n..running povray"; fi; #render the final png cd $cache_path/$commit cp /home/gitduino/tempname/tn_web/renderbot/axes_macro.inc . pov_file_path=$file-$temp_token.pov output_png_path=$file-$temp_token.png povray -s -i"${pov_file_path}" +FN +W640 +H480 -o"${output_png_path}" +Q9 +AM2 +A2 if [ $DEBUG -eq 1 ]; then echo "\n\n..povray done"; fi; done done done