63 lines
1.5 KiB
Bash
Executable File
63 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# The commands to submit - note that each statement must be ";"-terminated.
|
|
|
|
if [ ! -f ./apps.db ]; then
|
|
cmd0="CREATE TABLE latest (App string, Latest string, Published date, Url string);"
|
|
echo "$cmd0" | sqlite3 ./apps.db
|
|
fi
|
|
|
|
#cmd1='
|
|
#insert into latest (App, Version) values ("Nextcloud", "27.1.4"), ("Gitea", "1.20.6");
|
|
#'
|
|
|
|
app="nvm"
|
|
latest="0.39.5"
|
|
published="2023-08-22"
|
|
url="https://github.com/nvm-sh/nvm/releases/tag/v0.39.5"
|
|
|
|
#echo "$cmd1" | sqlite3 ./apps.db
|
|
|
|
|
|
app="nvm"
|
|
latest="0.39.7"
|
|
published="2023-10-20"
|
|
url="https://github.com/nvm-sh/nvm/releases/tag/v0.39.7"
|
|
|
|
app="Gitea"
|
|
latest="1.20.6"
|
|
published="2023-11-28"
|
|
url="https://github.com/go-gitea/gitea/releases/tag/v1.20.6"
|
|
|
|
app="Nextcloud"
|
|
latest="27.1.4"
|
|
published="2023-11-23"
|
|
url="https://github.com/nextcloud/server/releases/tag/v27.1.4"
|
|
|
|
# Pipe the commands to `sqlite3` while also passing the database file path.
|
|
#echo "$cmd2" | sqlite3 ./apps.db
|
|
|
|
|
|
#app="gitea"
|
|
#query="select * from latest where App = '$app' COLLATE NOCASE;"
|
|
|
|
insert() {
|
|
|
|
query="SELECT App FROM latest WHERE App LIKE '$1';"
|
|
result=$(sqlite3 ./apps.db "$query")
|
|
#echo "$result"
|
|
|
|
if [ -n "$result" ]; then
|
|
cmd1="UPDATE latest SET Latest = '$2', Url = '$4', Published = '$3' WHERE App = '$1';"
|
|
else
|
|
cmd1="INSERT INTO latest (App, Latest, Published, Url) VALUES ('$1','$2','$3','$4');"
|
|
fi
|
|
|
|
echo "$cmd1" | sqlite3 ./apps.db
|
|
}
|
|
|
|
insert $app $latest $published $url
|
|
|
|
query="SELECT * FROM latest;"
|
|
result=$(sqlite3 ./apps.db "$query")
|
|
echo "$result" |