0
0
Fork 0
mirror of https://codeberg.org/forgejo/docs.git synced 2024-11-21 17:36:59 -05:00

add sh syntax highlighting to all shell code blocks

This commit is contained in:
Alex Fu 2024-10-12 06:22:48 -04:00
parent c5ad84aea4
commit c132e28383

View file

@ -15,17 +15,15 @@ as described on [the Forgejo download page](/download/).
Next, copy the downloaded Forgejo binary to `/usr/local/bin/` (renaming it to "forgejo") Next, copy the downloaded Forgejo binary to `/usr/local/bin/` (renaming it to "forgejo")
and make it executable: and make it executable:
> **NOTE:** when a line starts with #, it means the command 'foo --bar' must be run as root (or with sudo). ```sh
sudo cp forgejo-x.y.z-linux-amd64 /usr/local/bin/forgejo
``` sudo chmod 755 /usr/local/bin/forgejo
# cp forgejo-x.y.z-linux-amd64 /usr/local/bin/forgejo
# chmod 755 /usr/local/bin/forgejo
``` ```
Make sure `git` and `git-lfs` are installed on your system. On Debian GNU/Linux you can use: Make sure `git` and `git-lfs` are installed on your system. On Debian GNU/Linux you can use:
``` ```sh
# apt install git git-lfs sudo apt install git git-lfs
``` ```
Create a user `git` on the system. Forgejo will run as that user, and when accessing git through SSH Create a user `git` on the system. Forgejo will run as that user, and when accessing git through SSH
@ -33,17 +31,17 @@ Create a user `git` on the system. Forgejo will run as that user, and when acces
`git clone git@git.example.com:YourOrg/YourRepo.git` the `git` before the `@` is the user you'll create now)._ `git clone git@git.example.com:YourOrg/YourRepo.git` the `git` before the `@` is the user you'll create now)._
On **Debian, Ubuntu** and their derivatives that's done with: On **Debian, Ubuntu** and their derivatives that's done with:
``` ```sh
# adduser --system --shell /bin/bash --gecos 'Git Version Control' \ sudo adduser --system --shell /bin/bash --gecos 'Git Version Control' \
--group --disabled-password --home /home/git git --group --disabled-password --home /home/git git
``` ```
On **Linux distributions not based on Debian/Ubuntu** (this should at least work with Red Hat derivatives On **Linux distributions not based on Debian/Ubuntu** (this should at least work with Red Hat derivatives
like Fedora, CentOS etc.), run this instead: like Fedora, CentOS etc.), run this instead:
``` ```sh
# groupadd --system git sudo groupadd --system git
# useradd --system --shell /bin/bash --comment 'Git Version Control' \ sudo useradd --system --shell /bin/bash --comment 'Git Version Control' \
--gid git --home-dir /home/git --create-home git --gid git --home-dir /home/git --create-home git
``` ```
@ -51,16 +49,16 @@ like Fedora, CentOS etc.), run this instead:
Now create the directories Forgejo will use and set access permissions appropriately: Now create the directories Forgejo will use and set access permissions appropriately:
``` ```sh
# mkdir /var/lib/forgejo sudo mkdir /var/lib/forgejo
# chown git:git /var/lib/forgejo && chmod 750 /var/lib/forgejo sudo chown git:git /var/lib/forgejo && chmod 750 /var/lib/forgejo
``` ```
This is the directory Forgejo will store its data in, including your Git repositories. This is the directory Forgejo will store its data in, including your Git repositories.
``` ```sh
# mkdir /etc/forgejo sudo mkdir /etc/forgejo
# chown root:git /etc/forgejo && chmod 770 /etc/forgejo sudo chown root:git /etc/forgejo && chmod 770 /etc/forgejo
``` ```
This is the directory Forgejo's config, called `app.ini`, is stored in. **Initially it needs to This is the directory Forgejo's config, called `app.ini`, is stored in. **Initially it needs to
@ -83,8 +81,8 @@ Forgejo provides a
[systemd service script](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/contrib/systemd/forgejo.service). [systemd service script](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/contrib/systemd/forgejo.service).
Download it to the correct location: Download it to the correct location:
``` ```sh
# wget -O /etc/systemd/system/forgejo.service https://codeberg.org/forgejo/forgejo/raw/branch/forgejo/contrib/systemd/forgejo.service sudo wget -O /etc/systemd/system/forgejo.service https://codeberg.org/forgejo/forgejo/raw/branch/forgejo/contrib/systemd/forgejo.service
``` ```
If you're _not_ using sqlite, but MySQL or MariaDB or PostgreSQL, you'll have to edit that file If you're _not_ using sqlite, but MySQL or MariaDB or PostgreSQL, you'll have to edit that file
@ -93,9 +91,9 @@ Otherwise it _should_ work as it is.
Now enable and start the Forgejo service, so you can go on with the installation: Now enable and start the Forgejo service, so you can go on with the installation:
``` ```sh
# systemctl enable forgejo.service sudo systemctl enable forgejo.service
# systemctl start forgejo.service sudo systemctl start forgejo.service
``` ```
## Forgejo's web-based configuration ## Forgejo's web-based configuration
@ -105,12 +103,12 @@ You should now be able to access Forgejo in your local web browser, so open http
If it doesn't work: If it doesn't work:
- Make sure the forgejo service started successfully by checking the output of: - Make sure the forgejo service started successfully by checking the output of:
``` ```sh
# systemctl status forgejo.service sudo systemctl status forgejo.service
``` ```
If that indicates an error but the log lines underneath are too incomplete to tell what caused it, If that indicates an error but the log lines underneath are too incomplete to tell what caused it,
``` ```sh
# journalctl -n 100 --unit forgejo.service sudo journalctl -n 100 --unit forgejo.service
``` ```
will print the last 100 lines logged by Forgejo. will print the last 100 lines logged by Forgejo.
@ -137,15 +135,15 @@ So far, so good, but we're not quite done yet - some manual configuration in the
Stop the forgejo service: Stop the forgejo service:
``` ```sh
# systemctl stop forgejo.service sudo systemctl stop forgejo.service
``` ```
While at it, make `/etc/forgejo/` and the `app.ini` read-only for the git user (Forgejo doesn't While at it, make `/etc/forgejo/` and the `app.ini` read-only for the git user (Forgejo doesn't
write to it after the initial configuration): write to it after the initial configuration):
``` ```sh
# chmod 750 /etc/forgejo && chmod 640 /etc/forgejo/app.ini sudo chmod 750 /etc/forgejo && chmod 640 /etc/forgejo/app.ini
``` ```
Now (as root) edit `/etc/forgejo/app.ini` Now (as root) edit `/etc/forgejo/app.ini`
@ -225,8 +223,8 @@ The following changes are recommended if dealing with many large files:
When you're done editing the app.ini, save it and start the forgejo service again: When you're done editing the app.ini, save it and start the forgejo service again:
``` ```sh
# systemctl start forgejo.service sudo systemctl start forgejo.service
``` ```
You can test sending a mail by clicking the user button on the upper right of the Forgejo page You can test sending a mail by clicking the user button on the upper right of the Forgejo page
@ -240,12 +238,12 @@ Sometimes you may want/need to use the Forgejo
Keep in mind that: Keep in mind that:
- You need to **run it as the `git` user**, for example with: - You need to **run it as the `git` user**, for example with:
``` ```sh
$ sudo -u git forgejo command --argument $ sudo -u git forgejo command --argument
``` ```
- You need to specify the **Forgejo work path**, either with the `--work-path /var/lib/forgejo` - You need to specify the **Forgejo work path**, either with the `--work-path /var/lib/forgejo`
(or `-w /var/lib/forgejo`) commandline option or by setting the `FORGEJO_WORK_DIR` environment variable before calling `forgejo`: (or `-w /var/lib/forgejo`) commandline option or by setting the `FORGEJO_WORK_DIR` environment variable before calling `forgejo`:
``` ```sh
$ export FORGEJO_WORK_DIR=/var/lib/forgejo $ export FORGEJO_WORK_DIR=/var/lib/forgejo
``` ```
- You need to specify the path to the config (app.ini) with `--config /etc/forgejo/app.ini` - You need to specify the path to the config (app.ini) with `--config /etc/forgejo/app.ini`
@ -253,7 +251,7 @@ Keep in mind that:
So all in all your command might look like: So all in all your command might look like:
``` ```sh
$ sudo -u git forgejo -w /var/lib/forgejo -c /etc/forgejo/app.ini admin user list $ sudo -u git forgejo -w /var/lib/forgejo -c /etc/forgejo/app.ini admin user list
``` ```
@ -266,14 +264,14 @@ $ sudo -u git forgejo -w /var/lib/forgejo -c /etc/forgejo/app.ini admin user lis
> >
> and make it executable: > and make it executable:
> >
> ``` > ```sh
> # chmod 755 /usr/local/bin/forgejo.sh > sudo chmod 755 /usr/local/bin/forgejo.sh
> ``` > ```
> >
> Now if you want to call `forgejo` on the commandline (for the default system-wide installation > Now if you want to call `forgejo` on the commandline (for the default system-wide installation
> in `/var/lib/forgejo`), instead of the long line shown above, use: > in `/var/lib/forgejo`), instead of the long line shown above, use:
> >
> ``` > ```sh
> $ forgejo.sh admin user list > $ forgejo.sh admin user list
> ``` > ```
@ -281,6 +279,6 @@ You can always call forgejo and its subcommands with `-h` or `--help` to make it
information like available options and (sub)commands, for example to show available subcommands information like available options and (sub)commands, for example to show available subcommands
to administrate users on the commandline: to administrate users on the commandline:
``` ```sh
$ forgejo admin user -h $ forgejo admin user -h
``` ```