webbuild: create webbuild.db if missing

This commit is contained in:
Silvan 2024-04-18 13:06:06 +02:00
parent 13407f5e51
commit 3717880b21
2 changed files with 7 additions and 4 deletions

View File

@ -53,7 +53,6 @@ if [ "$USER" ]; then
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
USER_ENABLED=1 USER_ENABLED=1
else else
echo "SECRET=$SECRET" >&2
USER_ENABLED= USER_ENABLED=
fi fi
elif [ "${REQUEST:0:7}" != "refresh" ]; then elif [ "${REQUEST:0:7}" != "refresh" ]; then
@ -199,7 +198,7 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshsocial" -o ! "$USER" ]; then
if [ "$WEBBUILD_URL" -a "${WEBBUILD_URL/\/localhost\//}" = "$WEBBUILD_URL" ]; then if [ "$WEBBUILD_URL" -a "${WEBBUILD_URL/\/localhost\//}" = "$WEBBUILD_URL" ]; then
curl -s "$WEBBUILD_URL?REQUEST=refreshsocial&USER=$USER&SECRET=`cgi_encodevar \"$USER_SECRET\"`&USER_EMAIL=$USER_EMAIL&FROMID=$FROMID" curl -s "$WEBBUILD_URL?REQUEST=refreshsocial&USER=$USER&SECRET=`cgi_encodevar \"$USER_SECRET\"`&USER_EMAIL=$USER_EMAIL&FROMID=$FROMID"
else else
[ -e "$WEBBUILD_STATEDIR/webbuild.db" ] || exit [ -e "$WEBBUILD_STATEDIR/webbuild.db" ] || create_webbuild_db
# social box # social box
echo -n "<socialbox>" echo -n "<socialbox>"
SID=0 SID=0

View File

@ -25,6 +25,11 @@ function set_user_state_var() {
[ "$statevalue" ] && echo "$statevar=$statevalue" >> $WEBBUILD_STATEDIR/users/$stateuser.state [ "$statevalue" ] && echo "$statevar=$statevalue" >> $WEBBUILD_STATEDIR/users/$stateuser.state
} }
function create_webbuild_db() {
sqlite3 $WEBBUILD_STATEDIR/webbuild.db \
"CREATE TABLE social_log(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, privacy BOOLEAN, user CHAR(40), type CHAR(40), target CHAR(40), email CHAR(80), text TEXT, time datetime default current_timestamp);"
}
function social_log() { function social_log() {
local line=$1 local line=$1
local SPRIVACY=0 local SPRIVACY=0
@ -34,8 +39,7 @@ function social_log() {
if [ ! "$STATE_FAKEUSER" ]; then if [ ! "$STATE_FAKEUSER" ]; then
[ -e $WEBBUILD_STATEDIR/webbuild.db ] || \ [ -e $WEBBUILD_STATEDIR/webbuild.db ] || \
sqlite3 $WEBBUILD_STATEDIR/webbuild.db \ creaqte_webbuild_db
"CREATE TABLE social_log(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, privacy BOOLEAN, user CHAR(40), type CHAR(40), target CHAR(40), email CHAR(80), text TEXT, time datetime default current_timestamp);"
eval "$line" eval "$line"
[ "$STATE_PRIVACYMODE" ] && $SPRIVACY=1 [ "$STATE_PRIVACYMODE" ] && $SPRIVACY=1