asu: improve packaging
* use gunicorn instead of Flask for main server threads * generate and deploy random database password * provide distribution files Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
parent
31950ff200
commit
c13ae5ba28
3 changed files with 18 additions and 12 deletions
|
@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=asu
|
PKG_NAME:=asu
|
||||||
PKG_VERSION:=0.2.3
|
PKG_VERSION:=0.2.3
|
||||||
PKG_RELEASE=1
|
PKG_RELEASE=2
|
||||||
|
|
||||||
PKG_LICENSE:=GPL-3.0
|
PKG_LICENSE:=GPL-3.0
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ define Package/asu
|
||||||
URL:=http://github.com/aparcar/gsoc17-attended-sysupgrade/
|
URL:=http://github.com/aparcar/gsoc17-attended-sysupgrade/
|
||||||
DEPENDS:=$(IMAGEBUILDER_DEPENDS) +pgsql-server +psqlodbcw \
|
DEPENDS:=$(IMAGEBUILDER_DEPENDS) +pgsql-server +psqlodbcw \
|
||||||
+python3-ctypes +python3-distutils +python3-flask \
|
+python3-ctypes +python3-distutils +python3-flask \
|
||||||
+python3-openssl +python3-pyodbc +python3-yaml \
|
+gunicorn +python3-openssl +python3-pyodbc +python3-yaml \
|
||||||
+libustream-mbedtls +ca-certificates +gnupg
|
+libustream-mbedtls +ca-certificates +gnupg
|
||||||
USERID:=asu:asu
|
USERID:=asu:asu
|
||||||
VARIANT:=python3
|
VARIANT:=python3
|
||||||
|
|
|
@ -1,15 +1,22 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
asu_tables="$(ls -1 /usr/lib/*/site-packages/asu/utils/tables.sql | head -n 1)"
|
asu_password=$(dd if=/dev/urandom bs=16 count=1 2>/dev/null | sha256sum | cut -d' ' -f1)
|
||||||
|
asu_tables="$(ls -1 /usr/lib/python*/site-packages/asu/utils/tables.sql | head -n 1)"
|
||||||
|
|
||||||
uci -q batch <<EOF
|
uci -q batch <<EOF
|
||||||
del postgresql.asu
|
del postgresql.asu
|
||||||
set postgresql.asu=postgres-db
|
set postgresql.asu=postgres-db
|
||||||
set postgresql.asu.name=asu
|
set postgresql.asu.name=asu
|
||||||
set postgresql.asu.user=asu
|
set postgresql.asu.user=asu
|
||||||
set postgresql.asu.pass=password
|
set postgresql.asu.pass='$asu_password'
|
||||||
set postgresql.asu.script='$asu_tables'
|
set postgresql.asu.script='$asu_tables'
|
||||||
commit postgresql
|
commit postgresql
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
sed -i 's/database_user:.*/database_user: asu/' /etc/asu/config.yml
|
sed -i "s/database_user.*/database_user: asu/" /etc/asu/config.yml
|
||||||
sed -i 's/database_pass:.*/database_pass: asu/' /etc/asu/config.yml
|
sed -i "s/database_pass.*/database_pass: $asu_password/" /etc/asu/config.yml
|
||||||
|
|
||||||
|
cp -r /usr/lib/python*/site-packages/asu/utils/distributions /etc/asu/
|
||||||
|
|
||||||
|
chown -R root:asu /etc/asu
|
||||||
|
chmod -R g+rX /etc/asu
|
||||||
|
|
|
@ -26,15 +26,14 @@ start_service() {
|
||||||
FLASK_APP=asu $PROG loaddb
|
FLASK_APP=asu $PROG loaddb
|
||||||
|
|
||||||
procd_open_instance asu_main
|
procd_open_instance asu_main
|
||||||
# procd_set_param user asu
|
procd_set_param user asu
|
||||||
# procd_set_param group asu
|
procd_set_param group asu
|
||||||
procd_set_param env FLASK_APP=asu
|
procd_set_param command gunicorn asu:app
|
||||||
procd_set_param command $PROG run
|
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
|
|
||||||
procd_open_instance main_worker
|
procd_open_instance main_worker
|
||||||
# procd_set_param user asu
|
procd_set_param user asu
|
||||||
# procd_set_param group asu
|
procd_set_param group asu
|
||||||
procd_set_param env FLASK_APP=asu
|
procd_set_param env FLASK_APP=asu
|
||||||
procd_set_param command $PROG run_worker
|
procd_set_param command $PROG run_worker
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
|
|
Loading…
Reference in a new issue