1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nextcloud_ynh.git synced 2024-09-03 19:55:57 +02:00

Fix typos, enhance comments, fix spacing

This commit is contained in:
Jimmy Monin 2017-09-05 21:42:51 +02:00
parent 42695427bb
commit 5a035dbed2
2 changed files with 216 additions and 216 deletions

View file

@ -70,48 +70,48 @@ is_url_handled() {
# Make the main steps to migrate an app to its fork.
#
# This helper have to be used for an app who need to migrate to a new name or a new fork.
# Like owncloud to nextcloud or zerobin to privatebin
# This helper has to be used for an app which needs to migrate to a new name or a new fork
# (like owncloud to nextcloud or zerobin to privatebin).
#
# This helper will move the files of an app to its new name
# Or recreate the things it can't moves.
# or recreate the things it can't move.
#
# To know which files it have to moves. You have to give a "migration file", stored in ../conf
# This file is simply a list of each file it have to moves.
# Except that you have to add all variables as variable. That mean you have to add $app instead of the real name of the app.
# And the same for domain or anything else like that.
# $app is espcially important because it's this variable which be used to identify the old place and the new one for each file.
# To specify which files it has to move, you have to create a "migration file", stored in ../conf
# This file is a simple list of each file it has to move,
# except that file names must reference the $app variable instead of the real name of the app,
# and every instance-specific variables (like $domain).
# $app is especially important because it's this variable which will be used to identify the old place and the new one for each file.
#
# If a database exist for this app, it will be dump then reload to a new database name, with a new user.
# You have to forward this change in the settings of your app.
# If a database exists for this app, it will be dumped and then imported in a newly created database, with a new name and new user.
# Don't forget you have to then apply these changes to application-specific settings (depends on the packaged application)
#
# Same things for an existing user, a new one will be create.
# But the old one can't be remove unless it's not using. See below.
# Same things for an existing user, a new one will be created.
# But the old one can't be removed unless it's not used. See below.
#
# If you have some dependencies for your app, it's possible to changed the fake package who manage them.
# You have to fill the variable $dependencies, and then a new fake package will be created and installed.
# And the old one will be removed.
# If you don't have a variable $dependencies, the helper can't know what's the dependencies of the app.
# If you have some dependencies for your app, it's possible to change the fake debian package which manages them.
# You have to fill the $dependencies variable, and then a new fake package will be created and installed,
# and the old one will be removed.
# If you don't have a $dependencies variable, the helper can't know what the app dependencies are.
#
# The settings.yml of the app will be modified as following:
# - finalpath will be changed, according to the new name. If it can find the old name in the existing $final_path
# - The checksum of php-fpm and nginx config file will be changed too.
# - If there a $db_name value, it will be changed.
# The app settings.yml will be modified as follows:
# - finalpath will be changed according to the new name (but only if the existing $final_path contains the old app name)
# - The checksums of php-fpm and nginx config files will be updated too.
# - If there is a $db_name value, it will be changed.
# - And, of course, the ID will be changed to the new name too.
#
# Finally, the $app variable will take the value of the new name.
# The helper will set the variable $migration_process at 1 if a migration has been proceed.
# The helper will set the $migration_process variable to 1 if a migration has been successfully handled.
#
# You have to handle all the migrations not done by this helper for your app, like configuration or special values in settings.yml
# Also, at the end of upgrade script, you have to add a post_migration script to handle all the things the helper can't do during YunoHost use your app.
# Especially remove the old user, move some hooks and remove the old configuration directory
# You have to handle by yourself all the migrations not done by this helper, like configuration or special values in settings.yml
# Also, at the end of the upgrade script, you have to add a post_migration script to handle all the things the helper can't do during YunoHost upgrade (mostly for permission reasons),
# especially remove the old user, move some hooks and remove the old configuration directory
# To launch this script, you have to move it elsewhere and start it after the upgrade script.
# `cp ../conf/$script_post_migration /tmp`
# `(cd /tmp; echo "/tmp/$script_post_migration" | at now + 2 minutes)`
#
# usage: ynh_handle_app_migration migration_id migration_list
# | arg: migration_id - ID from which to migrate
# | arg: migration_list - List of file to move.
# | arg: migration_list - File specifying every file to move (one file per line)
ynh_handle_app_migration () {
#=================================================
# LOAD SETTINGS
@ -160,7 +160,7 @@ ynh_handle_app_migration () {
#=================================================
# TODO Handle multi instance apps...
# Check that there not already an app installed for this id.
# Check that there is not already an app installed for this id.
(yunohost app list --installed -f "$new_app" | grep -q id) \
&& ynh_die "$new_app is already installed"
@ -173,17 +173,17 @@ ynh_handle_app_migration () {
# Build the list by removing blank lines and comment lines
sed '/^#.*\|^$/d' "../conf/$migration_list" > "$temp_migration_list"
# Check if there no files in the destination
# Check if there is no file in the destination
local file_to_move=""
while read file_to_move
do
# Replace all occurence of $app by $new_app in each file to move.
# Replace all occurences of $app by $new_app in each file to move.
local move_to_destination="${file_to_move//\$app/$new_app}"
test -e "$move_to_destination" && ynh_die "A file named $move_to_destination already exist."
test -e "$move_to_destination" && ynh_die "A file named $move_to_destination already exists."
done < "$temp_migration_list"
#=================================================
# COPY THE YUNOHOST SETTINGS FOR THIS APP
# COPY YUNOHOST SETTINGS FOR THIS APP
#=================================================
local settings_dir="/etc/yunohost/apps"
@ -191,9 +191,9 @@ ynh_handle_app_migration () {
# Replace the old id by the new one
ynh_replace_string "\(^id: .*\)$old_app" "\1$new_app" "$settings_dir/$new_app/settings.yml"
# INFO: There a special behavior with yunohost app setting
# INFO: There a special behavior with yunohost app setting:
# if the id given in argument does not match with the id
# stored in the config file. The config file will be purged.
# stored in the config file, the config file will be purged.
# That's why we use sed instead of app setting here.
# https://github.com/YunoHost/yunohost/blob/c6b5284be8da39cf2da4e1036a730eb5e0515096/src/yunohost/app.py#L1316-L1321
@ -206,12 +206,12 @@ ynh_handle_app_migration () {
# Replace all occurence of $app by $new_app in each file to move.
move_to_destination="$(eval echo "${file_to_move//\$app/$new_app}")"
local real_file_to_move="$(eval echo "${file_to_move//\$app/$old_app}")"
echo "Move the file $real_file_to_move to $move_to_destination" >&2
echo "Move file $real_file_to_move to $move_to_destination" >&2
mv "$real_file_to_move" "$move_to_destination"
done < "$temp_migration_list"
#=================================================
# UPDATE KNOWN FILES IN THE SETTINGS
# UPDATE SETTINGS KNOWN ENTRIES
#=================================================
# Replace nginx checksum
@ -230,7 +230,7 @@ ynh_handle_app_migration () {
db_pwd=$(ynh_app_setting_get $old_app mysqlpwd)
db_name=$(ynh_app_setting_get $old_app db_name)
# Check if a database exist before trying to move it
# Check if a database exists before trying to move it
local mysql_root_password=$(cat $MYSQL_ROOT_PWD_FILE)
if [ -n "$db_name" ] && mysqlshow -u root -p$mysql_root_password | grep -q "^| $db_name"
then
@ -273,7 +273,7 @@ ynh_handle_app_migration () {
#=================================================
# Check if a variable $dependencies exists
# If this variable doesn't exist, this part shall be manage in the upgrade script.
# If this variable doesn't exist, this part shall be managed in the upgrade script.
if [ -n "${dependencies:-}" ]
then
# Define the name of the package

View file

@ -65,7 +65,7 @@ then
}
fi
# Exit if an error occurs during the execution of the script
# Exit if an error occurs during the script execution
ynh_abort_if_errors
#=================================================
@ -81,10 +81,10 @@ then
db_name=$(ynh_app_setting_get $app db_name)
# Remove the old fake package for owncloud.
# Its name it's not regular, so the migration process can't remove it.
# Its name is specific, so the migration process can't remove it
ynh_package_autopurge owncloud-deps
# Change the database access in the config.
# Change the database access in the config
ynh_replace_string "\('dbname' =>\).*" "\1 '$db_name'," "$final_path/config/config.php"
ynh_replace_string "\('dbuser' =>\).*" "\1 '$db_name'," "$final_path/config/config.php"
@ -147,7 +147,7 @@ ynh_install_app_dependencies $dependencies
# SPECIFIC UPGRADE
#=================================================
# MAKE SEQUENTIAL UPGRADES FROM EACH MAJOR
# VERSION TO THE FOLLOWING
# VERSION TO THE NEXT ONE
#=================================================
# Load the last available version
@ -163,17 +163,17 @@ chown -R $app: "$final_path" "$datadir"
# Print the current version number of nextcloud
exec_occ -V
# While the current version is not the last version, do a upgrade
# While the current version is not the last version, do an upgrade
while [ "$last_version" != "$current_version" ]
do
# The major version is the first part of the version number
# major_version=${next_version%%.*}
# major_version=${next_version%%.*}
major_version=${last_version%%.*}
current_major_version=${current_version%%.*}
# If the current version have the same major version than the next.
# It's the last upgrade to do
# If the current version has the same major version than the next one,
# then it's the last upgrade to do
if [ "$major_version" -eq "$current_major_version" ]; then
current_major_version=last
fi
@ -201,7 +201,7 @@ do
cp -a "$final_path/config/config.php" "$tmpdir/config/config.php"
# Backup 3rd party applications from the current nextcloud
# But do not overwrite if there any upgrade
# But do not overwrite if there is any upgrade
cp -a --update "$final_path/apps" "$tmpdir/apps"
# Replace the old nextcloud by the new one
@ -327,7 +327,7 @@ done
# Warn about possible disabled apps
echo "Note that if you've installed some third-parties Nextcloud applications, \
they are probably disabled and you'll have to manually activate them again." >&2
they are probably disabled and you'll have to manually enable them again." >&2
#=================================================
# SETUP LOGROTATE