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

195 lines
8.5 KiB

  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 options] [arguments...]`
  18. ### Global options
  19. - `--help`, `-h`: Show help text and exit. Optional. This can be used with any of the
  20. subcommands to see help text for it.
  21. - `--version`, `-v`: Show version and exit. Optional. (example: `Gitea version
  22. 1.1.0+218-g7b907ed built with: bindata, sqlite`).
  23. ### Commands
  24. #### web
  25. Starts the server:
  26. - Options:
  27. - `--port number`, `-p number`: Port number. Optional. (default: 3000). Overrides configuration file.
  28. - `--config path`, `-c path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
  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.
  44. - `--password value`: Password. Required.
  45. - `--email value`: Email. Required.
  46. - `--admin`: If provided, this makes the user an admin. Optional.
  47. - `--config path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
  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 --name 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. - `--config path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
  61. - Examples:
  62. - `gitea admin change-password --username myname --password asecurepassword`
  63. - `regenerate`
  64. - Options:
  65. - `hooks`: Regenerate git-hooks for all repositories
  66. - `keys`: Regenerate authorized_keys file
  67. - Examples:
  68. - `gitea admin regenerate hooks`
  69. - `gitea admin regenerate keys`
  70. - `auth`:
  71. - `list`:
  72. - Description: lists all external authentication sources that exist
  73. - Options:
  74. - `--config path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
  75. - Examples:
  76. - `gitea admin auth list`
  77. - `delete`:
  78. - Options:
  79. - `--id`: ID of source to be deleted. Required.
  80. - `--config path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
  81. - Examples:
  82. - `gitea admin auth delete --id 1`
  83. - `add-oauth`:
  84. - Options:
  85. - `--config path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
  86. - `--name`: Application Name.
  87. - `--provider`: OAuth2 Provider.
  88. - `--key`: Client ID (Key).
  89. - `--secret`: Client Secret.
  90. - `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
  91. - `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
  92. - `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
  93. - `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
  94. - `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
  95. - `--custom-email-url`: Use a custom Email URL (option for GitHub).
  96. - Examples:
  97. - `gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE`
  98. - `update-oauth`:
  99. - Options:
  100. - `--id`: ID of source to be updated. Required.
  101. - `--config path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
  102. - `--name`: Application Name.
  103. - `--provider`: OAuth2 Provider.
  104. - `--key`: Client ID (Key).
  105. - `--secret`: Client Secret.
  106. - `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
  107. - `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
  108. - `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
  109. - `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
  110. - `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
  111. - `--custom-email-url`: Use a custom Email URL (option for GitHub).
  112. - Examples:
  113. - `gitea admin auth update-oauth --id 1 --name external-github-updated`
  114. #### cert
  115. Generates a self-signed SSL certificate. Outputs to `cert.pem` and `key.pem` in the current
  116. directory and will overwrite any existing files.
  117. - Options:
  118. - `--host value`: Comma seperated hostnames and ips which this certificate is valid for.
  119. Wildcards are supported. Required.
  120. - `--ecdsa-curve value`: ECDSA curve to use to generate a key. Optional. Valid options
  121. are P224, P256, P384, P521.
  122. - `--rsa-bits value`: Size of RSA key to generate. Optional. Ignored if --ecdsa-curve is
  123. set. (default: 2048).
  124. - `--start-date value`: Creation date. Optional. (format: `Jan 1 15:04:05 2011`).
  125. - `--duration value`: Duration which the certificate is valid for. Optional. (default: 8760h0m0s)
  126. - `--ca`: If provided, this cert generates it's own certificate authority. Optional.
  127. - Examples:
  128. - `gitea cert --host git.example.com,example.com,www.example.com --ca`
  129. #### dump
  130. Dumps all files and databases into a zip file. Outputs into a file like `gitea-dump-1482906742.zip`
  131. in the current directory.
  132. - Options:
  133. - `--config path`, `-c path`: Gitea configuration file path. Optional. (default: custom/conf/app.ini).
  134. - `--file name`, `-f name`: Name of the dump file with will be created. Optional. (default: gitea-dump-[timestamp].zip).
  135. - `--tempdir path`, `-t path`: Path to the temporary directory used. Optional. (default: /tmp).
  136. - `--skip-repository`, `-R`: Skip the repository dumping. Optional.
  137. - `--database`, `-d`: Specify the database SQL syntax. Optional.
  138. - `--verbose`, `-v`: If provided, shows additional details. Optional.
  139. - Examples:
  140. - `gitea dump`
  141. - `gitea dump --verbose`
  142. #### generate
  143. Generates random values and tokens for usage in configuration file. Useful for generating values
  144. for automatic deployments.
  145. - Commands:
  146. - `secret`:
  147. - Options:
  148. - `INTERNAL_TOKEN`: Token used for an internal API call authentication.
  149. - `LFS_JWT_SECRET`: LFS authentication secret.
  150. - `SECRET_KEY`: Global secret key.
  151. - Examples:
  152. - `gitea generate secret INTERNAL_TOKEN`
  153. - `gitea generate secret LFS_JWT_SECRET`
  154. - `gitea generate secret SECRET_KEY`
  155. #### keys
  156. Provides an SSHD AuthorizedKeysCommand. Needs to be configured in the sshd config file:
  157. ```ini
  158. ...
  159. # The value of -e and the AuthorizedKeysCommandUser should match the
  160. # username running gitea
  161. AuthorizedKeysCommandUser git
  162. AuthorizedKeysCommand /path/to/gitea keys -e git -u %u -t %t -k %k
  163. ```
  164. The command will return the appropriate authorized_keys line for the
  165. provided key. You should also set the value
  166. `SSH_CREATE_AUTHORIZED_KEYS_FILE=false` in the `[server]` section of
  167. `app.ini`.
  168. NB: opensshd requires the gitea program to be owned by root and not
  169. writable by group or others. The program must be specified by an absolute
  170. path.