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 sudo yunohost app upgrade -f /home/admin/gogs_ynh gogs
``` ```
## Todo
- check migration
- change-url

View file

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

View file

@ -5,27 +5,27 @@ RUN_MODE = prod
[database] [database]
DB_TYPE = mysql DB_TYPE = mysql
HOST = 127.0.0.1:3306 HOST = 127.0.0.1:3306
NAME = yuno_dbuser NAME = __DB_USER__
USER = yuno_dbuser USER = __DB_USER__
PASSWD = yuno_dbpdw PASSWD = __DB_PASSWORD__
SSL_MODE = disable SSL_MODE = disable
PATH = data/gogs.db PATH = data/gogs.db
[repository] [repository]
ROOT = yuno_repo_path ROOT = __REPOS_PATH__
FORCE_PRIVATE = false FORCE_PRIVATE = false
[server] [server]
DOMAIN = yuno_domain DOMAIN = __DOMAIN__
HTTP_PORT = 6000 HTTP_PORT = __PORT__
ROOT_URL = https://yuno_url/ ROOT_URL = https://__URL__/
DISABLE_SSH = false DISABLE_SSH = false
SSH_PORT = 22 SSH_PORT = 22
OFFLINE_MODE = false OFFLINE_MODE = false
APP_DATA_PATH = yuno_data_path APP_DATA_PATH = __DATA_PATH__
LANDING_PAGE = explore LANDING_PAGE = explore
[mailer] [mailer]
ENABLED = true ENABLED = true
HOST = 127.0.0.1:25 HOST = 127.0.0.1:25
FROM = "Gogs" <gogs-noreply@yuno_domain> FROM = "Gogs" <gogs-noreply@__DOMAIN__>
SKIP_VERIFY = true SKIP_VERIFY = true
[service] [service]
REGISTER_EMAIL_CONFIRM = false REGISTER_EMAIL_CONFIRM = false
@ -36,9 +36,9 @@ REQUIRE_SIGNIN_VIEW = false
ENABLE_REVERSE_PROXY_AUTHENTICATION = true ENABLE_REVERSE_PROXY_AUTHENTICATION = true
ENABLE_REVERSE_PROXY_AUTO_REGISTERATION = true ENABLE_REVERSE_PROXY_AUTO_REGISTERATION = true
[picture] [picture]
AVATAR_UPLOAD_PATH = yuno_data_path/avatars AVATAR_UPLOAD_PATH = __DATA_PATH__/avatars
[attachment] [attachment]
PATH = yuno_data_path/attachments PATH = __DATA_PATH__/attachments
[session] [session]
PROVIDER = memory PROVIDER = memory
[log] [log]
@ -47,5 +47,5 @@ LEVEL = Warn
ROOT_PATH = /var/log/gogs ROOT_PATH = /var/log/gogs
[security] [security]
INSTALL_LOCK = true INSTALL_LOCK = true
SECRET_KEY = yuno_key SECRET_KEY = __KEY__
REVERSE_PROXY_AUTHENTICATION_USER = REMOTE_USER 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; #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ { location __PATH__/ {
proxy_pass http://localhost:6000/; proxy_pass http://localhost:__PORT__/;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_buffering off; proxy_buffering off;
fastcgi_param REMOTE_USER $remote_user; fastcgi_param REMOTE_USER $remote_user;

View file

@ -40,19 +40,26 @@ config_nginx() {
} }
config_gogs() { config_gogs() {
ynh_backup_if_checksum_is_different "$final_path/custom/conf/app.ini"
cp ../conf/app.ini "$final_path"/custom/conf 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" = "/" ] if [ "$path_url" = "/" ]
then 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 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 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 "__REPOS_PATH__" "$REPO_PATH" "$final_path/custom/conf/app.ini"
ynh_replace_string "yuno_domain" "$domain" "$final_path"/custom/conf/app.ini ynh_replace_string "__DB_PASSWORD__" "$dbpass" "$final_path/custom/conf/app.ini"
ynh_replace_string "yuno_key" "$key" "$final_path"/custom/conf/app.ini ynh_replace_string "__DB_USER__" "$dbuser" "$final_path/custom/conf/app.ini"
ynh_replace_string "yuno_data_path" "$DATA_PATH" "$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() { set_permission() {
@ -63,28 +70,3 @@ set_permission() {
chmod u=rwX,g=rX,o= "/home/$app" chmod u=rwX,g=rX,o= "/home/$app"
chmod u=rwX,g=rX,o= "/var/log/$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) dbpass=$(ynh_string_random)
key=$(ynh_string_random) key=$(ynh_string_random)
# Find available ports
port=$(ynh_find_port 6000)
# Initialize database and store mysql password for upgrade # Initialize database and store mysql password for upgrade
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
ynh_app_setting_set $app mysqlpwd $dbpass ynh_app_setting_set $app mysqlpwd $dbpass
ynh_app_setting_set $app adminusername $admin ynh_app_setting_set $app adminusername $admin
ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app secret_key $is_public ynh_app_setting_set $app secret_key $is_public
ynh_app_setting_set $app web_port $port
# Add users # Add users
ynh_system_user_create $app 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 ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ../conf/login_source.sql
# Unprotect root from SSO if public # Unprotect root from SSO if public
if [ "$is_public" = "Yes" ] if [ ! "$is_public" ]
then then
ynh_app_setting_set $app unprotected_uris "/" ynh_app_setting_set $app unprotected_uris "/"
fi fi

View file

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