mirror of
https://github.com/YunoHost-Apps/dont-code_ynh.git
synced 2024-09-03 18:26:34 +02:00
continue port to manifestv2
This commit is contained in:
parent
50f19aabbb
commit
f1fddc0526
5 changed files with 132 additions and 515 deletions
|
@ -11,40 +11,11 @@ source ../settings/scripts/_common.sh
|
||||||
source ../settings/scripts/ynh_mongo_db__2
|
source ../settings/scripts/ynh_mongo_db__2
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MANAGE SCRIPT FAILURE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#REMOVEME? ynh_clean_setup () {
|
|
||||||
### Remove this function if there's nothing to clean before calling the remove script.
|
|
||||||
true
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
#REMOVEME? ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_print_info --message="Loading installation settings..."
|
|
||||||
|
|
||||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
|
||||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
#REMOVEME? html_path=$(ynh_app_setting_get --app=$app --key=html_path)
|
|
||||||
#REMOVEME? document_path=$(ynh_app_setting_get --app=$app --key=document_path)
|
|
||||||
#REMOVEME? public_key=$(ynh_app_setting_get --app=$app --key=public_key)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
ynh_print_info --message="Declaring files to be backed up..."
|
||||||
|
|
||||||
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
|
|
||||||
### to be backuped and not an actual copy of any file. The actual backup that
|
|
||||||
### creates and fill the archive with the files happens in the core after this
|
|
||||||
### script is called. Hence ynh_backups calls takes basically 0 seconds to run.
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -55,7 +26,7 @@ ynh_backup --src_path="$install_dir"
|
||||||
# BACKUP THE HTML AND DOCUMENT DIR
|
# BACKUP THE HTML AND DOCUMENT DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$html_path" --is_big
|
ynh_backup --src_path="$data_dir" --is_big
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
@ -66,12 +37,6 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC BACKUP
|
# SPECIFIC BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
if [ -n "$public_key" ]
|
|
||||||
then
|
|
||||||
ynh_backup --src_path="/etc/sudoers.d/$app-sudoers"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# BACKUP LOGROTATE
|
# BACKUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
@ -81,24 +46,23 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||||
# BACKUP SYSTEMD services
|
# BACKUP SYSTEMD services
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
for service_name in "${SERVICES_LIST[@]}"
|
for service_name in "${SERVICES_LIST[@]}"; do
|
||||||
do
|
|
||||||
ynh_backup --src_path="/etc/systemd/system/${app}-${service_name}.service"
|
ynh_backup --src_path="/etc/systemd/system/${app}-${service_name}.service"
|
||||||
done
|
done
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP VARIOUS FILES
|
# SPECIFIC BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
if [ -n "$public_key" ]; then
|
||||||
# ynh_backup --src_path="/etc/cron.d/$app"
|
ynh_backup --src_path="/etc/sudoers.d/$app-sudoers"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE MONGO DATABASES
|
# BACKUP THE MONGO DATABASES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Backing up the Mongo databases..."
|
ynh_print_info --message="Backing up the Mongo databases..."
|
||||||
|
|
||||||
for db_name in "${MONGO_DB_LIST[@]}"
|
for db_name in "${MONGO_DB_LIST[@]}"; do
|
||||||
do
|
|
||||||
ynh_mongo_dump_db --database=$db_name > ./dump-${db_name}.bson
|
ynh_mongo_dump_db --database=$db_name > ./dump-${db_name}.bson
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -9,69 +9,6 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RETRIEVE ARGUMENTS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
|
|
||||||
#REMOVEME? old_path=$YNH_APP_OLD_PATH
|
|
||||||
|
|
||||||
#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
|
|
||||||
#REMOVEME? new_path=$YNH_APP_NEW_PATH
|
|
||||||
|
|
||||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
||||||
|
|
||||||
#REMOVEME? # Needed for helper "ynh_add_nginx_config"
|
|
||||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
|
||||||
|
|
||||||
# Add settings here as needed by your application
|
|
||||||
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
|
||||||
#REMOVEME? port_ide=$(ynh_app_setting_get --app=$app --key=port_ide)
|
|
||||||
#REMOVEME? port_preview=$(ynh_app_setting_get --app=$app --key=port_preview)
|
|
||||||
#REMOVEME? port_project=$(ynh_app_setting_get --app=$app --key=port_project)
|
|
||||||
#REMOVEME? port_data=$(ynh_app_setting_get --app=$app --key=port_data)
|
|
||||||
#REMOVEME? html_path=$(ynh_app_setting_get --app=$app --key=html_path)
|
|
||||||
#REMOVEME? document_path=$(ynh_app_setting_get --app=$app --key=document_path)
|
|
||||||
#REMOVEME? document_url=$(ynh_app_setting_get --app=$app --key=document_url)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
|
|
||||||
|
|
||||||
# Backup the current version of the app
|
|
||||||
#REMOVEME? ynh_backup_before_upgrade
|
|
||||||
#REMOVEME? ynh_clean_setup () {
|
|
||||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
|
||||||
#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
|
||||||
|
|
||||||
# Restore it if the upgrade fails
|
|
||||||
#REMOVEME? ynh_restore_upgradebackup
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
#REMOVEME? ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#REMOVEME? change_domain=0
|
|
||||||
#REMOVEME? if [ "$old_domain" != "$new_domain" ]
|
|
||||||
then
|
|
||||||
#REMOVEME? change_domain=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#REMOVEME? change_path=0
|
|
||||||
#REMOVEME? if [ "$old_path" != "$new_path" ]
|
|
||||||
then
|
|
||||||
#REMOVEME? change_path=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -79,8 +16,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping systemd services..." --weight=1
|
ynh_script_progression --message="Stopping systemd services..." --weight=1
|
||||||
|
|
||||||
for service_name in "${SERVICES_LIST[@]}"
|
for service_name in "${SERVICES_LIST[@]}"; do
|
||||||
do
|
|
||||||
ynh_systemd_action --service_name="${app}-${service_name}" --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="${app}-${service_name}" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -91,30 +27,6 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
|
||||||
|
|
||||||
ynh_change_url_nginx_config
|
ynh_change_url_nginx_config
|
||||||
|
|
||||||
#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
|
||||||
|
|
||||||
# Change the path in the NGINX config file
|
|
||||||
if [ $change_path -eq 1 ]
|
|
||||||
then
|
|
||||||
# Make a backup of the original NGINX config file if modified
|
|
||||||
#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
|
||||||
# Set global variables for NGINX helper
|
|
||||||
#REMOVEME? domain="$old_domain"
|
|
||||||
#REMOVEME? path="$new_path"
|
|
||||||
# Create a dedicated NGINX config
|
|
||||||
#REMOVEME? ynh_add_nginx_config
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Change the domain for NGINX
|
|
||||||
if [ $change_domain -eq 1 ]
|
|
||||||
then
|
|
||||||
# Delete file checksum for the old conf file location
|
|
||||||
#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
|
|
||||||
#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
|
||||||
# Store file checksum for the new config file location
|
|
||||||
#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC MODIFICATIONS
|
# SPECIFIC MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -123,12 +35,11 @@ fi
|
||||||
ynh_script_progression --message="Updating .env configuration..."
|
ynh_script_progression --message="Updating .env configuration..."
|
||||||
|
|
||||||
new_document_url=$(append_uri "https://${new_domain}${new_path}" "docs")
|
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 --app="$app" --key=document_url --value="$new_document_url"
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different --file="$install_dir/.env"
|
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_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_store_file_checksum --file="$install_dir/.env"
|
||||||
document_url=new_document_url
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
|
@ -137,18 +48,10 @@ document_url=new_document_url
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting systemd services..." --weight=1
|
ynh_script_progression --message="Starting systemd services..." --weight=1
|
||||||
|
|
||||||
for service_name in "${SERVICES_LIST[@]}"
|
for service_name in "${SERVICES_LIST[@]}"; do
|
||||||
do
|
ynh_systemd_action --service_name="${app}-${service_name}" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name="${app}-${service_name}" --action="start" --log_path="/var/log/$app/$app.log"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
|
||||||
|
|
||||||
#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -21,6 +21,9 @@ ynh_setup_source --dest_dir="$install_dir"
|
||||||
chmod -R o-rwx "$install_dir"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R "$app:$app" "$install_dir"
|
chown -R "$app:$app" "$install_dir"
|
||||||
|
|
||||||
|
mkdir /var/log/$app
|
||||||
|
chown "$app:$app" /var/log/$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Configure document storage
|
# Configure document storage
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -63,10 +66,6 @@ if [ -n "$public_key" ]; then
|
||||||
chmod 700 "$install_dir/.ssh"
|
chmod 700 "$install_dir/.ssh"
|
||||||
chmod 600 "$install_dir/.ssh/authorized_keys"
|
chmod 600 "$install_dir/.ssh/authorized_keys"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# Create restart services file
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Enable restarting of services from ssh
|
# Enable restarting of services from ssh
|
||||||
ynh_add_config --template="restart-services.sh" --destination="$install_dir/restart-services.sh"
|
ynh_add_config --template="restart-services.sh" --destination="$install_dir/restart-services.sh"
|
||||||
chown "$app:$app" "$install_dir/restart-services.sh"
|
chown "$app:$app" "$install_dir/restart-services.sh"
|
||||||
|
|
185
scripts/restore
185
scripts/restore
|
@ -9,53 +9,8 @@
|
||||||
# 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 ../settings/scripts/ynh_mongo_db__2
|
source ../settings/scripts/ynh_mongo_db__2
|
||||||
source ../settings/scripts/ynh_install_java
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MANAGE SCRIPT FAILURE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#REMOVEME? ynh_clean_setup () {
|
|
||||||
#### Remove this function if there's nothing to clean before calling the remove script.
|
|
||||||
true
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
#REMOVEME? ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
||||||
|
|
||||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
|
||||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
|
||||||
#REMOVEME? db_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
|
||||||
#REMOVEME? html_path=$(ynh_app_setting_get --app=$app --key=html_path)
|
|
||||||
#REMOVEME? document_path=$(ynh_app_setting_get --app=$app --key=document_path)
|
|
||||||
#REMOVEME? public_key=$(ynh_app_setting_get --app=$app --key=public_key)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
|
||||||
|
|
||||||
#REMOVEME? test ! -d $install_dir \
|
|
||||||
|| ynh_die --message="There is already a directory: $install_dir "
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD RESTORATION STEPS
|
|
||||||
#=================================================
|
|
||||||
# RECREATE THE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
|
||||||
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --use_shell --groups="ssh.app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -63,141 +18,89 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$install_dir"
|
ynh_restore_file --origin_path="$install_dir"
|
||||||
|
|
||||||
# FIXME: this should be managed by the core in the future
|
|
||||||
# Here, as a packager, you may have to tweak the ownerhsip/permissions
|
|
||||||
# such that the appropriate users (e.g. maybe www-data) can access
|
|
||||||
# files in some cases.
|
|
||||||
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
|
|
||||||
# this will be treated as a security issue.
|
|
||||||
chmod 750 "$install_dir"
|
|
||||||
chmod -R o-rwx "$install_dir"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:$app "$install_dir"
|
chown -R $app:$app "$install_dir"
|
||||||
|
|
||||||
#Make sure the .ssh and files have the correct access rights
|
mkdir /var/log/$app
|
||||||
if [ -n "$public_key" ]
|
chown "$app:$app" /var/log/$app
|
||||||
then
|
|
||||||
chown -R $app:$app "$install_dir/.ssh"
|
|
||||||
chmod 700 "$install_dir/.ssh"
|
|
||||||
chmod 600 "$install_dir/.ssh/authorized_keys"
|
|
||||||
# Enable restart of services for the dont-code user
|
|
||||||
chown $app:$app "$install_dir/restart-services.sh"
|
|
||||||
chmod o-rwx,gu=rwx "$install_dir/restart-services.sh"
|
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/sudoers.d/$app-sudoers"
|
|
||||||
|
|
||||||
chown root:root "/etc/sudoers.d/$app-sudoers"
|
|
||||||
chmod o-rwx,gu=r "/etc/sudoers.d/$app-sudoers"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE DOCUMENTS DIRECTORY
|
# RESTORE THE DOCUMENTS DIRECTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the html directory..." --weight=1
|
ynh_script_progression --message="Restoring the document storage..." --weight=1
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$html_path" --not_mandatory
|
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
||||||
|
|
||||||
mkdir -p $document_path
|
mkdir -p $document_path
|
||||||
|
|
||||||
# FIXME: this should be managed by the core in the future
|
|
||||||
# Here, as a packager, you may have to tweak the ownerhsip/permissions
|
|
||||||
# such that the appropriate users (e.g. maybe www-data) can access
|
|
||||||
# files in some cases.
|
|
||||||
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
|
|
||||||
# this will be treated as a security issue.
|
|
||||||
chmod 750 "$html_path"
|
|
||||||
chmod -R o-rwx "$html_path"
|
chmod -R o-rwx "$html_path"
|
||||||
chown -R $app:www-data "$html_path"
|
chown -R $app:www-data "$html_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# ADD SSH ACCESS
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
chown -R "$app:$app" "$install_dir/.ssh"
|
||||||
|
chmod 700 "$install_dir/.ssh"
|
||||||
|
chmod 600 "$install_dir/.ssh/authorized_keys"
|
||||||
|
|
||||||
|
# Enable restart of services for the dont-code user
|
||||||
|
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_restore_file --origin_path="/etc/sudoers.d/$app-sudoers"
|
||||||
|
chown root:root "/etc/sudoers.d/$app-sudoers"
|
||||||
|
chmod o-rwx,gu=r "/etc/sudoers.d/$app-sudoers"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
# INSTALL MONGO
|
||||||
|
#=================================================
|
||||||
# Install the required version of Java
|
ynh_script_progression --message="Reinstalling MongoDB..." --weight=1
|
||||||
ynh_install_java --java_version=$java_version --jdk_type=jre
|
|
||||||
|
|
||||||
# Define and install dependencies
|
|
||||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
|
|
||||||
# Install the required version of Mongo
|
# Install the required version of Mongo
|
||||||
ynh_install_mongo --mongo_version=$mongo_version
|
ynh_install_mongo --mongo_version=$mongo_version
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE MONGO DATABASES
|
# RESTORE THE MONGO DATABASES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the Mongo databases..." --weight=1
|
ynh_script_progression --message="Restoring the Mongo databases..." --weight=1
|
||||||
|
|
||||||
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
|
||||||
ynh_mongo_setup_db --db_user=$db_user --db_name=${MONGO_DB_LIST[0]} --db_pwd=$db_pwd
|
ynh_mongo_setup_db --db_user=$db_user --db_name=${MONGO_DB_LIST[0]} --db_pwd=$db_pwd
|
||||||
|
|
||||||
for db_name in "${MONGO_DB_LIST[@]}"
|
for db_name in "${MONGO_DB_LIST[@]}"; do
|
||||||
do
|
ynh_mongo_restore_db --database="$db_name" < "./dump-${db_name}.bson"
|
||||||
ynh_mongo_restore_db --database="$db_name" < ./dump-${db_name}.bson
|
|
||||||
done
|
done
|
||||||
|
#=================================================
|
||||||
|
# RESTORE SYSTEM CONFIGURATIONS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||||
|
|
||||||
#=================================================
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
# RESTORE VARIOUS FILES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring various files..." --weight=1
|
|
||||||
|
|
||||||
# ynh_restore_file --origin_path="/etc/cron.d/$app"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE SYSTEMD
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
|
||||||
|
|
||||||
for service_name in "${SERVICES_LIST[@]}"
|
|
||||||
do
|
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/${app}-${service_name}.service"
|
|
||||||
systemctl enable "${app}-${service_name}.service" --quiet
|
|
||||||
done
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
|
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
mkdir --parents /var/log/$app
|
for service_name in "${SERVICES_LIST[@]}"; do
|
||||||
chown $app:adm /var/log/$app
|
ynh_restore_file --origin_path="/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"
|
||||||
# INTEGRATE SERVICES IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Integrating services in YunoHost..." --weight=1
|
|
||||||
|
|
||||||
for service_name in "${SERVICES_LIST[@]}"
|
|
||||||
do
|
|
||||||
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
|
|
||||||
|
|
||||||
for service_name in "${SERVICES_LIST[@]}"
|
|
||||||
do
|
|
||||||
ynh_systemd_action --service_name="${app}-${service_name}" --action="start" --log_path="/var/log/$app/$app.log"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
ynh_script_progression --message="Reloading NGINX web server and $app's services..." --weight=1
|
||||||
|
|
||||||
|
for service_name in "${SERVICES_LIST[@]}"; do
|
||||||
|
ynh_systemd_action --service_name="${app}-${service_name}" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
done
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
|
300
scripts/upgrade
300
scripts/upgrade
|
@ -8,57 +8,10 @@
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source ynh_mongo_db__2
|
source ynh_mongo_db__2
|
||||||
source ynh_install_java
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
||||||
|
|
||||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
|
||||||
#REMOVEME? port_ide=$(ynh_app_setting_get --app=$app --key=port_ide)
|
|
||||||
#REMOVEME? port_preview=$(ynh_app_setting_get --app=$app --key=port_preview)
|
|
||||||
#REMOVEME? port_project=$(ynh_app_setting_get --app=$app --key=port_project)
|
|
||||||
#REMOVEME? port_data=$(ynh_app_setting_get --app=$app --key=port_data)
|
|
||||||
#REMOVEME? db_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
|
||||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
|
||||||
#REMOVEME? document_path=$(ynh_app_setting_get --app=$app --key=document_path)
|
|
||||||
#REMOVEME? document_url=$(ynh_app_setting_get --app=$app --key=document_url)
|
|
||||||
#REMOVEME? html_path=$(ynh_app_setting_get --app=$app --key=html_path)
|
|
||||||
#REMOVEME? public_key=$(ynh_app_setting_get --app=$app --key=public_key)
|
|
||||||
|
|
||||||
PORT_LIST=($port_ide $port_preview $port_project $port_data)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK VERSION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
### This helper will compare the version of the currently installed app and the version of the upstream package.
|
|
||||||
### $upgrade_type can have 2 different values
|
|
||||||
### - UPGRADE_APP if the upstream app version has changed
|
|
||||||
### - UPGRADE_PACKAGE if only the YunoHost package has changed
|
|
||||||
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
|
|
||||||
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
|
||||||
|
|
||||||
# Backup the current version of the app
|
|
||||||
#REMOVEME? ynh_backup_before_upgrade
|
|
||||||
#REMOVEME? ynh_clean_setup () {
|
|
||||||
# Restore it if the upgrade fails
|
|
||||||
#REMOVEME? ynh_restore_upgradebackup
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
#REMOVEME? ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -66,209 +19,112 @@ upgrade_type=$(ynh_check_app_version_changed)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping systemd services..." --weight=1
|
ynh_script_progression --message="Stopping systemd services..." --weight=1
|
||||||
|
|
||||||
for service_name in "${SERVICES_LIST[@]}"
|
for service_name in "${SERVICES_LIST[@]}"; do
|
||||||
do
|
|
||||||
ynh_systemd_action --service_name="${app}-${service_name}" --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="${app}-${service_name}" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
done
|
done
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||||
|
|
||||||
# Create html_path if needed
|
if [[ -n "${html_path:-}" ]]; then
|
||||||
if [ -z "$html_path" ]; then
|
# Migrate html_path to data_dir
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
mv "$html_path/index.html" "$html_path/docs" "$data_dir"
|
||||||
html_path=/usr/share/nginx/html/$app
|
ynh_secure_remove --file="$html_path"
|
||||||
#REMOVEME? ynh_app_setting_set --app=$app --key=html_path --value=$html_path
|
ynh_app_setting_delete --app="$app" --key=html_path
|
||||||
mkdir --parents $html_path
|
# FIXME: other settings
|
||||||
|
|
||||||
chmod 750 "$html_path"
|
chmod -R o-rwx "$data_dir"
|
||||||
chmod -R o-rwx "$html_path"
|
chown -R "$app:www-data" "$data_dir"
|
||||||
chown -R $app:www-data "$html_path"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
|
||||||
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --use_shell --groups="ssh.app"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
||||||
then
|
|
||||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
|
||||||
ynh_setup_source --dest_dir="$install_dir"
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
# FIXME: this should be managed by the core in the future
|
|
||||||
# Here, as a packager, you may have to tweak the ownerhsip/permissions
|
|
||||||
# such that the appropriate users (e.g. maybe www-data) can access
|
|
||||||
# files in some cases.
|
|
||||||
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
|
|
||||||
# this will be treated as a security issue.
|
|
||||||
chmod 750 "$install_dir"
|
|
||||||
chmod -R o-rwx "$install_dir"
|
|
||||||
chown -R $app:$app "$install_dir"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPGRADE DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
|
||||||
|
|
||||||
# Install the required version of Java
|
|
||||||
ynh_install_java --java_version=$java_version --jdk_type=jre
|
|
||||||
|
|
||||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
|
|
||||||
# Install the required version of Mongo
|
|
||||||
ynh_install_mongo --mongo_version=$mongo_version
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
|
||||||
|
|
||||||
# Do we need to upgrade the status index ? Do it now as html_path variable is needed for nginx file
|
|
||||||
|
|
||||||
# Always Upgrade the status page
|
|
||||||
ynh_add_config --template="index.html" --destination="$html_path/index.html"
|
|
||||||
chmod 750 "$html_path/index.html"
|
|
||||||
chmod o-rwx "$html_path/index.html"
|
|
||||||
chown $app:www-data "$html_path/index.html"
|
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
|
||||||
ynh_add_nginx_config
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC UPGRADE
|
|
||||||
#=================================================
|
|
||||||
# Create document storage
|
|
||||||
#=================================================
|
|
||||||
# The document path has changed => Copy all the files
|
|
||||||
|
|
||||||
if [ "$document_path" != "/usr/share/nginx/html/$app/docs" ]; then
|
|
||||||
ynh_script_progression --message="Moving the document path to its new dir" --weight=8
|
|
||||||
|
|
||||||
old_doc_path=$document_path
|
|
||||||
document_path=/usr/share/nginx/html/$app/docs
|
|
||||||
test ! -e "$document_path" || ynh_die --message="This path already contains a folder"
|
|
||||||
mkdir --parents $document_path
|
|
||||||
|
|
||||||
mv $old_doc_path/* $document_path/*
|
|
||||||
|
|
||||||
ynh_secure_remove --file=$old_doc_path
|
|
||||||
#REMOVEME? ynh_app_setting_set --app=$app --key=document_path --value=$document_path
|
|
||||||
|
|
||||||
chmod 750 "$document_path"
|
|
||||||
chmod -R o-rwx "$document_path"
|
|
||||||
chown -R $app:www-data "$document_path"
|
|
||||||
|
|
||||||
# Update the path in .env file
|
|
||||||
ynh_backup_if_checksum_is_different --file="$install_dir/.env"
|
|
||||||
ynh_replace_string --match_string="$old_doc_path" --replace_string="$document_path" --target_file="$install_dir/.env"
|
|
||||||
ynh_store_file_checksum --file="$install_dir/.env"
|
|
||||||
|
|
||||||
|
# Update the path in .env file
|
||||||
|
ynh_backup_if_checksum_is_different --file="$install_dir/.env"
|
||||||
|
ynh_replace_string --match_string="$old_doc_path" --replace_string="$document_path" --target_file="$install_dir/.env"
|
||||||
|
ynh_store_file_checksum --file="$install_dir/.env"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Regenerate the .env file if the document_url was incorrectly set before
|
# Regenerate the .env file if the document_url was incorrectly set before
|
||||||
correct_document_url=$(append_uri "https://${domain}${path}" "docs")
|
correct_document_url=$(append_uri "https://${domain}${path}" "docs")
|
||||||
if [ "$correct_document_url" != "$document_url" ]; then
|
if [ "$correct_document_url" != "$document_url" ]; then
|
||||||
ynh_script_progression --message="Updading url for documents" --weight=1
|
ynh_script_progression --message="Updading url for documents" --weight=1
|
||||||
old_doc_url=$document_url
|
old_doc_url=$document_url
|
||||||
document_url=$correct_document_url
|
document_url=$correct_document_url
|
||||||
ynh_app_setting_set --app=$app --key=document_url --value=$document_url
|
ynh_app_setting_set --app=$app --key=document_url --value=$document_url
|
||||||
|
|
||||||
ynh_add_config --template=".env" --destination="$install_dir/.env"
|
ynh_add_config --template=".env" --destination="$install_dir/.env"
|
||||||
|
|
||||||
# FIXME: this should be handled by the core in the future
|
# FIXME: this should be handled by the core in the future
|
||||||
# You may need to use chmod 600 instead of 400,
|
# 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
|
# for example if the app is expected to be able to modify its own config
|
||||||
chmod 400 "$install_dir/.env"
|
chmod 400 "$install_dir/.env"
|
||||||
chown $app:$app "$install_dir/.env"
|
chown $app:$app "$install_dir/.env"
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$public_key" ] && [ ! -f "$install_dir/restart-services.sh" ];
|
|
||||||
then
|
|
||||||
ynh_script_progression --message="Upgrading ssh access for dev..." --weight=1
|
|
||||||
|
|
||||||
# Enable restarting of services from ssh
|
|
||||||
ynh_add_config --template="restart-services.sh" --destination="$install_dir/restart-services.sh"
|
|
||||||
|
|
||||||
# Enable root ownership to be able to call systemctl
|
|
||||||
chown $app:$app "$install_dir/restart-services.sh"
|
|
||||||
chmod o-rwx,gu=rwx "$install_dir/restart-services.sh"
|
|
||||||
|
|
||||||
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"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
# ynh_script_progression --message="Updating a configuration file..." --weight=1
|
|
||||||
|
|
||||||
### Same as during install
|
if [ "$upgrade_type" == "UPGRADE_APP" ]; then
|
||||||
###
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||||
### The file will automatically be backed-up if it's found to be manually modified (because
|
|
||||||
### ynh_add_config keeps track of the file's checksum)
|
|
||||||
|
|
||||||
# ynh_add_config --template="some_config_file" --destination="$install_dir/some_config_file"
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
ynh_setup_source --dest_dir="$install_dir"
|
||||||
|
fi
|
||||||
|
|
||||||
# FIXME: this should be handled by the core in the future
|
chmod -R o-rwx "$install_dir"
|
||||||
# You may need to use chmod 600 instead of 400,
|
chown -R "$app:$app" "$install_dir"
|
||||||
# for example if the app is expected to be able to modify its own config
|
|
||||||
# chmod 400 "$install_dir/some_config_file"
|
|
||||||
# chown $app:$app "$install_dir/some_config_file"
|
|
||||||
|
|
||||||
### For more complex cases where you want to replace stuff using regexes,
|
|
||||||
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
|
|
||||||
### When doing so, you also need to manually call ynh_store_file_checksum
|
|
||||||
###
|
|
||||||
### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$install_dir/some_config_file"
|
|
||||||
### ynh_store_file_checksum --file="$install_dir/some_config_file"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# Configure document storage
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
ynh_script_progression --message="Configuring document storage..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated systemd config for each service
|
ynh_add_config --template="index.html" --destination="$data_dir/index.html"
|
||||||
|
|
||||||
service_list_length=${#SERVICES_LIST[@]}
|
chmod o-rwx "$data_dir/index.html"
|
||||||
for (( j=0; j<${service_list_length}; j++ ))
|
chown "$app:www-data" "$data_dir/index.html"
|
||||||
do
|
|
||||||
service_name=${SERVICES_LIST[$j]}
|
|
||||||
port=${PORT_LIST[$j]}
|
|
||||||
ynh_add_systemd_config --service="${app}-${service_name}"
|
|
||||||
done
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# ADD SSH ACCESS
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
|
||||||
|
|
||||||
# Use logrotate to manage app-specific logfile(s)
|
if [ -n "$public_key" ]; then
|
||||||
|
ynh_script_progression --message="Upgrading ssh access for dev..." --weight=1
|
||||||
|
|
||||||
|
# Enable restarting of services from ssh
|
||||||
|
ynh_add_config --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"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE MongoDB
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading MongoDB..." --weight=1
|
||||||
|
|
||||||
|
# Install the required version of Mongo
|
||||||
|
ynh_install_mongo --mongo_version=$mongo_version
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REAPPLY SYSTEM CONFIGURATIONS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||||
|
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
ynh_use_logrotate --non-append
|
ynh_use_logrotate --non-append
|
||||||
|
|
||||||
#=================================================
|
for i in "${!SERVICES_LIST[@]}"; do
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
service_name="${SERVICES_LIST[i]}"
|
||||||
#=================================================
|
port="${PORT_LIST[i]}"
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
ynh_add_systemd_config --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"
|
||||||
for service_name in "${SERVICES_LIST[@]}"
|
|
||||||
do
|
|
||||||
yunohost service add "${app}-${service_name}" --description="Dont-code platform ${service_name} service" --log="/var/log/${app}/${service_name}-${app}.log"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -276,18 +132,10 @@ done
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting systemd services..." --weight=1
|
ynh_script_progression --message="Starting systemd services..." --weight=1
|
||||||
|
|
||||||
for service_name in "${SERVICES_LIST[@]}"
|
for service_name in "${SERVICES_LIST[@]}"; do
|
||||||
do
|
ynh_systemd_action --service_name="${app}-${service_name}" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name="${app}-${service_name}" --action="start" --log_path="/var/log/$app/$app.log"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
|
||||||
|
|
||||||
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue