From 45d27bf48dbf81862770dd3e1cda0f2808abf6fd Mon Sep 17 00:00:00 2001 From: Dmytro Bogovych Date: Sat, 17 Apr 2021 22:04:47 +0300 Subject: [PATCH] - initial work on backend --- redist/build_linux.sh | 115 ++++++++++++++++++++++++++++++++++ server/backend/server_litt.py | 30 +++++++++ server/sql/database.sql | 15 +++-- 3 files changed, 152 insertions(+), 8 deletions(-) create mode 100755 redist/build_linux.sh create mode 100644 server/backend/server_litt.py diff --git a/redist/build_linux.sh b/redist/build_linux.sh new file mode 100755 index 0000000..e24b59b --- /dev/null +++ b/redist/build_linux.sh @@ -0,0 +1,115 @@ +##!/usr/bin/sh + +# Make build or upload existing +MAKE_BUILD=YES + +# Prepare publishing +PREPARE_PUBLISH=YES + +# Upload build or no +PUBLISH_BUILD=YES + +# Codesign id +SIGNID="Developer ID Application: Dmytro Bogovych (563QRB9S29)" + +# Default values only - no need to change every run +ZIPBUILD=Litt-osx-0.9.2.dmg +DMGBUILD=Litt-osx-0.9.2.dmg + +# Find version +cd ../client +version=`less chooka.pro | grep "VERSION =" | cut -d' ' -f 3` + +echo "Found version: $version" + +if [ "$MAKE_BUILD" = "YES" ]; then + # qmake + echo Remove old build + rm -rf build + mkdir build + + echo Running cmake + QT_BINARY_DIR=/Users/anand/qt/5.12.2/clang_64/bin + cd build + QT_CMAKE_DIR=~/qt/5.12.2/clang_64/lib/cmake + cmake .. -D Qt5Core_DIR=$QT_CMAKE_DIR/Qt5Core \ + -D Qt5Widgets_DIR=$QT_CMAKE_DIR/Qt5Widgets \ + -D Qt5PrintSupport_DIR=$QT_CMAKE_DIR/Qt5PrintSupport \ + -D Qt5Network_DIR=$QT_CMAKE_DIR/Qt5Network \ + -D Qt5OpenGL_DIR=$QT_CMAKE_DIR/Qt5OpenGL \ + -D Qt5LinguistTools_DIR=$QT_CMAKE_DIR/Qt5LinguistTools + + if [ $? -ne 0 ]; then + echo "cmake failed. Exiting." + exit + fi + + cmake --build . -j4 + if [ $? -ne 0 ]; then + echo "cmake build failed. Exiting." + exit + fi + + + echo Deploying Qt libraries + $QT_BINARY_DIR/macdeployqt Litt.app -codesign="$SIGNID" + if [ $? -ne 0 ]; then + echo "macdeployqt failed. Exiting." + exit + fi + echo "Codesign is skipped for now, please purchase a Apple developer subscription!" + #codesign -s $CODESIGN Litt.app + + # mkdir Chooka.app/Contents/Resources + + # echo Cleaning object files + #rm -rf *.o + # rm -rf Makefile + + zip -r ../../Litt.zip Litt.app + + # Rename zip file + mv ../../Litt.zip ../../Litt-osx-$version.zip + ZIPBUILD=Litt-osx-$version.zip + + echo Prepare DMG file + cd ../../ + dmgbuild -s redist/dmgsettings.py "Litt application" Litt-osx-$version.dmg + DMGBUILD=Litt-osx-$version.dmg +fi + + +if [ "$PREPARE_PUBLISH" = "YES" ]; then + # Updating release notes file & application cast file + redist/updater.py -v $version -d $DMGBUILD -r site/releasenotes.html -c redist/changes.html -a site/LittAppCast.xml + + # Format cast file + xmllint -format site/LittAppCast.xml > site/LittAppCast2.xml + rm -rf site/LittAppCast.xml + mv site/LittAppCast2.xml site/LittAppCast.xml + + # Prepare index.html +# sed -i "s/Litt-osx.*\\.zip/$ZIPBUILD/g" ../site/index.html +# .bak modifier will produce backup file for index.html; it is neccessary for OS X + sed -i.bak "s/Litt-osx.*\\.dmg/$DMGBUILD/g" site/index.html +fi + +UPLOAD_ROLE=root@voipobjects.com +if [ "$PUBLISH_BUILD" = "YES" ]; then + # Copy to server + echo Copying files... + scp $DMGBUILD $UPLOAD_ROLE:/var/www/satorilight.com/public_html/downloads + scp $ZIPBUILD $UPLOAD_ROLE:/var/www/satorilight.com/public_html/downloads + scp site/releasenotes.html $UPLOAD_ROLE:/var/www/satorilight.com/public_html + scp site/LittAppCast.xml $UPLOAD_ROLE:/var/www/satorilight.com/public_html + scp site/index.html $UPLOAD_ROLE:/var/www/satorilight.com/public_html + + echo Modify symbol links... +# ssh uploader@voipobjects.com ln -s /var/www/satorilight.com/public_html/downloads/$ZIPBUILD /var/www/satorilight.com/public_html/downloads/litt-osx.zip + ssh $UPLOAD_ROLE rm /var/www/satorilight.com/public_html/downloads/litt-osx.dmg + ssh $UPLOAD_ROLE ln -s /var/www/satorilight.com/public_html/downloads/$DMGBUILD /var/www/satorilight.com/public_html/downloads/litt-osx.dmg + ssh $UPLOAD_ROLE rm /var/www/satorilight.com/public_html/downloads/Litt-osx.dmg + ssh $UPLOAD_ROLE ln -s /var/www/satorilight.com/public_html/downloads/$DMGBUILD /var/www/satorilight.com/public_html/downloads/Litt-osx.dmg +fi + + diff --git a/server/backend/server_litt.py b/server/backend/server_litt.py new file mode 100644 index 0000000..9a0cbd5 --- /dev/null +++ b/server/backend/server_litt.py @@ -0,0 +1,30 @@ +import flask +from flask import request, jsonify +import mysql.connector + +# Server software version +BACKEND_VERSION = '0.0.1' + +app = flask.Flask(__name__) +app.config["DEBUG"] = True + + +@app.route('/', methods=['GET']) +def home(): + return "

Litt backend

" + +@app.route('/version', methods=['GET']) +def version(): + return jsonify({'version': BACKEND_VERSION}) + +@app.route('/users', methods=['GET']) +def users(): + + return None + +@app.route('/users', methods=['POST']) +def user_post(): + return None + + +app.run() diff --git a/server/sql/database.sql b/server/sql/database.sql index fb875dd..a4a2358 100644 --- a/server/sql/database.sql +++ b/server/sql/database.sql @@ -3,16 +3,15 @@ CREATE DATABASE IF NOT EXISTS litt CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE diffs ( client_id int not null, device_id varchar(255) not null, created timestamp not null, - content blob not null ); + content blob not null, + diff_id int not null primary key ); -create table clients ( client_id int not null, +create table clients ( client_id int not null primary key, username varchar(255) not null, - password varchar(255) not null); - + pwdhash varchar(255) not null); + create table devices ( client_id int not null, device_id int not null, device_name varchar(255) not null, - device_platform int not null); - - - + device_platform int not null, + primary key (client_id, device_id));