mirror of
https://github.com/YunoHost-Apps/fittrackee_ynh.git
synced 2024-09-03 18:36:16 +02:00
Test
This commit is contained in:
parent
56cc1e8206
commit
90b5917ac7
6 changed files with 103 additions and 39 deletions
|
@ -1,3 +1,49 @@
|
|||
# Custom variables initialisation
|
||||
# (can overwrite variables present in Makefile.config)
|
||||
|
||||
# Application
|
||||
# export FLASK_APP=fittrackee
|
||||
export FLASK_SKIP_DOTENV=1
|
||||
# export HOST=
|
||||
# export PORT=
|
||||
# export APP_SETTINGS=fittrackee.config.ProductionConfig
|
||||
export APP_SECRET_KEY='__KEY__'
|
||||
# export APP_WORKERS=
|
||||
export APP_LOG=fittrackee.log
|
||||
export UPLOAD_FOLDER=/home/yunohost.app/__APP__/data
|
||||
|
||||
# PostgreSQL
|
||||
export DATABASE_URL=postgresql://__DB_USER__:__DB_PWD__@:5432/__DB_NAME__
|
||||
# export DATABASE_DISABLE_POOLING=
|
||||
|
||||
|
||||
|
||||
# Redis (required for API rate limits and email sending)
|
||||
# export REDIS_URL=redis://127.0.0.1:6379/__REDIS_DB__
|
||||
|
||||
# API rate limits
|
||||
# export API_RATE_LIMITS="300 per 5 minutes"
|
||||
|
||||
# Emails
|
||||
export UI_URL=__DOMAIN__
|
||||
export EMAIL_URL=
|
||||
export SENDER_EMAIL=
|
||||
# export WORKERS_PROCESSES=
|
||||
|
||||
# Workouts
|
||||
# export TILE_SERVER_URL=
|
||||
# export STATICMAP_SUBDOMAINS=
|
||||
# export MAP_ATTRIBUTION=
|
||||
# export DEFAULT_STATICMAP=False
|
||||
|
||||
# Weather
|
||||
# available weather API providers: darksky, visualcrossing
|
||||
# export WEATHER_API_PROVIDER=visualcrossing
|
||||
# export WEATHER_API_KEY=
|
||||
|
||||
|
||||
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY="__KEY__"
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
SOURCE_URL=https://codeload.github.com/SamR1/FitTrackee/tar.gz/refs/tags/v0.7.12
|
||||
SOURCE_SUM=8fe1e2768453058792f9f2b9bc9fa411dceeaa8aac2cd5f2096b583b8111de00
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
|
@ -15,7 +15,7 @@ Group=__APP__
|
|||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
SyslogIdentifier=__APP___workers
|
||||
Environment="FLASK_APP=__APP__"
|
||||
Environment="FLASK_APP=fittrackee"
|
||||
Environment="APP_SECRET_KEY="
|
||||
Environment="APP_LOG="
|
||||
Environment="UPLOAD_FOLDER="
|
||||
|
@ -26,8 +26,7 @@ Environment="SENDER_EMAIL="
|
|||
Environment="REDIS_URL="
|
||||
WorkingDirectory=__INSTALL_DIR__/
|
||||
EnvironmentFile=__INSTALL_DIR__/.env
|
||||
ExecStart=__INSTALL_DIR__/venv/bin/celery -A celerywyrm worker -l info -Q high_priority,medium_priority,low_priority
|
||||
ExecStart=__INSTALL_DIR__/.venv/bin/flask worker --processes 4
|
||||
ExecStart=__INSTALL_DIR__/.venv/bin/flask worker --processes 2
|
||||
Restart=always
|
||||
|
||||
NoNewPrivileges=yes
|
||||
|
|
|
@ -36,17 +36,15 @@ ram.runtime = "50M"
|
|||
type = "group"
|
||||
default = "visitors"
|
||||
|
||||
[install.language]
|
||||
ask.en = "Choose the application language"
|
||||
ask.fr = "Choisissez la langue de l'application"
|
||||
type = "string"
|
||||
choices = ["de-de", "en-us", "fr-fr", "it-it", "nl-nl"]
|
||||
default = "fr-fr"
|
||||
|
||||
[install.admin]
|
||||
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||
type = "user"
|
||||
|
||||
[install.weather_api_key]
|
||||
ask.en = "visualcrossing api key for the weather data"
|
||||
ask.fr = "Clé API visualcrossing pour les données météos"
|
||||
type = "string"
|
||||
|
||||
[resources]
|
||||
[resources.system_user]
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
fittrackee_version="0.7.12"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -9,27 +9,54 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
weather_api_key=$(ynh_string_random --length=32)
|
||||
|
||||
admin_mail=$(ynh_user_get_info --username=$admin --key=username)
|
||||
key=$(ynh_string_random --length=32)
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=23
|
||||
|
||||
ynh_exec_warn_less python3 -m pip install pipenv
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=1
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
ynh_script_progression --message="Setting up source files..." --weight=64
|
||||
|
||||
# Set permissions to app files
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
# mkdir -p "$install_dir/.venv"
|
||||
# chown -R $app:$app "$install_dir"
|
||||
# chmod -R g=u,g-w,o-rwx "$install_dir"
|
||||
# setfacl -nR -m g:$app.main:rx -m d:g:$app.main:rx "$install_dir/.venv"
|
||||
# setfacl -n -m g:$app.main:x "$install_dir"
|
||||
|
||||
# pushd "$install_dir"
|
||||
# sudo -u $app PIPENV_VENV_IN_PROJECT="enabled" PIPENV_SKIP_LOCK=true python3 -m pipenv install jupyterlab==$jupyterlab_version jupyterhub notebook jupyter-server jupyterhub-ldapauthenticator pyzmq sudospawner 2>&1
|
||||
# sudo -u $app python3 -m pipenv run jupyterhub upgrade-db 2>&1
|
||||
# popd
|
||||
|
||||
|
||||
mkdir -p "$install_dir"
|
||||
|
||||
pushd $install_dir
|
||||
mkdir -p .venv
|
||||
PIPENV_VENV_IN_PROJECT="enabled" PIPENV_SKIP_LOCK=true ynh_exec_warn_less python3 -m pipenv install fittrackee==$fittrackee_version
|
||||
popd
|
||||
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE THEN INSTALL SCRIPT AND DEPENDENCIES
|
||||
# CONFIGURE THE INSTALL SCRIPT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing service script..." --weight=1
|
||||
|
||||
key=$(ynh_string_random --length=45 | base64)
|
||||
redis_db=$(ynh_redis_get_free_db)
|
||||
|
||||
ynh_app_setting_set --app=$app --key=key --value=$key
|
||||
ynh_app_setting_set --app=$app --key=redis_db --value=$redis_db
|
||||
|
||||
|
||||
|
||||
ynh_add_config --template="../conf/.env.production" --destination="$install_dir/.env"
|
||||
chmod 600 $install_dir/.env
|
||||
chown $app:www-data "$install_dir/.env"
|
||||
|
@ -38,17 +65,16 @@ set -a; source "$install_dir/.env"; set +a
|
|||
|
||||
mkdir "$install_dir/venv"
|
||||
python3 -m venv "$install_dir/venv"
|
||||
$install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt"
|
||||
source $install_dir/.env
|
||||
|
||||
#=================================================
|
||||
# INITIALIZE DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Initializing database..." --weight=1
|
||||
|
||||
$install_dir/venv/bin/python3 "$install_dir/manage.py" migrate
|
||||
$install_dir/venv/bin/python3 "$install_dir/manage.py" initdb
|
||||
$install_dir/venv/bin/python3 "$install_dir/manage.py" collectstatic --no-input
|
||||
ftcli db upgrade
|
||||
|
||||
flask worker --processes 2
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -58,17 +84,16 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
|||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||
|
||||
ynh_add_config --template="../conf/${app}.target" --destination="/etc/systemd/system/$app.target"
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config --service="${app}-server" --template="${app}-server.service"
|
||||
ynh_add_systemd_config --service="${app}-worker" --template="${app}-worker.service"
|
||||
ynh_add_systemd_config --service="${app}-beat" --template="${app}-beat.service"
|
||||
ynh_add_systemd_config --service="${app}" --template="${app}.service"
|
||||
ynh_add_systemd_config --service="${app}-workers" --template="${app}-workers.service"
|
||||
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -77,9 +102,8 @@ ynh_add_systemd_config --service="${app}-beat" --template="${app}-beat.service
|
|||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add "${app}-beat"
|
||||
yunohost service add "${app}-server"
|
||||
yunohost service add "${app}-worker"
|
||||
yunohost service add "${app}"
|
||||
yunohost service add "${app}-workers"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
@ -87,9 +111,9 @@ yunohost service add "${app}-worker"
|
|||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name="${app}-beat" --action="start" --log_path="systemd" --line_match="Started"
|
||||
ynh_systemd_action --service_name="${app}-server" --action="start" --log_path="systemd" --line_match="Booting worker with pid"
|
||||
ynh_systemd_action --service_name="${app}-worker" --action="start" --log_path="systemd" --line_match="ready"
|
||||
ynh_systemd_action --service_name="${app}" --action="start" --log_path="systemd" --line_match="Booting worker with pid"
|
||||
ynh_systemd_action --service_name="${app}-workers" --action="start" --log_path="systemd" --line_match="ready"
|
||||
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
Loading…
Reference in a new issue