1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/gogs_ynh.git synced 2024-09-03 20:36:23 +02:00

Rename variable in app.ini

This commit is contained in:
Josué Tille 2018-02-08 00:09:28 +01:00
parent d0390934bd
commit 13ab394e5a
8 changed files with 48 additions and 58 deletions

View file

@ -78,3 +78,10 @@ sudo yunohost app install -l Gogs /home/admin/gogs_ynh
sudo yunohost app upgrade -f /home/admin/gogs_ynh gogs
```
## Todo
- check migration
- change-url

View file

@ -17,7 +17,7 @@
backup_restore=1
multi_instance=1
incorrect_path=0
port_already_use=1 (8448)
port_already_use=1 (6000)
change_url=0
;;; Levels
Level 1=auto

View file

@ -5,27 +5,27 @@ RUN_MODE = prod
[database]
DB_TYPE = mysql
HOST = 127.0.0.1:3306
NAME = yuno_dbuser
USER = yuno_dbuser
PASSWD = yuno_dbpdw
NAME = __DB_USER__
USER = __DB_USER__
PASSWD = __DB_PASSWORD__
SSL_MODE = disable
PATH = data/gogs.db
[repository]
ROOT = yuno_repo_path
ROOT = __REPOS_PATH__
FORCE_PRIVATE = false
[server]
DOMAIN = yuno_domain
HTTP_PORT = 6000
ROOT_URL = https://yuno_url/
DOMAIN = __DOMAIN__
HTTP_PORT = __PORT__
ROOT_URL = https://__URL__/
DISABLE_SSH = false
SSH_PORT = 22
OFFLINE_MODE = false
APP_DATA_PATH = yuno_data_path
APP_DATA_PATH = __DATA_PATH__
LANDING_PAGE = explore
[mailer]
ENABLED = true
HOST = 127.0.0.1:25
FROM = "Gogs" <gogs-noreply@yuno_domain>
FROM = "Gogs" <gogs-noreply@__DOMAIN__>
SKIP_VERIFY = true
[service]
REGISTER_EMAIL_CONFIRM = false
@ -36,9 +36,9 @@ REQUIRE_SIGNIN_VIEW = false
ENABLE_REVERSE_PROXY_AUTHENTICATION = true
ENABLE_REVERSE_PROXY_AUTO_REGISTERATION = true
[picture]
AVATAR_UPLOAD_PATH = yuno_data_path/avatars
AVATAR_UPLOAD_PATH = __DATA_PATH__/avatars
[attachment]
PATH = yuno_data_path/attachments
PATH = __DATA_PATH__/attachments
[session]
PROVIDER = memory
[log]
@ -47,5 +47,5 @@ LEVEL = Warn
ROOT_PATH = /var/log/gogs
[security]
INSTALL_LOCK = true
SECRET_KEY = yuno_key
SECRET_KEY = __KEY__
REVERSE_PROXY_AUTHENTICATION_USER = REMOTE_USER

View file

@ -1,10 +0,0 @@
# gogs logs:
/var/log/gogs/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
copytruncate
}

View file

@ -1,6 +1,6 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
proxy_pass http://localhost:6000/;
proxy_pass http://localhost:__PORT__/;
proxy_set_header Host $host;
proxy_buffering off;
fastcgi_param REMOTE_USER $remote_user;

View file

@ -40,19 +40,26 @@ config_nginx() {
}
config_gogs() {
ynh_backup_if_checksum_is_different "$final_path/custom/conf/app.ini"
cp ../conf/app.ini "$final_path"/custom/conf
ynh_replace_string "yuno_repo_path" "$REPO_PATH" "$final_path"/custom/conf/app.ini
if [ "$path_url" = "/" ]
then
ynh_replace_string "yuno_url" "$domain" "$final_path"/custom/conf/app.ini
ynh_replace_string "__URL__" "$domain" "$final_path/custom/conf/app.ini"
else
ynh_replace_string "yuno_url" "$domain${path_url%/}" "$final_path"/custom/conf/app.ini
ynh_replace_string "__URL__" "$domain${path_url%/}" "$final_path/custom/conf/app.ini"
fi
ynh_replace_string "yuno_dbpdw" "$dbpass" "$final_path"/custom/conf/app.ini
ynh_replace_string "yuno_dbuser" "$dbuser" "$final_path"/custom/conf/app.ini
ynh_replace_string "yuno_domain" "$domain" "$final_path"/custom/conf/app.ini
ynh_replace_string "yuno_key" "$key" "$final_path"/custom/conf/app.ini
ynh_replace_string "yuno_data_path" "$DATA_PATH" "$final_path"/custom/conf/app.ini
ynh_replace_string "__REPOS_PATH__" "$REPO_PATH" "$final_path/custom/conf/app.ini"
ynh_replace_string "__DB_PASSWORD__" "$dbpass" "$final_path/custom/conf/app.ini"
ynh_replace_string "__DB_USER__" "$dbuser" "$final_path/custom/conf/app.ini"
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/custom/conf/app.ini"
ynh_replace_string "__KEY__" "$key" "$final_path/custom/conf/app.ini"
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_store_file_checksum "$final_path/custom/conf/app.ini"
}
set_permission() {
@ -63,28 +70,3 @@ set_permission() {
chmod u=rwX,g=rX,o= "/home/$app"
chmod u=rwX,g=rX,o= "/var/log/$app"
}
# Remote URL to fetch Gogs tarball
# GOGS_BINARY_URL="https://github.com/gogits/gogs/releases/download/v${VERSION}/${architecture}.zip"
#
# Common helpers
#
# Download and extract Gogs binary to the given directory
# # usage: extract_gogs DESTDIR
# extract_gogs() {
# # local DESTDIR=$1
# # local TMPDIR=$(mktemp -d)
# #
# # # retrieve and extract Gogs tarball
# # gogs_tarball="/tmp/gogs.zip"
# # rm -f "$gogs_tarball"
# # wget -q -O "$gogs_tarball" "$GOGS_BINARY_URL" \
# # || ynh_die "Unable to download Gogs tarball"
# # unzip -q "$gogs_tarball" -d "$TMPDIR" \
# # || ynh_die "Unable to extract Gogs tarball"
# # sudo rsync -a "$TMPDIR"/gogs/* "$DESTDIR"
# # rm -rf "$gogs_tarball" "${TMPDIR:-/tmp/fakefile}"
#
# }

View file

@ -31,12 +31,16 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder"
dbpass=$(ynh_string_random)
key=$(ynh_string_random)
# Find available ports
port=$(ynh_find_port 6000)
# Initialize database and store mysql password for upgrade
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
ynh_app_setting_set $app mysqlpwd $dbpass
ynh_app_setting_set $app adminusername $admin
ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app secret_key $is_public
ynh_app_setting_set $app web_port $port
# Add users
ynh_system_user_create $app
@ -80,7 +84,7 @@ ynh_replace_string "yuno_admin" "$admin" ../conf/login_source.sql
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ../conf/login_source.sql
# Unprotect root from SSO if public
if [ "$is_public" = "Yes" ]
if [ ! "$is_public" ]
then
ynh_app_setting_set $app unprotected_uris "/"
fi

View file

@ -17,6 +17,7 @@ dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
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)
# Backup the current version of the app
if [[ $(ynh_app_setting_get $app disable_backup_before_upgrade) != '1' ]]
@ -39,6 +40,12 @@ fi
# Stop service
systemctl stop "$app".service
if [[ $port == "" ]]
then
port=$(ynh_find_port 6000)
ynh_app_setting_set $app web_port $port
fi
# create needed directories if not already created
create_dir