Skip to content
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

Allow Gitea to run on POSIX shell (not relying on bash) #4897

Closed
2 of 7 tasks
tinxx opened this issue Sep 9, 2018 · 8 comments
Closed
2 of 7 tasks

Allow Gitea to run on POSIX shell (not relying on bash) #4897

tinxx opened this issue Sep 9, 2018 · 8 comments
Labels
issue/stale type/enhancement An improvement of existing functionality

Comments

@tinxx
Copy link

tinxx commented Sep 9, 2018

  • Gitea version (or commit ref): 1.5.1
  • Git version: 2.18.0
  • Operating system: Alpine Linux v3.8
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

As I found out during working around issues described in #4894, Gitea relies on bash being present on host system.
I think it should be beneficial to evaluate if it is possible to make Gitea compatible with POSIX compliant shells. This would drop Bash dependency and make Gitea more flexible and portable.

@SagePtr
Copy link
Contributor

SagePtr commented Sep 9, 2018

Did you try setting SCRIPT_TYPE in gitea configuration?
After doing this, do "Resynchronize pre-receive, update and post-receive hooks of all repositories." in gitea admin panel

@tinxx
Copy link
Author

tinxx commented Sep 9, 2018

I tried it with this in my app.ini:

[repository]
SCRIPT_TYPE = sh

Still, with busybox sh as user's login shell, I get this when pushing to repo:

halt: unrecognized option: c
BusyBox v1.28.4 (2018-07-17 15:21:40 UTC) multi-call binary.

Usage: halt [-d DELAY] [-n] [-f]

Halt the system

	-d SEC	Delay interval
	-n	Do not sync
	-f	Force (don't go through init)
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

And with dash I get this:

Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 530 bytes | 530.00 KiB/s, done.
Total 5 (delta 3), reused 0 (delta 0)
remote: env: can't execute 'bash': No such file or directory
To ssh:https://domain.tld/user/repo.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh:https://domain.tld/user/repo.git

@SagePtr
Copy link
Contributor

SagePtr commented Sep 9, 2018

Resynchronize hooks (after setting dash to SCRIPT_TYPE) and try with dash again. If same problem occurs - check if hooks really have dash in their first line, if not - this seems to be hook resynchronization problem.

@tinxx
Copy link
Author

tinxx commented Sep 9, 2018

Oh, I missed that for dash. It does run on dash now, but still no luck on busybox.
Thanks for the assistance!

EDIT:
I still would suggest to look into supporting busybox' sh.

What is the benefit in relying on bash by default if Gitea is able to use sh instead? Why not use sh as a default?

@SagePtr
Copy link
Contributor

SagePtr commented Sep 9, 2018

Tested for both docker alpine:3.8 (under Ubuntu 18) and alpine-virt-3.8.0-x86_64.iso (under Virtualbox) - for both of them gitea 1.5.1 worked without problems under busybox sh (in both cases I used SCRIPT_TYPE = sh to make sh used in hooks). Checked with both openssh and internal gitea ssh server, had no problem with git push at all. Even tried auto-rejecting hook - and it printed message well.
Could not reproduce your "halt: unrecognized option: c" result.

@SagePtr
Copy link
Contributor

SagePtr commented Sep 9, 2018

Still I think gitea install script should check whenever bash is available and default to sh if not, or simply add script interpreter field to installation form.

@lafriks lafriks added the type/enhancement An improvement of existing functionality label Sep 9, 2018
@stale
Copy link

stale bot commented Jan 11, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label Jan 11, 2019
@stale
Copy link

stale bot commented Feb 21, 2019

This issue has been automatically closed because of inactivity. You can re-open it if needed.

@stale stale bot closed this as completed Feb 21, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/stale type/enhancement An improvement of existing functionality
Projects
None yet
Development

No branches or pull requests

3 participants