gitea hook scripts implicitly depends on bash #13160

Closed
opened 2025-11-02 10:33:09 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @eglic on GitHub (Jun 15, 2024).

Description

because of dockerhub fell down in china
i rebuild my docker images from scratch with gitea-1.22.0 and alpine-3.20.0-rootfs , but without bash

when push to remote , server rejected:

remote: env: can't execute 'bash': No such file or directory

so found the reason at:

[root@a9d18e012b0e:/var/git/data/gitea-repositories/arch/docker-alpine.git/hooks]# cat pre-receive
#!/usr/bin/env bash
# AUTO GENERATED BY GITEA, DO NOT MODIFY
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
data=$(cat)
exitcodes=""
hookname=$(basename $0)

Is there a way to automatically recognize or be compatible with bash and sh?

Gitea Version

1.22.0

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

2.34.1

Operating System

Apline

How are you running Gitea?

in my customer docker and frontend by nginx

Database

PostgreSQL

Originally created by @eglic on GitHub (Jun 15, 2024). ### Description because of dockerhub fell down in china i rebuild my docker images from scratch with gitea-1.22.0 and alpine-3.20.0-rootfs , but without bash when push to remote , server rejected: ``` remote: env: can't execute 'bash': No such file or directory ``` so found the reason at: ``` [root@a9d18e012b0e:/var/git/data/gitea-repositories/arch/docker-alpine.git/hooks]# cat pre-receive #!/usr/bin/env bash # AUTO GENERATED BY GITEA, DO NOT MODIFY ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ data=$(cat) exitcodes="" hookname=$(basename $0) ``` Is there a way to automatically recognize or be compatible with bash and sh? ### Gitea Version 1.22.0 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version 2.34.1 ### Operating System Apline ### How are you running Gitea? in my customer docker and frontend by nginx ### Database PostgreSQL
GiteaMirror added the issue/needs-feedback label 2025-11-02 10:33:09 -06:00
Author
Owner

@eeyrjmr commented on GitHub (Jun 15, 2024):

Can you regenerate the hooks?
All the hooks on my system point to sh not bash


[/var/lib/gitea/git/info/tips_tricks.git/hooks]# cat pre-receive
#!/usr/bin/env sh
# AUTO GENERATED BY GITEA, DO NOT MODIFY
data=$(cat)
exitcodes=""
hookname=$(basename $0)
GIT_DIR=${GIT_DIR:-$(dirname $0)/..}

for hook in ${GIT_DIR}/hooks/${hookname}.d/*; do
  test -x "${hook}" && test -f "${hook}" || continue
  echo "${data}" | "${hook}"
  exitcodes="${exitcodes} $?"
done

for i in ${exitcodes}; do
  [ ${i} -eq 0 ] || exit ${i}
done
@eeyrjmr commented on GitHub (Jun 15, 2024): Can you regenerate the hooks? All the hooks on my system point to sh not bash ``` [/var/lib/gitea/git/info/tips_tricks.git/hooks]# cat pre-receive #!/usr/bin/env sh # AUTO GENERATED BY GITEA, DO NOT MODIFY data=$(cat) exitcodes="" hookname=$(basename $0) GIT_DIR=${GIT_DIR:-$(dirname $0)/..} for hook in ${GIT_DIR}/hooks/${hookname}.d/*; do test -x "${hook}" && test -f "${hook}" || continue echo "${data}" | "${hook}" exitcodes="${exitcodes} $?" done for i in ${exitcodes}; do [ ${i} -eq 0 ] || exit ${i} done ```
Author
Owner

@wxiaoguang commented on GitHub (Jun 15, 2024):

Actually , there is a config option for it:

;[repository]
;; The script type this server supports. Usually this is `bash`, but some users report that only `sh` is available.
;SCRIPT_TYPE = bash

After setting it, you need to re-generate the Gitea hooks.

(It has been there for long time, TBH I do not know whether it still works nowadays)

@wxiaoguang commented on GitHub (Jun 15, 2024): Actually , there is a config option for it: ``` ;[repository] ;; The script type this server supports. Usually this is `bash`, but some users report that only `sh` is available. ;SCRIPT_TYPE = bash ``` After setting it, you need to re-generate the Gitea hooks. (It has been there for long time, TBH I do not know whether it still works nowadays)
Author
Owner

@eglic commented on GitHub (Jun 15, 2024):

SOGA!!!
how to re-generate the hook scripts?

@eglic commented on GitHub (Jun 15, 2024): SOGA!!! how to re-generate the hook scripts?
Author
Owner

@wxiaoguang commented on GitHub (Jun 15, 2024):

see the admin panel dashboard

@wxiaoguang commented on GitHub (Jun 15, 2024): see the admin panel dashboard
Author
Owner

@eglic commented on GitHub (Jun 15, 2024):

that's right.
thanks all

@eglic commented on GitHub (Jun 15, 2024): that's right. thanks all
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#13160