mirror of
https://github.com/YunoHost-Apps/coin_ynh.git
synced 2024-09-03 18:16:26 +02:00
Merge cebe7c23d8
into 2aa237f096
This commit is contained in:
commit
dd6e06f13e
9 changed files with 97 additions and 110 deletions
|
@ -1,11 +1,11 @@
|
||||||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||||
location __PATH__/ {
|
location __PATH__/ {
|
||||||
try_files $uri @__NAME__;
|
try_files $uri @__APP__;
|
||||||
}
|
}
|
||||||
|
|
||||||
location __PATH__/protected/ {
|
location __PATH__/protected/ {
|
||||||
internal;
|
internal;
|
||||||
alias __INSTALL_DIR__/__NAME__/smedia/;
|
alias __INSTALL_DIR__/__APP__/smedia/;
|
||||||
}
|
}
|
||||||
|
|
||||||
location __PATH__/media/ {
|
location __PATH__/media/ {
|
||||||
|
@ -20,7 +20,7 @@ location __PATH__/assets/ {
|
||||||
alias __INSTALL_DIR__/static/;
|
alias __INSTALL_DIR__/static/;
|
||||||
}
|
}
|
||||||
|
|
||||||
location @__NAME__ {
|
location @__APP__ {
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
|
|
@ -17,7 +17,8 @@ website = "https://code.ffdn.org/FFDN/coin"
|
||||||
code = "https://code.ffdn.org/ffdn/coin"
|
code = "https://code.ffdn.org/ffdn/coin"
|
||||||
|
|
||||||
[integration]
|
[integration]
|
||||||
yunohost = ">= 11.2.20"
|
yunohost = ">= 11.2.18"
|
||||||
|
helpers_version = "2.1"
|
||||||
architectures = "all"
|
architectures = "all"
|
||||||
multi_instance = false
|
multi_instance = false
|
||||||
ldap = false
|
ldap = false
|
||||||
|
@ -61,6 +62,7 @@ ram.runtime = "50M"
|
||||||
allow_email = true
|
allow_email = true
|
||||||
|
|
||||||
[resources.install_dir]
|
[resources.install_dir]
|
||||||
|
group = "www-data:r-x"
|
||||||
|
|
||||||
[resources.permissions]
|
[resources.permissions]
|
||||||
main.url = "/"
|
main.url = "/"
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
|
@ -4,32 +4,29 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
ynh_print_info "Declaring files to be backed up..."
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$install_dir"
|
ynh_backup "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SYSTEM CONFIGURATION
|
# SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
ynh_backup "/etc/systemd/system/$app.service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE DATABASE
|
# BACKUP THE 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
|
# 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)."
|
||||||
|
|
|
@ -3,15 +3,15 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service=$app --action="stop"
|
||||||
|
|
||||||
ynh_change_url_nginx_config
|
ynh_config_change_url_nginx
|
||||||
|
|
||||||
ynh_add_config --jinja --template=local.py.j2 --destination="$install_dir/coin/settings_local.py"
|
ynh_config_add --jinja --template=local.py.j2 --destination="$install_dir/coin/settings_local.py"
|
||||||
|
|
||||||
chmod 400 "$install_dir/coin/settings_local.py"
|
#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/coin/settings_local.py"
|
||||||
chown $app "$install_dir/coin/settings_local.py"
|
#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 "$install_dir/coin/settings_local.py"
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service=$app --action="start"
|
||||||
|
|
||||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
ynh_script_progression "Change of URL completed for $app"
|
||||||
|
|
|
@ -3,26 +3,25 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
secret=$(ynh_string_random 24)
|
secret=$(ynh_string_random --length=24)
|
||||||
ynh_app_setting_set --app=$app --key=secret --value=$secret
|
ynh_app_setting_set --key=secret --value=$secret
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setting up source files..."
|
ynh_script_progression "Setting up source files..."
|
||||||
|
|
||||||
ynh_setup_source --dest_dir="$install_dir"
|
ynh_setup_source --dest_dir="$install_dir"
|
||||||
|
|
||||||
chmod 750 "$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 750 "$install_dir"
|
||||||
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 | 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 | chown -R $app:www-data "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
# PYTHON DEPENDENCIES
|
# PYTHON DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing more dependencies..."
|
ynh_script_progression "Installing more dependencies..."
|
||||||
|
|
||||||
pushd "$install_dir"
|
pushd "$install_dir"
|
||||||
python3 -m venv venv
|
python3 -m venv venv
|
||||||
|
@ -35,49 +34,48 @@ popd
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURATION DJANGO
|
# CONFIGURATION DJANGO
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring application..."
|
ynh_script_progression "Configuring application..."
|
||||||
|
|
||||||
ynh_add_config --jinja --template=local.py.j2 --destination="$install_dir/coin/settings_local.py"
|
ynh_config_add --jinja --template=local.py.j2 --destination="$install_dir/coin/settings_local.py"
|
||||||
chmod 400 "$install_dir/coin/settings_local.py"
|
#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/coin/settings_local.py"
|
||||||
chown $app "$install_dir/coin/settings_local.py"
|
#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 "$install_dir/coin/settings_local.py"
|
||||||
|
|
||||||
# SERVE STATIC FILES IN PRODUCTION MODE
|
# SERVE STATIC FILES IN PRODUCTION MODE
|
||||||
ln -s $install_dir/$app/static $install_dir/static
|
ln -s $install_dir/$app/static $install_dir/static
|
||||||
|
|
||||||
pushd $install_dir
|
pushd $install_dir
|
||||||
ynh_exec_warn_less venv/bin/python3 manage.py migrate --noinput
|
ynh_hide_warnings venv/bin/python3 manage.py migrate --noinput
|
||||||
ynh_exec_warn_less venv/bin/python3 manage.py collectstatic --noinput
|
ynh_hide_warnings venv/bin/python3 manage.py collectstatic --noinput
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Set permissions to directory
|
# Set permissions to directory
|
||||||
chmod 750 "$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 750 "$install_dir"
|
||||||
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 | 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 | chown -R $app:www-data "$install_dir"
|
||||||
|
|
||||||
# Setup log permissions
|
# Setup log permissions
|
||||||
mkdir -p /var/log/$app
|
mkdir -p /var/log/$app
|
||||||
chown -R $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 /var/log/$app
|
||||||
chown -R $app:www-data "/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:www-data "/var/log/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD A CONFIGURATION
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding a configuration file..."
|
ynh_script_progression "Adding $app's configuration..."
|
||||||
|
|
||||||
ynh_add_config --template="gunicorn_config.py" --destination="$install_dir/gunicorn_config.py"
|
ynh_config_add --template="gunicorn_config.py" --destination="$install_dir/gunicorn_config.py"
|
||||||
|
|
||||||
chown $app:www-data "$install_dir/gunicorn_config.py"
|
#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:www-data "$install_dir/gunicorn_config.py"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring system..."
|
ynh_script_progression "Configuring system..."
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_config_add_nginx
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
ynh_config_add_systemd
|
||||||
|
|
||||||
# Integrating service in YunoHost
|
# Integrating service in YunoHost
|
||||||
yunohost service add $app --description "$app daemon" --log="/var/log/$app/$app.log"
|
yunohost service add $app --description "$app daemon" --log="/var/log/$app/$app.log"
|
||||||
|
@ -85,13 +83,13 @@ yunohost service add $app --description "$app daemon" --log="/var/log/$app/$app.
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting systemd service..."
|
ynh_script_progression "Starting systemd service..."
|
||||||
|
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service=$app --action="start"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of $app completed" --last
|
ynh_script_progression "Installation of $app completed"
|
||||||
|
|
|
@ -6,22 +6,22 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SYSTEM CONFIGURATIONS
|
# REMOVE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
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`)
|
# 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
|
then
|
||||||
yunohost service remove $app
|
yunohost service remove $app
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
ynh_remove_systemd_config
|
ynh_config_remove_systemd
|
||||||
|
|
||||||
# Remove the dedicated NGINX config
|
# Remove the dedicated NGINX config
|
||||||
ynh_remove_nginx_config
|
ynh_config_remove_nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed" --last
|
ynh_script_progression "Removal of $app completed"
|
||||||
|
|
|
@ -7,29 +7,28 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# 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 750 "$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 750 "$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"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
ynh_script_progression "Restoring the NGINX web server configuration..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
ynh_psql_db_shell < "./db.sql""
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PYTHON DEPENDENCIES
|
# PYTHON DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling venv..." --weight=1
|
ynh_script_progression "Reinstalling venv..."
|
||||||
|
|
||||||
ynh_secure_remove --file="${install_dir}/venv"
|
ynh_safe_rm "${install_dir}/venv"
|
||||||
pushd "$install_dir"
|
pushd "$install_dir"
|
||||||
python3 -m venv venv
|
python3 -m venv venv
|
||||||
venv/bin/pip install --upgrade pip
|
venv/bin/pip install --upgrade pip
|
||||||
|
@ -43,14 +42,14 @@ popd
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
mkdir -p /var/log/$app
|
mkdir -p /var/log/$app
|
||||||
chown -R $app:www-data /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:www-data /var/log/$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
ynh_script_progression "Restoring $app's systemd service..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
ynh_restore "/etc/systemd/system/$app.service"
|
||||||
systemctl enable $app.service --quiet
|
systemctl enable $app.service --quiet
|
||||||
|
|
||||||
yunohost service add $app --description "$app daemon" --log="/var/log/$app/$app.log"
|
yunohost service add $app --description "$app daemon" --log="/var/log/$app/$app.log"
|
||||||
|
@ -58,14 +57,14 @@ yunohost service add $app --description "$app daemon" --log="/var/log/$app/$app.
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
ynh_script_progression "Reloading NGINX web server and $app's service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service=$app --action="start"
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemctl --service=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Restoration completed for $app" --last
|
ynh_script_progression "Restoration completed for $app"
|
||||||
|
|
|
@ -3,31 +3,27 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD UPGRADE STEPS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# 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="/var/log/$app/$app.log"
|
ynh_systemctl --service=$app --action="stop"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# 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
|
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
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep=coin/settings_local.py
|
ynh_setup_source --dest_dir="$install_dir" --full_replace --keep=coin/settings_local.py
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ynh_safe_rm "${install_dir}/venv"
|
||||||
ynh_secure_remove --file="${install_dir}/venv"
|
|
||||||
pushd "$install_dir"
|
pushd "$install_dir"
|
||||||
python3 -m venv venv
|
python3 -m venv venv
|
||||||
venv/bin/pip install --upgrade pip
|
venv/bin/pip install --upgrade pip
|
||||||
|
@ -36,69 +32,65 @@ pushd "$install_dir"
|
||||||
venv/bin/pip install -r requirements.txt
|
venv/bin/pip install -r requirements.txt
|
||||||
popd
|
popd
|
||||||
|
|
||||||
chmod 750 "$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 750 "$install_dir"
|
||||||
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 | 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 | chown -R $app:www-data "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC UPGRADE
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE DJANGO
|
# CONFIGURE DJANGO
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring Django..." --weight=1
|
ynh_script_progression "Configuring Django..."
|
||||||
|
|
||||||
# NB: We do NOT regen the settings_local.py using the template
|
# NB: We do NOT regen the settings_local.py using the template
|
||||||
# because we absolutely don't want to overwrite it
|
# because we absolutely don't want to overwrite it
|
||||||
chmod 400 "$install_dir/coin/settings_local.py"
|
#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/coin/settings_local.py"
|
||||||
chown $app "$install_dir/coin/settings_local.py"
|
#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 "$install_dir/coin/settings_local.py"
|
||||||
|
|
||||||
ynh_add_config --template="../conf/gunicorn_config.py" --destination="$install_dir/gunicorn_config.py"
|
ynh_config_add --template="gunicorn_config.py" --destination="$install_dir/gunicorn_config.py"
|
||||||
chown $app:www-data "$install_dir/gunicorn_config.py"
|
#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:www-data "$install_dir/gunicorn_config.py"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MIGRATE DB
|
# MIGRATE DB
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Migrating database..." --weight=1
|
ynh_script_progression "Migrating database..."
|
||||||
|
|
||||||
pushd "$install_dir"
|
pushd "$install_dir"
|
||||||
ynh_exec_warn_less venv/bin/python3 manage.py migrate --noinput
|
ynh_hide_warnings venv/bin/python3 manage.py migrate --noinput
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# COLLECT FILES
|
# COLLECT FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Collecting files..." --weight=1
|
ynh_script_progression "Collecting files..."
|
||||||
|
|
||||||
pushd "$install_dir"
|
pushd "$install_dir"
|
||||||
ynh_exec_warn_less venv/bin/python3 manage.py collectstatic --noinput
|
ynh_hide_warnings venv/bin/python3 manage.py collectstatic --noinput
|
||||||
popd
|
popd
|
||||||
|
|
||||||
chmod 750 "$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 750 "$install_dir"
|
||||||
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 | 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 | chown -R $app:www-data "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading system configurations..." --weight=1
|
ynh_script_progression "Upgrading system configurations..."
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_config_add_nginx
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
ynh_config_add_systemd
|
||||||
|
|
||||||
yunohost service add $app --description "$app daemon" --log="/var/log/$app/$app.log"
|
yunohost service add $app --description "$app daemon" --log="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# 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="/var/log/$app/$app.log"
|
ynh_systemctl --service=$app --action="start"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
ynh_script_progression "Upgrade of $app completed"
|
||||||
|
|
Loading…
Add table
Reference in a new issue