1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/kresus_ynh.git synced 2024-09-03 19:36:10 +02:00
This commit is contained in:
YunoHost Bot 2024-08-31 13:20:38 +02:00 committed by GitHub
commit 9f50020368
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 139 additions and 202 deletions

View file

@ -1,7 +1,7 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
alias __INSTALL_DIR__/build/client/;
try_files $uri $uri/index.html @__NAME__;
try_files $uri $uri/index.html @__APP__;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
@ -10,10 +10,10 @@ location __PATH__/ {
location ~ __PATH__/\.(css|js|png|jpe?g|svg|eot|woff2?)$ {
more_set_headers 'Cache-Control: max-age=2592000, must-revalidate, public';
gzip_types text/plain text/css application/javascript text/javascript;
try_files $uri $uri/index.html @__NAME__;
try_files $uri $uri/index.html @__APP__;
}
location @__NAME__ {
location @__APP__ {
client_max_body_size 8M;
send_timeout 600;
proxy_connect_timeout 600;

View file

@ -7,7 +7,7 @@ Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__INSTALL_DIR__/
Environment="__YNH_NODE_LOAD_PATH__"
Environment="PATH=__PATH_WITH_NODEJS__"
Environment=NODE_ENV=production
ExecStart=__INSTALL_DIR__/bin/kresus.js --config __INSTALL_DIR__/config.ini
Restart=always

View file

@ -17,7 +17,8 @@ admindoc = "https://kresus.org/en/doc.html"
code = "https://framagit.org/kresusapp/kresus"
[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = ["amd64", "arm64"]
multi_instance = true
@ -53,6 +54,7 @@ ram.runtime = "50M"
allow_email = true
[resources.install_dir]
group = "www-data:r-x"
[resources.data_dir]

View file

@ -1,19 +1,7 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
nodejs_version=20
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,37 +1,28 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$install_dir"
ynh_backup "$install_dir"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$data_dir" --is_big
ynh_backup "$data_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
@ -39,23 +30,23 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup "/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup "/etc/systemd/system/$app.service"
#=================================================
# BACKUP THE POSTGRESQL DATABASE
#=================================================
ynh_print_info --message="Backing up the PostgreSQL database..."
ynh_print_info "Backing up the PostgreSQL database..."
ynh_psql_dump_db --database="$db_name" > db.sql
ynh_psql_dump_db > db.sql
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,56 +1,46 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
ynh_systemctl --service=$app --action="stop" --log_path=systemd
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config
ynh_config_change_url_nginx
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
ynh_script_progression "Updating configuration..."
domain=$new_domain
path=$new_path
ynh_add_config --template="../conf/config.ini" --destination="$install_dir/config.ini"
ynh_config_add --template="config.ini" --destination="$install_dir/config.ini"
chmod 400 "$install_dir/config.ini"
chown $app:$app "$install_dir/config.ini"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/config.ini"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/config.ini"
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready"
ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Server is ready"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last
ynh_script_progression "Change of URL completed for $app"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -14,43 +8,42 @@ source /usr/share/yunohost/helpers
#=================================================
salt=$(ynh_string_random --length=40)
ynh_app_setting_set --app=$app --key=salt --value=$salt
ynh_app_setting_set --key=salt --value=$salt
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_script_progression "Installing dependencies..."
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_nodejs_install
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_script_progression "Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
ynh_script_progression "Configuring NGINX web server..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd
mkdir -p "/var/log/$app/"
touch "/var/log/$app/$app.log"
chown -R $app:$app "/var/log/$app/"
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "/var/log/$app/"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
ynh_config_add_logrotate
yunohost service add $app --description="Personal finance manager" --log="/var/log/$app/$app.log"
@ -59,61 +52,61 @@ yunohost service add $app --description="Personal finance manager" --log="/var/l
#=================================================
# INSTALL WOOB WITH PIP
#=================================================
ynh_script_progression --message="Installing woob..." --weight=1
ynh_script_progression "Installing woob..."
locale-gen C.UTF-8
update-locale C.UTF-8
ynh_exec_as $app virtualenv --python=python3 --system-site-packages "${install_dir}/venv"
ynh_exec_as_app virtualenv --python=python3 --system-site-packages "${install_dir}/venv"
(
set +o nounset
source "${install_dir}/venv/bin/activate"
set -o nounset
ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$install_dir"/.rustup CARGO_HOME="$install_dir"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y --default-toolchain=stable --profile=minimal'
ynh_hide_warnings ynh_exec_as_app RUSTUP_HOME="$install_dir"/.rustup CARGO_HOME="$install_dir"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y --default-toolchain=stable --profile=minimal'
export PATH="$install_dir/.cargo/bin:$PATH"
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade pip
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade 'setuptools<71'
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install woob simplejson BeautifulSoup4 PyExecJS typing-extensions pdfminer.six Pillow chompjs --ignore-installed
ynh_secure_remove --file="$install_dir/.cargo"
ynh_secure_remove --file="$install_dir/.rustup"
ynh_secure_remove --file="$install_dir/.cache"
ynh_secure_remove --file="$install_dir/.local"
ynh_hide_warnings ynh_exec_as_app PATH=$PATH pip install --upgrade pip
ynh_hide_warnings ynh_exec_as_app PATH=$PATH pip install --upgrade 'setuptools<71'
ynh_hide_warnings ynh_exec_as_app PATH=$PATH pip install woob simplejson BeautifulSoup4 PyExecJS typing-extensions pdfminer.six Pillow chompjs --ignore-installed
ynh_safe_rm "$install_dir/.cargo"
ynh_safe_rm "$install_dir/.rustup"
ynh_safe_rm "$install_dir/.cache"
ynh_safe_rm "$install_dir/.local"
)
#=================================================
# INSTALL KRESUS WITH NPM
#=================================================
ynh_script_progression --message="Installing $app..." --weight=1
ynh_script_progression "Installing $app..."
pushd $install_dir
ynh_use_nodejs
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn config set network-timeout 300000
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --production
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean --all
ynh_secure_remove --file="$install_dir/.cache"
ynh_secure_remove --file="$install_dir/.yarn"
ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn config set network-timeout 300000
ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn install --production
ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn cache clean --all
ynh_safe_rm "$install_dir/.cache"
ynh_safe_rm "$install_dir/.yarn"
popd
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_script_progression "Adding $app's configuration..."
ynh_add_config --template="../conf/config.ini" --destination="$install_dir/config.ini"
ynh_config_add --template="config.ini" --destination="$install_dir/config.ini"
chmod 400 "$install_dir/config.ini"
chown $app:$app "$install_dir/config.ini"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/config.ini"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/config.ini"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready"
ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Server is ready"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression "Installation of $app completed"

View file

@ -1,42 +1,37 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
# REMOVE SYSTEMD SERVICE
# REMOVE SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
ynh_script_progression "Removing system configurations related to $app..."
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
if ynh_hide_warnings yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..." --weight=1
ynh_script_progression "Removing $app service integration..."
yunohost service remove $app
fi
# Remove the dedicated systemd config
ynh_remove_systemd_config
ynh_config_remove_systemd
# Remove the app-specific logrotate config
ynh_remove_logrotate
ynh_config_remove_logrotate
# Remove the dedicated NGINX config
ynh_remove_nginx_config
ynh_config_remove_nginx
# Remove metapackage and its dependencies
ynh_remove_nodejs
ynh_nodejs_remove
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -13,22 +7,21 @@ source /usr/share/yunohost/helpers
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir"
ynh_restore "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod 400 "$install_dir/config.ini"
chown $app:$app "$install_dir/config.ini"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/config.ini"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/config.ini"
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_script_progression "Restoring the data directory..."
ynh_restore_file --origin_path="$data_dir" --not_mandatory
ynh_restore "$data_dir"
# (Same as for install dir)
chown -R $app:www-data "$data_dir"
@ -38,47 +31,47 @@ chown -R $app:www-data "$data_dir"
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
ynh_script_progression "Reinstalling dependencies..."
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_nodejs_install
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
ynh_script_progression "Restoring the PostgreSQL database..."
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
ynh_psql_db_shell < ./db.sql
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_script_progression "Restoring system configurations related to $app..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
ynh_restore "/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
mkdir -p "/var/log/$app/"
touch "/var/log/$app/$app.log"
chown -R $app:$app "/var/log/$app/"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "/var/log/$app/"
ynh_restore "/etc/logrotate.d/$app"
yunohost service add $app --description="Personal finance manager" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready"
ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Server is ready"
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemctl --service=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last
ynh_script_progression "Restoration completed for $app"

View file

@ -1,150 +1,135 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
ynh_systemctl --service=$app --action="stop" --log_path=systemd
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
ynh_script_progression "Ensuring downward compatibility..."
if [ -d "/home/ynh$app" ]; then
mv "/home/ynh$app/data" "$install_dir/data"
ynh_secure_remove --file="/home/ynh$app"
ynh_safe_rm "/home/ynh$app"
fi
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=salt --value=$(ynh_string_random --length=40)
if [ -z "${salt:-}" ]; then
salt=$(ynh_string_random 40)
ynh_app_setting_set --app=$app --key=salt --value=$salt
salt=$(ynh_string_random --length=40)
ynh_app_setting_set --key=salt --value=$salt
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
if ynh_app_upstream_version_changed
then
ynh_script_progression --message="Upgrading source files..." --weight=1
ynh_script_progression "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --keep="config.ini"
fi
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_script_progression "Upgrading dependencies..."
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_nodejs_install
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
ynh_script_progression "Upgrading system configurations related to $app..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd
mkdir -p "/var/log/$app/"
touch "/var/log/$app/$app.log"
chown -R $app:$app "/var/log/$app/"
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "/var/log/$app/"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
ynh_config_add_logrotate
yunohost service add $app --description="Personal finance manager" --log="/var/log/$app/$app.log"
#=================================================
# SPECIFIC UPGRADE
#=================================================
# INSTALL WOOB WITH PIP
#=================================================
ynh_script_progression --message="Installing woob..." --weight=1
ynh_script_progression "Installing woob..."
locale-gen C.UTF-8
update-locale C.UTF-8
ynh_secure_remove --file="${install_dir}/venv"
ynh_exec_as $app virtualenv --python=python3 --system-site-packages "${install_dir}/venv"
ynh_safe_rm "${install_dir}/venv"
ynh_exec_as_app virtualenv --python=python3 --system-site-packages "${install_dir}/venv"
(
set +o nounset
source "${install_dir}/venv/bin/activate"
set -o nounset
ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$install_dir"/.rustup CARGO_HOME="$install_dir"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y --default-toolchain=stable --profile=minimal'
ynh_hide_warnings ynh_exec_as_app RUSTUP_HOME="$install_dir"/.rustup CARGO_HOME="$install_dir"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y --default-toolchain=stable --profile=minimal'
export PATH="$install_dir/.cargo/bin:$PATH"
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade pip
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade 'setuptools<71'
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install woob simplejson BeautifulSoup4 PyExecJS typing-extensions pdfminer.six Pillow chompjs --ignore-installed
ynh_secure_remove --file="$install_dir/.cargo"
ynh_secure_remove --file="$install_dir/.rustup"
ynh_secure_remove --file="$install_dir/.cache"
ynh_secure_remove --file="$install_dir/.local"
ynh_hide_warnings ynh_exec_as_app PATH=$PATH pip install --upgrade pip
ynh_hide_warnings ynh_exec_as_app PATH=$PATH pip install --upgrade 'setuptools<71'
ynh_hide_warnings ynh_exec_as_app PATH=$PATH pip install woob simplejson BeautifulSoup4 PyExecJS typing-extensions pdfminer.six Pillow chompjs --ignore-installed
ynh_safe_rm "$install_dir/.cargo"
ynh_safe_rm "$install_dir/.rustup"
ynh_safe_rm "$install_dir/.cache"
ynh_safe_rm "$install_dir/.local"
)
#=================================================
# INSTALL KRESUS WITH NPM
#=================================================
ynh_script_progression --message="Installing app..." --weight=1
ynh_script_progression "Installing app..."
pushd $install_dir
ynh_use_nodejs
# In case of nodejs upgrade, remove the current node_modules to make sure there are no errors
# linked to modules compiled for the previous version.
ynh_secure_remove --file="$install_dir/node_modules"
ynh_safe_rm "$install_dir/node_modules"
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn config set network-timeout 300000
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --production
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean --all
ynh_secure_remove --file="$install_dir/.cache"
ynh_secure_remove --file="$install_dir/.yarn"
ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn config set network-timeout 300000
ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn install --production
ynh_hide_warnings ynh_exec_as_app node_load_PATH yarn cache clean --all
ynh_safe_rm "$install_dir/.cache"
ynh_safe_rm "$install_dir/.yarn"
popd
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
ynh_script_progression "Updating configuration..."
ynh_add_config --template="../conf/config.ini" --destination="$install_dir/config.ini"
ynh_config_add --template="config.ini" --destination="$install_dir/config.ini"
chmod 400 "$install_dir/config.ini"
chown $app:$app "$install_dir/config.ini"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/config.ini"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/config.ini"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready"
ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Server is ready"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression "Upgrade of $app completed"