mirror of
https://github.com/YunoHost-Apps/endi_ynh.git
synced 2024-09-03 18:35:54 +02:00
Write helpers to move code to _common.sh
This commit is contained in:
parent
ef56820259
commit
50b490e329
2 changed files with 60 additions and 41 deletions
|
@ -30,6 +30,62 @@ pkg_dependencies=(
|
|||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
__ynh_endi_patch_src() {
|
||||
# Patching requirements.txt to use system provided Cython
|
||||
cython_version=$(cython3 --version 2>&1 | sed 's|Cython version ||')
|
||||
sed -i "s|Cython=.*|Cython==$cython_version|" "$final_path/endi/requirements.txt"
|
||||
}
|
||||
|
||||
__ynh_endi_build() {
|
||||
#=================================================
|
||||
# NPM setup
|
||||
#=================================================
|
||||
ynh_use_nodejs
|
||||
ynh_install_nodejs --nodejs_version=16
|
||||
|
||||
pushd "$final_path/endi" 2>&1
|
||||
ynh_script_progression --message="Downloading NPM dependencies..." --weight=1
|
||||
ynh_exec_as $app $ynh_node_load_PATH $ynh_npm --prefix js_sources install 2>&1
|
||||
ynh_exec_as $app $ynh_node_load_PATH $ynh_npm --prefix vue_sources install 2>&1
|
||||
|
||||
ynh_script_progression --message="Building Web interface code..." --weight=1
|
||||
ynh_exec_as $app make prodjs devjs prodjs2 devjs2 2>&1 \
|
||||
|| ynh_die --message="Build of javascript code failed, maybe because of high RAM usage!"
|
||||
popd 2>&1
|
||||
|
||||
#=================================================
|
||||
# Python + Virtualenv setup
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Python dependencies and Endi..." --weight=1
|
||||
|
||||
__ynh_python_venv_setup --venv_dir="$final_path/venv"
|
||||
python_venv_site_packages=$(__ynh_python_venv_get_site_packages_dir -d "$final_path/venv")
|
||||
chown -R $app:www-data "$final_path/venv"
|
||||
|
||||
pushd "$final_path/endi" 2>&1
|
||||
ynh_exec_as $app "$final_path/venv/bin/python3" ./setup.py install 2>&1
|
||||
popd
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
}
|
||||
|
||||
__ynh_endi_migratedb() {
|
||||
ynh_exec_as $app "$final_path/venv/bin/endi-admin" "$final_path/endi.ini" \
|
||||
syncdb
|
||||
}
|
||||
|
||||
__ynh_endi_add_admin() {
|
||||
ynh_exec_as $app "$final_path/venv/bin/endi-admin" "$final_path/endi.ini" \
|
||||
useradd --group=admin --user="admin" --pwd="$password" --email="admin@$domain"
|
||||
}
|
||||
|
||||
|
||||
#=================================================
|
||||
# Python Venv HELPERS
|
||||
#=================================================
|
||||
|
||||
__ynh_python_venv_setup() {
|
||||
local -A args_array=( [d]=venv_dir= [p]=packages= )
|
||||
local venv_dir
|
||||
|
|
|
@ -111,9 +111,7 @@ ynh_script_progression --message="Setting up source files..." --weight=1
|
|||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
ynh_setup_source --dest_dir="$final_path/endi"
|
||||
|
||||
# Patching requirements.txt to use system provided Cython
|
||||
cython_version=$(cython3 --version 2>&1 | sed 's|Cython version ||')
|
||||
sed -i "s|Cython=.*|Cython==$cython_version|" "$final_path/endi/requirements.txt"
|
||||
__ynh_endi_patch_src
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
|
@ -128,37 +126,8 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# NPM setup
|
||||
#=================================================
|
||||
ynh_use_nodejs
|
||||
ynh_install_nodejs --nodejs_version=16
|
||||
|
||||
pushd "$final_path/endi" 2>&1
|
||||
ynh_script_progression --message="Downloading NPM dependencies..." --weight=1
|
||||
ynh_exec_as $app $ynh_node_load_PATH $ynh_npm --prefix js_sources install 2>&1
|
||||
ynh_exec_as $app $ynh_node_load_PATH $ynh_npm --prefix vue_sources install 2>&1
|
||||
|
||||
ynh_script_progression --message="Building Web interface code..." --weight=1
|
||||
ynh_exec_as $app make prodjs devjs prodjs2 devjs2 2>&1 \
|
||||
|| ynh_die --message="Build of javascript code failed, maybe because of high RAM usage!"
|
||||
popd 2>&1
|
||||
|
||||
#=================================================
|
||||
# Python + Virtualenv setup
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Python dependencies and Endi..." --weight=1
|
||||
|
||||
__ynh_python_venv_setup --venv_dir="$final_path/venv"
|
||||
python_venv_site_packages=$(__ynh_python_venv_get_site_packages_dir -d "$final_path/venv")
|
||||
chown -R $app:www-data "$final_path/venv"
|
||||
|
||||
pushd "$final_path/endi" 2>&1
|
||||
ynh_exec_as $app "$final_path/venv/bin/python3" ./setup.py install 2>&1
|
||||
popd
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:www-data "$final_path"
|
||||
__ynh_endi_build
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
|
@ -183,14 +152,8 @@ ynh_add_systemd_config
|
|||
#=================================================
|
||||
ynh_script_progression --message="Configuring enDI..." --weight=1
|
||||
|
||||
pushd "$final_path" 2>&1
|
||||
ynh_exec_as $app "$final_path/venv/bin/endi-admin" endi.ini syncdb
|
||||
|
||||
# ynh_exec_as $app "$final_path/venv/bin/endi-migrate" app.ini syncdb --pkg=endi_payment
|
||||
|
||||
ynh_exec_as $app "$final_path/venv/bin/endi-admin" endi.ini useradd --group=admin --user="admin" --pwd="$password" \
|
||||
--email="admin@$domain"
|
||||
popd 2>&1
|
||||
__ynh_endi_migratedb
|
||||
__ynh_endi_add_admin
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
|
Loading…
Add table
Reference in a new issue