31 lines
483 B
Bash
Executable File
31 lines
483 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Simple script for uploading a base64 encoded image into our database. For
|
|
# grafana business image panels.
|
|
|
|
if [ $# -ne 2 ]
|
|
then
|
|
echo "Usage: $0 <image-name> <file>.png"
|
|
exit 1
|
|
fi
|
|
|
|
filename=$1
|
|
file=$2
|
|
|
|
if [ ! -e $file ]
|
|
then
|
|
echo "file $file does not exist"
|
|
exit 1
|
|
fi
|
|
|
|
function create_image() {
|
|
local filename=$1
|
|
local data=$2
|
|
cat << EOF
|
|
INSERT INTO images VALUES('$filename', '$data');
|
|
EOF
|
|
}
|
|
|
|
data=$(cat $file | base64 -w0)
|
|
create_image $filename $data
|