mirror of
https://framagit.org/YunoHost-Apps/gitea_ynh.git
synced 2024-12-22 09:35:06 +01:00
Merge remote-tracking branch 'uptream/testing' into add-fail2ban
This commit is contained in:
commit
05229ae7b1
@ -19,7 +19,7 @@ From the command-line:
|
||||
## Upgrade
|
||||
From the command-line:
|
||||
|
||||
`sudo yunohost app upgrade Gitea -u https://framagit.org/YunoHost-Apps/gitea_ynh gitea`
|
||||
`sudo yunohost app upgrade gitea -u https://framagit.org/YunoHost-Apps/gitea_ynh`
|
||||
|
||||
## 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:
|
||||
@ -52,4 +52,4 @@ Any issue is welcome here : https://framagit.org/YunoHost-Apps/gitea_ynh/issues
|
||||
Gitea is published under the MIT License:
|
||||
https://github.com/go-gitea/gitea/blob/master/LICENSE
|
||||
|
||||
This package is published under the MIT License.
|
||||
This package is published under the MIT License.
|
@ -12,6 +12,8 @@
|
||||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=349992d4f3921e4e1adb37a0cace4a5a9eb67099
|
||||
upgrade=1 from_commit=4e078e91129725c8b09ba551ab2a04e0328a45b3
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
incorrect_path=0
|
||||
@ -28,4 +30,9 @@
|
||||
Level 7=auto
|
||||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
Level 10=0
|
||||
;;; Upgrade options
|
||||
; commit=349992d4f3921e4e1adb37a0cace4a5a9eb67099
|
||||
name=First package version
|
||||
; commit=4e078e91129725c8b09ba551ab2a04e0328a45b3
|
||||
name=Gogs code, check migration from gogs
|
||||
|
@ -18,7 +18,7 @@ DOMAIN = __DOMAIN__
|
||||
HTTP_PORT = __PORT__
|
||||
ROOT_URL = https://__URL__/
|
||||
DISABLE_SSH = false
|
||||
SSH_PORT = 22
|
||||
SSH_PORT = __SSH_PORT_
|
||||
OFFLINE_MODE = false
|
||||
APP_DATA_PATH = __DATA_PATH__
|
||||
LANDING_PAGE = explore
|
||||
|
5
conf/gogs_migrations
Normal file
5
conf/gogs_migrations
Normal file
@ -0,0 +1,5 @@
|
||||
/opt/$app
|
||||
/home/$app
|
||||
/var/log/$app
|
||||
/etc/systemd/system/$app.service
|
||||
/etc/nginx/conf.d/$domain.d/$app.conf
|
32
conf/gogs_post_migration.sh
Normal file
32
conf/gogs_post_migration.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Ending the migration process from Gogs to Gitea
|
||||
|
||||
set -u
|
||||
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# SET VARIABLES
|
||||
#=================================================
|
||||
|
||||
old_app="__OLD_APP__"
|
||||
new_app="__NEW_APP__"
|
||||
script_name="$0"
|
||||
|
||||
#=================================================
|
||||
# DELETE OLD APP'S SETTINGS
|
||||
#=================================================
|
||||
|
||||
ynh_secure_remove "/etc/yunohost/apps/$old_app"
|
||||
yunohost app ssowatconf
|
||||
|
||||
#=================================================
|
||||
# DELETE THIS SCRIPT
|
||||
#=================================================
|
||||
|
||||
echo "rm $script_name" | at now + 1 minutes
|
@ -4,9 +4,9 @@ location __PATH__/ {
|
||||
proxy_set_header Host $host;
|
||||
proxy_buffering off;
|
||||
fastcgi_param REMOTE_USER $remote_user;
|
||||
client_max_body_size 50M;
|
||||
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;
|
||||
|
5
conf/source/arm.src
Normal file
5
conf/source/arm.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.8.2/gitea-1.8.2-linux-arm-6
|
||||
SOURCE_SUM=38ab6c0ac42e87370238c2482432420ff509b5a03d964712a984d4d603bb4c97
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/arm_1.0.src
Normal file
5
conf/source/arm_1.0.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.0.2/gitea-1.0.2-linux-arm-6
|
||||
SOURCE_SUM=d8cd551840b4b5620609eba92e810f4963b259d2809a34724e8fae7b1db00d91
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/arm_1.1.src
Normal file
5
conf/source/arm_1.1.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.1.4/gitea-1.1.4-linux-arm-6
|
||||
SOURCE_SUM=f39bce7927b363402d37774484a5d0c893ee55595175e3a4d14a12126bccdd80
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/arm_1.2.src
Normal file
5
conf/source/arm_1.2.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.2.3/gitea-1.2.3-linux-arm-6
|
||||
SOURCE_SUM=06023c75babee8c9d76cee2886890ae9fe82b84a0e723c11ef9fafe3c5ba9539
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/arm_1.3.src
Normal file
5
conf/source/arm_1.3.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.3.3/gitea-1.3.3-linux-arm-6
|
||||
SOURCE_SUM=b1b20d5905cd275b384da2a08d36ed0730801f23fb33df5c45302c9a6ec62dc6
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/arm_1.4.src
Normal file
5
conf/source/arm_1.4.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.4.3/gitea-1.4.3-linux-arm-6
|
||||
SOURCE_SUM=d7341bd9536dbc7b1c3935efe3b0b6be953b0c3f0390b9b794e8fd54d58fee5b
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/arm_1.5.src
Normal file
5
conf/source/arm_1.5.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.5.3/gitea-1.5.3-linux-arm-6
|
||||
SOURCE_SUM=6d16b6bcc3cf804cc9b4e0e9ce3aa42e6699662f99998a06c25c7a43df64b0b6
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/arm_1.6.src
Normal file
5
conf/source/arm_1.6.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.6.4/gitea-1.6.4-linux-arm-6
|
||||
SOURCE_SUM=30bb6220cde6b35522bdaf5ffca0d2daba8a0eebee56e3f11cd40d3e5f8f5669
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/arm_1.7.src
Normal file
5
conf/source/arm_1.7.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.7.3/gitea-1.7.3-linux-arm-6
|
||||
SOURCE_SUM=c38394be40634b0e1bd0fac0898474ff50e4535af610c12ee16ec3cabd2d4771
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
8
conf/source/armv7.src
Normal file
8
conf/source/armv7.src
Normal file
@ -0,0 +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.8.2/gitea-1.8.2-linux-arm-6
|
||||
SOURCE_SUM=38ab6c0ac42e87370238c2482432420ff509b5a03d964712a984d4d603bb4c97
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
@ -1,5 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.6.0/gitea-1.6.0-linux-arm-6
|
||||
SOURCE_SUM=36a19d4cf5328bd41382489c7b27856b18a86dd1523148c43e95ffe705f21454
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.0.2/gitea-1.0.2-linux-arm-7
|
||||
SOURCE_SUM=1533c4b9142d89e3ac78ac9650a1f1507d24f9ac7afcdbe73c83ae5517c36165
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/armv7_1.1.src
Normal file
5
conf/source/armv7_1.1.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.1.4/gitea-1.1.4-linux-arm-7
|
||||
SOURCE_SUM=3b66cbca2f6ad10c8323c3d35280d63d17e192ab5e4aaa7415f5048710c00705
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/armv7_1.2.src
Normal file
5
conf/source/armv7_1.2.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.2.3/gitea-1.2.3-linux-arm-7
|
||||
SOURCE_SUM=92a1a6fccae6d9382dccee90223457850124a8a9e9505401a04f507b8a90c1dd
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/armv7_1.3.src
Normal file
5
conf/source/armv7_1.3.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.3.3/gitea-1.3.3-linux-arm-7
|
||||
SOURCE_SUM=1f52cbaf97ca70cf6db5c152f6cff7921e9b066ffbe21ee4015616946c9d4251
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/armv7_1.4.src
Normal file
5
conf/source/armv7_1.4.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.4.3/gitea-1.4.3-linux-arm-7
|
||||
SOURCE_SUM=2a93d7a09f0f9b999651f156a4c0c65a1d4da0c75a68a13bdd0b920082d514de
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/armv7_1.5.src
Normal file
5
conf/source/armv7_1.5.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.5.3/gitea-1.5.3-linux-arm-7
|
||||
SOURCE_SUM=eb939edb6cdc46702109410f38e358cc572564307e619c4798b6b8b99d6ec7e5
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/armv7_1.6.src
Normal file
5
conf/source/armv7_1.6.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.6.4/gitea-1.6.4-linux-arm-7
|
||||
SOURCE_SUM=e78d31922e42ccaaf6566f32e249fb6ba4af2876102c6248b3ba32d051e69327
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/armv7_1.7.src
Normal file
5
conf/source/armv7_1.7.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.7.3/gitea-1.7.3-linux-arm-7
|
||||
SOURCE_SUM=fd4ba028a30eb2fac1f8570fd3f6157f0c46c21992a2062dd7a6751cc8a47f2f
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
@ -1,5 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.6.0/gitea-1.6.0-linux-386
|
||||
SOURCE_SUM=28404390f70ae5c6c71326606a6aedf39bff0c3f7a4c16c14f6d28a6adf92bd3
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.8.2/gitea-1.8.2-linux-386
|
||||
SOURCE_SUM=762ab39855958f61165a1332a34d2a227f527acdc3bf60aa91c5a3e4e4e906ce
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/i386_1.0.src
Normal file
5
conf/source/i386_1.0.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.0.2/gitea-1.0.2-linux-386
|
||||
SOURCE_SUM=966840c7b815662332c3785a65685bed08c8eab508b8af0fe41307b5ebce8399
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/i386_1.1.src
Normal file
5
conf/source/i386_1.1.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.1.4/gitea-1.1.4-linux-386
|
||||
SOURCE_SUM=d3fc91e4da9282abc2785bb96d1d805c85ae0a253228c2277e21fb332946c0fe
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/i386_1.2.src
Normal file
5
conf/source/i386_1.2.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.2.3/gitea-1.2.3-linux-386
|
||||
SOURCE_SUM=a8593c5e908c7e6c26620d45122d017e38441e915a4ea472543251772dc5a6d9
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/i386_1.3.src
Normal file
5
conf/source/i386_1.3.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.3.3/gitea-1.3.3-linux-386
|
||||
SOURCE_SUM=1b746cccffca446876ccc71efe328699f002622dab1d438e2142c8d7c23a22d7
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/i386_1.4.src
Normal file
5
conf/source/i386_1.4.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.4.3/gitea-1.4.3-linux-386
|
||||
SOURCE_SUM=760dda6f1cd76aa705915686a1d18837af3c4d912f731d1399048409a46ed2ea
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/i386_1.5.src
Normal file
5
conf/source/i386_1.5.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.5.3/gitea-1.5.3-linux-386
|
||||
SOURCE_SUM=292ef977c46b15650a68782666710bc3379bb4b22a3ae2cae761724569ca5857
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/i386_1.6.src
Normal file
5
conf/source/i386_1.6.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.6.4/gitea-1.6.4-linux-386
|
||||
SOURCE_SUM=1ccdca624582fbfb8c2b0a819b63b33e7b05a2d355bb4527cc55a6e367d5765d
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/i386_1.7.src
Normal file
5
conf/source/i386_1.7.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.7.3/gitea-1.7.3-linux-386
|
||||
SOURCE_SUM=a420bccb17e6e1c317c014475ce5a5bf8091da123cc55b0569660ae43ababf44
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
@ -1,5 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.6.0/gitea-1.6.0-linux-amd64
|
||||
SOURCE_SUM=9c66d4207b49309de9d4d750bab1090c15bf6de5d99e0de819f5215cba35d2cb
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.8.2/gitea-1.8.2-linux-amd64
|
||||
SOURCE_SUM=a843f2fe526b62ad1e698b80f6193d8c42a3920b35542de014af44d1eb998141
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/x86-64_1.0.src
Normal file
5
conf/source/x86-64_1.0.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.0.2/gitea-1.0.2-linux-amd64
|
||||
SOURCE_SUM=02ed9a3bb7bcd1c8f3d8888e51a0887b3c0f44b2a80d50c99f9e407e457545ab
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/x86-64_1.1.src
Normal file
5
conf/source/x86-64_1.1.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.1.4/gitea-1.1.4-linux-amd64
|
||||
SOURCE_SUM=1d8804ff7bed26464d61115b9d88ead8a7a7937ceed66fd0bfaceecd4be41274
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/x86-64_1.2.src
Normal file
5
conf/source/x86-64_1.2.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.2.3/gitea-1.2.3-linux-amd64
|
||||
SOURCE_SUM=bc71b6005617700c9b5654ddf5649aa9ee28dc2344d84254ddeb2678f4d44809
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/x86-64_1.3.src
Normal file
5
conf/source/x86-64_1.3.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.3.3/gitea-1.3.3-linux-amd64
|
||||
SOURCE_SUM=4f37b280eb9dcde7820e801e51ca07682faee703c220548da2f8aa9b6adb5231
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/x86-64_1.4.src
Normal file
5
conf/source/x86-64_1.4.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.4.3/gitea-1.4.3-linux-amd64
|
||||
SOURCE_SUM=fe60fca294baa24fe4862bbcfe29c92d5a8a883a48aadb80f3a1270cf5de9bd4
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/x86-64_1.5.src
Normal file
5
conf/source/x86-64_1.5.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.5.3/gitea-1.5.3-linux-amd64
|
||||
SOURCE_SUM=f84eb0b77b47d88b16b1de6ca443dab4a77e940835748d309956052887b9c507
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/x86-64_1.6.src
Normal file
5
conf/source/x86-64_1.6.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.6.4/gitea-1.6.4-linux-amd64
|
||||
SOURCE_SUM=e9508e04688e9840708c341125b47b43a2c12cad52185be4b7b6cf7a2fb8bb71
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
5
conf/source/x86-64_1.7.src
Normal file
5
conf/source/x86-64_1.7.src
Normal file
@ -0,0 +1,5 @@
|
||||
SOURCE_URL=https://github.com/go-gitea/gitea/releases/download/v1.7.3/gitea-1.7.3-linux-amd64
|
||||
SOURCE_SUM=49b733a3272dc49cb869c1ba9624a9880168f27b8112197d0c7fa32411dbf625
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitea
|
||||
SOURCE_EXTRACT=false
|
@ -9,10 +9,10 @@
|
||||
},
|
||||
"url": "http://gitea.io",
|
||||
"license": "MIT",
|
||||
"version": "1.5.2~ynh1",
|
||||
"version": "1.8.0~ynh1",
|
||||
"maintainer": {
|
||||
"name": "",
|
||||
"email": ""
|
||||
"name": "rafi59",
|
||||
"email": "rafi59_dev@srvmaison.fr.nf"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
|
@ -17,6 +17,8 @@ if [ -n "$(uname -m | grep 64)" ]; then
|
||||
architecture="x86-64"
|
||||
elif [ -n "$(uname -m | grep 86)" ]; then
|
||||
architecture="i386"
|
||||
elif [ -n "$(uname -m | grep armv7)" ]; then
|
||||
architecture="armv7"
|
||||
elif [ -n "$(uname -m | grep arm)" ]; then
|
||||
architecture="arm"
|
||||
else
|
||||
@ -46,6 +48,7 @@ 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 "$final_path/custom/conf/app.ini"
|
||||
|
||||
cp ../conf/app.ini "$final_path/custom/conf"
|
||||
@ -66,6 +69,7 @@ config_gitea() {
|
||||
ynh_replace_string "__DATA_PATH__" "$DATA_PATH" "$final_path/custom/conf/app.ini"
|
||||
ynh_replace_string "__PORT__" $port "$final_path/custom/conf/app.ini"
|
||||
ynh_replace_string "__APP__" $app "$final_path/custom/conf/app.ini"
|
||||
ynh_replace_string "__SSH_PORT_" $ssh_port "$final_path/custom/conf/app.ini"
|
||||
|
||||
ynh_store_file_checksum "$final_path/custom/conf/app.ini"
|
||||
}
|
||||
@ -81,3 +85,21 @@ set_permission() {
|
||||
chmod u=rwX,g=rX,o= "/home/$app"
|
||||
chmod u=rwX,g=rX,o= "/var/log/$app"
|
||||
}
|
||||
|
||||
set_access_settings() {
|
||||
if [ "$is_public" = '1' ]
|
||||
then
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
else
|
||||
# For an access to the git server by https in private mode we need to allow the access to theses URL :
|
||||
# - "DOMAIN/PATH/USER/REPOSITORY/info/refs"
|
||||
# - "DOMAIN/PATH/USER/REPOSITORY/git-upload-pack"
|
||||
# - "DOMAIN/PATH/USER/REPOSITORY/git-receive-pack"
|
||||
|
||||
excaped_domain=${domain//'.'/'%.'}
|
||||
excaped_domain=${excaped_domain//'-'/'%-'}
|
||||
excaped_path=${path_url//'.'/'%.'}
|
||||
excaped_path=${excaped_path//'-'/'%-'}
|
||||
ynh_app_setting_set $app skipped_regex "$excaped_domain$excaped_path/[%w-.]*/[%w-.]*/git%-receive%-pack,$excaped_domain$excaped_path/[%w-.]*/[%w-.]*/git%-upload%-pack,$excaped_domain$excaped_path/[%w-.]*/[%w-.]*/info/refs"
|
||||
fi
|
||||
}
|
||||
|
@ -18,9 +18,8 @@ cp -r /etc/yunohost/apps/${app}/conf ../ # Quick hack for https://github.com/Yu
|
||||
|
||||
# RETRIEVE ARGUMENTS
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
old_path=$YNH_APP_OLD_PATH
|
||||
new_domain=$YNH_APP_NEW_DOMAIN
|
||||
new_path=$YNH_APP_NEW_PATH
|
||||
domain=$YNH_APP_NEW_DOMAIN
|
||||
path_url=$(ynh_normalize_url_path ${YNH_APP_NEW_PATH:-'/'})
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
@ -28,28 +27,6 @@ admin=$(ynh_app_setting_get "$app" adminusername)
|
||||
key=$(ynh_app_setting_get "$app" secret_key)
|
||||
port=$(ynh_app_setting_get "$app" web_port)
|
||||
|
||||
# CHECK THE SYNTAX OF THE PATHS
|
||||
test -n "$old_path" || old_path="/"
|
||||
test -n "$new_path" || new_path="/"
|
||||
new_path=$(ynh_normalize_url_path $new_path)
|
||||
old_path=$(ynh_normalize_url_path $old_path)
|
||||
|
||||
domain="$new_domain"
|
||||
path_url="$new_path"
|
||||
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
change_domain=1
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
change_path=1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
@ -58,13 +35,13 @@ fi
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the domain for nginx
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Change the domain for nginx
|
||||
if [[ "$old_domain" != "$domain" ]]; then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum "$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
config_nginx
|
||||
@ -73,5 +50,9 @@ config_nginx
|
||||
config_gitea
|
||||
|
||||
# RELOAD services
|
||||
ynh_check_starting "INFO] Listen: http://0.0.0.0:" "/var/log/$app/gitea.log"
|
||||
sleep 1
|
||||
ynh_systemd_action -l "Serving \[::\]:$port with pid" -p "systemd" -a restart
|
||||
sleep 1
|
||||
|
||||
# Store the checksum with the 'INTERNAL_TOKEN' value.
|
||||
# Should be removed when the issue https://github.com/go-gitea/gitea/issues/3246 is fixed
|
||||
ynh_store_file_checksum "$final_path/custom/conf/app.ini"
|
||||
|
@ -9,321 +9,387 @@ ynh_delete_file_checksum () {
|
||||
ynh_app_setting_delete $app $checksum_setting_name
|
||||
}
|
||||
|
||||
# Start or restart a service and follow its booting
|
||||
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
|
||||
#
|
||||
# usage: ynh_check_starting "Line to match" [Log file] [Timeout] [Service name]
|
||||
#
|
||||
# | arg: Line to match - The line to find in the log to attest the service have finished to boot.
|
||||
# | arg: Log file - The log file to watch
|
||||
# | arg: Service name
|
||||
# /var/log/$app/$app.log will be used if no other log is defined.
|
||||
# | arg: Timeout - The maximum time to wait before ending the watching. Defaut 300 seconds.
|
||||
ynh_check_starting () {
|
||||
local line_to_match="$1"
|
||||
local service_name="${4:-$app}"
|
||||
local app_log="${2:-/var/log/$service_name/$service_name.log}"
|
||||
local timeout=${3:-300}
|
||||
# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ]
|
||||
# | arg: -n, --service_name= - Name of the service to reload. Default : $app
|
||||
# | arg: -a, --action= - Action to perform with systemctl. Default: start
|
||||
# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot.
|
||||
# If not defined it don't wait until the service is completely started.
|
||||
# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log
|
||||
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
|
||||
# | arg: -e, --length= - Length of the error log : Default : 20
|
||||
ynh_systemd_action() {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= )
|
||||
local service_name
|
||||
local action
|
||||
local line_match
|
||||
local length
|
||||
local log_path
|
||||
local timeout
|
||||
|
||||
ynh_clean_check_starting () {
|
||||
# Stop the execution of tail.
|
||||
kill -s 15 $pid_tail 2>&1
|
||||
ynh_secure_remove "$templog" 2>&1
|
||||
}
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
echo "Starting of $service_name" >&2
|
||||
systemctl stop $service_name
|
||||
local templog="$(mktemp)"
|
||||
# Following the starting of the app in its log
|
||||
tail -F -n0 "$app_log" > "$templog" &
|
||||
# Get the PID of the tail command
|
||||
local pid_tail=$!
|
||||
systemctl start $service_name
|
||||
local service_name="${service_name:-$app}"
|
||||
local action=${action:-start}
|
||||
local log_path="${log_path:-/var/log/$service_name/$service_name.log}"
|
||||
local length=${length:-20}
|
||||
local timeout=${timeout:-300}
|
||||
|
||||
local i=0
|
||||
for i in `seq 1 $timeout`
|
||||
do
|
||||
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
|
||||
if grep --quiet "$line_to_match" "$templog"
|
||||
then
|
||||
echo "The service $service_name has correctly started." >&2
|
||||
break
|
||||
fi
|
||||
echo -n "." >&2
|
||||
sleep 1
|
||||
done
|
||||
if [ $i -eq $timeout ]
|
||||
then
|
||||
echo "The service $service_name didn't fully started before the timeout." >&2
|
||||
fi
|
||||
# Start to read the log
|
||||
if [[ -n "${line_match:-}" ]]
|
||||
then
|
||||
local templog="$(mktemp)"
|
||||
# Following the starting of the app in its log
|
||||
if [ "$log_path" == "systemd" ] ; then
|
||||
# Read the systemd journal
|
||||
journalctl --unit=$service_name --follow --since=-0 --quiet > "$templog" &
|
||||
else
|
||||
# Read the specified log file
|
||||
tail -F -n0 "$log_path" > "$templog" &
|
||||
fi
|
||||
# Get the PID of the tail command
|
||||
local pid_tail=$!
|
||||
fi
|
||||
|
||||
echo ""
|
||||
ynh_clean_check_starting
|
||||
echo "${action^} the service $service_name" >&2
|
||||
systemctl $action $service_name \
|
||||
|| ( journalctl --lines=$length -u $service_name >&2 \
|
||||
; test -e "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \
|
||||
; false )
|
||||
|
||||
# Start the timeout and try to find line_match
|
||||
if [[ -n "${line_match:-}" ]]
|
||||
then
|
||||
local i=0
|
||||
for i in $(seq 1 $timeout)
|
||||
do
|
||||
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
|
||||
if grep --quiet "$line_match" "$templog"
|
||||
then
|
||||
echo "The service $service_name has correctly started." >&2
|
||||
break
|
||||
fi
|
||||
echo -n "." >&2
|
||||
sleep 1
|
||||
done
|
||||
if [ $i -eq $timeout ]
|
||||
then
|
||||
echo "The service $service_name didn't fully started before the timeout." >&2
|
||||
echo "Please find here an extract of the end of the log of the service $service_name:"
|
||||
journalctl --lines=$length -u $service_name >&2
|
||||
test -e "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2
|
||||
fi
|
||||
|
||||
echo ""
|
||||
ynh_clean_check_starting
|
||||
fi
|
||||
}
|
||||
|
||||
# Fail2ban
|
||||
# Clean temporary process and file used by ynh_check_starting
|
||||
# (usually used in ynh_clean_setup scripts)
|
||||
#
|
||||
# usage: ynh_clean_check_starting
|
||||
ynh_clean_check_starting () {
|
||||
# Stop the execution of tail.
|
||||
kill -s 15 $pid_tail 2>&1
|
||||
ynh_secure_remove "$templog" 2>&1
|
||||
}
|
||||
|
||||
# Read the value of a key in a ynh manifest file
|
||||
#
|
||||
# usage: ynh_read_manifest manifest key
|
||||
# | arg: -m, --manifest= - Path of the manifest to read
|
||||
# | arg: -k, --key= - Name of the key to find
|
||||
ynh_read_manifest () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [m]=manifest= [k]=manifest_key= )
|
||||
local manifest
|
||||
local manifest_key
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
if [ ! -e "$manifest" ]; then
|
||||
# If the manifest isn't found, try the common place for backup and restore script.
|
||||
manifest="../settings/manifest.json"
|
||||
fi
|
||||
|
||||
jq ".$manifest_key" "$manifest" --raw-output
|
||||
}
|
||||
|
||||
# Read the upstream version from the manifest
|
||||
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||
# For example : 4.3-2~ynh3
|
||||
# This include the number before ~ynh
|
||||
# In the last example it return 4.3-2
|
||||
#
|
||||
# usage: ynh_app_upstream_version [-m manifest]
|
||||
# | arg: -m, --manifest= - Path of the manifest to read
|
||||
ynh_app_upstream_version () {
|
||||
declare -Ar args_array=( [m]=manifest= )
|
||||
local manifest
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
manifest="${manifest:-../manifest.json}"
|
||||
version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version")
|
||||
echo "${version_key/~ynh*/}"
|
||||
}
|
||||
|
||||
# Execute a command as another user
|
||||
# usage: exec_as USER COMMAND [ARG ...]
|
||||
exec_as() {
|
||||
local USER=$1
|
||||
shift 1
|
||||
|
||||
if [[ $USER = $(whoami) ]]; then
|
||||
eval "$@"
|
||||
else
|
||||
sudo -u "$USER" "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args
|
||||
|
||||
# Create a dedicated fail2ban config (jail and filter conf files)
|
||||
# Make the main steps to migrate an app to its fork.
|
||||
#
|
||||
# usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]]
|
||||
# | arg: -l, --logpath= - Log file to be checked by fail2ban
|
||||
# | arg: -r, --failregex= - Failregex to be looked for by fail2ban
|
||||
# | arg: -m, --max_retry= - Maximum number of retries allowed before banning IP address - default: 3
|
||||
# | arg: -p, --ports= - Ports blocked for a banned IP address - default: http,https
|
||||
ynh_add_fail2ban_config () {
|
||||
# This helper has to be used for an app which needs to migrate to a new name or a new fork
|
||||
# (like owncloud to nextcloud or zerobin to privatebin).
|
||||
#
|
||||
# This helper will move the files of an app to its new name
|
||||
# or recreate the things it can't move.
|
||||
#
|
||||
# To specify which files it has to move, you have to create a "migration file", stored in ../conf
|
||||
# This file is a simple list of each file it has to move,
|
||||
# except that file names must reference the $app variable instead of the real name of the app,
|
||||
# and every instance-specific variables (like $domain).
|
||||
# $app is especially important because it's this variable which will be used to identify the old place and the new one for each file.
|
||||
#
|
||||
# If a database exists for this app, it will be dumped and then imported in a newly created database, with a new name and new user.
|
||||
# Don't forget you have to then apply these changes to application-specific settings (depends on the packaged application)
|
||||
#
|
||||
# Same things for an existing user, a new one will be created.
|
||||
# But the old one can't be removed unless it's not used. See below.
|
||||
#
|
||||
# If you have some dependencies for your app, it's possible to change the fake debian package which manages them.
|
||||
# You have to fill the $pkg_dependencies variable, and then a new fake package will be created and installed,
|
||||
# and the old one will be removed.
|
||||
# If you don't have a $pkg_dependencies variable, the helper can't know what the app dependencies are.
|
||||
#
|
||||
# The app settings.yml will be modified as follows:
|
||||
# - finalpath will be changed according to the new name (but only if the existing $final_path contains the old app name)
|
||||
# - The checksums of php-fpm and nginx config files will be updated too.
|
||||
# - If there is a $db_name value, it will be changed.
|
||||
# - And, of course, the ID will be changed to the new name too.
|
||||
#
|
||||
# Finally, the $app variable will take the value of the new name.
|
||||
# The helper will set the $migration_process variable to 1 if a migration has been successfully handled.
|
||||
#
|
||||
# You have to handle by yourself all the migrations not done by this helper, like configuration or special values in settings.yml
|
||||
# Also, at the end of the upgrade script, you have to add a post_migration script to handle all the things the helper can't do during YunoHost upgrade (mostly for permission reasons),
|
||||
# especially remove the old user, move some hooks and remove the old configuration directory
|
||||
# To launch this script, you have to move it elsewhere and start it after the upgrade script.
|
||||
# `cp ../conf/$script_post_migration /tmp`
|
||||
# `(cd /tmp; echo "/tmp/$script_post_migration" | at now + 2 minutes)`
|
||||
#
|
||||
# usage: ynh_handle_app_migration migration_id migration_list
|
||||
# | arg: -i, --migration_id= - ID from which to migrate
|
||||
# | arg: -l, --migration_list= - File specifying every file to move (one file per line)
|
||||
ynh_handle_app_migration () {
|
||||
# Need for end of install
|
||||
ynh_package_install at
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
old_app=$YNH_APP_INSTANCE_NAME
|
||||
local old_app_id=$YNH_APP_ID
|
||||
local old_app_number=$YNH_APP_INSTANCE_NUMBER
|
||||
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [l]=logpath= [r]=failregex= [m]=max_retry= [p]=ports= )
|
||||
local logpath
|
||||
local failregex
|
||||
local max_retry
|
||||
local ports
|
||||
declare -Ar args_array=( [i]=migration_id= [l]=migration_list= )
|
||||
# Get the id from which to migrate
|
||||
local migration_id
|
||||
# And the file with the paths to move
|
||||
local migration_list
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
max_retry=${max_retry:-3}
|
||||
ports=${ports:-http,https}
|
||||
|
||||
test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing."
|
||||
test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing."
|
||||
|
||||
finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf"
|
||||
finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf"
|
||||
ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1
|
||||
ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1
|
||||
|
||||
sudo tee $finalfail2banjailconf <<EOF
|
||||
[$app]
|
||||
enabled = true
|
||||
port = $ports
|
||||
filter = $app
|
||||
logpath = $logpath
|
||||
maxretry = $max_retry
|
||||
EOF
|
||||
|
||||
sudo tee $finalfail2banfilterconf <<EOF
|
||||
[INCLUDES]
|
||||
before = common.conf
|
||||
[Definition]
|
||||
failregex = $failregex
|
||||
ignoreregex =
|
||||
EOF
|
||||
|
||||
ynh_store_file_checksum "$finalfail2banjailconf"
|
||||
ynh_store_file_checksum "$finalfail2banfilterconf"
|
||||
|
||||
if [ "$(lsb_release --codename --short)" != "jessie" ]; then
|
||||
systemctl reload fail2ban
|
||||
# Get the new app id in the manifest
|
||||
local new_app_id=$(grep \"id\": ../manifest.json | cut -d\" -f4)
|
||||
if [ $old_app_number -eq 1 ]; then
|
||||
local new_app=$new_app_id
|
||||
else
|
||||
systemctl restart fail2ban
|
||||
local new_app=${new_app_id}__${old_app_number}
|
||||
fi
|
||||
local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
|
||||
if [ -n "$fail2ban_error" ]
|
||||
|
||||
#=================================================
|
||||
# CHECK IF IT HAS TO MIGRATE
|
||||
#=================================================
|
||||
|
||||
migration_process=0
|
||||
|
||||
if [ "$old_app_id" == "$new_app_id" ]
|
||||
then
|
||||
echo "[ERR] Fail2ban failed to load the jail for $app" >&2
|
||||
echo "WARNING${fail2ban_error#*WARNING}" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
# Remove the dedicated fail2ban config (jail and filter conf files)
|
||||
#
|
||||
# usage: ynh_remove_fail2ban_config
|
||||
ynh_remove_fail2ban_config () {
|
||||
ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf"
|
||||
if [ "$(lsb_release --codename --short)" != "jessie" ]; then
|
||||
systemctl reload fail2ban
|
||||
# If the 2 id are the same
|
||||
# No migration to do.
|
||||
echo 0
|
||||
return 0
|
||||
else
|
||||
systemctl restart fail2ban
|
||||
if [ "$old_app_id" != "$migration_id" ]
|
||||
then
|
||||
# If the new app is not the authorized id, fail.
|
||||
ynh_die "Incompatible application for migration from $old_app_id to $new_app_id"
|
||||
fi
|
||||
|
||||
echo "Migrate from $old_app_id to $new_app_id" >&2
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE MIGRATION CAN BE DONE
|
||||
#=================================================
|
||||
|
||||
# TODO Handle multi instance apps...
|
||||
# Check that there is not already an app installed for this id.
|
||||
(yunohost app list --installed -f "$new_app" | grep -q id) \
|
||||
&& ynh_die "$new_app is already installed"
|
||||
|
||||
#=================================================
|
||||
# CHECK THE LIST OF FILES TO MOVE
|
||||
#=================================================
|
||||
|
||||
local temp_migration_list="$(tempfile)"
|
||||
|
||||
# Build the list by removing blank lines and comment lines
|
||||
sed '/^#.*\|^$/d' "../conf/$migration_list" > "$temp_migration_list"
|
||||
|
||||
# Check if there is no file in the destination
|
||||
local file_to_move=""
|
||||
while read file_to_move
|
||||
do
|
||||
# Replace all occurences of $app by $new_app in each file to move.
|
||||
local move_to_destination="${file_to_move//\$app/$new_app}"
|
||||
test -e "$move_to_destination" && ynh_die "A file named $move_to_destination already exists."
|
||||
done < "$temp_migration_list"
|
||||
|
||||
#=================================================
|
||||
# COPY YUNOHOST SETTINGS FOR THIS APP
|
||||
#=================================================
|
||||
|
||||
local settings_dir="/etc/yunohost/apps"
|
||||
cp -a "$settings_dir/$old_app" "$settings_dir/$new_app"
|
||||
cp -a ../{scripts,conf} "$settings_dir/$new_app"
|
||||
|
||||
# Replace the old id by the new one
|
||||
ynh_replace_string "\(^id: .*\)$old_app" "\1$new_app" "$settings_dir/$new_app/settings.yml"
|
||||
# INFO: There a special behavior with yunohost app setting:
|
||||
# if the id given in argument does not match with the id
|
||||
# stored in the config file, the config file will be purged.
|
||||
# That's why we use sed instead of app setting here.
|
||||
# https://github.com/YunoHost/yunohost/blob/c6b5284be8da39cf2da4e1036a730eb5e0515096/src/yunohost/app.py#L1316-L1321
|
||||
|
||||
# Change the label if it's simply the name of the app
|
||||
old_label=$(ynh_app_setting_get $new_app label)
|
||||
if [ "${old_label,,}" == "$old_app_id" ]
|
||||
then
|
||||
# Build the new label from the id of the app. With the first character as upper case
|
||||
new_label=$(echo $new_app_id | cut -c1 | tr [:lower:] [:upper:])$(echo $new_app_id | cut -c2-)
|
||||
ynh_app_setting_set $new_app label $new_label
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# MOVE FILES TO THE NEW DESTINATION
|
||||
#=================================================
|
||||
|
||||
while read file_to_move
|
||||
do
|
||||
# Replace all occurence of $app by $new_app in each file to move.
|
||||
move_to_destination="$(eval echo "${file_to_move//\$app/$new_app}")"
|
||||
local real_file_to_move="$(eval echo "${file_to_move//\$app/$old_app}")"
|
||||
echo "Move file $real_file_to_move to $move_to_destination" >&2
|
||||
mv "$real_file_to_move" "$move_to_destination"
|
||||
done < "$temp_migration_list"
|
||||
|
||||
#=================================================
|
||||
# UPDATE SETTINGS KNOWN ENTRIES
|
||||
#=================================================
|
||||
|
||||
# Replace nginx checksum
|
||||
ynh_replace_string "\(^checksum__etc_nginx.*\)_$old_app" "\1_$new_app/" "$settings_dir/$new_app/settings.yml"
|
||||
|
||||
# Replace php5-fpm checksums
|
||||
ynh_replace_string "\(^checksum__etc_php5.*[-_]\)$old_app" "\1$new_app/" "$settings_dir/$new_app/settings.yml"
|
||||
|
||||
# Replace final_path
|
||||
ynh_replace_string "\(^final_path: .*\)$old_app" "\1$new_app" "$settings_dir/$new_app/settings.yml"
|
||||
|
||||
#=================================================
|
||||
# MOVE THE DATABASE
|
||||
#=================================================
|
||||
|
||||
db_pwd=$(ynh_app_setting_get $old_app mysqlpwd)
|
||||
db_name=$dbname
|
||||
|
||||
# Check if a database exists before trying to move it
|
||||
local mysql_root_password=$(cat $MYSQL_ROOT_PWD_FILE)
|
||||
if [ -n "$db_name" ] && mysqlshow -u root -p$mysql_root_password | grep -q "^| $db_name"
|
||||
then
|
||||
new_db_name=$(ynh_sanitize_dbid $new_app)
|
||||
echo "Rename the database $db_name to $new_db_name" >&2
|
||||
|
||||
local sql_dump="/tmp/${db_name}-$(date '+%s').sql"
|
||||
|
||||
# Dump the old database
|
||||
ynh_mysql_dump_db "$db_name" > "$sql_dump"
|
||||
|
||||
# Create a new database
|
||||
ynh_mysql_setup_db $new_db_name $new_db_name $db_pwd
|
||||
# Then restore the old one into the new one
|
||||
ynh_mysql_connect_as $new_db_name $db_pwd $new_db_name < "$sql_dump"
|
||||
|
||||
# Remove the old database
|
||||
ynh_mysql_remove_db $db_name $db_name
|
||||
# And the dump
|
||||
ynh_secure_remove "$sql_dump"
|
||||
|
||||
# Update the value of $db_name
|
||||
db_name=$new_db_name
|
||||
ynh_app_setting_set $new_app db_name $db_name
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CHANGE THE FAKE DEPENDENCIES PACKAGE
|
||||
#=================================================
|
||||
|
||||
# Check if a variable $pkg_dependencies exists
|
||||
# If this variable doesn't exist, this part shall be managed in the upgrade script.
|
||||
if [ -n "${pkg_dependencies:-}" ]
|
||||
then
|
||||
# Define the name of the package
|
||||
local old_package_name="${old_app//_/-}-ynh-deps"
|
||||
local new_package_name="${new_app//_/-}-ynh-deps"
|
||||
|
||||
if ynh_package_is_installed "$old_package_name"
|
||||
then
|
||||
# Install a new fake package
|
||||
app=$new_app
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
# Then remove the old one
|
||||
app=$old_app
|
||||
ynh_remove_app_dependencies
|
||||
fi
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPDATE THE ID OF THE APP
|
||||
#=================================================
|
||||
|
||||
app=$new_app
|
||||
|
||||
|
||||
# Set migration_process to 1 to inform that an upgrade has been made
|
||||
migration_process=1
|
||||
fi
|
||||
}
|
||||
|
||||
# Internal helper design to allow helpers to use getopts to manage their arguments
|
||||
#
|
||||
# example: function my_helper()
|
||||
# {
|
||||
# declare -Ar args_array=( [a]=arg1= [b]=arg2= [c]=arg3 )
|
||||
# local arg1
|
||||
# local arg2
|
||||
# local arg3
|
||||
# ynh_handle_getopts_args "$@"
|
||||
#
|
||||
# [...]
|
||||
# }
|
||||
# my_helper --arg1 "val1" -b val2 -c
|
||||
#
|
||||
# usage: ynh_handle_getopts_args "$@"
|
||||
# | arg: $@ - Simply "$@" to tranfert all the positionnal arguments to the function
|
||||
#
|
||||
# This helper need an array, named "args_array" with all the arguments used by the helper
|
||||
# that want to use ynh_handle_getopts_args
|
||||
# Be carreful, this array has to be an associative array, as the following example:
|
||||
# declare -Ar args_array=( [a]=arg1 [b]=arg2= [c]=arg3 )
|
||||
# Let's explain this array:
|
||||
# a, b and c are short options, -a, -b and -c
|
||||
# arg1, arg2 and arg3 are the long options associated to the previous short ones. --arg1, --arg2 and --arg3
|
||||
# For each option, a short and long version has to be defined.
|
||||
# Let's see something more significant
|
||||
# declare -Ar args_array=( [u]=user [f]=finalpath= [d]=database )
|
||||
#
|
||||
# NB: Because we're using 'declare' without -g, the array will be declared as a local variable.
|
||||
#
|
||||
# Please keep in mind that the long option will be used as a variable to store the values for this option.
|
||||
# For the previous example, that means that $finalpath will be fill with the value given as argument for this option.
|
||||
#
|
||||
# Also, in the previous example, finalpath has a '=' at the end. That means this option need a value.
|
||||
# So, the helper has to be call with --finalpath /final/path, --finalpath=/final/path or -f /final/path, the variable $finalpath will get the value /final/path
|
||||
# If there's many values for an option, -f /final /path, the value will be separated by a ';' $finalpath=/final;/path
|
||||
# For an option without value, like --user in the example, the helper can be called only with --user or -u. $user will then get the value 1.
|
||||
#
|
||||
# To keep a retrocompatibility, a package can still call a helper, using getopts, with positional arguments.
|
||||
# The "legacy mode" will manage the positional arguments and fill the variable in the same order than they are given in $args_array.
|
||||
# e.g. for `my_helper "val1" val2`, arg1 will be filled with val1, and arg2 with val2.
|
||||
ynh_handle_getopts_args () {
|
||||
# Manage arguments only if there's some provided
|
||||
set +x
|
||||
if [ $# -ne 0 ]
|
||||
then
|
||||
# Store arguments in an array to keep each argument separated
|
||||
local arguments=("$@")
|
||||
|
||||
# For each option in the array, reduce to short options for getopts (e.g. for [u]=user, --user will be -u)
|
||||
# And built parameters string for getopts
|
||||
# ${!args_array[@]} is the list of all keys in the array (A key is 'u' in [u]=user, user is a value)
|
||||
local getopts_parameters=""
|
||||
local key=""
|
||||
for key in "${!args_array[@]}"
|
||||
do
|
||||
# Concatenate each keys of the array to build the string of arguments for getopts
|
||||
# Will looks like 'abcd' for -a -b -c -d
|
||||
# If the value of a key finish by =, it's an option with additionnal values. (e.g. --user bob or -u bob)
|
||||
# Check the last character of the value associate to the key
|
||||
if [ "${args_array[$key]: -1}" = "=" ]
|
||||
then
|
||||
# For an option with additionnal values, add a ':' after the letter for getopts.
|
||||
getopts_parameters="${getopts_parameters}${key}:"
|
||||
else
|
||||
getopts_parameters="${getopts_parameters}${key}"
|
||||
fi
|
||||
# Check each argument given to the function
|
||||
local arg=""
|
||||
# ${#arguments[@]} is the size of the array
|
||||
for arg in `seq 0 $(( ${#arguments[@]} - 1 ))`
|
||||
do
|
||||
# And replace long option (value of the key) by the short option, the key itself
|
||||
# (e.g. for [u]=user, --user will be -u)
|
||||
# Replace long option with =
|
||||
arguments[arg]="${arguments[arg]//--${args_array[$key]}/-${key} }"
|
||||
# And long option without =
|
||||
arguments[arg]="${arguments[arg]//--${args_array[$key]%=}/-${key}}"
|
||||
done
|
||||
done
|
||||
|
||||
# Read and parse all the arguments
|
||||
# Use a function here, to use standart arguments $@ and be able to use shift.
|
||||
parse_arg () {
|
||||
# Read all arguments, until no arguments are left
|
||||
while [ $# -ne 0 ]
|
||||
do
|
||||
# Initialize the index of getopts
|
||||
OPTIND=1
|
||||
# Parse with getopts only if the argument begin by -, that means the argument is an option
|
||||
# getopts will fill $parameter with the letter of the option it has read.
|
||||
local parameter=""
|
||||
getopts ":$getopts_parameters" parameter || true
|
||||
|
||||
if [ "$parameter" = "?" ]
|
||||
then
|
||||
ynh_die "Invalid argument: -${OPTARG:-}"
|
||||
elif [ "$parameter" = ":" ]
|
||||
then
|
||||
ynh_die "-$OPTARG parameter requires an argument."
|
||||
else
|
||||
local shift_value=1
|
||||
# Use the long option, corresponding to the short option read by getopts, as a variable
|
||||
# (e.g. for [u]=user, 'user' will be used as a variable)
|
||||
# Also, remove '=' at the end of the long option
|
||||
# The variable name will be stored in 'option_var'
|
||||
local option_var="${args_array[$parameter]%=}"
|
||||
# If this option doesn't take values
|
||||
# if there's a '=' at the end of the long option name, this option takes values
|
||||
if [ "${args_array[$parameter]: -1}" != "=" ]
|
||||
then
|
||||
# 'eval ${option_var}' will use the content of 'option_var'
|
||||
eval ${option_var}=1
|
||||
else
|
||||
# Read all other arguments to find multiple value for this option.
|
||||
# Load args in a array
|
||||
local all_args=("$@")
|
||||
|
||||
# If the first argument is longer than 2 characters,
|
||||
# There's a value attached to the option, in the same array cell
|
||||
if [ ${#all_args[0]} -gt 2 ]; then
|
||||
# Remove the option and the space, so keep only the value itself.
|
||||
all_args[0]="${all_args[0]#-${parameter} }"
|
||||
# Reduce the value of shift, because the option has been removed manually
|
||||
shift_value=$(( shift_value - 1 ))
|
||||
fi
|
||||
|
||||
# Then read the array value per value
|
||||
for i in `seq 0 $(( ${#all_args[@]} - 1 ))`
|
||||
do
|
||||
# If this argument is an option, end here.
|
||||
if [ "${all_args[$i]:0:1}" == "-" ] || [ -z "${all_args[$i]}" ]
|
||||
then
|
||||
# Ignore the first value of the array, which is the option itself
|
||||
if [ "$i" -ne 0 ]; then
|
||||
break
|
||||
fi
|
||||
else
|
||||
# Declare the content of option_var as a variable.
|
||||
eval ${option_var}=""
|
||||
# Else, add this value to this option
|
||||
# Each value will be separated by ';'
|
||||
if [ -n "${!option_var}" ]
|
||||
then
|
||||
# If there's already another value for this option, add a ; before adding the new value
|
||||
eval ${option_var}+="\;"
|
||||
fi
|
||||
eval ${option_var}+=\"${all_args[$i]}\"
|
||||
shift_value=$(( shift_value + 1 ))
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
# Shift the parameter and its argument(s)
|
||||
shift $shift_value
|
||||
done
|
||||
}
|
||||
|
||||
# LEGACY MODE
|
||||
# Check if there's getopts arguments
|
||||
if [ "${arguments[0]:0:1}" != "-" ]
|
||||
then
|
||||
# If not, enter in legacy mode and manage the arguments as positionnal ones.
|
||||
echo "! Helper used in legacy mode !"
|
||||
for i in `seq 0 $(( ${#arguments[@]} -1 ))`
|
||||
do
|
||||
# Use getopts_parameters as a list of key of the array args_array
|
||||
# Remove all ':' in getopts_parameters
|
||||
getopts_parameters=${getopts_parameters//:}
|
||||
# Get the key from getopts_parameters, by using the key according to the position of the argument.
|
||||
key=${getopts_parameters:$i:1}
|
||||
# Use the long option, corresponding to the key, as a variable
|
||||
# (e.g. for [u]=user, 'user' will be used as a variable)
|
||||
# Also, remove '=' at the end of the long option
|
||||
# The variable name will be stored in 'option_var'
|
||||
local option_var="${args_array[$key]%=}"
|
||||
|
||||
# Store each value given as argument in the corresponding variable
|
||||
# The values will be stored in the same order than $args_array
|
||||
eval ${option_var}+=\"${arguments[$i]}\"
|
||||
done
|
||||
else
|
||||
# END LEGACY MODE
|
||||
# Call parse_arg and pass the modified list of args as an array of arguments.
|
||||
parse_arg "${arguments[@]}"
|
||||
fi
|
||||
fi
|
||||
set -x
|
||||
}
|
@ -16,7 +16,7 @@ source ./_common.sh
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
path_url=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
|
||||
@ -60,7 +60,12 @@ config_nginx
|
||||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||
|
||||
# Add users
|
||||
ynh_system_user_create $app
|
||||
# We can't use the official helper (for now) because we need to set the shell for the login
|
||||
test getent passwd "$app" &>/dev/null || \
|
||||
useradd -d "$DATADIR" --system --user-group "$app" --shell /bin/bash || \
|
||||
ynh_die "Unable to create $app system account"
|
||||
# Should be replaced by this when getops is available in the helper ynh_system_user_create (probably in Yunohost 3.5)
|
||||
# ynh_system_user_create --username= $app --home_dir=/opt/yunohost/$app --use_shell
|
||||
|
||||
# create needed directories
|
||||
create_dir
|
||||
@ -75,7 +80,7 @@ config_nginx
|
||||
config_gitea
|
||||
|
||||
# Install gitea
|
||||
ynh_setup_source $final_path $architecture
|
||||
ynh_setup_source $final_path source/$architecture
|
||||
|
||||
# Set permissions
|
||||
set_permission
|
||||
@ -104,10 +109,7 @@ ynh_add_fail2ban_config "/var/log/$app/$app.log" ".*Failed authentication attemp
|
||||
#=================================================
|
||||
|
||||
# Unprotect root from SSO if public
|
||||
if [ "$is_public" = '1' ]
|
||||
then
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
fi
|
||||
set_access_settings
|
||||
|
||||
# Add gitea to YunoHost's monitored services
|
||||
yunohost service add "$app" --log "/var/log/$app/$app.log"
|
||||
@ -115,7 +117,13 @@ yunohost service add "$app" --log "/var/log/$app/$app.log"
|
||||
# Configure logrotate
|
||||
ynh_use_logrotate "/var/log/$app"
|
||||
|
||||
# Save Version
|
||||
ynh_app_setting_set $app upstream_version $(ynh_app_upstream_version)
|
||||
|
||||
# Reload services
|
||||
# ynh_check_starting "Serving [::]:$port with pid" "/var/log/$app/gitea.log"
|
||||
sleep 20
|
||||
systemctl start gitea
|
||||
ynh_systemd_action -l "Serving \[::\]:$port with pid" -p "systemd"
|
||||
sleep 1
|
||||
|
||||
# Store the checksum with the 'INTERNAL_TOKEN' value.
|
||||
# Should be removed when the issue https://github.com/go-gitea/gitea/issues/3246 is fixed
|
||||
ynh_store_file_checksum "$final_path/custom/conf/app.ini"
|
||||
|
@ -15,7 +15,7 @@ source ./_common.sh
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
|
||||
# Stop gogs
|
||||
# Stop gitea
|
||||
systemctl stop "$app".service
|
||||
|
||||
# Drop MySQL database and user
|
||||
@ -36,7 +36,7 @@ ynh_remove_logrotate
|
||||
# Remove nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
# Remove gogs user and data
|
||||
# Remove gitea user and data
|
||||
ynh_system_user_delete $app
|
||||
|
||||
# Remove init script
|
||||
|
@ -19,6 +19,7 @@ domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_app_setting_get "$app" path)
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
admin=$(ynh_app_setting_get "$app" adminusername)
|
||||
port=$(ynh_app_setting_get "$app" web_port)
|
||||
|
||||
# Check domain/path availability with app helper
|
||||
ynh_webpath_available $domain $path_url || ynh_die "$domain is not available as domain, please use an other domain."
|
||||
@ -35,7 +36,12 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
#=================================================
|
||||
|
||||
# Add users
|
||||
ynh_system_user_create $app
|
||||
# We can't use the official helper (for now) because we need to set the shell for the login
|
||||
test getent passwd "$app" &>/dev/null || \
|
||||
useradd -d "$DATADIR" --system --user-group "$app" --shell /bin/bash || \
|
||||
ynh_die "Unable to create $app system account"
|
||||
# Should be replaced by this when getops is available in the helper ynh_system_user_create (probably in Yunohost 3.5)
|
||||
# ynh_system_user_create --username= $app --home_dir=/opt/yunohost/$app --use_shell
|
||||
|
||||
# Restore all files
|
||||
ynh_restore
|
||||
@ -68,5 +74,5 @@ yunohost service add "$app" --log /var/log/"$app"/"$app".log
|
||||
|
||||
# Reload services
|
||||
systemctl reload nginx.service
|
||||
sleep 20
|
||||
systemctl start gitea
|
||||
ynh_systemd_action -l "Serving \[::\]:$port with pid" -p "systemd"
|
||||
sleep 1
|
||||
|
180
scripts/upgrade
180
scripts/upgrade
@ -22,6 +22,7 @@ admin=$(ynh_app_setting_get "$app" adminusername)
|
||||
key=$(ynh_app_setting_get "$app" secret_key)
|
||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||
port=$(ynh_app_setting_get "$app" web_port)
|
||||
upstream_version=$(ynh_app_setting_get $app upstream_version)
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
@ -33,51 +34,49 @@ ynh_clean_setup () {
|
||||
systemctl stop "$app".service
|
||||
|
||||
#=================================================
|
||||
# MIGRATION FROM OLD VERSION
|
||||
# MIGRATION FROM GOGS
|
||||
#=================================================
|
||||
|
||||
# Update settings is_public to new standard
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set $app is_public 1 # Fixe is_public en booléen
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set $app is_public 0
|
||||
is_public=0
|
||||
fi
|
||||
[[ $YNH_APP_ID == "gogs" ]] \
|
||||
&& [[ "$(cat "/opt/$app/templates/.VERSION")" != 0.11.79.1211 ]] \
|
||||
&& ynh_die "It look like that you have an old gogs install. You need first upgrade gogs instance (id : $gogs_migrate_id) and after migrate to gitea."
|
||||
ynh_handle_app_migration gogs gogs_migrations
|
||||
|
||||
if [[ $port == "" ]]
|
||||
then
|
||||
port=$(ynh_find_port 6000)
|
||||
ynh_app_setting_set $app web_port $port
|
||||
fi
|
||||
if [[ $migration_process -eq 1 ]]; then
|
||||
# Reload variables
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
final_path="/opt/$app"
|
||||
DATADIR="/home/$app"
|
||||
REPO_PATH="$DATADIR/repositories"
|
||||
DATA_PATH="$DATADIR/data"
|
||||
|
||||
# handle upgrade from old package installation
|
||||
# this test that /etc/gitea exist since this was used in the old package
|
||||
# but not in the new
|
||||
# this code will be removed in the future
|
||||
if [ -d "/etc/gitea" ]
|
||||
then
|
||||
# create needed directories if not already created
|
||||
create_dir
|
||||
# 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 || \
|
||||
ynh_die "Unable to create $app system account"
|
||||
|
||||
# move repositories to new dir
|
||||
old_repo_path=$(ynh_app_setting_get "$app" repopath)
|
||||
mv "${old_repo_path:-/home/yunohost.app/gitea}"/* "$REPO_PATH" || true # Avoid if the directory is empty
|
||||
# cleanup old dir and conf
|
||||
ynh_secure_remove /opt/gitea
|
||||
ynh_secure_remove /etc/gitea
|
||||
ynh_secure_remove /opt/gitea_src
|
||||
# Clean old binary
|
||||
ynh_secure_remove $final_path/gogs
|
||||
ynh_secure_remove $final_path/custom/conf/auth.d
|
||||
|
||||
# create needed directories if not already created
|
||||
create_dir
|
||||
fi
|
||||
# end of old package upgrade
|
||||
# Restore authentication from SQL database
|
||||
ynh_replace_string "__ADMIN__" "$admin" ../conf/login_source.sql
|
||||
ynh_replace_string "__APP__" "$app" ../conf/login_source.sql
|
||||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ../conf/login_source.sql
|
||||
|
||||
# test if user gitea is locked because of an old installation of the package.
|
||||
# if it's blocked, unlock it to allow ssh usage with git
|
||||
if [[ $(grep "$app" /etc/shadow | cut -d: -f2) == '!' ]]
|
||||
then
|
||||
usermod -p '*' "$app"
|
||||
# Fix hooks
|
||||
if [[ -e $REPO_PATH ]];then
|
||||
ls $REPO_PATH/*/*.git/hooks/pre-receive | while read p; do
|
||||
ynh_secure_remove $p
|
||||
done
|
||||
ls $REPO_PATH/*/*.git/hooks/post-receive | while read p; do
|
||||
ynh_secure_remove $p
|
||||
done
|
||||
fi
|
||||
|
||||
upstream_version="0.0.1"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
@ -85,10 +84,7 @@ fi
|
||||
#=================================================
|
||||
|
||||
# Clean template to fix issue : https://github.com/gogits/gogs/issues/4585
|
||||
ynh_secure_remove "/opt/gitea/templates"
|
||||
|
||||
# Install gitea
|
||||
ynh_setup_source $final_path $architecture
|
||||
ynh_secure_remove "/opt/$app/templates"
|
||||
|
||||
# Configure gitea with app.ini file
|
||||
config_gitea
|
||||
@ -99,6 +95,71 @@ ynh_add_systemd_config
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
config_nginx
|
||||
|
||||
#=================================================
|
||||
# DB migration
|
||||
#=================================================
|
||||
|
||||
# Before the version 1.7 the upstream version was not stored
|
||||
# The way to find the version for the install < 1.7 is to parse the binary file to find which version is installed
|
||||
if [ -z ${upstream_version:-} ]; then
|
||||
for version in "0.0." "1.0." "1.1." "1.2." "1.3." "1.4." "1.5." "1.6." "1.7."; do
|
||||
if strings $final_path/gitea | grep -P "^${version//./\\.}\d"; then
|
||||
upstream_version="${version}0"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
restart_gitea() {
|
||||
# Set permissions
|
||||
set_permission
|
||||
ynh_systemd_action -l "Serving \[::\]:$port with pid" -p "systemd"
|
||||
# Leave the time to update the database schema
|
||||
sleep 5
|
||||
systemctl stop $app
|
||||
}
|
||||
|
||||
case $upstream_version in
|
||||
"0.0."* )
|
||||
ynh_setup_source $final_path source/${architecture}_1.0
|
||||
set_permission
|
||||
systemctl start $app
|
||||
sleep 20
|
||||
systemctl stop $app
|
||||
;&
|
||||
"1.0."* )
|
||||
ynh_setup_source $final_path source/${architecture}_1.1
|
||||
restart_gitea
|
||||
;&
|
||||
"1.1."* )
|
||||
ynh_setup_source $final_path source/${architecture}_1.2
|
||||
restart_gitea
|
||||
;&
|
||||
"1.2."* )
|
||||
ynh_setup_source $final_path source/${architecture}_1.3
|
||||
restart_gitea
|
||||
;&
|
||||
"1.3."* )
|
||||
ynh_setup_source $final_path source/${architecture}_1.4
|
||||
restart_gitea
|
||||
;&
|
||||
"1.4."* )
|
||||
ynh_setup_source $final_path source/${architecture}_1.5
|
||||
restart_gitea
|
||||
;&
|
||||
"1.5."* )
|
||||
ynh_setup_source $final_path source/${architecture}_1.6
|
||||
restart_gitea
|
||||
;&
|
||||
"1.6."* )
|
||||
ynh_setup_source $final_path source/${architecture}_1.7
|
||||
restart_gitea
|
||||
;&
|
||||
esac
|
||||
|
||||
# Install gitea
|
||||
ynh_setup_source $final_path source/$architecture
|
||||
|
||||
#=================================================
|
||||
# SETUP FAIL2BAN
|
||||
#=================================================
|
||||
@ -111,7 +172,36 @@ ynh_add_fail2ban_config "/var/log/$app/$app.log" ".*Failed authentication attemp
|
||||
# Set permissions
|
||||
set_permission
|
||||
|
||||
# Save Version
|
||||
ynh_app_setting_set $app upstream_version $(ynh_app_upstream_version)
|
||||
|
||||
# Unprotect root from SSO if public
|
||||
set_access_settings
|
||||
|
||||
# Reload services
|
||||
# ynh_check_starting "INFO] Listen: http://0.0.0.0:" "/var/log/$app/gitea.log"
|
||||
sleep 20
|
||||
systemctl restart gitea
|
||||
ynh_systemd_action -l "Serving \[::\]:$port with pid" -p "systemd"
|
||||
sleep 1
|
||||
|
||||
# Store the checksum with the 'INTERNAL_TOKEN' value.
|
||||
# Should be removed when the issue https://github.com/go-gitea/gitea/issues/3246 is fixed
|
||||
ynh_store_file_checksum "$final_path/custom/conf/app.ini"
|
||||
|
||||
#=================================================
|
||||
# FINISH MIGRATION PROCESS
|
||||
#=================================================
|
||||
|
||||
if [[ $migration_process -eq 1 ]]; then
|
||||
echo "gogs has been successfully migrated to Gitea! \
|
||||
A last scheduled operation will run in a couple of minutes to finish the \
|
||||
migration in YunoHost side. Do not proceed any application operation while \
|
||||
you don't see Gogs as installed." >&2
|
||||
|
||||
# Execute a post migration script after the end of this upgrade.
|
||||
# Mainly for some cleaning
|
||||
script_post_migration=gogs_post_migration.sh
|
||||
ynh_replace_string "__OLD_APP__" "$old_app" ../conf/$script_post_migration
|
||||
ynh_replace_string "__NEW_APP__" "$app" ../conf/$script_post_migration
|
||||
cp ../conf/$script_post_migration /tmp
|
||||
chmod +x /tmp/$script_post_migration
|
||||
(cd /tmp; echo "/tmp/$script_post_migration > /tmp/$script_post_migration.log 2>&1" | at now + 2 minutes)
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user