mirror of
https://github.com/YunoHost-Apps/pleroma_ynh.git
synced 2024-09-03 20:15:59 +02:00
Merge pull request #100 from YunoHost-Apps/example_ynh
Applying example_ynh
This commit is contained in:
commit
29f881a6b0
5 changed files with 25 additions and 13 deletions
|
@ -110,16 +110,19 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# MODIFY A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Modifying a config file..."
|
||||||
|
|
||||||
ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$final_path/$app/config/prod.secret.exs"
|
config="/etc/$app/config.exs"
|
||||||
|
ynh_backup_if_checksum_is_different --file="$config"
|
||||||
|
ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$config"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE THE CONFIG FILE CHECKSUM
|
# STORE THE CONFIG FILE CHECKSUM
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Storing the config file checksum..."
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different --file="$final_path/$app/config/prod.secret.exs"
|
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
ynh_store_file_checksum --file="$final_path/$app/config/prod.secret.exs"
|
ynh_store_file_checksum --file="$config"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
|
|
|
@ -126,6 +126,7 @@ ynh_print_info --message="Configuring nginx web server..."
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
if [ $cache -eq 1 ]
|
if [ $cache -eq 1 ]
|
||||||
then
|
then
|
||||||
cp -rf "../conf/cache.conf" "/etc/nginx/conf.d/$app-cache.conf"
|
cp -rf "../conf/cache.conf" "/etc/nginx/conf.d/$app-cache.conf"
|
||||||
|
@ -151,7 +152,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE THE DATA DIRECTORY
|
# CREATE THE DATA DIRECTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Create the data directory..."
|
ynh_print_info --message="Creating the data directory..."
|
||||||
|
|
||||||
# Define app's data directory
|
# Define app's data directory
|
||||||
datadir="/home/yunohost.app/${app}"
|
datadir="/home/yunohost.app/${app}"
|
||||||
|
@ -168,8 +169,9 @@ chown -R "$app":"$app" "$datadir"
|
||||||
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
|
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# CREATE THE CONFIG DIRECTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Creating the config directory..."
|
||||||
|
|
||||||
mkdir -p /etc/$app
|
mkdir -p /etc/$app
|
||||||
chown -R $app /etc/$app
|
chown -R $app /etc/$app
|
||||||
|
@ -187,6 +189,7 @@ ynh_add_systemd_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# MAKE SETUP
|
# MAKE SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Making setup..."
|
||||||
|
|
||||||
# Give permission to the final_path
|
# Give permission to the final_path
|
||||||
chown -R "$app":"$app" "$final_path"
|
chown -R "$app":"$app" "$final_path"
|
||||||
|
@ -226,6 +229,7 @@ popd
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE THE CONFIG FILE CHECKSUM
|
# STORE THE CONFIG FILE CHECKSUM
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Storing the config file checksum..."
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
# Calculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum --file="$config"
|
ynh_store_file_checksum --file="$config"
|
||||||
|
|
|
@ -88,7 +88,7 @@ ynh_secure_remove --file="/etc/nginx/conf.d/$app-cache.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
# CLOSE A PORT
|
# CLOSE A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Closing a port"
|
ynh_print_info --message="Closing a port..."
|
||||||
|
|
||||||
if yunohost firewall list | grep -q "\- $port$"
|
if yunohost firewall list | grep -q "\- $port$"
|
||||||
then
|
then
|
||||||
|
@ -101,12 +101,13 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DIRECTORIES
|
# REMOVE DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Removing directories..."
|
||||||
|
|
||||||
# Remove the config directory securely
|
# Remove the config directory securely
|
||||||
ynh_secure_remove "/etc/$app/"
|
ynh_secure_remove --file="/etc/$app"
|
||||||
|
|
||||||
# Remove the data directory securely
|
# Remove the data directory securely
|
||||||
ynh_secure_remove "$datadir/"
|
ynh_secure_remove --file="$datadir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
|
|
@ -53,8 +53,10 @@ test ! -d $final_path \
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Restoring the nginx configuration..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
if [ $cache -eq 1 ]
|
if [ $cache -eq 1 ]
|
||||||
then
|
then
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$app-cache.conf"
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$app-cache.conf"
|
||||||
|
@ -88,7 +90,7 @@ chown -R "$app":"$app" "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DATA DIRECTORY
|
# RECREATE THE DATA DIRECTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Recreate the data directory..."
|
ynh_print_info --message="Recreating the data directory..."
|
||||||
|
|
||||||
# Create app folders
|
# Create app folders
|
||||||
mkdir -p "$datadir/"
|
mkdir -p "$datadir/"
|
||||||
|
|
|
@ -37,6 +37,7 @@ registration=$(ynh_app_setting_get --app=$app --key=registration)
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Checking version..."
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
|
@ -94,6 +95,7 @@ apt-key del A14F4FCA
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION NUMBER
|
# CHECK VERSION NUMBER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Checking version number..."
|
||||||
|
|
||||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||||
sleep 60
|
sleep 60
|
||||||
|
@ -110,9 +112,9 @@ ynh_print_info --message="Backing up the app before upgrading (may take a while)
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
|
ynh_clean_check_starting
|
||||||
# restore it if the upgrade fails
|
# restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
ynh_restore_upgradebackup
|
||||||
ynh_clean_check_starting
|
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
@ -129,9 +131,10 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE TO OTP RELEASE
|
# UPGRADE TO OTP RELEASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Upgrading to OTP release..."
|
|
||||||
|
|
||||||
if ynh_version_gt "1.1.1~ynh1" "${previous_version}" ; then
|
if ynh_version_gt "1.1.1~ynh1" "${previous_version}" ; then
|
||||||
|
ynh_print_info --message="Upgrading to OTP release..."
|
||||||
|
|
||||||
# Define app's data directory
|
# Define app's data directory
|
||||||
datadir="/home/yunohost.app/${app}"
|
datadir="/home/yunohost.app/${app}"
|
||||||
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
|
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
|
||||||
|
@ -161,13 +164,12 @@ if ynh_version_gt "1.1.1~ynh1" "${previous_version}" ; then
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different --file="$config"
|
ynh_backup_if_checksum_is_different --file="$config"
|
||||||
|
|
||||||
rm -r $final_path/$app/*
|
ynh_secure_remove --file="$final_path/$app"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Upgrading source files..."
|
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
|
|
Loading…
Add table
Reference in a new issue