|
|
| |||||||
| |||||||||
巻き戻し中。
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2024-01-02(火)
恒例の [長年日記]
_
監視
自宅鯖のRAIDカード監視、Javaの鯖を経由して見るのだけど最新版だとバグでUbuntuでは動かない。
Windows版もあるけど、Winでtomcatとか試しに動かしてリソース見たら白目になりそうなので使いたくない。
あと、ESXiのHTML5クライアントに突っ込むプラグインもあるようだけど、手順が面倒なのとESXiのパッチの度にどうなるか不安なのでパス。
と言うことで、上手く行かない場合は一つ前の安定版というセオリー通りの展開。
2024-01-03(水)
冬休みの [長年日記]
_
宿題
写真アルバムの自動生成。
長男氏とNASに置いてる写真の共有方法を考えたのは良いが、apacheの自動インデックスだとサムネとか見えないので困る。
と言うことでhtmlのインデックス自動生成ツールを作っていたのだけど、ようやく完了。
とりあえず生成するだけのものは数日で出来て、長男には公開してた。
でも、ファイル追加したら自動で生成とか重複起動防止とか、体裁をちゃんとするのは冬休みの宿題だったのだ。
ちなみに、表示ファイルのサムネを作っているのではなくて縮小表示で並べてるだけなので表示時間は掛かる。
いわゆる手抜きである(゚∀゚)
#!/bin/sh
#################################################
# Auto HTML index generator #
# By H.Uekusa 20240101 #
# Ver 1.00 #
#################################################
#
#################################################
# Location of commands #
#################################################
LS="/bin/ls"
PWD="/bin/pwd"
AWK="/usr/bin/awk"
GREP="/usr/bin/grep"
FIND="/usr/bin/find"
DIFF="/usr/bin/diff"
LOGGER="/usr/bin/logger"
SORT="/usr/bin/sort"
CAT="/bin/cat"
#################################################
# Location/Name of files and directories #
#################################################
PIDFILE="/var/run/make_thumb_index.pid"
PIDFILE2="/var/run/make_thumb_index-oneexec.pid"
BASE_DIR="/HOGEHOGE/HOGEHOGE"
PHOTO_DIR="HOGEHOGEHOGE"
TMP_DIR="/var/tmp"
SELF="/HOGEHOGE/make_thumb_index.sh"
SELF_NAME="make_thumb_index.sh"
HTML_icon="/img/HTML-file.png"
File_icon="/img/simple-file.png"
Folder_icon="/img/simple-folder-b.png"
#################################################
# Parameters for html "table" #
#################################################
NUM_FOLD="5"
NUM_FILE="4"
#################################################
# Flags for debug #
#################################################
TST_FLAG="0"
LOG_FLAG="0"
#################################################
# Main procedure #
#################################################
OPTION=`echo $1`
if [ $TST_FLAG != "0" ];then
echo $OPTION
fi
#################################################
# Force exec oprion "-f" #
#################################################
if [ "$OPTION" == "-f" ];then
rm -f $TMP_DIR/Photo_LS-LR.prev
if [ -f "$PIDFILE" ];then
PIDKILL=`$CAT $PIDFILE`
$LOGGER -is -t $SELF_NAME "Killing $PIDKILL"
kill -9 $PIDKILL
rm -f $PIDFILE
fi
if [ -f "$PIDFILE2" ];then
PIDKILL2=`$CAT $PIDFILE2`
$LOGGER -is -t $SELF_NAME "Killing $PIDKILL2"
kill -9 $PIDKILL2
rm -f $PIDFILE2
fi
$SELF
exit 4
#################################################
# Normal execute mode #
#################################################
elif [ "$OPTION" == "" ];then
if [ -f "$PIDFILE" ];then #Exist PID file?
$LOGGER -is -t $SELF_NAME "There is PID file at $PIDFILE,I am exiting"
$LOGGER -is -t $SELF_NAME "If you would like to start forcibly, Use -f option first"
exit 2
fi
PID=`echo $$`
echo $PID > $PIDFILE
$FIND $BASE_DIR/$PHOTO_DIR -ls \
|$AWK 'NR > 0 \
{printf $3" "$7" "$8" "$9" "$10" "; printf "\"" ; \
for (i = 11; i < NF; i++) { printf("%s ", $i) } printf $NF; print "\"" }' \
| $GREP $PHOTO_DIR \
> $TMP_DIR/Photo_LS-LR
if [ ! -f $TMP_DIR/Photo_LS-LR.prev ];then
touch $TMP_DIR/Photo_LS-LR.prev
fi
$DIFF $TMP_DIR/Photo_LS-LR $TMP_DIR/Photo_LS-LR.prev \
>/dev/null 2>&1
DIFF_STAT=`echo $?`
if [ $TST_FLAG != "0" ];then
echo "diff-stat $DIFF_STAT"
fi
if [ "$DIFF_STAT" == "1" ];then
$DIFF $TMP_DIR/Photo_LS-LR $TMP_DIR/Photo_LS-LR.prev | $GREP "^< d" \
|$AWK 'NR > 0 {for ( i = 7 ; i < NF ; i++ ) { printf ( "%s ", $i ) } printf $NF ; print "/" }' \
| sed s/'"\/$'/'\/"'/g \
> $TMP_DIR/Photo-DIR.0
$DIFF $TMP_DIR/Photo_LS-LR $TMP_DIR/Photo_LS-LR.prev | $GREP -v "^< d" \
|$AWK 'NR > 0 {for ( i = 7 ; i < NF ; i++ ) { printf ( "%s ", $i ) } printf $NF ; print "/" }' \
| sed s/'"\/$'/'\/"'/g \
| $AWK -F/ '{for (i = 1; i <= NF - 2 ; i++){printf $i"/"};print "\"" }' \
>> $TMP_DIR/Photo-DIR.0
$SORT -u $TMP_DIR/Photo-DIR.0 | $GREP -v '^\"$' > $TMP_DIR/Photo-DIR
DIFF_COUNT=`$CAT $TMP_DIR/Photo-DIR | wc -l | $AWK '{print $1}'`
if [ "$LOG_FLAG" == "0" ];then
$LOGGER -is -t $SELF_NAME "make_thumb_index.sh" "There is $DIFF_COUNT diff"
$LOGGER -is -t $SELF_NAME "make_thumb_index.sh" "Remaking index..."
else
echo "There is $DIFF_COUNT diff"
fi
$AWK -v SELF=$SELF '{system ("cd "$0"; "SELF" -oneexec"); \
printf("%100s\r"," "); \
printf $0"\r"}; END {printf "\n"}' $TMP_DIR/Photo-DIR
$FIND $BASE_DIR/$PHOTO_DIR -ls |$AWK 'NR > 0 \
{printf $3" "$7" "$8" "$9" "$10" "; printf "\"" ; \
for (i = 11; i < NF; i++) { printf("%s ", $i) } printf $NF; print "\"" }' \
| $GREP $PHOTO_DIR \
> $TMP_DIR/Photo_LS-LR.prev
$LOGGER -is -t $SELF_NAME "make_thumb_index.sh" "Remaking $DIFF_COUNT indexes done"
rm -f $PIDFILE
exit 1
else
if [ "$LOG_FLAG" == "0" ];then
$LOGGER -is -t $SELF_NAME "make_thumb_index.sh" "There is no diff"
else
echo "There is no diff"
fi
fi
rm -f $PIDFILE
exit 0
#################################################
# One exec mode for each directories #
# (For child process) #
#################################################
elif [ "$OPTION" == "-oneexec" ];then
PID2=`echo $$`
echo $PID2 > $PIDFILE2
if [ $TST_FLAG == "0" ];then
echo "<html>" > index.html
echo "<head></head>" >> index.html
echo "<body>" >> index.html
$PWD | $AWK -F$BASE_DIR/ '{print "<font size=+3><b>Index of /"$2"</b></font><br>"}' \
>> index.html
echo "<font size=+2><b><a href='"'../'"' > Parent Directory </a></b></font><br><br><b>" \
>> index.html
echo -n `$LS -lp | $GREP -v ^d | $GREP -v ^total |wc -l` \
>> index.html
echo -n " Files " >> index.html
echo -n `$LS -lp | $GREP ^d | $GREP -v ^total |wc -l` \
>> index.html
echo " Directories</b><br>" >> index.html
echo "<table border=1><tr>" >> index.html
$LS -lp | $GREP ^d \
| $AWK '{c="";for(i=9;i<=NF;i++) c=c $i" "; print c}' \
| $AWK '{print $0}' | sort \
| $AWK -F. -v Folder_icon=$Folder_icon -v NUM_FOLD=$NUM_FOLD '{\
if ($0 ~ /\/ $/) \
{print "<td><a href=\"./"$0"\"><img width=120 src=\""Folder_icon"\"><br>"$0"</a></td>"} \
if (NR % NUM_FOLD == 0) {print "</tr><tr>"} }\
END{if (NR % NUM_FOLD != 0) {print "</tr>"} \
}' >> index.html
$LS -lp | $GREP -v ^d | $GREP -v ^total \
| $AWK '{c="";for(i=9;i<=NF;i++) c=c $i" "; print c}' \
| $AWK '{print $0}' | sort \
| $AWK -F. -v HTML_icon=$HTML_icon -v File_icon=$File_icon -v NUM_FILE=$NUM_FILE '{\
if ($2 == "JPG " || $2 == "jpg " || $2 == "jpeg " || $2 == "gif " || $2 == "BMP " || $2 == "bmp " || $2 == "png ") \
{print "<td><a target=\"_blank\" href=\"./"$0"\"><img width=240 src=\"./"$0"\"><br>"$0"</a></td>"} \
else if($2 == "html " || $2 == "HTML " || $2 == "htm " ||$2 == "HTM ") \
{print "<td><a href=\"./"$0"\"><img width=80 src=\""HTML_icon"\"><br>"$0"</a></td>"} \
else {print "<td><a href=\"./"$0"\"><img width=80 src=\""File_icon"\"><br>"$0"</a></td>"} \
if (NR % NUM_FILE == 0) {print "</tr><tr>"} }\
END{print "</tr>" }' \
>> index.html
echo "</table>" >> index.html
echo "</body>" >> index.html
echo "</html>" >> index.html
fi
rm -f $PIDFILE2
exit 3
fi
#################################################
# Error handling for unknown option #
#################################################
echo "Unknown option"
echo "Usage: \"make_thumb_index.sh\" for all recurcive directories from BASE_DIR"
echo " or \"make_thumb_index.sh -oneexec\" for current directory"
echo " or \"make_thumb_index.sh -f\" for execute forcibly"
exit 9
*1*2*3
_
使い方
冒頭の編集を環境に合わせたらcronで適当に。
生成はディレクトリ数が多いと10分以上掛かるけど、重複起動は排除してるので時間間隔はあまり気にしなくて良いはず。
あるのは起動中に再度やり直したり、途中で死んでPIDファイルが残った時用の-fオプションぐらい。
2024-01-05(金)
改良 [長年日記]
_
サムネ生成
ImageMagickのconvertを使ってサムネを作成するように改良。
元イメージの大きさにもよるけど、数十倍から100倍ぐらいの読み込み速度になってるはず。
cronで安定運用中。
#!/bin/sh
#################################################
# Auto HTML index generator #
# By H.Uekusa 20240105 #
# Ver 2.00 #
#################################################
#################################################
# Location of commands #
#################################################
LS="/bin/ls"
PWD="/bin/pwd"
AWK="/usr/bin/awk"
GREP="/usr/bin/grep"
FIND="/usr/bin/find"
DIFF="/usr/bin/diff"
LOGGER="/usr/bin/logger"
SORT="/usr/bin/sort"
CAT="/bin/cat"
CONV="/usr/local/bin/convert"
#################################################
# Location/Name of files and directories #
#################################################
PIDFILE="/var/run/make_thumb_index.pid"
PIDFILE2="/var/run/make_thumb_index-oneexec.pid"
BASE_DIR="/HOGEHOGE/HOGEHOGE"
PHOTO_DIR="HOGEHOGEHOGE"
TMP_DIR="/var/tmp"
SELF="/HOGEHOGE/make_thumb_index.sh"
SELF_NAME="make_thumb_index.sh"
HTML_icon="/img/HTML-file.png"
File_icon="/img/simple-file.png"
Folder_icon="/img/simple-folder-b.png"
THUMB_DIR=".thumb"
#################################################
# Parameters for html "table" #
#################################################
NUM_FOLD="5"
NUM_FILE="4"
#################################################
# Flags for debug #
#################################################
TST_FLAG="0"
LOG_FLAG="0"
#################################################
# Main procedure #
#################################################
OPTION=`echo $1`
if [ $TST_FLAG != "0" ];then
echo $OPTION
fi
#################################################
# Force exec oprion "-f" #
#################################################
if [ "$OPTION" == "-f" ];then
rm -f $TMP_DIR/Photo_LS-LR.prev
if [ -f "$PIDFILE" ];then
PIDKILL=`$CAT $PIDFILE`
$LOGGER -is -t $SELF_NAME "Killing main process $PIDKILL"
kill -9 $PIDKILL
rm -f $PIDFILE
fi
if [ -f "$PIDFILE2" ];then
PIDKILL2=`$CAT $PIDFILE2`
$LOGGER -is -t $SELF_NAME "Killing child process $PIDKILL2"
kill -9 $PIDKILL2
rm -f $PIDFILE2
fi
$SELF
exit 4
#################################################
# Normal execute mode #
#################################################
elif [ "$OPTION" == "" ];then
if [ -f "$PIDFILE" ];then #Exist PID file?
$LOGGER -is -t $SELF_NAME "There is PID file at $PIDFILE,I am exiting"
$LOGGER -is -t $SELF_NAME "If you would like to start forcibly, Use -f option first"
exit 2
fi
PID=`echo $$`
echo $PID > $PIDFILE
$FIND $BASE_DIR/$PHOTO_DIR -ls \
|$GREP -v $THUMB_DIR \
|$AWK 'NR > 0 \
{printf $3" "$7" "$8" "$9" "$10" "; printf "\"" ; \
for (i = 11; i < NF; i++) { printf("%s ", $i) } printf $NF; print "\"" }' \
| $GREP $PHOTO_DIR \
> $TMP_DIR/Photo_LS-LR
if [ ! -f $TMP_DIR/Photo_LS-LR.prev ];then
touch $TMP_DIR/Photo_LS-LR.prev
fi
$DIFF $TMP_DIR/Photo_LS-LR $TMP_DIR/Photo_LS-LR.prev \
>/dev/null 2>&1
DIFF_STAT=`echo $?`
if [ $TST_FLAG != "0" ];then
echo "diff-stat $DIFF_STAT"
fi
if [ "$DIFF_STAT" == "1" ];then
$DIFF $TMP_DIR/Photo_LS-LR $TMP_DIR/Photo_LS-LR.prev | $GREP "^< d" \
|$GREP -v $THUMB_DIR \
|$AWK 'NR > 0 {for ( i = 7 ; i < NF ; i++ ) { printf ( "%s ", $i ) } printf $NF ; print "/" }' \
| sed s/'"\/$'/'\/"'/g \
> $TMP_DIR/Photo-DIR.0
$DIFF $TMP_DIR/Photo_LS-LR $TMP_DIR/Photo_LS-LR.prev | $GREP -v "^< d" \
|$GREP -v $THUMB_DIR \
|$AWK 'NR > 0 {for ( i = 7 ; i < NF ; i++ ) { printf ( "%s ", $i ) } printf $NF ; print "/" }' \
| sed s/'"\/$'/'\/"'/g \
| $AWK -F/ '{for (i = 1; i <= NF - 2 ; i++){printf $i"/"};print "\"" }' \
>> $TMP_DIR/Photo-DIR.0
$SORT -u $TMP_DIR/Photo-DIR.0 | $GREP -v '^\"$' > $TMP_DIR/Photo-DIR
DIFF_COUNT=`$CAT $TMP_DIR/Photo-DIR | wc -l | $AWK '{print $1}'`
if [ "$LOG_FLAG" == "0" ];then
$LOGGER -is -t $SELF_NAME "make_thumb_index.sh" "There is $DIFF_COUNT diff"
$LOGGER -is -t $SELF_NAME "make_thumb_index.sh" "Remaking index..."
else
echo "There is $DIFF_COUNT diff"
fi
$AWK -v SELF=$SELF '{system ("cd "$0"; "SELF" -oneexec"); \
printf("%100s\r"," "); \
printf $0"\r"}; END {printf "\n"}' $TMP_DIR/Photo-DIR
$FIND $BASE_DIR/$PHOTO_DIR -ls |$AWK 'NR > 0 \
{printf $3" "$7" "$8" "$9" "$10" "; printf "\"" ; \
for (i = 11; i < NF; i++) { printf("%s ", $i) } printf $NF; print "\"" }' \
|$GREP $PHOTO_DIR \
|$GREP -v $THUMB_DIR \
> $TMP_DIR/Photo_LS-LR.prev
$LOGGER -is -t $SELF_NAME "make_thumb_index.sh" "Remaking $DIFF_COUNT indexes done"
rm -f $PIDFILE
exit 1
else
if [ "$LOG_FLAG" == "0" ];then
# $LOGGER -is -t $SELF_NAME "make_thumb_index.sh" "There is no diff"
else
echo "There is no diff"
fi
fi
rm -f $PIDFILE
exit 0
#################################################
# One exec mode for each directories #
# (For child process) #
#################################################
elif [ "$OPTION" == "-oneexec" ];then
PID2=`echo $$`
echo $PID2 > $PIDFILE2
if [ $TST_FLAG == "0" ];then
echo "<html>" > index.html
echo "<head></head>" >> index.html
echo "<body>" >> index.html
$PWD | $AWK -F$BASE_DIR/ '{print "<font size=+3><b>Index of /"$2"</b></font><br>"}' \
>> index.html
echo "<font size=+2><b><a href='"'../'"' > Parent Directory </a></b></font><br><br><b>" \
>> index.html
echo -n `$LS -lp | $GREP -v ^d | $GREP -v ^total |wc -l` \
>> index.html
echo -n " Files " >> index.html
echo -n `$LS -lp | $GREP ^d | $GREP -v ^total |wc -l` \
>> index.html
echo " Directories</b><br>" >> index.html
echo "<table border=1><tr>" >> index.html
$LS -lp | $GREP ^d \
| $GREP -v $THUMB_DIR \
| $AWK '{c="";for(i=9;i<=NF;i++) c=c $i" "; print c}' \
| $AWK '{print $0}' | sort \
| $AWK -F. -v Folder_icon=$Folder_icon -v NUM_FOLD=$NUM_FOLD '{\
if ($0 ~ /\/ $/) \
{print "<td><a href=\"./"$0"\"><img width=120 src=\""Folder_icon"\"><br>"$0"</a></td>"} \
if (NR % NUM_FOLD == 0) {print "</tr><tr>"} }\
END{if (NR % NUM_FOLD != 0) {print "</tr>"} \
}' >> index.html
if [ ! -d "./$THUMB_DIR" ];then
mkdir "./$THUMB_DIR"
fi
$LS -lp | $GREP -v ^d | $GREP -v ^total \
| $AWK '{c="";for(i=9;i<=NF;i++) c=c $i" "; print c}' \
| $AWK '{print $0}' | sort \
| $AWK -F. -v HTML_icon=$HTML_icon -v File_icon=$File_icon \
-v NUM_FILE=$NUM_FILE -v THUMB_DIR=$THUMB_DIR -v CONV=$CONV '{\
if ($2 == "JPG " || $2 == "jpg " || $2 == "jpeg " || $2 == "gif " || $2 == "BMP " || $2 == "bmp " || $2 == "png ") \
{system (CONV" -auto-orient -resize 240x ./"$0" ./"THUMB_DIR"/"$0); \
print "<td><a target=\"_blank\" href=\"./"$0"\"><img width=240 src=\"./"THUMB_DIR"/"$0"\"><br>"$0"</a></td>"}\
else if($2 == "html " || $2 == "HTML " || $2 == "htm " ||$2 == "HTM ") \
{print "<td><a href=\"./"$0"\"><img width=80 src=\""HTML_icon"\"><br>"$0"</a></td>"} \
else {print "<td><a href=\"./"$0"\"><img width=80 src=\""File_icon"\"><br>"$0"</a></td>"} \
if (NR % NUM_FILE == 0) {print "</tr><tr>"} }\
END{print "</tr>" }' \
>> index.html
echo "</table>" >> index.html
echo "</body>" >> index.html
echo "</html>" >> index.html
fi
rm -f $PIDFILE2
exit 3
fi
#################################################
# Error handling for unknown option #
#################################################
echo "Unknown option"
echo "Usage: \"make_thumb_index.sh\" for all recurcive directories from BASE_DIR"
echo " or \"make_thumb_index.sh -oneexec\" for current directory"
echo " or \"make_thumb_index.sh -f\" for execute forcibly"
exit 9
*1*1 バージョンは2.0になっておりますw
_ 脚
机上のデジタルマルチメータとAR8600を置いているメタルラックの下、少し隙間があって書類とか物を置きたい。
100均で丁度よい横幅の金網があったので、3Dプリンタで脚を作成。
ぴったりの高さで作れるので、きちんと収まってよろしい(・∀・)
それにしても、4本出すと24時間越えるのしんどいな。
2024-01-06(土)
冬休みの [長年日記]
_ 宿題
着々とこなしてる。
----------------------------------------------------------
[完了]
・RAID監視ツールをubuntuで動かしておく
・自動化した写真一覧生成ツール(縮小ファイル作成まで)実装
・机の棚用脚の作図と3Dプリンタ出力
・タンク取り付け
[未完]
・フロントのブレンボキャリパー取り付け
----------------------------------------------------------
_
amazon
今まで、日記内で使った物品のメモも兼ねてamazonの書影付きアフィリンク張ってたのだけど、11月末でサ終。
年が明けたら表示もされなくなってエラー。
tdiaryのamazonプラグインで文字のみ表示に戻すしかないのだけど、過去の分を書き換えるのツール作るにしても面倒だな。
_
タンク
結局ほぼ一年越しになったタンクの修理完結。
ガソリンコックからの漏れもあって焦ったが、ガスケットの交換で治って一安心。
結構ガソリンまみれw
でも玄関に保管してたガソリンが無くなってスッキリ。
海外とのやりとりに使った段ボールも、ようやくノーマルタンクを突っ込んでクローゼットにしまえる。
明日はブレーキやるか(・∀・)
2024-01-08(月)
忘れてた [長年日記]
_
キャリパー
ブレンボ取り付けようと思ったら、ブレンボはピッチ1.00だったの忘れてた。
NAPS来たけど変換置いてないし、せっかくのストレートのフイッテイングをアングルにしてバンジョーボルトもイケてない。
密林でゆっくり探すか。(´・ω・`)
_
サイドスタンド
キャリパーは手が付けられなかったので、サイドスタンドの面積拡張。
昨年、柔らかい所に立ててめり込む事案をいくつか見たので。
密林で見つけたアダプターは微妙に形状が合わないので現物合わせで削る。
これでおいらの体重でもめり込まないで済むかも(゚∀゚)
| Tweets by RC31E | |||||||||
| |||||||||
| |||||||||


















