-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add support for NFS backed config directories. #12
Conversation
…ate the uid when creating files, and we are unable to chown files, so we check if the correct permissions are set before attempting an operation (chown) that will fail.
entrypoint.sh
Outdated
fi | ||
CFG_DIR_UID=`ls -lnd "$APP_DATA" | awk 'NR==1 {print $3}'` | ||
CFG_DIR_GID=`ls -lnd "$APP_DATA" | awk 'NR==1 {print $4}'` | ||
if [ $APP_UID -ne $CFG_DIR_UID ] && [ $APP_GID -ne $CFG_DIR_GID ]; then |
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.
Can we adjust this to not parse human readable output:
if [ $(stat -c "%u:%g" ${APP_DATA}) != "${APP_UID:=0}:${APP_GID:=0}" ]; then
Also if we move the template copying below this test, we don't have to do assignment in all of the variables. (The :=0
bit..)
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.
From what I could find, using ls was the most portable solution to determining file permissions. stat has variable output across platforms whereas ls
does not.
We have to make a decision on portability vs. slightly different looking code. Your decision.
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.
That is a good point. At least busybox doesn't support format strings properly in stat, but considering that the image is built on Debian, we should be fine with using stat.
Also considering that we depend on external utilities anyway and we can't really run on a busybox environment, this should be a safe call in terms of portability as well.
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.
See new commit. We can't eliminate default value assignment from what I can see because it's possible that neither our conditions are met before finally attempting to launch python with gosu.
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.
If we moved the permission check before the file copying, that way the assignment is triggered with the check. But your new solution works well too, so looks good to me.
When this PR is ready, can you squash/combine into 1 commit. Also, for the amended commit message, I suggest split it like so...
Line 1 is the short commit title, then a blank line, then a more descriptive comment to accompany the title line, you get the point ;) |
Can you advise on the best way to approach this with specific git commands?
…On 13 July 2017 at 21:10, JackDandy ***@***.***> wrote:
Can you squash/combine this PR into 1 commit, also, a new hotfix was
pushed since this started so you will want to add that amendment before the
squash.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADX01x0qL5Eud4kgPVQIk-nvyrtTRF-Nks5sNnmdgaJpZM4OR3ak>
.
--
From George Hafiz
|
Rebasing needs a bit of practice before it feels natural, but the way it works is you take all the commits since the merge point and reorder or squash them into more clean commits. It can take a bit of time to get it right, but it helps keep the master repo clean. This is one of the more comprehensive documentations on rebasing: https://www.atlassian.com/git/tutorials/rewriting-history#git-rebase-i The TL;DR version is: git rebase -i origin/development (this is assuming that origin points to the upstream repo) You get a list of commits and instructions. You squash the commits into logical blocks and edit the commit messages to make sense (this happens during the rebase process after you selected the actions) Finally, when you are happy with the result you push the changes back to your branch. But since you have now altered the history, you need to force the push. git push --force |
I can squash it if you are both happy that the current state is complete. |
if [ ! -f ${APP_DATA}/config.ini ]; then | ||
cp /template/config.ini ${APP_DATA}/ | ||
exec gosu ${APP_DATA_UIDGID} cp /template/config.ini ${APP_DATA}/ |
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.
Hmm.. this exec
will actually prevent from rest of the script happening. exec
command replaces the current script with the command about to be run. Simply removing the exec
will fix the behavior
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.
Done.
Note to self: do not use github "squash" as it will remove original author of a feature branch, use "merge squash" instead.
The UID is impersonated when creating files, therefore, a check for correct permissions is done before attempting an operation that may fail e.g. a chown.