mirror of
https://github.com/YunoHost-Apps/dont-code_ynh.git
synced 2024-09-03 18:26:34 +02:00
Merge 22c3a40927
into 77d33f2aed
This commit is contained in:
commit
cacebf09c2
9 changed files with 127 additions and 182 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
*~
|
||||
*.sw[op]
|
||||
.DS_Store
|
||||
|
|
|
@ -20,7 +20,8 @@ userdoc = "https://dont-code.net/news.html"
|
|||
code = "https://github.com/dont-code"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.2.12"
|
||||
yunohost = ">= 11.2.18"
|
||||
helpers_version = "2.1"
|
||||
architectures = "all"
|
||||
multi_instance = true
|
||||
ldap = false
|
||||
|
@ -65,6 +66,7 @@ ram.runtime = "400M"
|
|||
[resources.system_user]
|
||||
|
||||
[resources.install_dir]
|
||||
group = "www-data:r-x"
|
||||
|
||||
[resources.data_dir]
|
||||
subdirs = ["docs"]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||
#=================================================
|
||||
|
||||
mongo_version=7.0
|
||||
|
@ -18,9 +18,6 @@ PORT_LIST=("$port_ide" "$port_preview" "$port_project" "$port_data")
|
|||
java_version=17
|
||||
ynh_java="/usr/lib/jvm/java-${java_version}-openjdk-amd64/bin/java"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
append_uri() {
|
||||
local return="";
|
||||
if [[ $1 == */ ]]; then
|
||||
|
@ -33,26 +30,18 @@ append_uri() {
|
|||
|
||||
_install_restart_script_and_sudoers() {
|
||||
# Enable restarting of services from ssh
|
||||
ynh_add_config --template="restart-services.sh" --destination="$install_dir/restart-services.sh"
|
||||
ynh_config_add --template="restart-services.sh" --destination="$install_dir/restart-services.sh"
|
||||
chown "$app:$app" "$install_dir/restart-services.sh"
|
||||
chmod o-rwx,gu=rwx "$install_dir/restart-services.sh"
|
||||
|
||||
# Add sudoers file for this specific command
|
||||
ynh_add_config --template="dont-code-sudoers" --destination="/etc/sudoers.d/$app-sudoers"
|
||||
chown root:root "/etc/sudoers.d/$app-sudoers"
|
||||
chmod o-rwx,gu=r "/etc/sudoers.d/$app-sudoers"
|
||||
ynh_config_add --template="dont-code-sudoers" --destination="/etc/sudoers.d/$app-sudoers"
|
||||
#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 root:root "/etc/sudoers.d/$app-sudoers"
|
||||
#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 o-rwx,gu=r "/etc/sudoers.d/$app-sudoers"
|
||||
}
|
||||
|
||||
_remove_restart_script_and_sudoers() {
|
||||
if [ -f "/etc/sudoers.d/$app-sudoers" ]; then
|
||||
ynh_secure_remove --file="/etc/sudoers.d/$app-sudoers"
|
||||
ynh_safe_rm "/etc/sudoers.d/$app-sudoers"
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -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 HTML AND DOCUMENT 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,27 +30,27 @@ 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 services
|
||||
#=================================================
|
||||
|
||||
for service_name in "${SERVICES_LIST[@]}"; do
|
||||
ynh_backup --src_path="/etc/systemd/system/${app}-${service_name}.service"
|
||||
ynh_backup "/etc/systemd/system/${app}-${service_name}.service"
|
||||
done
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
if [ -n "$public_key" ]; then
|
||||
ynh_backup --src_path="/etc/sudoers.d/$app-sudoers"
|
||||
ynh_backup "/etc/sudoers.d/$app-sudoers"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MONGO DATABASES
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the Mongo databases..."
|
||||
ynh_print_info "Backing up the Mongo databases..."
|
||||
|
||||
for db_name in "${MONGO_DB_LIST[@]}"; do
|
||||
ynh_mongo_dump_db --database="dontCode$tenant$db_name" > ./dump-dontCode${tenant}${db_name}.bson
|
||||
|
@ -69,4 +60,4 @@ done
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app with tenant $tenant. (YunoHost will then actually copy those files to the archive)."
|
||||
ynh_print_info "Backup script completed for $app with tenant $tenant. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -1,63 +1,55 @@
|
|||
#!/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 systemd services..." --weight=1
|
||||
ynh_script_progression "Stopping systemd services..."
|
||||
|
||||
for service_name in "${SERVICES_LIST[@]}"; do
|
||||
ynh_systemd_action --service_name="${app}-${service_name}" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemctl --service="${app}-${service_name}" --action="stop"
|
||||
|
||||
done
|
||||
|
||||
#=================================================
|
||||
# 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 document url in .env
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating .env configuration..."
|
||||
ynh_script_progression "Updating .env configuration..."
|
||||
|
||||
new_document_url=$(append_uri "https://${new_domain}${new_path}" "docs")
|
||||
ynh_app_setting_set --app="$app" --key=document_url --value="$new_document_url"
|
||||
ynh_app_setting_set --key=document_url --value="$new_document_url"
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$install_dir/.env"
|
||||
ynh_replace_string --match_string="$document_url" --replace_string="$new_document_url" --target_file="$install_dir/.env"
|
||||
ynh_store_file_checksum --file="$install_dir/.env"
|
||||
ynh_backup_if_checksum_is_different "$install_dir/.env"
|
||||
ynh_replace --match="$document_url" --replace="$new_document_url" --file="$install_dir/.env"
|
||||
ynh_store_file_checksum "$install_dir/.env"
|
||||
|
||||
# Update the repository pages
|
||||
ynh_add_config --template="repository-next.json" --destination="$data_dir/repository-next.json"
|
||||
ynh_add_config --template="repository-stable.json" --destination="$data_dir/repository-stable.json"
|
||||
ynh_config_add --template="repository-next.json" --destination="$data_dir/repository-next.json"
|
||||
ynh_config_add --template="repository-stable.json" --destination="$data_dir/repository-stable.json"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting systemd services..." --weight=1
|
||||
ynh_script_progression "Starting systemd services..."
|
||||
|
||||
for service_name in "${SERVICES_LIST[@]}"; do
|
||||
ynh_systemd_action --service_name="${app}-${service_name}" --action="start" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemctl --service="${app}-${service_name}" --action="start"
|
||||
|
||||
done
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||
ynh_script_progression "Change of URL completed for $app"
|
||||
|
|
|
@ -1,43 +1,35 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# 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:$app" "$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:$app" "$install_dir"
|
||||
#=================================================
|
||||
# Configure document storage
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring document storage..." --weight=1
|
||||
ynh_script_progression "Configuring document storage..."
|
||||
|
||||
document_dir=$data_dir/docs
|
||||
ynh_app_setting_set --app="$app" --key=document_dir --value="$document_dir"
|
||||
ynh_app_setting_set --key=document_dir --value="$document_dir"
|
||||
|
||||
document_url=$(append_uri "https://${domain}${path}" "docs")
|
||||
ynh_app_setting_set --app="$app" --key=document_url --value="$document_url"
|
||||
ynh_app_setting_set --key=document_url --value="$document_url"
|
||||
|
||||
# Add the status pageindex
|
||||
ynh_add_config --template="index.html" --destination="$data_dir/index.html"
|
||||
ynh_config_add --template="index.html" --destination="$data_dir/index.html"
|
||||
|
||||
# Add the repository pages
|
||||
ynh_add_config --template="repository-next.json" --destination="$data_dir/repository-next.json"
|
||||
ynh_add_config --template="repository-stable.json" --destination="$data_dir/repository-stable.json"
|
||||
|
||||
ynh_config_add --template="repository-next.json" --destination="$data_dir/repository-next.json"
|
||||
ynh_config_add --template="repository-stable.json" --destination="$data_dir/repository-stable.json"
|
||||
|
||||
chmod -R o-rwx "$data_dir"
|
||||
chown -R $app:www-data "$data_dir"
|
||||
|
@ -45,30 +37,30 @@ chown -R $app:www-data "$data_dir"
|
|||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
ynh_script_progression "Adding $app's configuration..."
|
||||
|
||||
# The .env needs db_user and db_password
|
||||
new_db_pwd=$(ynh_string_random) # Generate a random password
|
||||
db_pwd="${db_pwd:-$new_db_pwd}"
|
||||
|
||||
db_user=$(ynh_sanitize_dbid --db_name="${app}")
|
||||
ynh_app_setting_set --app="$app" --key=db_user --value="$db_user"
|
||||
ynh_app_setting_set --key=db_user --value="$db_user"
|
||||
|
||||
ynh_add_config --template=".env" --destination="$install_dir/.env"
|
||||
ynh_config_add --template=".env" --destination="$install_dir/.env"
|
||||
|
||||
chmod 400 "$install_dir/.env"
|
||||
chown $app:$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 | chmod 400 "$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:$app "$install_dir/.env"
|
||||
|
||||
#=================================================
|
||||
# ADD SSH ACCESS
|
||||
#=================================================
|
||||
|
||||
if [ -n "$public_key" ]; then
|
||||
ynh_script_progression --message="Enabling ssh access for dev..." --weight=1
|
||||
ynh_script_progression "Enabling ssh access for dev..."
|
||||
# enable ssh access to the files for updates
|
||||
# todo: Secure it more with https://github.com/YunoHost-Apps/ssh_chroot_dir_ynh
|
||||
mkdir --parents "$install_dir/.ssh"
|
||||
ynh_add_config --template="authorized_keys" --destination="$install_dir/.ssh/authorized_keys"
|
||||
ynh_config_add --template="authorized_keys" --destination="$install_dir/.ssh/authorized_keys"
|
||||
|
||||
chown -R "$app:$app" "$install_dir/.ssh"
|
||||
chmod 700 "$install_dir/.ssh"
|
||||
|
@ -80,15 +72,15 @@ fi
|
|||
#=================================================
|
||||
# INSTALL MONGO
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing MongoDB..." --weight=1
|
||||
ynh_script_progression "Installing MongoDB..."
|
||||
|
||||
# Install the required version of Mongo
|
||||
ynh_install_mongo --mongo_version=$mongo_version
|
||||
ynh_install_mongo
|
||||
|
||||
#=================================================
|
||||
# CREATE A MONGO DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating the Mongo databases..." --weight=1
|
||||
ynh_script_progression "Creating the Mongo databases..."
|
||||
|
||||
for db_name in "${MONGO_DB_LIST[@]}"; do
|
||||
ynh_mongo_setup_db --db_user="$db_user" --db_pwd="$db_pwd" --db_name="dontCode$tenant${db_name}"
|
||||
|
@ -97,33 +89,34 @@ done
|
|||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Adding system configurations related to $app..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
ynh_config_add_logrotate
|
||||
|
||||
for i in "${!SERVICES_LIST[@]}"; do
|
||||
service_name="${SERVICES_LIST[i]}"
|
||||
port="${PORT_LIST[i]}"
|
||||
ynh_add_systemd_config --service="${app}-${service_name}"
|
||||
ynh_config_add_systemd --service="${app}-${service_name}"
|
||||
yunohost service add "${app}-${service_name}" --description="Dont-code platform ${service_name} service" --log="/var/log/${app}/${service_name}-${app}.log"
|
||||
done
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting systemd services..." --weight=1
|
||||
ynh_script_progression "Starting systemd services..."
|
||||
|
||||
# Start a systemd service
|
||||
for service_name in "${SERVICES_LIST[@]}"; do
|
||||
ynh_systemd_action --service_name="${app}-${service_name}" --action="start" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemctl --service="${app}-${service_name}" --action="start"
|
||||
|
||||
done
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -1,37 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# 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`)
|
||||
for service_name in "${SERVICES_LIST[@]}"; do
|
||||
if ynh_exec_warn_less yunohost service status "${app}-${service_name}" >/dev/null; then
|
||||
if ynh_hide_warnings yunohost service status "${app}-${service_name}" >/dev/null; then
|
||||
yunohost service remove "${app}-${service_name}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
for service_name in "${SERVICES_LIST[@]}"; do
|
||||
ynh_remove_systemd_config --service="${app}-${service_name}"
|
||||
ynh_config_remove_systemd"${app}-${service_name}"
|
||||
done
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
ynh_config_remove_nginx
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
ynh_config_remove_logrotate
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
for db_name in "${MONGO_DB_LIST[@]}"; do
|
||||
|
@ -47,4 +40,4 @@ _remove_restart_script_and_sudoers
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
ynh_script_progression "Removal of $app completed"
|
||||
|
|
|
@ -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,19 +7,18 @@ 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"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:$app "$install_dir"
|
||||
ynh_restore "$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:$app "$install_dir"
|
||||
#=================================================
|
||||
# RESTORE THE DOCUMENTS DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the document storage..." --weight=1
|
||||
ynh_script_progression "Restoring the document storage..."
|
||||
|
||||
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
||||
ynh_restore "$data_dir"
|
||||
|
||||
mkdir -p $document_dir
|
||||
|
||||
|
@ -38,7 +31,7 @@ chown -R $app:www-data "$data_dir"
|
|||
|
||||
# Make sure the .ssh and files have the correct access rights
|
||||
if [ -n "$public_key" ]; then
|
||||
ynh_script_progression --message="Restoring ssh access for dev..." --weight=1
|
||||
ynh_script_progression "Restoring ssh access for dev..."
|
||||
|
||||
chown -R "$app:$app" "$install_dir/.ssh"
|
||||
chmod 700 "$install_dir/.ssh"
|
||||
|
@ -50,15 +43,15 @@ fi
|
|||
#=================================================
|
||||
# INSTALL MONGO
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling MongoDB..." --weight=1
|
||||
ynh_script_progression "Reinstalling MongoDB..."
|
||||
|
||||
# Install the required version of Mongo
|
||||
ynh_install_mongo --mongo_version=$mongo_version
|
||||
ynh_install_mongo
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MONGO DATABASES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the Mongo databases..." --weight=1
|
||||
ynh_script_progression "Restoring the Mongo databases..."
|
||||
|
||||
for db_name in "${MONGO_DB_LIST[@]}"; do
|
||||
ynh_mongo_setup_db --db_user="$db_user" --db_pwd="$db_pwd" --db_name="dontCode$tenant${db_name}"
|
||||
|
@ -68,34 +61,33 @@ done
|
|||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
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/logrotate.d/$app"
|
||||
ynh_restore "/etc/logrotate.d/$app"
|
||||
mkdir --parents /var/log/$app
|
||||
|
||||
for service_name in "${SERVICES_LIST[@]}"; do
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/${app}-${service_name}.service"
|
||||
ynh_restore "/etc/systemd/system/${app}-${service_name}.service"
|
||||
systemctl enable "${app}-${service_name}.service" --quiet
|
||||
yunohost service add "${app}-${service_name}" --description="Dont-code platform ${service_name} service" --log="/var/log/${app}/${service_name}-${app}.log"
|
||||
done
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and $app's services..." --weight=1
|
||||
ynh_script_progression "Reloading NGINX web server and $app's services..."
|
||||
|
||||
for service_name in "${SERVICES_LIST[@]}"; do
|
||||
ynh_systemd_action --service_name="${app}-${service_name}" --action="start" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemctl --service="${app}-${service_name}" --action="start"
|
||||
|
||||
done
|
||||
|
||||
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"
|
||||
|
|
|
@ -1,42 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping systemd services..." --weight=1
|
||||
ynh_script_progression "Stopping systemd services..."
|
||||
|
||||
for service_name in "${SERVICES_LIST[@]}"; do
|
||||
ynh_systemd_action --service_name="${app}-${service_name}" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemctl --service="${app}-${service_name}" --action="stop"
|
||||
|
||||
done
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
ynh_script_progression "Ensuring downward compatibility..."
|
||||
|
||||
# Missing settings ?
|
||||
if [ -z "${public_key+x}" ]; then
|
||||
public_key=""
|
||||
ynh_app_setting_set --app="$app" --key=public_key --value="$public_key"
|
||||
ynh_app_setting_set --key=public_key --value="$public_key"
|
||||
fi
|
||||
|
||||
# Set default tenant to empty if needed
|
||||
if [ -z "${tenant+x}" ]; then
|
||||
tenant=""
|
||||
ynh_app_setting_set --app="$app" --key=tenant --value="$tenant"
|
||||
ynh_app_setting_set --key=tenant --value="$tenant"
|
||||
fi
|
||||
|
||||
# The .env needs db_password
|
||||
|
@ -46,8 +37,8 @@ db_pwd="${db_pwd:-$new_db_pwd}"
|
|||
if [[ -n "${document_path:-}" ]]; then
|
||||
# Renamed setting key
|
||||
document_dir="$document_path"
|
||||
ynh_app_setting_delete --app="$app" --key=document_path
|
||||
ynh_app_setting_set --app="$app" --key=document_dir --value="$document_dir"
|
||||
ynh_app_setting_delete --key=document_path
|
||||
ynh_app_setting_set --key=document_dir --value="$document_dir"
|
||||
fi
|
||||
|
||||
if [[ -n "${html_path:-}" ]]; then
|
||||
|
@ -55,33 +46,33 @@ if [[ -n "${html_path:-}" ]]; then
|
|||
# document dir has moved from html_path to data_dir, so set the variable accordingly
|
||||
if [[ ${document_dir} == ${html_path}* ]]; then
|
||||
document_dir=$data_dir/docs
|
||||
ynh_app_setting_set --app="$app" --key=document_dir --value="$document_dir"
|
||||
ynh_app_setting_set --key=document_dir --value="$document_dir"
|
||||
fi
|
||||
|
||||
# Migrate html_path to data_dir
|
||||
mv "$html_path/index.html" "$html_path/docs" "$data_dir"
|
||||
old_doc_dir="$html_path/docs"
|
||||
ynh_secure_remove --file="$html_path"
|
||||
ynh_app_setting_delete --app="$app" --key=html_path
|
||||
ynh_safe_rm "$html_path"
|
||||
ynh_app_setting_delete --key=html_path
|
||||
# FIXME: other settings
|
||||
|
||||
chmod -R o-rwx "$data_dir"
|
||||
chown -R "$app:www-data" "$data_dir"
|
||||
|
||||
# Update the path in .env file
|
||||
ynh_backup_if_checksum_is_different --file="$install_dir/.env"
|
||||
ynh_replace_string --match_string="$old_doc_dir" --replace_string="$document_dir" --target_file="$install_dir/.env"
|
||||
ynh_store_file_checksum --file="$install_dir/.env"
|
||||
ynh_backup_if_checksum_is_different "$install_dir/.env"
|
||||
ynh_replace --match="$old_doc_dir" --replace="$document_dir" --file="$install_dir/.env"
|
||||
ynh_store_file_checksum "$install_dir/.env"
|
||||
|
||||
fi
|
||||
|
||||
# Recalculate the document_url if it was incorrectly set before
|
||||
correct_document_url=$(append_uri "https://${domain}${path}" "docs")
|
||||
if [ "$correct_document_url" != "$document_url" ]; then
|
||||
ynh_script_progression --message="Updading url for documents" --weight=1
|
||||
ynh_script_progression "Updading url for documents"
|
||||
old_doc_url=$document_url
|
||||
document_url=$correct_document_url
|
||||
ynh_app_setting_set --app=$app --key=document_url --value=$document_url
|
||||
ynh_app_setting_set --key=document_url --value=$document_url
|
||||
|
||||
fi
|
||||
|
||||
|
@ -89,36 +80,36 @@ fi
|
|||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]; then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
# 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 "Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep ".env .ssh/authorized_keys restart_services.sh"
|
||||
ynh_setup_source --dest_dir="$install_dir" --full_replace --keep ".env .ssh/authorized_keys restart_services.sh"
|
||||
|
||||
# Always update .env
|
||||
ynh_add_config --template=".env" --destination="$install_dir/.env"
|
||||
ynh_config_add --template=".env" --destination="$install_dir/.env"
|
||||
|
||||
# FIXME: this should be handled by the core in the future
|
||||
# You may need to use chmod 600 instead of 400,
|
||||
# for example if the app is expected to be able to modify its own config
|
||||
chmod 400 "$install_dir/.env"
|
||||
chown $app:$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 | chmod 400 "$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:$app "$install_dir/.env"
|
||||
|
||||
fi
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:$app" "$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:$app" "$install_dir"
|
||||
#=================================================
|
||||
# Configure document storage
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring document storage..." --weight=1
|
||||
ynh_script_progression "Configuring document storage..."
|
||||
|
||||
ynh_add_config --template="index.html" --destination="$data_dir/index.html"
|
||||
ynh_config_add --template="index.html" --destination="$data_dir/index.html"
|
||||
|
||||
# Add the repository pages
|
||||
ynh_add_config --template="repository-next.json" --destination="$data_dir/repository-next.json"
|
||||
ynh_add_config --template="repository-stable.json" --destination="$data_dir/repository-stable.json"
|
||||
ynh_config_add --template="repository-next.json" --destination="$data_dir/repository-next.json"
|
||||
ynh_config_add --template="repository-stable.json" --destination="$data_dir/repository-stable.json"
|
||||
|
||||
chmod -R o-rwx "$data_dir"
|
||||
chown -R "$app:www-data" "$data_dir"
|
||||
|
@ -128,17 +119,17 @@ chown -R "$app:www-data" "$data_dir"
|
|||
#=================================================
|
||||
|
||||
if [ -n "$public_key" ]; then
|
||||
ynh_script_progression --message="Upgrading ssh access for dev..." --weight=1
|
||||
ynh_script_progression "Upgrading ssh access for dev..."
|
||||
_install_restart_script_and_sudoers
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPGRADE MongoDB
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading MongoDB..." --weight=1
|
||||
ynh_script_progression "Upgrading MongoDB..."
|
||||
|
||||
# Install the required version of Mongo
|
||||
ynh_install_mongo --mongo_version=$mongo_version
|
||||
ynh_install_mongo
|
||||
|
||||
# We are now assigning the user to the database, so update the user's rights
|
||||
for db_name in "${MONGO_DB_LIST[@]}"; do
|
||||
|
@ -148,30 +139,31 @@ done
|
|||
#=================================================
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Upgrading system configurations related to $app..."
|
||||
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
ynh_use_logrotate --non-append
|
||||
ynh_config_add_logrotate
|
||||
|
||||
for i in "${!SERVICES_LIST[@]}"; do
|
||||
service_name="${SERVICES_LIST[i]}"
|
||||
port="${PORT_LIST[i]}"
|
||||
ynh_add_systemd_config --service="${app}-${service_name}"
|
||||
ynh_config_add_systemd --service="${app}-${service_name}"
|
||||
yunohost service add "${app}-${service_name}" --description="Dont-code platform ${service_name} service" --log="/var/log/${app}/${service_name}-${app}.log"
|
||||
done
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting systemd services..." --weight=1
|
||||
ynh_script_progression "Starting systemd services..."
|
||||
|
||||
for service_name in "${SERVICES_LIST[@]}"; do
|
||||
ynh_systemd_action --service_name="${app}-${service_name}" --action="start" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemctl --service="${app}-${service_name}" --action="start"
|
||||
|
||||
done
|
||||
|
||||
#=================================================
|
||||
# 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