[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-30 22:41:53 +02:00 committed by Alexandre Aubin
parent 0a2a53d312
commit 26d128c485
10 changed files with 117 additions and 179 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*~ *~
*.sw[op] *.sw[op]
.DS_Store

View file

@ -18,7 +18,8 @@ code = "https://github.com/bookwyrm-social/bookwyrm"
cpe = "cpe:2.3:a:joinbookwyrm:bookwyrm" cpe = "cpe:2.3:a:joinbookwyrm:bookwyrm"
[integration] [integration]
yunohost = ">= 11.2" 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.data_dir] [resources.data_dir]

View file

@ -1,17 +1,5 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#================================================= #=================================================

View file

@ -1,50 +1,41 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
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"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # 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"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
#================================================= #=================================================
ynh_backup --src_path="/etc/systemd/system/$app-beat.service" ynh_backup "/etc/systemd/system/$app-beat.service"
ynh_backup --src_path="/etc/systemd/system/$app-server.service" ynh_backup "/etc/systemd/system/$app-server.service"
ynh_backup --src_path="/etc/systemd/system/$app-worker.service" ynh_backup "/etc/systemd/system/$app-worker.service"
ynh_backup --src_path="/etc/systemd/system/$app.target" ynh_backup "/etc/systemd/system/$app.target"
#================================================= #=================================================
# BACKUP THE POSTGRESQL DATABASE # 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 # 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,38 +1,31 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
key=$(ynh_string_random --length=32) key=$(ynh_string_random --length=32)
ynh_app_setting_set --app=$app --key=key --value=$key ynh_app_setting_set --key=key --value=$key
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # 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 # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --source_id="main" ynh_setup_source --dest_dir="$install_dir" --source_id="main"
ynh_setup_source --dest_dir="$install_dir/static/fonts/source_han_sans" --source_id="fonts" ynh_setup_source --dest_dir="$install_dir/static/fonts/source_han_sans" --source_id="fonts"
# Set permissions to app files # Set permissions to app files
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"
#================================================= #=================================================
# CONFIGURE THEN INSTALL SCRIPT AND DEPENDENCIES # CONFIGURE THEN INSTALL SCRIPT AND DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing service script..." --weight=1 ynh_script_progression "Installing service script..."
ynh_add_config --template="../conf/.env.production" --destination="$install_dir/.env" ynh_config_add --template=".env.production" --destination="$install_dir/.env"
chmod 600 $install_dir/.env #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 600 $install_dir/.env
chown $app:www-data "$install_dir/.env" #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/.env"
mkdir "$install_dir/venv" mkdir "$install_dir/venv"
python3 -m venv "$install_dir/venv" python3 -m venv "$install_dir/venv"
@ -41,7 +34,7 @@ $install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt"
#================================================= #=================================================
# INITIALIZE DATABASE # INITIALIZE DATABASE
#================================================= #=================================================
ynh_script_progression --message="Initializing database..." --weight=1 ynh_script_progression "Initializing database..."
pushd $install_dir pushd $install_dir
$install_dir/venv/bin/python3 "$install_dir/manage.py" migrate $install_dir/venv/bin/python3 "$install_dir/manage.py" migrate
@ -53,41 +46,40 @@ popd
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1 ynh_script_progression "Configuring NGINX web server..."
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_config_add_nginx
#================================================= #=================================================
# LOGROTATE CONFIGURATION # LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring logrotate..." --weight=1 ynh_script_progression "Configuring logrotate..."
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate --specific_user=$app ynh_config_add_logrotate
touch /var/log/$app/$app.log touch /var/log/$app/$app.log
touch /var/log/$app/$app-beat.log touch /var/log/$app/$app-beat.log
touch /var/log/$app/$app-worker.log touch /var/log/$app/$app-worker.log
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/
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1 ynh_script_progression "Configuring $app's systemd service..."
ynh_add_config --template="../conf/bookwyrm.target" --destination="/etc/systemd/system/$app.target" ynh_config_add --template="bookwyrm.target" --destination="/etc/systemd/system/$app.target"
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config --service="$app-server" --template="bookwyrm-server.service" ynh_config_add_systemd --service="$app-server" --template="bookwyrm-server.service"
ynh_add_systemd_config --service="$app-worker" --template="bookwyrm-worker.service" ynh_config_add_systemd --service="$app-worker" --template="bookwyrm-worker.service"
ynh_add_systemd_config --service="$app-beat" --template="bookwyrm-beat.service" ynh_config_add_systemd --service="$app-beat" --template="bookwyrm-beat.service"
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression "Integrating service in YunoHost..."
yunohost service add "$app-beat" --log="/var/log/$app/$app-beat.log" yunohost service add "$app-beat" --log="/var/log/$app/$app-beat.log"
yunohost service add "$app-server" --log="/var/log/$app/$app.log" yunohost service add "$app-server" --log="/var/log/$app/$app.log"
@ -96,15 +88,15 @@ yunohost service add "$app-worker" --log="/var/log/$app/$app-worker.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..."
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="systemd" --line_match="Started bookwyrm celery beat process" ynh_systemctl --service="$app-beat" --action="start" --log_path="systemd" --wait_until="Started bookwyrm celery beat process"
ynh_systemd_action --service_name="$app-server" --action="start" --log_path="systemd" --line_match="Booting worker with pid" ynh_systemctl --service="$app-server" --action="start" --log_path="systemd" --wait_until="Booting worker with pid"
ynh_systemd_action --service_name="$app-worker" --action="start" --log_path="systemd" --line_match="ready" ynh_systemctl --service="$app-worker" --action="start" --log_path="systemd" --wait_until="ready"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression "Installation of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -16,57 +10,57 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# 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-server" >/dev/null if ynh_hide_warnings yunohost service status "$app-server" >/dev/null
then then
ynh_script_progression --message="Removing $app-server service integration..." ynh_script_progression "Removing $app-server service integration..."
yunohost service remove "$app-server" yunohost service remove "$app-server"
fi fi
if ynh_exec_warn_less yunohost service status "$app-worker" >/dev/null if ynh_hide_warnings yunohost service status "$app-worker" >/dev/null
then then
ynh_script_progression --message="Removing $app-worker service integration..." ynh_script_progression "Removing $app-worker service integration..."
yunohost service remove "$app-worker" yunohost service remove "$app-worker"
fi fi
if ynh_exec_warn_less yunohost service status "$app-beat" >/dev/null if ynh_hide_warnings yunohost service status "$app-beat" >/dev/null
then then
ynh_script_progression --message="Removing $app-beat service integration..." ynh_script_progression "Removing $app-beat service integration..."
yunohost service remove "$app-beat" yunohost service remove "$app-beat"
fi fi
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 ynh_script_progression "Stopping and removing the systemd service..."
ynh_systemd_action --service_name="$app-beat" --action="stop" --log_path="systemd" --line_match="Stopped $app" ynh_systemctl --service="$app-beat" --action="stop" --log_path="systemd" --wait_until="Stopped $app"
ynh_systemd_action --service_name="$app-server" --action="stop" --log_path="systemd" --line_match="Stopped $app" ynh_systemctl --service="$app-server" --action="stop" --log_path="systemd" --wait_until="Stopped $app"
ynh_systemd_action --service_name="$app-worker" --action="stop" --log_path="systemd" --line_match="Stopped $app" ynh_systemctl --service="$app-worker" --action="stop" --log_path="systemd" --wait_until="Stopped $app"
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config --service="$app-beat" ynh_config_remove_systemd"$app-beat"
ynh_remove_systemd_config --service="$app-server" ynh_config_remove_systemd"$app-server"
ynh_remove_systemd_config --service="$app-worker" ynh_config_remove_systemd"$app-worker"
ynh_secure_remove --file="/etc/systemd/system/$app.target" ynh_safe_rm "/etc/systemd/system/$app.target"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 ynh_script_progression "Removing NGINX web server configuration..."
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_config_remove_nginx
#================================================= #=================================================
# REMOVE LOGS # REMOVE LOGS
#================================================= #=================================================
ynh_script_progression --message="Removing logs..." --weight=5 ynh_script_progression "Removing logs..."
ynh_remove_logrotate ynh_config_remove_logrotate
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression "Removal of $app completed"

