Skip to content

Fix upgrade.sh script error with su -c #19483

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

Merged
merged 5 commits into from
Apr 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion contrib/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# upgrade.sh 1.15.10
# giteahome=/opt/gitea giteaconf=$giteahome/app.ini upgrade.sh

# load environment variables from `giteaenv` when `giteaenv` exists.
[[ -f "$(dirname $0)/giteaenv" ]] && source "$(dirname $0)/giteaenv"

# apply variables from environment
: "${giteabin:="/usr/local/bin/gitea"}"
: "${giteahome:="/var/lib/gitea"}"
Expand All @@ -24,7 +27,8 @@

function giteacmd {
if [[ $sudocmd = "su" ]]; then
"$sudocmd" - "$giteauser" -c "$giteabin" --config "$giteaconf" --work-path "$giteahome" "$@"
# `-c` accept one string as argument.
"$sudocmd" - "$giteauser" -c "$giteabin --config $giteaconf --work-path $giteahome $@"
else
"$sudocmd" --user "$giteauser" "$giteabin" --config "$giteaconf" --work-path "$giteahome" "$@"
fi
Expand Down