New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Packaging] restore php.ini if something bad happened #116
Conversation
if [ -e "${PHP_INI_FILE_PATH}${BACKUP_EXTENSION}" ] ; then | ||
echo "Reverted changes in the file ${PHP_INI_FILE_PATH}" | ||
mv -f "${PHP_INI_FILE_PATH}${BACKUP_EXTENSION}" "${PHP_INI_FILE_PATH}" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record, it uses the -f
flag, so it forces the move, are we happy with this approach?
packaging/post-install.sh
Outdated
@@ -37,7 +38,8 @@ function is_extension_installed() { | |||
################################################################################ | |||
#### Function add_extension_configuration_to_file ############################## | |||
function add_extension_configuration_to_file() { | |||
tee -a "$@" <<EOF | |||
cp -fa "$1" "${1}${BACKUP_EXTENSION}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-fa
flag should help to force if the file already exists and then it will populate the permissions too. Are we happy with this approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So after restore will the file have the same owner user/group and permissions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, that's the meaning for those flags, see below:
-a Same as -pPR options. Preserves structure and attributes of files but not directory structure.
-f If the destination file cannot be opened, remove it and create a new file, without prompting for confirmation regardless of its permissions. (The -f option overrides any
previous -n option.)
The target file is not unlinked before the copy. Thus, any existing access rights will be retained.
-p Cause cp to preserve the following attributes of each source file in the copy: modification time, access time, file flags, file mode, user ID, and group ID, as allowed by
permissions. Access Control Lists (ACLs) and Extended Attributes (EAs), including resource forks, will also be preserved.
If the user ID and group ID cannot be preserved, no error message is displayed and the exit value is not altered.
If the source file has its set-user-ID bit on and the user ID cannot be preserved, the set-user-ID bit is not preserved in the copy's permissions. If the source file has
its set-group-ID bit on and the group ID cannot be preserved, the set-group-ID bit is not preserved in the copy's permissions. If the source file has both its set-user-ID
and set-group-ID bits on, and either the user ID or group ID cannot be preserved, neither the set-user-ID nor set-group-ID bits are preserved in the copy's permissions.
* upstream/master: Add ENVIRONMENT configuration option Change composer installation in docker (elastic#128) Add tests/APM_Agents_shared directory [packaging] support multiple PHP API (elastic#121) [Packaging] restore php.ini if something bad happened (elastic#116) [CI] Cosmetic changes in the stage names (elastic#115)
What
Let's restore the
php.ini
file if something bad happened. The restore should keep the file as used to be and also preserving the permissions.Tests
Then, it will fail if installing php.7.4 in in php7.2:
Then it will work when installing it in a php.version 7.4
Issues
Closes #112