You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

command-line.en-us.md 8.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. ---
  2. date: "2017-01-01T16:00:00+02:00"
  3. title: "Usage: Command Line"
  4. slug: "command-line"
  5. weight: 10
  6. toc: true
  7. draft: false
  8. menu:
  9. sidebar:
  10. parent: "usage"
  11. name: "Command Line"
  12. weight: 10
  13. identifier: "command-line"
  14. ---
  15. ## Command Line
  16. ### Usage
  17. `gitea [global options] command [command or global options] [arguments...]`
  18. ### Global options
  19. All global options can be placed at the command level.
  20. - `--help`, `-h`: Show help text and exit. Optional.
  21. - `--version`, `-v`: Show version and exit. Optional. (example: `Gitea version 1.1.0+218-g7b907ed built with: bindata, sqlite`).
  22. - `--custom-path path`, `-C path`: Location of the Gitea custom folder. Optional. (default: $PWD/custom).
  23. - `--config path`, `-c path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
  24. ### Commands
  25. #### web
  26. Starts the server:
  27. - Options:
  28. - `--port number`, `-p number`: Port number. Optional. (default: 3000). Overrides configuration file.
  29. - `--pid path`, `-P path`: Pidfile path. Optional.
  30. - Examples:
  31. - `gitea web`
  32. - `gitea web --port 80`
  33. - `gitea web --config /etc/gitea.ini --pid /var/run/gitea.pid`
  34. - Notes:
  35. - Gitea should not be run as root. To bind to a port below 1000, you can use setcap on
  36. Linux: `sudo setcap 'cap_net_bind_service=+ep' /path/to/gitea`. This will need to be
  37. redone every time you update Gitea.
  38. #### admin
  39. Admin operations:
  40. - Commands:
  41. - `create-user`
  42. - Options:
  43. - `--name value`: Username. Required. As of gitea 1.9.0, use the `--username` flag instead.
  44. - `--username value`: Username. Required. New in gitea 1.9.0.
  45. - `--password value`: Password. Required.
  46. - `--email value`: Email. Required.
  47. - `--admin`: If provided, this makes the user an admin. Optional.
  48. - `--must-change-password`: If provided, the created user will be required to choose a newer password after
  49. the initial login. Optional. (default: true).
  50. - ``--random-password``: If provided, a randomly generated password will be used as the password of
  51. the created user. The value of `--password` will be discarded. Optional.
  52. - `--random-password-length`: If provided, it will be used to configure the length of the randomly
  53. generated password. Optional. (default: 12)
  54. - Examples:
  55. - `gitea admin create-user --username myname --password asecurepassword --email me@example.com`
  56. - `change-password`
  57. - Options:
  58. - `--username value`, `-u value`: Username. Required.
  59. - `--password value`, `-p value`: New password. Required.
  60. - Examples:
  61. - `gitea admin change-password --username myname --password asecurepassword`
  62. - `regenerate`
  63. - Options:
  64. - `hooks`: Regenerate git-hooks for all repositories
  65. - `keys`: Regenerate authorized_keys file
  66. - Examples:
  67. - `gitea admin regenerate hooks`
  68. - `gitea admin regenerate keys`
  69. - `auth`:
  70. - `list`:
  71. - Description: lists all external authentication sources that exist
  72. - Examples:
  73. - `gitea admin auth list`
  74. - `delete`:
  75. - Options:
  76. - `--id`: ID of source to be deleted. Required.
  77. - Examples:
  78. - `gitea admin auth delete --id 1`
  79. - `add-oauth`:
  80. - Options:
  81. - `--name`: Application Name.
  82. - `--provider`: OAuth2 Provider.
  83. - `--key`: Client ID (Key).
  84. - `--secret`: Client Secret.
  85. - `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
  86. - `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
  87. - `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
  88. - `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
  89. - `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
  90. - `--custom-email-url`: Use a custom Email URL (option for GitHub).
  91. - Examples:
  92. - `gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE`
  93. - `update-oauth`:
  94. - Options:
  95. - `--id`: ID of source to be updated. Required.
  96. - `--name`: Application Name.
  97. - `--provider`: OAuth2 Provider.
  98. - `--key`: Client ID (Key).
  99. - `--secret`: Client Secret.
  100. - `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
  101. - `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
  102. - `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
  103. - `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
  104. - `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
  105. - `--custom-email-url`: Use a custom Email URL (option for GitHub).
  106. - Examples:
  107. - `gitea admin auth update-oauth --id 1 --name external-github-updated`
  108. #### cert
  109. Generates a self-signed SSL certificate. Outputs to `cert.pem` and `key.pem` in the current
  110. directory and will overwrite any existing files.
  111. - Options:
  112. - `--host value`: Comma seperated hostnames and ips which this certificate is valid for.
  113. Wildcards are supported. Required.
  114. - `--ecdsa-curve value`: ECDSA curve to use to generate a key. Optional. Valid options
  115. are P224, P256, P384, P521.
  116. - `--rsa-bits value`: Size of RSA key to generate. Optional. Ignored if --ecdsa-curve is
  117. set. (default: 2048).
  118. - `--start-date value`: Creation date. Optional. (format: `Jan 1 15:04:05 2011`).
  119. - `--duration value`: Duration which the certificate is valid for. Optional. (default: 8760h0m0s)
  120. - `--ca`: If provided, this cert generates it's own certificate authority. Optional.
  121. - Examples:
  122. - `gitea cert --host git.example.com,example.com,www.example.com --ca`
  123. #### dump
  124. Dumps all files and databases into a zip file. Outputs into a file like `gitea-dump-1482906742.zip`
  125. in the current directory.
  126. - Options:
  127. - `--file name`, `-f name`: Name of the dump file with will be created. Optional. (default: gitea-dump-[timestamp].zip).
  128. - `--tempdir path`, `-t path`: Path to the temporary directory used. Optional. (default: /tmp).
  129. - `--skip-repository`, `-R`: Skip the repository dumping. Optional.
  130. - `--database`, `-d`: Specify the database SQL syntax. Optional.
  131. - `--verbose`, `-V`: If provided, shows additional details. Optional.
  132. - Examples:
  133. - `gitea dump`
  134. - `gitea dump --verbose`
  135. #### generate
  136. Generates random values and tokens for usage in configuration file. Useful for generating values
  137. for automatic deployments.
  138. - Commands:
  139. - `secret`:
  140. - Options:
  141. - `INTERNAL_TOKEN`: Token used for an internal API call authentication.
  142. - `JWT_SECRET`: LFS & OAUTH2 JWT authentication secret (LFS_JWT_SECRET is aliased to this option for backwards compatibility).
  143. - `SECRET_KEY`: Global secret key.
  144. - Examples:
  145. - `gitea generate secret INTERNAL_TOKEN`
  146. - `gitea generate secret JWT_SECRET`
  147. - `gitea generate secret SECRET_KEY`
  148. #### keys
  149. Provides an SSHD AuthorizedKeysCommand. Needs to be configured in the sshd config file:
  150. ```ini
  151. ...
  152. # The value of -e and the AuthorizedKeysCommandUser should match the
  153. # username running gitea
  154. AuthorizedKeysCommandUser git
  155. AuthorizedKeysCommand /path/to/gitea keys -e git -u %u -t %t -k %k
  156. ```
  157. The command will return the appropriate authorized_keys line for the
  158. provided key. You should also set the value
  159. `SSH_CREATE_AUTHORIZED_KEYS_FILE=false` in the `[server]` section of
  160. `app.ini`.
  161. NB: opensshd requires the gitea program to be owned by root and not
  162. writable by group or others. The program must be specified by an absolute
  163. path.