View file

@ -1,53 +1,46 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --key=db_name)
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#================================================= #=================================================
# 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"
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 ynh_script_progression "Restoring the PostgreSQL database..."
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name ynh_psql_db_shell < "./db.sql""
#================================================= #=================================================
# 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 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/bookwyrm-beat.service" ynh_restore "/etc/systemd/system/bookwyrm-beat.service"
ynh_restore_file --origin_path="/etc/systemd/system/bookwyrm-server.service" ynh_restore "/etc/systemd/system/bookwyrm-server.service"
ynh_restore_file --origin_path="/etc/systemd/system/bookwyrm-worker.service" ynh_restore "/etc/systemd/system/bookwyrm-worker.service"
ynh_restore_file --origin_path="/etc/systemd/system/bookwyrm.target" ynh_restore "/etc/systemd/system/bookwyrm.target"
systemctl enable "bookwyrm-beat.service" --quiet systemctl enable "bookwyrm-beat.service" --quiet
systemctl enable "bookwyrm-server.service" --quiet systemctl enable "bookwyrm-server.service" --quiet
@ -56,7 +49,7 @@ systemctl enable "bookwyrm-worker.service" --quiet
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression "Integrating service in YunoHost..."
yunohost service add "$app-beat" --log="/var/log/$app/$app-beat.log" yunohost service add "$app-beat" --log="/var/log/$app/$app-beat.log"
yunohost service add "$app-server" --log="/var/log/$app/$app.log" yunohost service add "$app-server" --log="/var/log/$app/$app.log"
@ -65,23 +58,21 @@ yunohost service add "$app-worker" --log="/var/log/$app/$app-worker.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-beat" --action="start" --log_path="systemd" --line_match="Started bookwyrm celery beat process" ynh_systemctl --service="$app-beat" --action="start" --log_path="systemd" --wait_until="Started bookwyrm celery beat process"
ynh_systemd_action --service_name="$app-server" --action="start" --log_path="systemd" --line_match="Booting worker with pid" ynh_systemctl --service="$app-server" --action="start" --log_path="systemd" --wait_until="Booting worker with pid"
ynh_systemd_action --service_name="$app-worker" --action="start" --log_path="systemd" --line_match="ready" ynh_systemctl --service="$app-worker" --action="start" --log_path="systemd" --wait_until="ready"
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_script_progression "Reloading NGINX web server..."
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"

