- Initial release: bash profile config & default library included.
This commit is contained in:
163
usr/lib/rx3/isl.bash
Normal file
163
usr/lib/rx3/isl.bash
Normal file
@@ -0,0 +1,163 @@
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# ISL: Image Stack Log
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
# Global Variable
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
export ISL_FILE=/etc/img_stack_log
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# ISL Add
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
isl_add()
|
||||
{
|
||||
url="$1"
|
||||
|
||||
|
||||
reg=${url%%/*}
|
||||
|
||||
if [[ "${reg}" == *.* ]]
|
||||
then
|
||||
url=${url#*/}
|
||||
else
|
||||
reg="-"
|
||||
fi
|
||||
|
||||
tag=${url/*:}
|
||||
name=${url%:*}
|
||||
|
||||
if [[ "${tag}" == "${name}" ]]
|
||||
then
|
||||
echo "Bad tag format in URL!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
ts=$(date -u +"%Y/%m/%d %H:%M:%S")
|
||||
|
||||
if [[ ! -e ${ISL_FILE} ]]
|
||||
then
|
||||
id=1
|
||||
else
|
||||
id=$(( $(wc -l <${ISL_FILE}) + 1))
|
||||
fi
|
||||
|
||||
str="${id} ${ts} ${reg} ${name} ${tag}"
|
||||
|
||||
if [[ $id == "1" ]]
|
||||
then
|
||||
echo "${str}" >${ISL_FILE}
|
||||
else
|
||||
sed -i '1i\'"${str}" ${ISL_FILE}
|
||||
fi
|
||||
}
|
||||
|
||||
export -f isl_add
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# ISL Top
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
isl_top()
|
||||
{
|
||||
line=$( head -1 ${ISL_FILE})
|
||||
|
||||
if [[ "$1" == "-i" ]]
|
||||
then
|
||||
set ${line}
|
||||
|
||||
echo "$5:$6"
|
||||
else
|
||||
echo "${line}"
|
||||
fi
|
||||
}
|
||||
|
||||
export -f isl_top
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# ISL Cat
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
isl_cat()
|
||||
{
|
||||
if [[ "$1" == "-r" ]]
|
||||
then
|
||||
tac ${ISL_FILE}
|
||||
else
|
||||
cat ${ISL_FILE}
|
||||
fi
|
||||
}
|
||||
|
||||
export -f isl_cat
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# ISL HTML Dump
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
isl_html_dump()
|
||||
{
|
||||
r_flag=""
|
||||
i_flag=""
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
if [[ "$1" == "-r" ]]
|
||||
then
|
||||
r_flag="$1"
|
||||
else
|
||||
if [[ "$1" == "-i" ]]
|
||||
then
|
||||
i_flag="-i"
|
||||
fi
|
||||
fi
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
i=1
|
||||
|
||||
isl_cat "${r_flag}" | while read line
|
||||
do
|
||||
set $line
|
||||
|
||||
if [[ $(( $i % 2)) -eq 0 ]]
|
||||
then
|
||||
print "${i_flag}" ' <tr class="shade">'
|
||||
else
|
||||
print "${i_flag}" " <tr>"
|
||||
fi
|
||||
|
||||
j=1
|
||||
while [[ $j -lt 7 ]]
|
||||
do
|
||||
if [[ "$j" == "1" ]]
|
||||
then
|
||||
print "${i_flag}" " <th>${!j}</th>"
|
||||
else
|
||||
print "${i_flag}" " <td>${!j}</td>"
|
||||
fi
|
||||
|
||||
j=$(( $j + 1))
|
||||
done
|
||||
|
||||
print "${i_flag}" " </tr>"
|
||||
i=$(( $i + 1))
|
||||
done
|
||||
}
|
||||
|
||||
export -f isl_html_dump
|
||||
Reference in New Issue
Block a user