-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
migrate database if app.ini found #5290
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
Changes from all commits
a161f18
670f44b
8caca61
e9469e6
81be951
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,14 @@ if [ "${USER}" != "git" ]; then | |
sed -i -e "s/AllowUsers git$/AllowUsers ${USER}/g" /etc/ssh/sshd_config | ||
fi | ||
|
||
if [ -z "${USER_GID}" ]; then | ||
USER_GID="`id -g ${USER}`" | ||
fi | ||
|
||
if [ -z "${USER_UID}" ]; then | ||
USER_UID="`id -u ${USER}`" | ||
fi | ||
|
||
## Change GID for USER? | ||
if [ -n "${USER_GID}" ] && [ "${USER_GID}" != "`id -g ${USER}`" ]; then | ||
sed -i -e "s/^${USER}:\([^:]*\):[0-9]*/${USER}:\1:${USER_GID}/" /etc/group | ||
|
@@ -22,6 +30,13 @@ for FOLDER in /data/gitea/conf /data/gitea/log /data/git /data/ssh; do | |
mkdir -p ${FOLDER} | ||
done | ||
|
||
if [ -f /data/gitea/conf/app.ini ]; then | ||
echo "Found app.ini config file, migrating database" | ||
chmod 644 /data/gitea/conf/app.ini | ||
chown -R ${USER_UID}:${USER_GID} /data/git /data/gitea | ||
su - ${USER} -c gitea migrate -c /data/gitea/conf/app.ini | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see these variables ( So I don't understand why they are undefined, i've There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original entry point script just checks for the variables and if they're there does something. That's why they're undefined. You may have to adjust it to define the variables if they're not there or empty. if [ -z "${USER_GID}" ]; then
USER_GID="`id -g ${USER}`"
fi And similarly for UID. Otherwise I'd be suspicious that the chown could choose the wrong UID and GID in cases were they were set explicitly - but I'd happily defer to more expert opinion on this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
if [ $# -gt 0 ]; then | ||
exec "$@" | ||
else | ||
|
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.
This will allow anyone with access to the server to read the
app.ini
, exposing any credentials (database, metrics, smtp).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... I guess you're right. I guess this should be
600
. In some ways this is not so bad because this for docker - you shouldn't have other users on it in any case, that's not the docker way.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.
Is there any reason to change the file 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.
Possibly not. If you've not set the
INSTALL_LOCK
setting in yourapp.ini
and you've got the wrong mode then you won't be able to use/install
. However I guess we shouldn't be being preventing people from shooting themselves in the foot like that. Pop a PR on if you're able otherwise I can when I'm next at a dev box. @techknowlogick do you agree that perhaps we shouldn't changing the mode here?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.
@pciavald What was your reasoning for changing the mode?