mirror of
https://github.com/YunoHost-Apps/gogs_ynh.git
synced 2024-09-03 20:36:23 +02:00
Add multinstance support
This commit is contained in:
parent
13ab394e5a
commit
943f689f9d
10 changed files with 34 additions and 41 deletions
|
@ -81,6 +81,8 @@ sudo yunohost app upgrade -f /home/admin/gogs_ynh gogs
|
||||||
|
|
||||||
## Todo
|
## Todo
|
||||||
|
|
||||||
|
- Big comment
|
||||||
|
- Test multi instance
|
||||||
- check migration
|
- check migration
|
||||||
- change-url
|
- change-url
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,9 @@
|
||||||
setup_private=1
|
setup_private=1
|
||||||
setup_public=1
|
setup_public=1
|
||||||
upgrade=1
|
upgrade=1
|
||||||
# upgrade=1 from_commit=a62bce7dbc6bc0e1f1b4e872286ff124747ea009
|
upgrade=1 from_commit=aa075b2051ffad7b0b6fef3a9c767376d5bdbfab
|
||||||
# upgrade=1 from_commit=f050f88fbfe7bad1bf74d4584ec62ffcf28248e7
|
upgrade=1 from_commit=1cbec051e1171de5a8ed1e850eb4fb3506114da5
|
||||||
|
upgrade=1 from_commit=5a706ed246392c1ce39c47a648cb93e2996e80d3
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=1
|
||||||
incorrect_path=0
|
incorrect_path=0
|
||||||
|
@ -32,7 +33,9 @@
|
||||||
Level 9=0
|
Level 9=0
|
||||||
Level 10=0
|
Level 10=0
|
||||||
;;; Upgrade options
|
;;; Upgrade options
|
||||||
# ; commit=a62bce7dbc6bc0e1f1b4e872286ff124747ea009
|
; commit=aa075b2051ffad7b0b6fef3a9c767376d5bdbfab
|
||||||
# name=Before multi_instance
|
name=Before multi_instance and refactoring
|
||||||
# ; commit=f050f88fbfe7bad1bf74d4584ec62ffcf28248e7
|
; commit=1cbec051e1171de5a8ed1e850eb4fb3506114da5
|
||||||
# name=Old version package
|
name=From V0.10.18
|
||||||
|
; commit=5a706ed246392c1ce39c47a648cb93e2996e80d3
|
||||||
|
name=The oldest package
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
;https://github.com/gogits/gogs/blob/master/conf/app.ini
|
;https://github.com/gogits/gogs/blob/master/conf/app.ini
|
||||||
APP_NAME = Gogs: Go Git Service
|
APP_NAME = Gogs: Go Git Service
|
||||||
RUN_USER = gogs
|
RUN_USER = __APP__
|
||||||
RUN_MODE = prod
|
RUN_MODE = prod
|
||||||
[database]
|
[database]
|
||||||
DB_TYPE = mysql
|
DB_TYPE = mysql
|
||||||
|
@ -44,7 +44,7 @@ PROVIDER = memory
|
||||||
[log]
|
[log]
|
||||||
MODE = file
|
MODE = file
|
||||||
LEVEL = Warn
|
LEVEL = Warn
|
||||||
ROOT_PATH = /var/log/gogs
|
ROOT_PATH = /var/log/__APP__
|
||||||
[security]
|
[security]
|
||||||
INSTALL_LOCK = true
|
INSTALL_LOCK = true
|
||||||
SECRET_KEY = __KEY__
|
SECRET_KEY = __KEY__
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
INSERT INTO `gogs`.`login_source` (`id`, `type`, `name`, `is_actived`, `cfg`, `created_unix`, `updated_unix`) VALUES
|
INSERT INTO `__APP__`.`login_source` (`id`, `type`, `name`, `is_actived`, `cfg`, `created_unix`, `updated_unix`) VALUES
|
||||||
('1', '2', 'Yunohost LDAP', '1', '{"Name":"Yunohost LDAP","Host":"localhost","Port":389,"UseSSL":false,"BindDN":"","BindPassword":"","UserBase":"ou=users,dc=yunohost,dc=org","AttributeName":"givenName","AttributeSurname":"sn","AttributeMail":"mail","Filter":"(uid=%s)","AdminFilter":"(uid=yuno_admin)","Enabled":true}', '1464014433', '1464015955')
|
('1', '2', 'Yunohost LDAP', '1', '{"Name":"Yunohost LDAP","Host":"localhost","Port":389,"UseSSL":false,"BindDN":"","BindPassword":"","UserBase":"ou=users,dc=yunohost,dc=org","AttributeName":"givenName","AttributeSurname":"sn","AttributeMail":"mail","Filter":"(uid=%s)","AdminFilter":"(uid=__ADMIN__)","Enabled":true}', '1464014433', '1464015955')
|
||||||
ON DUPLICATE KEY UPDATE cfg='{"Name":"Yunohost LDAP","Host":"localhost","Port":389,"UseSSL":false,"BindDN":"","BindPassword":"","UserBase":"ou=users,dc=yunohost,dc=org","AttributeName":"givenName","AttributeSurname":"sn","AttributeMail":"mail","Filter":"(uid=%s)","AdminFilter":"(uid=yuno_admin)","Enabled":true}'
|
ON DUPLICATE KEY UPDATE cfg='{"Name":"Yunohost LDAP","Host":"localhost","Port":389,"UseSSL":false,"BindDN":"","BindPassword":"","UserBase":"ou=users,dc=yunohost,dc=org","AttributeName":"givenName","AttributeSurname":"sn","AttributeMail":"mail","Filter":"(uid=%s)","AdminFilter":"(uid=__ADMIN__)","Enabled":true}'
|
||||||
|
|
|
@ -13,12 +13,12 @@ After=slapd.service
|
||||||
#LimitMEMLOCK=infinity
|
#LimitMEMLOCK=infinity
|
||||||
#LimitNOFILE=65535
|
#LimitNOFILE=65535
|
||||||
Type=simple
|
Type=simple
|
||||||
User=gogs
|
User=__APP__
|
||||||
Group=gogs
|
Group=__APP__
|
||||||
WorkingDirectory=/home/gogs
|
WorkingDirectory=/home/__APP__
|
||||||
ExecStart=/opt/gogs/gogs web
|
ExecStart=/opt/__APP__/gogs web
|
||||||
Restart=always
|
Restart=always
|
||||||
Environment=USER=gogs HOME=/home/gogs
|
Environment=USER=__APP__ HOME=/home/__APP__
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"name": "tostaki",
|
"name": "tostaki",
|
||||||
"email": "maxime@max.privy.place"
|
"email": "maxime@max.privy.place"
|
||||||
},
|
},
|
||||||
"multi_instance": false,
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
"nginx",
|
"nginx",
|
||||||
"mysql"
|
"mysql"
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
# Common variables
|
# Common variables
|
||||||
#
|
#
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
final_path="/opt/$app"
|
|
||||||
dbname=$app
|
dbname=$app
|
||||||
dbuser=$app
|
dbuser=$app
|
||||||
|
final_path="/opt/$app"
|
||||||
DATADIR="/home/$app"
|
DATADIR="/home/$app"
|
||||||
REPO_PATH="$DATADIR/repositories"
|
REPO_PATH="$DATADIR/repositories"
|
||||||
DATA_PATH="$DATADIR/data"
|
DATA_PATH="$DATADIR/data"
|
||||||
|
@ -24,6 +24,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
create_dir() {
|
create_dir() {
|
||||||
|
mkdir -p "$final_path/data"
|
||||||
mkdir -p "$final_path/custom/conf"
|
mkdir -p "$final_path/custom/conf"
|
||||||
mkdir -p "$REPO_PATH"
|
mkdir -p "$REPO_PATH"
|
||||||
mkdir -p "$DATA_PATH/avatars"
|
mkdir -p "$DATA_PATH/avatars"
|
||||||
|
@ -58,6 +59,7 @@ config_gogs() {
|
||||||
ynh_replace_string "__KEY__" "$key" "$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 "__DATA_PATH__" "$DATA_PATH" "$final_path/custom/conf/app.ini"
|
||||||
ynh_replace_string "__PORT__" $port "$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_store_file_checksum "$final_path/custom/conf/app.ini"
|
ynh_store_file_checksum "$final_path/custom/conf/app.ini"
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,16 +45,9 @@ ynh_app_setting_set $app web_port $port
|
||||||
# Add users
|
# Add users
|
||||||
ynh_system_user_create $app
|
ynh_system_user_create $app
|
||||||
|
|
||||||
# id -g "$app" &>/dev/null || sudo addgroup "$app" --system --quiet
|
|
||||||
# id -u "$app" &>/dev/null || sudo adduser "$app" \
|
|
||||||
# --ingroup "$app" --system --quiet --shell /bin/bash
|
|
||||||
|
|
||||||
# create needed directories
|
# create needed directories
|
||||||
create_dir
|
create_dir
|
||||||
|
|
||||||
# Create uploads folder and permissions
|
|
||||||
mkdir /opt/$app/data
|
|
||||||
|
|
||||||
# Install Gogs
|
# Install Gogs
|
||||||
ynh_setup_source $final_path $architecture
|
ynh_setup_source $final_path $architecture
|
||||||
|
|
||||||
|
@ -80,11 +73,12 @@ do
|
||||||
done
|
done
|
||||||
|
|
||||||
# Add ldap config
|
# Add ldap config
|
||||||
ynh_replace_string "yuno_admin" "$admin" ../conf/login_source.sql
|
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
|
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" ]
|
if [ "$is_public" = '1' ]
|
||||||
then
|
then
|
||||||
ynh_app_setting_set $app unprotected_uris "/"
|
ynh_app_setting_set $app unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -10,11 +10,6 @@ ynh_abort_if_errors
|
||||||
source ../settings/scripts/experimental_helper.sh
|
source ../settings/scripts/experimental_helper.sh
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
|
|
||||||
# Set app specific variables
|
|
||||||
app=${APPNAME:-gogs}
|
|
||||||
dbname=$app
|
|
||||||
dbuser=$app
|
|
||||||
|
|
||||||
# Retrieve old app settings
|
# Retrieve old app settings
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
path_url=$(ynh_app_setting_get "$app" path)
|
path_url=$(ynh_app_setting_get "$app" path)
|
||||||
|
|
|
@ -12,7 +12,7 @@ source ./_common.sh
|
||||||
|
|
||||||
# Retrieve app settings
|
# Retrieve app settings
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
path_url=$(ynh_app_setting_get "$app" path)
|
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get "$app" path))
|
||||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
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)
|
||||||
|
@ -20,13 +20,10 @@ is_public=$(ynh_app_setting_get "$app" is_public)
|
||||||
port=$(ynh_app_setting_get "$app" web_port)
|
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' ]]
|
ynh_backup_before_upgrade
|
||||||
then
|
ynh_clean_setup () {
|
||||||
ynh_backup_before_upgrade
|
ynh_restore_upgradebackup
|
||||||
ynh_clean_setup () {
|
}
|
||||||
ynh_restore_upgradebackup
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update settings is_public to new standard
|
# Update settings is_public to new standard
|
||||||
if [ "$is_public" = "Yes" ]; then
|
if [ "$is_public" = "Yes" ]; then
|
||||||
|
@ -78,7 +75,7 @@ ynh_add_systemd_config
|
||||||
config_nginx
|
config_nginx
|
||||||
|
|
||||||
# Unprotect root from SSO if public
|
# Unprotect root from SSO if public
|
||||||
if [ "$is_public" ]
|
if [ ! "$is_public" ]
|
||||||
then
|
then
|
||||||
ynh_app_setting_set $app unprotected_uris "/"
|
ynh_app_setting_set $app unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue