1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/gitlab_ynh.git synced 2024-09-03 18:36:35 +02:00

Merge pull request #18 from YunoHost-Apps/testing

Fix web account and add function to wait gitlab service
This commit is contained in:
bourreP 2019-01-13 21:12:59 +01:00 committed by GitHub
commit f39f81ce30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 73 additions and 46 deletions

View file

@ -3,7 +3,7 @@
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
path="/" (PATH)
path="/gitlab" (PATH)
admin="john" (USER)
is_public=1 (PUBLIC|public=1|private=0)
password="pass"

View file

@ -61,13 +61,13 @@
"default": true
},
{
"name": "only_use_ldap",
"name": "use_web_account",
"type": "boolean",
"ask": {
"en": "Use only Yunohost account to sign in?",
"fr": "Utiliser seulement les comptes Yunohost pour se connecter ?"
"en": "Allow account creation via the gitlab web interface?",
"fr": "Autoriser la création de compte via l'interface web de gitlab ?"
},
"default": true
"default": false
}
]
}

View file

@ -117,8 +117,54 @@ setup_source() {
then
dpkg -i $src_filename || true # This command will fail in lxc env
sed -i 's/command \"cat \/etc\/sysctl.conf \/etc\/sysctl.d\/\*.conf | sysctl -e -p -\"/command \"cat \/etc\/sysctl.conf\"/g' $final_path/embedded/cookbooks/package/resources/sysctl.rb
sudo gitlab-ctl reconfigure
dpkg --configure gitlab-ce || true
else
dpkg -i $src_filename
dpkg -i $src_filename || true
fi;
}
#=================================================
# WAIT
#=================================================
# This function is inspired by the ynh_systemd_action function
waiting_to_start() {
echo "Start Waiting"
log_path="/var/log/gitlab/unicorn/current"
if [ ! -f "$log_path" ]
then
return 0
fi
line_match_new="adopted new unicorn master"
line_match_existing="adopted existing unicorn master"
clean_check_starting() {
# Stop the execution of tail
kill -s 15 $pid_tail 2>&1
ynh_secure_remove "$templog" 2>&1
}
# Following the starting of the app in its log
local templog="$(mktemp)"
tail -F -n1 "$log_path" > "$templog" &
# get the PID of the tail command
local pid_tail=$!
for i in $(seq 1 100)
do
if grep --quiet "${line_match_new}" $templog || grep --quiet "${line_match_existing}" $templog
then
echo "Gitlab has correctly started." >&2
break
fi
sleep 1
echo -n "." >&2
done
echo "Stop Waiting"
clean_check_starting
}

View file

@ -108,6 +108,7 @@ sudo gitlab-ctl reconfigure
if [ $change_path -eq 1 ]
then
sudo gitlab-ctl restart
sudo gitlab-ctl restart unicorn
fi
#=================================================
@ -118,17 +119,8 @@ fi
systemctl reload nginx
#Fix for the CI
if sudo grep -qa container=lxc /proc/1/environ;
then
status_code=$(curl -s -o /dev/null -w '%{http_code}' "$domain${path_url%/}")
inc=0
#=================================================
# WAIT
#=================================================
# Have to wait the time that gitlab reload
while [ $status_code == "502" ] && [ $inc -lt 10 ]
do
sleep 10;
status_code=$(curl -s -o /dev/null -w '%{http_code}' "$domain${path_url%/}")
((inc++))
done;
fi;
waiting_to_start

View file

@ -22,7 +22,7 @@ source ./_common.sh
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
only_use_ldap=$YNH_APP_ARG_IS_PUBLIC
use_web_account=$YNH_APP_ARG_USE_WEB_ACCOUNT
admin=$YNH_APP_ARG_ADMIN
#=================================================
@ -50,7 +50,7 @@ ynh_user_exists "$admin" \
ynh_app_setting_set $app admin $admin
ynh_app_setting_set $app path_url $path_url
ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app only_use_ldap $only_use_ldap
ynh_app_setting_set $app use_web_account $use_web_account
#=================================================
# STANDARD MODIFICATIONS
@ -107,7 +107,7 @@ newuser.admin = true
newuser.confirmed_at = Time.now
newuser.confirmation_token = nil
newuser.save
ApplicationSetting.last.update_attributes(password_authentication_enabled_for_web: $only_use_ldap, signup_enabled: $only_use_ldap)" | sudo gitlab-rails console
ApplicationSetting.last.update_attributes(password_authentication_enabled_for_web: $use_web_account, signup_enabled: $use_web_account)" | sudo gitlab-rails console
#=================================================
# RESTART TO TAKE INTO ACCOUNT CHANGES
@ -134,8 +134,7 @@ fi
systemctl reload nginx
#=================================================
# SETUP LOGROTATE
# WAIT
#=================================================
# Configure logrotate
#ynh_use_logrotate "/var/log/$app"
waiting_to_start

View file

@ -30,13 +30,12 @@ portUnicorn=$(ynh_app_setting_get "$app" unicorn_port)
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
# TODO: Backup and Restore Scripts
## Backup the current version of the app
#ynh_backup_before_upgrade
#ynh_clean_setup () {
# # restore it if the upgrade fails
# ynh_restore_upgradebackup
#}
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -96,17 +95,8 @@ fi
# Reload nginx service
systemctl reload nginx
#Fix for the CI
if sudo grep -qa container=lxc /proc/1/environ;
then
status_code=$(curl -s -o /dev/null -w '%{http_code}' "$domain${path_url%/}")
inc=0
#=================================================
# WAIT
#=================================================
# Have to wait the time that gitlab reload
while [ $status_code == "502" ] && [ $inc -lt 10 ]
do
sleep 10;
status_code=$(curl -s -o /dev/null -w '%{http_code}' "$domain${path_url%/}")
((inc++))
done;
fi;
waiting_to_start