mirror of
https://github.com/YunoHost-Apps/flohmarkt_ynh.git
synced 2024-09-03 18:36:30 +02:00
reworked install paths
new paths are now defined in _common.sh like this ``` flohmarkt_install="/opt/${id}/${domain}${url_path}/src" flohmarkt_venv_dir="/opt/${id}/${domain}${url_path}/venv" ``` giving a nice layout following the domain and path the flohmarkt uses as its URL. Activated path resource in manifest.toml to let the admin choose a path different from '/'.
This commit is contained in:
parent
bc8eea5e6d
commit
b5e0f424f9
5 changed files with 39 additions and 28 deletions
|
@ -6,10 +6,11 @@ After=network.target couchdb.service
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__INSTALL_DIR__/__APP__
|
WorkingDirectory=__FLOHMARKT_INSTALL__
|
||||||
Environment="VENV_DIR=__INSTALL_DIR__/venv/"
|
Environment="VENV_DIR=__FLOHMARKT_VENV_DIR__"
|
||||||
ExecStart=/bin/bash -c "/opt/flohmarkt/venv/bin/uvicorn --host 127.0.0.1 --port 8000 --reload flohmarkt.web:start 2>&1 | /usr/bin/ts '%%Y-%%m-%%d %%H:%%M:%%S'"
|
ExecStart=/bin/bash -c "__FLOHMARKT_VENV_DIR__/bin/uvicorn --host 127.0.0.1 --port 8000 --reload flohmarkt.web:start 2>&1 | /usr/bin/ts '%%Y-%%m-%%d %%H:%%M:%%S'"
|
||||||
StandardOutput=append:/var/log/__APP__/__APP__.log
|
# nicer logfile naming https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/38
|
||||||
|
StandardOutput=append:/var/log/__ID__/__APP__.log
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
|
||||||
# Sandboxing options to harden security
|
# Sandboxing options to harden security
|
||||||
|
|
|
@ -54,13 +54,12 @@ ram.runtime = "100M"
|
||||||
# ask admin on which domain to run flohmarkt
|
# ask admin on which domain to run flohmarkt
|
||||||
type = "domain"
|
type = "domain"
|
||||||
|
|
||||||
# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/4
|
[install.path]
|
||||||
# [install.path]
|
# ask admin under which path flohmarkt will be reachable
|
||||||
# # ask admin under which path flohmarkt will be reachable
|
# e.g. 'https://doma.in/path' - might not work, needs to be tested:
|
||||||
# # e.g. 'https://doma.in/path' - might not work, needs to be tested:
|
# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/4
|
||||||
# # https://codeberg.org/ChriChri/flohmarkt_ynh/issues/4
|
type = "path"
|
||||||
# type = "path"
|
default = "/"
|
||||||
# default = "/"
|
|
||||||
|
|
||||||
[install.init_main_permission]
|
[install.init_main_permission]
|
||||||
# who will be able to access the apps URL after installation?
|
# who will be able to access the apps URL after installation?
|
||||||
|
|
|
@ -4,6 +4,13 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# replace '/' by nothing for the path
|
||||||
|
if [ "$path" == '/' ]; then url_path=''; else url_path=$path; fi
|
||||||
|
# directory flohmarkts software is installed to
|
||||||
|
flohmarkt_install="/opt/${id}/${domain}${url_path}/src"
|
||||||
|
# diretory the venv for flohmarkt is installed to
|
||||||
|
flohmarkt_venv_dir="/opt/${id}/${domain}${url_path}/venv"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -6,7 +6,11 @@ source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/9
|
# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/9
|
||||||
# check if couchdb is already installed
|
# check if couchdb is already installed
|
||||||
if [[ -e /opt/couchdb ]] || pgrep epmd > /dev/null || pgrep beam.smp || dpkg-query -W couchdb > /dev/null 2>&1;
|
# if there's a couchdb configuration file for flohmarkt we'll assume that couchdb
|
||||||
|
# had been installed by flohmarkt and we thus can savely do whatever we want to it
|
||||||
|
# with the resulting damage hopefully only influencing flohmarkt instances
|
||||||
|
if [[ -e /opt/couchdb ]] || pgrep epmd > /dev/null || pgrep beam.smp || dpkg-query -W couchdb > /dev/null 2>&1 \
|
||||||
|
&& ![[ -e /opt/couchdb/etc/local.d/05-flohmarkt.ini ]];
|
||||||
then
|
then
|
||||||
ynh_die --message="CouchDB already installed on this host - will not proceed."
|
ynh_die --message="CouchDB already installed on this host - will not proceed."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -58,20 +62,20 @@ systemctl restart couchdb
|
||||||
systemctl status couchdb
|
systemctl status couchdb
|
||||||
|
|
||||||
# get flohmarkt
|
# get flohmarkt
|
||||||
ynh_setup_source --dest_dir="$install_dir/$app/"
|
ynh_setup_source --dest_dir="$flohmarkt_install"
|
||||||
|
|
||||||
# setup python environment for flohmarkt
|
# setup python environment for flohmarkt
|
||||||
ynh_secure_remove "$install_dir/venv"
|
ynh_secure_remove "$flohmarkt_venv_dir"
|
||||||
python3 -m venv --without-pip "$install_dir/venv"
|
python3 -m venv --without-pip "$flohmarkt_venv_dir"
|
||||||
|
|
||||||
# install python dependencies
|
# install python dependencies
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "$install_dir/venv/bin/activate"
|
source "$flohmarkt_venv_dir/bin/activate"
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -x
|
set -x
|
||||||
$install_dir/venv/bin/python3 -m ensurepip
|
$flohmarkt_venv_dir/bin/python3 -m ensurepip
|
||||||
$install_dir/venv/bin/pip3 install -r "$install_dir/$app/requirements.txt"
|
$flohmarkt_venv_dir/bin/pip3 install -r "$flohmarkt_install/requirements.txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
# JwtSecret
|
# JwtSecret
|
||||||
|
@ -83,14 +87,14 @@ password_couchdb_flohmarkt=$(ynh_string_random --length=31 --filter='A-Za-z0-9_.
|
||||||
ynh_app_setting_set --app=$app --key=password_couchdb_flohmarkt --value="$password_couchdb_flohmarkt"
|
ynh_app_setting_set --app=$app --key=password_couchdb_flohmarkt --value="$password_couchdb_flohmarkt"
|
||||||
|
|
||||||
# generate flohmarkt.conf
|
# generate flohmarkt.conf
|
||||||
ynh_add_config --template="../conf/flohmarkt.conf" --destination="$install_dir/$app/flohmarkt.conf"
|
ynh_add_config --template="../conf/flohmarkt.conf" --destination="$flohmarkt_install/flohmarkt.conf"
|
||||||
|
|
||||||
# setup couchdb
|
# setup couchdb
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "$install_dir/venv/bin/activate"
|
source "$flohmarkt_venv_dir/bin/activate"
|
||||||
set -o nounset
|
set -o nounset
|
||||||
cd "$install_dir/$app"
|
cd "$flohmarkt_install"
|
||||||
# initialize_couchdb seems to re-try on connect problems endlessly blocking the yunohost api
|
# initialize_couchdb seems to re-try on connect problems endlessly blocking the yunohost api
|
||||||
# give it 45 seconds to finish and then fail
|
# give it 45 seconds to finish and then fail
|
||||||
# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/13
|
# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/13
|
||||||
|
|
|
@ -46,30 +46,30 @@ systemctl status couchdb
|
||||||
|
|
||||||
# install upgrade for flohmarkt
|
# install upgrade for flohmarkt
|
||||||
ynh_script_progression --message="Upgrading flohmarkt..." --weight=4
|
ynh_script_progression --message="Upgrading flohmarkt..." --weight=4
|
||||||
ynh_setup_source --dest_dir="$install_dir/$app/"
|
ynh_setup_source --dest_dir="$flohmarkt_install/"
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrading flohmarkt python dependencies..." --weight=5
|
ynh_script_progression --message="Upgrading flohmarkt python dependencies..." --weight=5
|
||||||
# upgrade python environment / install new dependencies
|
# upgrade python environment / install new dependencies
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "$install_dir/venv/bin/activate"
|
source "$flohmarkt_venv_dir/bin/activate"
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -x
|
set -x
|
||||||
$install_dir/venv/bin/python3 -m ensurepip
|
$flohmarkt_venv_dir/bin/python3 -m ensurepip
|
||||||
$install_dir/venv/bin/pip3 install -r "$install_dir/$app/requirements.txt"
|
$flohmarkt_venv_dir/bin/pip3 install -r "$flohmarkt_install/requirements.txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
# upgrade flohmarkt.conf
|
# upgrade flohmarkt.conf
|
||||||
ynh_script_progression --message="Upgrading flohmarkt configuration..." --weight=1
|
ynh_script_progression --message="Upgrading flohmarkt configuration..." --weight=1
|
||||||
ynh_add_config --template="../conf/flohmarkt.conf" --destination="$install_dir/$app/flohmarkt.conf"
|
ynh_add_config --template="../conf/flohmarkt.conf" --destination="$flohmarkt_install/flohmarkt.conf"
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrading flohmarkt couchdb..." --weight=10
|
ynh_script_progression --message="Upgrading flohmarkt couchdb..." --weight=10
|
||||||
# run initialize_couchdb.py
|
# run initialize_couchdb.py
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "$install_dir/venv/bin/activate"
|
source "$flohmarkt_venv_dir/bin/activate"
|
||||||
set -o nounset
|
set -o nounset
|
||||||
cd "$install_dir/$app"
|
cd "$flohmarkt_install"
|
||||||
# initialize_couchdb seems to re-try on connect problems endlessly blocking the yunohost api
|
# initialize_couchdb seems to re-try on connect problems endlessly blocking the yunohost api
|
||||||
# give it 45 seconds to finish and then fail
|
# give it 45 seconds to finish and then fail
|
||||||
# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/13
|
# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/13
|
||||||
|
|
Loading…
Reference in a new issue