ajout des fichiers pour la génération du paquet wheel et du paquet deb
This commit is contained in:
@@ -17,14 +17,14 @@ from flask_jwt_extended import JWTManager
|
||||
|
||||
import jwt
|
||||
|
||||
from src.config import DefaultConfig
|
||||
from src.auth import auth
|
||||
from src.account import account
|
||||
from src.params import params
|
||||
from src.schedule import schedule
|
||||
from src.log import log as logs
|
||||
from src.manager import sock
|
||||
from src.infos import info
|
||||
from ConfBack.config import DefaultConfig
|
||||
from ConfBack.auth import auth
|
||||
from ConfBack.account import account
|
||||
from ConfBack.params import params
|
||||
from ConfBack.schedule import schedule
|
||||
from ConfBack.log import log as logs
|
||||
from ConfBack.manager import sock
|
||||
from ConfBack.infos import info
|
||||
|
||||
#########################################################
|
||||
# Corps principal du programme #
|
||||
@@ -41,6 +41,7 @@ class BaseConfig(object):
|
||||
ALLOWED_EXTENSIONS = {'json', 'tar', 'txt'}
|
||||
MAX_CONTENT_LENGTH = 200 * 1024 * 1024 # 100 megabytes
|
||||
|
||||
# Database path
|
||||
DB_PATH = os.path.join(os.getcwd(), 'db.json')
|
||||
UNIX_ADDR = "/tmp/uds_socket"
|
||||
|
||||
@@ -57,7 +58,13 @@ class DefaultConfig(BaseConfig):
|
||||
DELTA = datetime.timedelta(minutes=5) # in minutes
|
||||
|
||||
class ProdConfig(BaseConfig):
|
||||
DEBUG = False
|
||||
TESTING = False
|
||||
FLASK_ENV = 'production'
|
||||
|
||||
ROOT_BASE_FOLDER = "/opt"
|
||||
# Log Folder path
|
||||
LOG_FOLDER = "/var/log"
|
||||
LOG_FOLDER = "/var/log/kineintercom"
|
||||
# Database path
|
||||
DB_PATH = os.path.join('/etc/kineintercom', 'db.json')
|
||||
|
||||
@@ -24,7 +24,7 @@ import shutil
|
||||
import hashlib
|
||||
from werkzeug.exceptions import HTTPException
|
||||
|
||||
from src.manager import sock
|
||||
from ConfBack.manager import sock
|
||||
|
||||
#########################################################
|
||||
# Class et Methods #
|
||||
3
Pipfile
3
Pipfile
@@ -1,6 +1,6 @@
|
||||
[[source]]
|
||||
url = "https://pypi.python.org/simple"
|
||||
verify_ssl = true
|
||||
verify_ssl = false
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
@@ -11,6 +11,7 @@ jsonschema = "*"
|
||||
pyjwt = "*"
|
||||
flask-jwt-extended = "*"
|
||||
psutil = "*"
|
||||
waitress = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
|
||||
41
build.sh
Executable file
41
build.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Author : vincent.benoit@scle.fr
|
||||
# Date : 07/2022
|
||||
# Version : 1.0
|
||||
# Brief : création des packages necessaires pour le backend ScleSignRESTful
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
create_deb() {
|
||||
dirname=configurateurback-$1
|
||||
/usr/bin/mkdir -p bdist_deb/$dirname
|
||||
cd bdist_deb/$dirname
|
||||
/usr/bin/dh_make -t $2/misc/template -n -y -i -d
|
||||
/usr/bin/find $2/3rdparty -type f -exec /usr/bin/cp -a {} . \;
|
||||
/usr/bin/find $2/certs/pub -type f -exec /usr/bin/cp -a {} . \;
|
||||
/usr/bin/find $2/template -type f -exec /usr/bin/cp -a {} . \;
|
||||
/usr/bin/cp -a $2/run_prod.py .
|
||||
/usr/bin/dpkg-buildpackage -b -uc -us -rfakeroot
|
||||
cd ..
|
||||
if [ $? == "0" ] && [ ! -d "$2/dist" ]; then
|
||||
/usr/bin/mkdir -p $2/dist
|
||||
/usr/bin/find . -type f -name "*.deb" -exec /usr/bin/cp -a {} $2/dist \;
|
||||
fi
|
||||
}
|
||||
|
||||
create_wheel() {
|
||||
cd $1
|
||||
/usr/bin/python3 setup.py bdist_wheel --universal
|
||||
}
|
||||
|
||||
echo "*** Remove old dirs ***"
|
||||
/usr/bin/rm -rf bdist_deb build dist ScleSignRESTful.egg-info
|
||||
echo "*** read version ***"
|
||||
vers=`/usr/bin/cat ConfBack/VERSION`
|
||||
rootpath=`pwd`
|
||||
echo "*** Create Debian Misc Package ***"
|
||||
create_deb "$vers" "$rootpath"
|
||||
echo "*** Create Python Package ***"
|
||||
create_wheel "$rootpath"
|
||||
echo "*** that's All Folks ...***"
|
||||
17
misc/configurateur_backend.service
Normal file
17
misc/configurateur_backend.service
Normal file
@@ -0,0 +1,17 @@
|
||||
[Unit]
|
||||
Description=Démarrage du Backend du Configurateur
|
||||
StartLimitIntervalSec=300
|
||||
StartLimitBurst=5
|
||||
Wants=kineintercom.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=pi
|
||||
Group=pi
|
||||
ExecStart=/usr/bin/python3 /usr/local/bin/run_prod.py
|
||||
Restart=on-failure
|
||||
RestartSec=15s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
5
misc/template/changelog
Normal file
5
misc/template/changelog
Normal file
@@ -0,0 +1,5 @@
|
||||
#PACKAGE# (#VERSION#) stable; urgency=medium
|
||||
|
||||
* Initial release
|
||||
|
||||
-- #USERNAME# <#EMAIL#> #DATE#
|
||||
25
misc/template/confbackmisc.postinst
Normal file
25
misc/template/confbackmisc.postinst
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
# postinst script for confbackmisc
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
|
||||
set -e
|
||||
user="root"
|
||||
|
||||
# dh_installdeb will replace this with shell code automatically
|
||||
# generated by other debhelper scripts.
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
userpi="pi"
|
||||
dirname="kineintercom"
|
||||
# create log directory
|
||||
if [ ! -d "/var/log/$dirname" ]; then
|
||||
/usr/bin/mkdir -p /var/log/$dirname
|
||||
/usr/bin/chown -R $user:$userpi /var/log/$dirname
|
||||
/usr/bin/chmod 770 /var/log/$dirname
|
||||
fi
|
||||
|
||||
# Restart service
|
||||
/usr/bin/systemctl enable configurateur_backend.service
|
||||
/usr/bin/systemctl restart configurateur_backend.service
|
||||
12
misc/template/control
Normal file
12
misc/template/control
Normal file
@@ -0,0 +1,12 @@
|
||||
Source: #PACKAGE#
|
||||
Section: misc
|
||||
Priority: optional
|
||||
Maintainer: #USERNAME# <#EMAIL#>
|
||||
Build-Depends: #BUILD_DEPS#
|
||||
Standards-Version: #POLICY#
|
||||
Homepage: https://git.nas.benserv.fr/vincent/Kine-backend
|
||||
|
||||
Package: #PACKAGE#
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}, kineintercommisc
|
||||
Description: Installation des fichiers nécessaires au fonctionnement du Backend Configurateur
|
||||
2
misc/template/install
Normal file
2
misc/template/install
Normal file
@@ -0,0 +1,2 @@
|
||||
configurateur_backend.service /lib/systemd/system/
|
||||
run_prod.py /usr/local/bin/
|
||||
12
misc/template/rules
Executable file
12
misc/template/rules
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/make -f
|
||||
# See debhelper(7) (uncomment to enable)
|
||||
# output every command that modifies files on the build system.
|
||||
#export DH_VERBOSE = 1
|
||||
|
||||
#RULES_START_TEXT#
|
||||
%:
|
||||
dh $@#DH_ADDON#
|
||||
|
||||
override_dh_auto_install:
|
||||
|
||||
#RULES_END_TEXT#
|
||||
2
run.py
2
run.py
@@ -3,7 +3,7 @@
|
||||
# @author : vincent.benoit@benserv.fr
|
||||
# @brief : Backend Configurateur KineInterCOM
|
||||
|
||||
from src import app
|
||||
from ConfBack import app
|
||||
print("Launch Flask KineInterCOM Configurateur Backend ...")
|
||||
ret, application = app.create_app()
|
||||
if application and ret:
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
# @author : vincent.benoit@benserv.fr
|
||||
# @brief : KineIntercom Backend
|
||||
|
||||
from src import app
|
||||
from src.config import ProdConfig
|
||||
from ConfBack import app
|
||||
from ConfBack.config import ProdConfig
|
||||
from waitress import serve
|
||||
|
||||
print("Launch Flask KineIntercom Backend ...")
|
||||
|
||||
39
setup.py
Normal file
39
setup.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import io, os
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
def read(*paths, **kwargs):
|
||||
"""Read the contents of a text file safely.
|
||||
>>> read("project_name", "VERSION")
|
||||
'0.1.0'
|
||||
>>> read("README.md")
|
||||
...
|
||||
"""
|
||||
|
||||
content = ""
|
||||
with io.open(
|
||||
os.path.join(os.path.dirname(__file__), *paths),
|
||||
encoding=kwargs.get("encoding", "utf8"),
|
||||
) as open_file:
|
||||
content = open_file.read().strip()
|
||||
return content
|
||||
|
||||
def read_requirements(path):
|
||||
ret = []
|
||||
with open(path, "r") as f:
|
||||
ret = f.read().splitlines()
|
||||
return ret
|
||||
|
||||
setup(
|
||||
name='ConfigurateurBack',
|
||||
version=read("ConfBack", "VERSION"),
|
||||
author='Vincent BENOIT',
|
||||
author_email='vincent.benoit@benserv.fr',
|
||||
url='https://git.nas.benserv.fr/vincent/Kine-backend.git',
|
||||
description='Backend RESTful API pour l\'outil de configuration KineIntercom',
|
||||
long_description=read("README.md"),
|
||||
long_description_content_type="text/markdown",
|
||||
packages=["ConfBack"],
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
install_requires=read_requirements("requirements.txt")
|
||||
)
|
||||
Reference in New Issue
Block a user