1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/endi_ynh.git synced 2024-09-03 18:35:54 +02:00

Coding style, install nodejs at start of script

This commit is contained in:
Salamandar 2024-07-13 14:08:17 +02:00
parent b1f825d469
commit 14c1976dd1
3 changed files with 45 additions and 39 deletions

View file

@ -4,58 +4,53 @@
# COMMON VARIABLES
#=================================================
nodejs_version=16
#=================================================
# PERSONAL HELPERS
#=================================================
__ynh_endi_patch_src() {
_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|" "$install_dir/endi/requirements.txt"
}
__ynh_endi_build() {
#=================================================
# NPM setup
#=================================================
_ynh_endi_build_ui() {
ynh_use_nodejs
ynh_install_nodejs --nodejs_version=16
pushd "$install_dir/endi" 2>&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_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 $ynh_node_load_PATH make prodjs devjs prodjs2 devjs2 2>&1 \
ynh_exec_as "$app" "$ynh_node_load_PATH" 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="$install_dir/venv"
python_venv_site_packages=$(__ynh_python_venv_get_site_packages_dir -d "$install_dir/venv")
chown -R $app:www-data "$install_dir/venv"
_ynh_endi_build_python
_ynh_python_venv_setup --venv_dir="$install_dir/venv"
python_venv_site_packages=$(_ynh_python_venv_get_site_packages_dir -d "$install_dir/venv")
chown -R "$app:www-data" "$install_dir/venv"
pushd "$install_dir/endi" 2>&1
ynh_exec_as $app "$install_dir/venv/bin/python3" ./setup.py install 2>&1
ynh_exec_as "$app" "$install_dir/venv/bin/python3" ./setup.py install 2>&1
popd 2>&1
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chown -R "$app:www-data" "$install_dir"
}
__ynh_endi_migratedb() {
_ynh_endi_migratedb() {
pushd "$install_dir" 2>&1
ynh_exec_as $app "$install_dir/venv/bin/endi-admin" "$install_dir/endi.ini" \
syncdb
popd 2>&1
}
__ynh_endi_add_admin() {
_ynh_endi_add_admin() {
pushd "$install_dir" 2>&1
ynh_exec_as $app "$install_dir/venv/bin/endi-admin" "$install_dir/endi.ini" \
useradd --group=admin --user="admin" --pwd="$password" --email="admin@$domain"
@ -67,7 +62,7 @@ __ynh_endi_add_admin() {
# Python Venv HELPERS
#=================================================
__ynh_python_venv_setup() {
_ynh_python_venv_setup() {
local -A args_array=( [d]=venv_dir= [p]=packages= )
local venv_dir
local packages
@ -81,7 +76,7 @@ __ynh_python_venv_setup() {
fi
}
__ynh_python_venv_get_site_packages_dir() {
_ynh_python_venv_get_site_packages_dir() {
local -A args_array=( [d]=venv_dir= )
local venv_dir
ynh_handle_getopts_args "$@"

View file

@ -7,6 +7,13 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# INSTALL NODEJS
#=================================================
ynh_script_progression --message="Installing NodeJS..." --weight=1
ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version"
#=================================================
# ENABLE MANDATORY FRENCH LOCALE
#=================================================
@ -14,14 +21,6 @@ ynh_script_progression --message="Enabling french system locale..." --weight=1
sed -i 's|^#\? \?\(fr_FR.UTF-8 \?.*\)$|\1|' /etc/locale.gen
#=================================================
# FIND A REDIS DATABASE
#=================================================
ynh_script_progression --message="Searching for an available Redis database..." --weight=1
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -32,20 +31,24 @@ ynh_setup_source --dest_dir="$install_dir/endi"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
# __ynh_endi_patch_src
# _ynh_endi_patch_src
#=================================================
# SETUP APPLICATION
#=================================================
ynh_script_progression --message="Building $app..." --weight=1
__ynh_endi_build
_ynh_endi_build_ui
_ynh_endi_build_python
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding $app's configuration file..." --weight=1
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
ynh_add_config --template="endi.ini" --destination="$install_dir/endi.ini"
chmod 500 "$install_dir/endi.ini"
@ -64,8 +67,8 @@ chmod 750 "/var/log/$app"
#=================================================
ynh_script_progression --message="Configuring $app..." --weight=1
__ynh_endi_migratedb
__ynh_endi_add_admin
_ynh_endi_migratedb
_ynh_endi_add_admin
#=================================================
# GENERIC FINALIZATION

View file

@ -14,6 +14,13 @@ ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/logfile.log"
#=================================================
# INSTALL NODEJS
#=================================================
ynh_script_progression --message="Updating NodeJS..." --weight=1
ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -25,7 +32,7 @@ ynh_setup_source --dest_dir="$install_dir/endi" --full_replace --keep="endi.ini"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
# __ynh_endi_patch_src
# _ynh_endi_patch_src
#=================================================
# UPDATE A CONFIG FILE
@ -41,13 +48,14 @@ chown "$app:$app" "$install_dir/endi.ini"
# SETUP APPLICATION
#=================================================
ynh_script_progression --message="Building $app..." --weight=1
__ynh_endi_build
_ynh_endi_build_ui
_ynh_endi_build_python
#=================================================
# SETUP APPLICATION
#=================================================
ynh_script_progression --message="Migrating databases..." --weight=1
__ynh_endi_migratedb
_ynh_endi_migratedb
#=================================================
# SETUP SYSTEMD