View file

@ -1,11 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -14,60 +8,52 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# uncomment me after some updates whenever the key variable is set in install for some times # uncomment me after some updates whenever the key variable is set in install for some times
#key=$(ynh_app_setting_get --app=$app --key=key --value=$key) #key=$(ynh_app_setting_get --key=key --value=$key)
#remove me when key setting is uncommented (see above) #remove me when key setting is uncommented (see above)
key=$(ynh_string_random --length=32) key=$(ynh_string_random --length=32)
#=================================================
# CHECK VERSION
#=================================================
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 --action="stop" --service_name="bookwyrm-beat" --log_path="systemd" ynh_systemctl --action="stop" --service="bookwyrm-beat" --log_path="systemd"
ynh_systemd_action --action="stop" --service_name="bookwyrm-server" --log_path="systemd" ynh_systemctl --action="stop" --service="bookwyrm-server" --log_path="systemd"
ynh_systemd_action --action="stop" --service_name="bookwyrm-worker" --log_path="systemd" ynh_systemctl --action="stop" --service="bookwyrm-worker" --log_path="systemd"
#================================================= #=================================================
# 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" --source_id="main" --full_replace=1 --keep=".env" ynh_setup_source --dest_dir="$install_dir" --source_id="main" --full_replace --keep=".env"
ynh_setup_source --dest_dir="$install_dir/static/fonts/source_han_sans" --source_id="fonts" --full_replace=1 ynh_setup_source --dest_dir="$install_dir/static/fonts/source_han_sans" --source_id="fonts" --full_replace
fi fi
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"
#================================================= #=================================================
# CONFIGURE THE INSTALL SCRIPT # CONFIGURE THE INSTALL SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrading .env file..." --weight=1 ynh_script_progression "Upgrading .env file..."
ynh_add_config --template="../conf/.env.production" --destination="$install_dir/.env" ynh_config_add --template=".env.production" --destination="$install_dir/.env"
chmod 600 $install_dir/.env #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 600 $install_dir/.env
chown $app: "$install_dir/.env" #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/.env"
#================================================= #=================================================
# CONFIGURE THEN INSTALL SCRIPT AND DEPENDENCIES # CONFIGURE THEN INSTALL SCRIPT AND DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing service script..." --weight=1 ynh_script_progression "Installing service script..."
ynh_secure_remove --file="$install_dir/venv" ynh_safe_rm "$install_dir/venv"
mkdir "$install_dir/venv" mkdir "$install_dir/venv"
python3 -m venv "$install_dir/venv" python3 -m venv "$install_dir/venv"
$install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt" $install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt"
@ -75,7 +61,7 @@ $install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt"
#================================================= #=================================================
# Update DATABASE # Update DATABASE
#================================================= #=================================================
ynh_script_progression --message="Upgrading database..." --weight=1 ynh_script_progression "Upgrading database..."
pushd $install_dir pushd $install_dir
$install_dir/venv/bin/python3 "$install_dir/manage.py" compile_themes $install_dir/venv/bin/python3 "$install_dir/manage.py" compile_themes
@ -88,34 +74,31 @@ popd
# SET PERMISSIONS ON BOOKWYRM DIRECTORY # SET PERMISSIONS ON BOOKWYRM DIRECTORY
#================================================= #=================================================
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
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 ynh_script_progression "Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_config_add_nginx
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 ynh_script_progression "Upgrading systemd configuration..."
ynh_add_config --template="../conf/bookwyrm.target" --destination="/etc/systemd/system/$app.target" ynh_config_add --template="bookwyrm.target" --destination="/etc/systemd/system/$app.target"
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config --service="$app-server" --template="bookwyrm-server.service" ynh_config_add_systemd --service="$app-server" --template="bookwyrm-server.service"
ynh_add_systemd_config --service="$app-worker" --template="bookwyrm-worker.service" ynh_config_add_systemd --service="$app-worker" --template="bookwyrm-worker.service"
ynh_add_systemd_config --service="$app-beat" --template="bookwyrm-beat.service" ynh_config_add_systemd --service="$app-beat" --template="bookwyrm-beat.service"
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression "Integrating service in YunoHost..."
yunohost service add "$app-beat" --log="/var/log/$app/$app-beat.log" yunohost service add "$app-beat" --log="/var/log/$app/$app-beat.log"
yunohost service add "$app-server" --log="/var/log/$app/$app.log" yunohost service add "$app-server" --log="/var/log/$app/$app.log"
@ -124,14 +107,14 @@ yunohost service add "$app-worker" --log="/var/log/$app/$app-worker.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-beat" --action="start" --log_path="systemd" --line_match="Started bookwyrm celery beat process" ynh_systemctl --service="$app-beat" --action="start" --log_path="systemd" --wait_until="Started bookwyrm celery beat process"
ynh_systemd_action --service_name="$app-server" --action="start" --log_path="systemd" --line_match="Booting worker with pid" ynh_systemctl --service="$app-server" --action="start" --log_path="systemd" --wait_until="Booting worker with pid"
ynh_systemd_action --service_name="$app-worker" --action="start" --log_path="systemd" --line_match="ready" ynh_systemctl --service="$app-worker" --action="start" --log_path="systemd" --wait_until="ready"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression "Upgrade of $app completed"

View file

@ -1,2 +0,0 @@
*~
*.sw[op]

View file

@ -1,2 +0,0 @@
*~
*.sw[op]