Merge pull request #44 from YunoHost-Apps/fix_linter

Fix linter
This commit is contained in:
yalh76 2022-05-29 19:02:05 +02:00 committed by GitHub
commit a5bb99f809
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 316 additions and 197 deletions

102
README.md
View File

@ -1,48 +1,30 @@
Gitea package for YunoHost
==========================
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# Gitea for YunoHost
[![Integration level](https://dash.yunohost.org/integration/gitea.svg)](https://dash.yunohost.org/appci/app/gitea) ![](https://ci-apps.yunohost.org/ci/badges/gitea.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/gitea.maintain.svg)
[![Install gitea with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=gitea)
[![Integration level](https://dash.yunohost.org/integration/gitea.svg)](https://dash.yunohost.org/appci/app/gitea) ![Working status](https://ci-apps.yunohost.org/ci/badges/gitea.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/gitea.maintain.svg)
[![Install Gitea with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=gitea)
> *This package allow you to install gitea quickly and simply on a YunoHost server.
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
*[Lire ce readme en français.](./README_fr.md)*
Overview
--------
> *This package allows you to install Gitea quickly and simply on a YunoHost server.
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview
Gitea is a fork of Gogs a self-hosted Git service written in Go. Alternative to Github.
**Shipped version:** 1.16.4
Screenshots
-----------
**Shipped version:** 1.16.8~ynh1
![](https://gitea.io/images/screenshot.png)
## Screenshots
Documentation
-------------
![Screenshot of Gitea](./doc/screenshots/screenshot.png)
* Official documentation: https://docs.gitea.io/
* YunoHost documentation: There no other documentations, feel free to contribute.
YunoHost specific features
--------------------------
### Multi-users support
LDAP and HTTP auth are supported.
### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/gitea%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/gitea/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/gitea%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/gitea/)
<!--Limitations
------------
* Any known limitations.
-->
## Disclaimers / important information
Additional informations
-----------------------
@ -53,7 +35,7 @@ If you want to use Gitea with ssh and be able to pull/push with you ssh key, you
```bash
PubkeyAuthentication yes
AuthorizedKeysFile /home/%u/.ssh/authorized_keys
AuthorizedKeysFile /home/yunohost.app/%u/.ssh/authorized_keys
ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM no
@ -68,10 +50,6 @@ Host domain.tld
port 2222 # change this with the port you use
```
### Architecture
This package is compatible with amd64, i386 and arm. The package will try to detect it with the command uname -m and fail if it can't detect the architecture. If that happens please open an issue describing your hardware and the result of the command `uname -m`.
### Upgrade
By default a backup is made before the upgrade. To avoid this you have theses following possibilites:
@ -98,14 +76,14 @@ This app use now the core-only feature of the backup. To keep the integrity of t
`yunohost backup create --app gitea`
- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is generally stored in `/home/gitea`.
- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is generally stored in `/home/yunohost.app/gitea`.
- Restart the gitea service with theses command:
`systemctl start gitea.service`
### Remove
Due of the backup core only feature the data directory in `/home/gitea` **is not removed**. It need to be removed manually to purge app user data.
Due of the backup core only feature the data directory in `/home/yunohost.app/gitea` **is not removed**. It need to be removed manually to purge app user data.
### LFS setup
To use a repository with an `LFS` setup, you need to activate-it on `/opt/gitea/custom/conf/app.ini`
@ -126,36 +104,24 @@ Don't forget to restart Gitea `sudo systemctl restart gitea.service`.
If you want to use the git command (like `git clone`, `git pull`, `git push`), you need to set this app as **public**.
Links
-----
## Documentation and resources
* Report a bug: https://framagit.org/YunoHost-Apps/gitea_ynh/issues
* App website: http://gitea.io
* YunoHost website: https://yunohost.org/
* Official app website: <https://gitea.io/>
* Official admin documentation: <https://docs.gitea.io/>
* Upstream app code repository: <https://github.com/go-gitea/gitea>
* YunoHost documentation for this app: <https://yunohost.org/app_gitea>
* Report a bug: <https://github.com/YunoHost-Apps/gitea_ynh/issues>
---
## Developer info
Install
-------
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/gitea_ynh/tree/testing).
From command line:
To try the testing branch, please proceed like that.
`sudo yunohost app install -l gitea https://github.com/YunoHost-Apps/gitea_ynh`
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/gitea_ynh/tree/testing --debug
or
sudo yunohost app upgrade gitea -u https://github.com/YunoHost-Apps/gitea_ynh/tree/testing --debug
```
Upgrade
-------
From command line:
`sudo yunohost app upgrade gitea -u https://github.com/YunoHost-Apps/gitea_ynh`
License
-------
Gitea is published under the MIT License:
https://github.com/go-gitea/gitea/blob/master/LICENSE
This package is published under the MIT License.
Todo
----
**More info regarding app packaging:** <https://yunohost.org/packaging_apps>

127
README_fr.md Normal file
View File

@ -0,0 +1,127 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# Gitea pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/gitea.svg)](https://dash.yunohost.org/appci/app/gitea) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/gitea.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/gitea.maintain.svg)
[![Installer Gitea avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=gitea)
*[Read this readme in english.](./README.md)*
> *Ce package vous permet d'installer Gitea rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
## Vue d'ensemble
Gitea is a fork of Gogs a self-hosted Git service written in Go. Alternative to Github.
**Version incluse :** 1.16.8~ynh1
## Captures d'écran
![Capture d'écran de Gitea](./doc/screenshots/screenshot.png)
## Avertissements / informations importantes
Additional informations
-----------------------
### Notes on SSH usage
If you want to use Gitea with ssh and be able to pull/push with you ssh key, your ssh daemon must be properly configured to use private/public keys. Here is a sample configuration of `/etc/ssh/sshd_config` that works with Gitea:
```bash
PubkeyAuthentication yes
AuthorizedKeysFile /home/yunohost.app/%u/.ssh/authorized_keys
ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM no
```
You also need to add your public key to your Gitea profile.
If you use ssh on another port than 22, you need to add theses lines to your ssh config in `~/.ssh/config`:
```bash
Host domain.tld
port 2222 # change this with the port you use
```
### Upgrade
By default a backup is made before the upgrade. To avoid this you have theses following possibilites:
- Pass the `NO_BACKUP_UPGRADE` env variable with `1` at each upgrade. By example `NO_BACKUP_UPGRADE=1 yunohost app upgrade gitea`.
- Set the settings `disable_backup_before_upgrade` to `1`. You can set this with this command:
`yunohost app setting gitea disable_backup_before_upgrade -v 1`
After this settings will be applied for **all** next upgrade.
From command line:
`yunohost app upgrade gitea`
### Backup
This app use now the core-only feature of the backup. To keep the integrity of the data and to have a better guarantee of the restoration is recommended to proceed like this:
- Stop gitea service with theses following command:
`systemctl stop gitea.service`
- Launch the backup of gitea with this following command:
`yunohost backup create --app gitea`
- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is generally stored in `/home/yunohost.app/gitea`.
- Restart the gitea service with theses command:
`systemctl start gitea.service`
### Remove
Due of the backup core only feature the data directory in `/home/yunohost.app/gitea` **is not removed**. It need to be removed manually to purge app user data.
### LFS setup
To use a repository with an `LFS` setup, you need to activate-it on `/opt/gitea/custom/conf/app.ini`
```ini
[server]
LFS_START_SERVER = true
LFS_HTTP_AUTH_EXPIRY = 20m
```
By default Nginx is setup with a max value to updload files at 200 Mo. It's possible to change this value on `/etc/nginx/conf.d/my.domain.tld.d/gitea.conf`.
```
client_max_body_size 200M;
```
Don't forget to restart Gitea `sudo systemctl restart gitea.service`.
> This settings are restored to the default config when Gitea is updated. Don't forget to restore your setup after all updates.
### Git command access with HTTPS
If you want to use the git command (like `git clone`, `git pull`, `git push`), you need to set this app as **public**.
## Documentations et ressources
* Site officiel de l'app : <https://gitea.io/>
* Documentation officielle de l'admin : <https://docs.gitea.io/>
* Dépôt de code officiel de l'app : <https://github.com/go-gitea/gitea>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_gitea>
* Signaler un bug : <https://github.com/YunoHost-Apps/gitea_ynh/issues>
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/gitea_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/gitea_ynh/tree/testing --debug
ou
sudo yunohost app upgrade gitea -u https://github.com/YunoHost-Apps/gitea_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>

View File

@ -21,7 +21,7 @@ FORCE_PRIVATE = false
DOMAIN = __DOMAIN__
HTTP_PORT = __PORT__
HTTP_ADDR = 127.0.0.1
ROOT_URL = https://__URL__/
ROOT_URL = https://__DOMAIN____PATH_URL__
DISABLE_SSH = false
SSH_PORT = __SSH_PORT__
OFFLINE_MODE = false
@ -72,5 +72,5 @@ XORM = file
[security]
INSTALL_LOCK = true
SECRET_KEY = __KEY__
REVERSE_PROXY_AUTHENTICATION_USER = REMOTE_USER
REVERSE_PROXY_AUTHENTICATION_USER = REMOTE-USER
REVERSE_PROXY_TRUSTED_PROXIES = 127.0.0.0/8,::1/128

View File

@ -6,11 +6,6 @@ location __PATH__/ {
client_max_body_size 200M;
proxy_set_header X-Real-IP $remote_addr;
# Force https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

View File

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.16.4/gitea-1.16.4-linux-arm-6
SOURCE_SUM=ed5c2fd355c05111c74cdf1ac9f6d184071fa1cabf194cdd11b8eb945db87195
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.16.8/gitea-1.16.8-linux-arm-6
SOURCE_SUM=5fc53c77655b31b148eed6417dbeed44087e2b1caf83e2583ca3695f209f8664
SOURCE_SUM_PRG=sha256sum
SOURCE_FILENAME=gitea
SOURCE_EXTRACT=false

View File

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.16.4/gitea-1.16.4-linux-arm64
SOURCE_SUM=570e334a327f4dc1b8412bf0af6423efc52508300ef54a646d63d4838dba0273
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.16.8/gitea-1.16.8-linux-arm64
SOURCE_SUM=1afed74f74792e35daec5b2fd381e4e06ddda906ed940c8d7f604744d1f65d39
SOURCE_SUM_PRG=sha256sum
SOURCE_FILENAME=gitea
SOURCE_EXTRACT=false

View File

@ -1,8 +1,8 @@
# The armv7 build is brocken
# See : https://github.com/go-gitea/gitea/issues/6700
# Use temporary the armv6 binary
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.16.4/gitea-1.16.4-linux-arm-6
SOURCE_SUM=ed5c2fd355c05111c74cdf1ac9f6d184071fa1cabf194cdd11b8eb945db87195
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.16.8/gitea-1.16.8-linux-arm-6
SOURCE_SUM=5fc53c77655b31b148eed6417dbeed44087e2b1caf83e2583ca3695f209f8664
SOURCE_SUM_PRG=sha256sum
SOURCE_FILENAME=gitea
SOURCE_EXTRACT=false

View File

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.16.4/gitea-1.16.4-linux-386
SOURCE_SUM=016e4c7c99337edf4a44231e872aea4f29575a63efa9b15b39e3319efe962139
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.16.8/gitea-1.16.8-linux-386
SOURCE_SUM=59d9979e0cf20b712692471c389e2aad3f2536290e517674db18003c303a1024
SOURCE_SUM_PRG=sha256sum
SOURCE_FILENAME=gitea
SOURCE_EXTRACT=false

View File

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.16.4/gitea-1.16.4-linux-amd64
SOURCE_SUM=49f2469a7aabe3f5dc432b2c967e2d2c6c5c4fad6aae4c1ab4197ebbd159ddd1
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.16.8/gitea-1.16.8-linux-amd64
SOURCE_SUM=1fedb3dd22a8fa2e815dd0491d3db36b3ebf1bb78eafdb8d3f60f740c8885365
SOURCE_SUM_PRG=sha256sum
SOURCE_FILENAME=gitea
SOURCE_EXTRACT=false

View File

@ -15,10 +15,10 @@ After=slapd.service
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=/home/__APP__
WorkingDirectory=/home/yunohost.app/__APP__
ExecStart=/opt/__APP__/gitea web
Restart=always
Environment=USER=__APP__ HOME=/home/__APP__
Environment=USER=__APP__ HOME=/home/yunohost.app/__APP__
# Sandboxing options to harden security
# Depending on specificities of your service/app, you may need to tweak these

1
doc/DESCRIPTION.md Normal file
View File

@ -0,0 +1 @@
Gitea is a fork of Gogs a self-hosted Git service written in Go. Alternative to Github.

77
doc/DISCLAIMER.md Normal file
View File

@ -0,0 +1,77 @@
Additional informations
-----------------------
### Notes on SSH usage
If you want to use Gitea with ssh and be able to pull/push with you ssh key, your ssh daemon must be properly configured to use private/public keys. Here is a sample configuration of `/etc/ssh/sshd_config` that works with Gitea:
```bash
PubkeyAuthentication yes
AuthorizedKeysFile /home/yunohost.app/%u/.ssh/authorized_keys
ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM no
```
You also need to add your public key to your Gitea profile.
If you use ssh on another port than 22, you need to add theses lines to your ssh config in `~/.ssh/config`:
```bash
Host domain.tld
port 2222 # change this with the port you use
```
### Upgrade
By default a backup is made before the upgrade. To avoid this you have theses following possibilites:
- Pass the `NO_BACKUP_UPGRADE` env variable with `1` at each upgrade. By example `NO_BACKUP_UPGRADE=1 yunohost app upgrade gitea`.
- Set the settings `disable_backup_before_upgrade` to `1`. You can set this with this command:
`yunohost app setting gitea disable_backup_before_upgrade -v 1`
After this settings will be applied for **all** next upgrade.
From command line:
`yunohost app upgrade gitea`
### Backup
This app use now the core-only feature of the backup. To keep the integrity of the data and to have a better guarantee of the restoration is recommended to proceed like this:
- Stop gitea service with theses following command:
`systemctl stop gitea.service`
- Launch the backup of gitea with this following command:
`yunohost backup create --app gitea`
- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is generally stored in `/home/yunohost.app/gitea`.
- Restart the gitea service with theses command:
`systemctl start gitea.service`
### Remove
Due of the backup core only feature the data directory in `/home/yunohost.app/gitea` **is not removed**. It need to be removed manually to purge app user data.
### LFS setup
To use a repository with an `LFS` setup, you need to activate-it on `/opt/gitea/custom/conf/app.ini`
```ini
[server]
LFS_START_SERVER = true
LFS_HTTP_AUTH_EXPIRY = 20m
```
By default Nginx is setup with a max value to updload files at 200 Mo. It's possible to change this value on `/etc/nginx/conf.d/my.domain.tld.d/gitea.conf`.
```
client_max_body_size 200M;
```
Don't forget to restart Gitea `sudo systemctl restart gitea.service`.
> This settings are restored to the default config when Gitea is updated. Don't forget to restore your setup after all updates.
### Git command access with HTTPS
If you want to use the git command (like `git clone`, `git pull`, `git push`), you need to set this app as **public**.

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

View File

@ -6,9 +6,15 @@
"en": "Lightweight Git forge",
"fr": "Forge Git légère"
},
"upstream": {
"license": "free",
"website": "https://gitea.io/",
"admindoc": "https://docs.gitea.io/",
"code": "https://github.com/go-gitea/gitea"
},
"url": "http://gitea.io",
"license": "MIT",
"version": "1.16.4~ynh1",
"version": "1.16.8~ynh1",
"maintainer": {
"name": "Josué Tille",
"email": "josue@tille.ch"
@ -29,39 +35,20 @@
"install" : [
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain for Gitea",
"fr": "Choisissez un domaine pour Gitea"
},
"example": "domain.org"
"type": "domain"
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for Gitea",
"fr": "Choisissez un chemin pour Gitea"
},
"example": "/gitea",
"default": "/gitea"
},
{
"name": "admin",
"type": "user",
"ask": {
"en": "Choose the Gitea administrator (must be an existing YunoHost user)",
"fr": "Choisissez l'administrateur de Gitea (doit être un utilisateur YunoHost existant)"
},
"example": "johndoe"
"type": "user"
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public site?",
"fr": "Est-ce un site public ?"
},
"help": {
"en": "A public server means that everybody is able to access to the main page of the forge, on the public profile of the user and on the public repository. But you still can limit the access to each repository if you set it as private. Note that to be able to use the remote Git command (clone, pull, push) with HTTP and to use the API by (by example with a smartphone), you need to set this application as public.",
"fr": "Un serveur public signifie que tout le monde peut accéder à la page principale de la forge, au profil public des utilisateurs et aux dépôts publics. Vous pouvez également définir les dépôts comme étant privés. Notez que pour pouvoir utiliser les commandes Git distantes (clone, pull, push) avec HTTP et pour pouvoir utiliser l'API (par exemple avec un smartphone), vous devez paramétrer cette application comme étant publique."

View File

@ -4,12 +4,12 @@
app=$YNH_APP_INSTANCE_NAME
dbname=$app
dbuser=$app
db_user=$app
final_path="/opt/$app"
DATADIR="/home/$app"
REPO_PATH="$DATADIR/repositories"
DATA_PATH="$DATADIR/data"
SSH_PATH="$DATADIR/.ssh"
datadir="/home/yunohost.app/$app"
repos_path="$datadir/repositories"
data_path="$datadir/data"
ssh_path="$datadir/.ssh"
# Detect the system architecture to download the right tarball
# NOTE: `uname -m` is more accurate and universal than `arch`
@ -36,10 +36,10 @@ fi
create_dir() {
mkdir -p "$final_path/data"
mkdir -p "$final_path/custom/conf"
mkdir -p "$SSH_PATH"
mkdir -p "$REPO_PATH"
mkdir -p "$DATA_PATH/avatars"
mkdir -p "$DATA_PATH/attachments"
mkdir -p "$ssh_path"
mkdir -p "$repos_path"
mkdir -p "$data_path/avatars"
mkdir -p "$data_path/attachments"
mkdir -p "/var/log/$app"
}
@ -53,46 +53,17 @@ config_nginx() {
config_gitea() {
ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+")
ynh_backup_if_checksum_is_different --file "$final_path/custom/conf/app.ini"
cp ../conf/app.ini "$final_path/custom/conf"
usermod -s /bin/bash $app
if [ "$path_url" = "/" ]
then
ynh_replace_string --match_string __URL__ --replace_string "$domain" --target_file "$final_path/custom/conf/app.ini"
else
ynh_replace_string --match_string __URL__ --replace_string "$domain${path_url%/}" --target_file "$final_path/custom/conf/app.ini"
fi
ynh_replace_string --match_string __REPOS_PATH__ --replace_string "$REPO_PATH" --target_file "$final_path/custom/conf/app.ini"
ynh_replace_string --match_string __DB_PASSWORD__ --replace_string "$dbpass" --target_file "$final_path/custom/conf/app.ini"
ynh_replace_string --match_string __DB_USER__ --replace_string "$dbuser" --target_file "$final_path/custom/conf/app.ini"
ynh_replace_string --match_string __DOMAIN__ --replace_string "$domain" --target_file "$final_path/custom/conf/app.ini"
ynh_replace_string --match_string __KEY__ --replace_string "$key" --target_file "$final_path/custom/conf/app.ini"
ynh_replace_string --match_string __DATA_PATH__ --replace_string "$DATA_PATH" --target_file "$final_path/custom/conf/app.ini"
ynh_replace_string --match_string __PORT__ --replace_string $port --target_file "$final_path/custom/conf/app.ini"
ynh_replace_string --match_string __APP__ --replace_string $app --target_file "$final_path/custom/conf/app.ini"
ynh_replace_string --match_string __SSH_PORT__ --replace_string $ssh_port --target_file "$final_path/custom/conf/app.ini"
ynh_store_file_checksum --file "$final_path/custom/conf/app.ini"
ynh_add_config --template="app.ini" --destination="$final_path/custom/conf/app.ini"
}
set_permission() {
chown -R $app:$app "$final_path"
chown -R $app:$app "/home/$app"
chown -R $app:$app "$datadir"
chown -R $app:$app "/var/log/$app"
chmod u=rwX,g=rX,o= "$final_path"
chmod u=rwx,g=rx,o= "$final_path/gitea"
chmod u=rwx,g=rx,o= "$final_path/custom/conf/app.ini"
chmod u=rwX,g=rX,o= "/home/$app"
chmod u=rwX,g=rX,o= "$datadir"
chmod u=rwX,g=rX,o= "/var/log/$app"
}
set_access_settings() {
if [ "$is_public" == '1' ];
then
ynh_permission_update --permission "main" --add "visitors"
fi
}

View File

@ -32,7 +32,7 @@ ynh_backup --src_path "$final_path"
# Copy the data files
ynh_print_info --message="Backing up user data..."
ynh_backup --src_path "$DATADIR" --is_big=1
ynh_backup --src_path "$datadir" --is_big=1
ynh_print_info --message="Backing up configuration..."

View File

@ -22,7 +22,7 @@ domain=$YNH_APP_NEW_DOMAIN
path_url=$(ynh_normalize_url_path --path_url ${YNH_APP_NEW_PATH:-'/'})
app=$YNH_APP_INSTANCE_NAME
dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
db_password=$(ynh_app_setting_get --app $app --key mysqlpwd)
admin=$(ynh_app_setting_get --app $app --key adminusername)
key=$(ynh_app_setting_get --app $app --key secret_key)
port=$(ynh_app_setting_get --app $app --key web_port)
@ -55,7 +55,7 @@ config_gitea
# RELOAD services
ynh_script_progression --message="Starting services..."
ynh_systemd_action -l "Starting new server: tcp:127.0.0.1:" -p "/var/log/$app/gitea.log" -t 10 -a restart
ynh_systemd_action -l "Starting new Web server: tcp:127.0.0.1:" -p "/var/log/$app/gitea.log" -t 10 -a restart
sleep 1
# Store the checksum with the 'INTERNAL_TOKEN' value.

View File

@ -33,15 +33,15 @@ ynh_user_exists "$admin" \
# Check Final Path availability
test ! -e "$final_path" || ynh_die --message "This path already contains a folder"
if [ -e "$DATADIR" ]; then
old_data_dir_path="$DATADIR$(date '+%Y%m%d.%H%M%S')"
if [ -e "$datadir" ]; then
old_data_dir_path="$datadir$(date '+%Y%m%d.%H%M%S')"
ynh_print_warn "A data directory already exist. Data was renamed to $old_data_dir_path"
mv "$DATADIR" "$old_data_dir_path"
mv "$datadir" "$old_data_dir_path"
fi
# Generate random password and key
ynh_script_progression --message="Defining db password and key..."
dbpass=$(ynh_string_random)
db_password=$(ynh_string_random)
key=$(ynh_string_random)
# Find available ports
@ -49,9 +49,8 @@ port=$(ynh_find_port --port 6000)
# Store Settings
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app $app --key mysqlpwd --value $dbpass
ynh_app_setting_set --app $app --key mysqlpwd --value $db_password
ynh_app_setting_set --app $app --key adminusername --value $admin
ynh_app_setting_set --app $app --key is_public --value $is_public
ynh_app_setting_set --app $app --key secret_key --value $key
ynh_app_setting_set --app $app --key web_port --value $port
@ -61,11 +60,11 @@ ynh_app_setting_set --app $app --key web_port --value $port
# Initialize database and store mysql password for upgrade
ynh_script_progression --message="Configuring MySQL database..."
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
ynh_mysql_create_db "$dbname" "$db_user" "$db_password"
# Add users
ynh_script_progression --message="Configuring system user..."
ynh_system_user_create --username=$app --home_dir=/home/$app --use_shell
ynh_system_user_create --username=$app --home_dir=$datadir --use_shell
# Add ssh permission for gitea user
adduser $app ssh.app
@ -99,14 +98,14 @@ ynh_script_progression --message="Configuring application, step 2/2..."
systemctl start "$app".service
# Wait untill login_source mysql table is created
while ! $(ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" <<< "SELECT * FROM login_source;" &>/dev/null)
while ! $(ynh_mysql_connect_as "$db_user" "$db_password" "$dbname" <<< "SELECT * FROM login_source;" &>/dev/null)
do
sleep 2
done
# Add ldap config
ynh_replace_string --match_string "__APP__" --replace_string "$app" --target_file ../conf/login_source.sql
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ../conf/login_source.sql
ynh_mysql_connect_as "$db_user" "$db_password" "$dbname" < ../conf/login_source.sql
# SETUP FAIL2BAN
ynh_script_progression --message="Configuring fail2ban..."
@ -117,8 +116,11 @@ ynh_add_fail2ban_config --logpath "/var/log/$app/gitea.log" --failregex ".*Faile
#=================================================
# Unprotect root from SSO if public
ynh_script_progression --message="Protecting directory"
set_access_settings
ynh_script_progression --message="Configuring permissions..."
if [ "$is_public" == '1' ];
then
ynh_permission_update --permission "main" --add "visitors"
fi
# Create permission
ynh_script_progression --message="Configuring permissions"
@ -137,7 +139,7 @@ ynh_app_setting_set --app $app --key upstream_version --value $(ynh_app_upstream
# Reload services
ynh_script_progression --message="Starting gitea services..." --weight=3
ynh_systemd_action -l "Starting new server: tcp:127.0.0.1:" -p "/var/log/$app/gitea.log" -t 10
ynh_systemd_action -l "Starting new Web server: tcp:127.0.0.1:" -p "/var/log/$app/gitea.log" -t 10
sleep 1
# Store the checksum with the 'INTERNAL_TOKEN' value.

View File

@ -27,7 +27,7 @@ systemctl stop "$app".service
# Drop MySQL database and user
ynh_script_progression --message="Removing databases..."
ynh_mysql_drop_db "$dbname" 2>/dev/null
ynh_mysql_drop_user "$dbuser" 2>/dev/null
ynh_mysql_drop_user "$db_user" 2>/dev/null
# Delete app directory and configurations
ynh_script_progression --message="Removing code..."
@ -58,7 +58,7 @@ yunohost service remove "$app"
ynh_script_progression --message="Removing fail2ban configuration..."
ynh_remove_fail2ban_config
ynh_print_info --message="Due of the backup core only feature the data directory in '$DATADIR' was not removed. It need to be removed manually to purge app user data."
ynh_print_info --message="Due of the backup core only feature the data directory in '$datadir' was not removed. It need to be removed manually to purge app user data."
ynh_script_progression --message="Removal of $app completed" --last
sleep 1

View File

@ -19,14 +19,11 @@ ynh_script_progression --message="Loading settings..."
# Retrieve old app settings
domain=$(ynh_app_setting_get --app $app --key domain)
path_url=$(ynh_app_setting_get --app $app --key path)
dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
db_password=$(ynh_app_setting_get --app $app --key mysqlpwd)
admin=$(ynh_app_setting_get --app $app --key adminusername)
port=$(ynh_app_setting_get --app $app --key web_port)
upstream_version=$(ynh_app_setting_get $app upstream_version)
# Check domain/path availability with app helper
ynh_webpath_available --domain $domain --path_url $path_url || ynh_die --message "$domain is not available as domain, please use an other domain."
# Check user parameter
ynh_user_exists "$admin" \
|| ynh_die --message "The chosen admin user does not exist."
@ -40,7 +37,7 @@ test ! -e "$final_path" || ynh_die --message "This path already contains a folde
# Add users
ynh_script_progression --message="Configuring system user..."
ynh_system_user_create --username=$app --home_dir=/home/$app --use_shell
ynh_system_user_create --username=$app --home_dir=$datadir --use_shell
# Restore all files
ynh_script_progression --message="Restoring files..." --weight=10
@ -48,8 +45,8 @@ ynh_restore
# Create and restore the database
ynh_script_progression --message="Restoring database..." --weight=3
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
ynh_mysql_create_db "$dbname" "$db_user" "$db_password"
ynh_mysql_connect_as "$db_user" "$db_password" "$dbname" < ./db.sql
# Restore systemd files
systemctl daemon-reload
@ -78,7 +75,7 @@ yunohost service add "$app" --log /var/log/"$app"/gitea.log
# Reload services
ynh_script_progression --message="Reloading services..."
systemctl reload nginx.service
ynh_systemd_action -l "Starting new server: tcp:127.0.0.1:" -p "/var/log/$app/gitea.log" -t 10
ynh_systemd_action -l "Starting new Web server: tcp:127.0.0.1:" -p "/var/log/$app/gitea.log" -t 10
sleep 1
ynh_script_progression --message="Restoration completed for $app" --last

View File

@ -18,10 +18,9 @@ ynh_abort_if_errors
ynh_script_progression --message="Loading installation settings..."
domain=$(ynh_app_setting_get --app $app --key domain)
path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
db_password=$(ynh_app_setting_get --app $app --key mysqlpwd)
admin=$(ynh_app_setting_get --app $app --key adminusername)
key=$(ynh_app_setting_get --app $app --key secret_key)
is_public=$(ynh_app_setting_get --app $app --key is_public)
port=$(ynh_app_setting_get --app $app --key web_port)
upstream_version=$(ynh_app_setting_get --app $app --key upstream_version)
@ -56,16 +55,16 @@ ynh_handle_app_migration --migration_id=gogs --migration_list=gogs_migrations
if [[ $migration_process -eq 1 ]]; then
# Reload variables
dbname=$app
dbuser=$app
db_user=$app
final_path="/opt/$app"
DATADIR="/home/$app"
REPO_PATH="$DATADIR/repositories"
DATA_PATH="$DATADIR/data"
datadir="/home/""$app"
repos_path="$datadir/repositories"
data_path="$datadir/data"
# Replace the user
ynh_system_user_delete $old_app
test getent passwd "$app" &>/dev/null || \
useradd -d "$DATADIR" --system --user-group "$app" --shell /bin/bash || \
useradd -d "$datadir" --system --user-group "$app" --shell /bin/bash || \
ynh_die --message "Unable to create $app system account"
# Clean old binary
@ -74,14 +73,14 @@ if [[ $migration_process -eq 1 ]]; then
# Restore authentication from SQL database
ynh_replace_string --match_string __APP__ --replace_string "$app" --target_file ../conf/login_source.sql
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ../conf/login_source.sql
ynh_mysql_connect_as "$db_user" "$db_password" "$dbname" < ../conf/login_source.sql
# Fix hooks
if [[ -e $REPO_PATH ]];then
ls $REPO_PATH/*/*.git/hooks/pre-receive | while read p; do
if [[ -e $repos_path ]];then
ls $repos_path/*/*.git/hooks/pre-receive | while read p; do
ynh_secure_remove --file=$p
done
ls $REPO_PATH/*/*.git/hooks/post-receive | while read p; do
ls $repos_path/*/*.git/hooks/post-receive | while read p; do
ynh_secure_remove --file=$p
done
fi
@ -89,6 +88,11 @@ if [[ $migration_process -eq 1 ]]; then
upstream_version="0.0.1"
fi
# Move data directory
if [ -e "/home/""$app" ] && [ ! -e $datadir ]; then
mv "/home/""$app" "$datadir"
fi
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -224,11 +228,7 @@ if ! ynh_permission_exists --permission admin; then
ynh_permission_create --permission 'admin' --allowed "$admin"
# Update ldap config
ynh_replace_string --match_string "__APP__" --replace_string "$app" --target_file ../conf/login_source.sql
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ../conf/login_source.sql
fi
if [ "$is_public" == '1' ];
then
ynh_permission_update --permission "main" --add "visitors"
ynh_mysql_connect_as "$db_user" "$db_password" "$dbname" < ../conf/login_source.sql
fi
# Add gitea to YunoHost's monitored services
@ -245,13 +245,9 @@ set_permission
# Save Version
ynh_app_setting_set --app $app --key upstream_version --value $(ynh_app_upstream_version)
# Unprotect root from SSO if public
ynh_script_progression --message="Configuring permissions..."
set_access_settings
# Reload services
ynh_script_progression --message="Starting gitea services..." --weight=3
ynh_systemd_action -l "Starting new server: tcp:127.0.0.1:" -p "/var/log/$app/gitea.log" -t 10
ynh_systemd_action -l "Starting new Web server: tcp:127.0.0.1:" -p "/var/log/$app/gitea.log" -t 10
sleep 1
# Store the checksum with the 'INTERNAL_TOKEN' value.