mirror of
https://github.com/YunoHost-Apps/gitlab_ynh.git
synced 2024-09-03 18:36:35 +02:00
Merge pull request #21 from YunoHost-Apps/testing
Format files, fix restore
This commit is contained in:
commit
151d6d43c4
9 changed files with 137 additions and 126 deletions
|
@ -7,7 +7,7 @@ gitlab_rails['ldap_servers'] = YAML.load <<-'EOS' # remember to close this block
|
|||
host: 'localhost'
|
||||
port: 389
|
||||
uid: 'uid'
|
||||
method: 'plain' # "tls" or "ssl" or "plain"
|
||||
encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
|
||||
bind_dn: ''
|
||||
password: ''
|
||||
active_directory: false
|
||||
|
|
|
@ -34,6 +34,8 @@ create_dir() {
|
|||
# CONFIGURATION FILE FOR GITLAB
|
||||
#=================================================
|
||||
config_gitlab() {
|
||||
ynh_print_info "Configuring Gitlab..."
|
||||
|
||||
create_dir
|
||||
|
||||
gitlab_conf_path="$config_path/gitlab.rb"
|
||||
|
@ -54,6 +56,8 @@ config_gitlab() {
|
|||
# REMOVE THE CONFIGURATION FILE FOR GITLAB
|
||||
#=================================================
|
||||
remove_config_gitlab() {
|
||||
ynh_print_info "Removing the configuration file..."
|
||||
|
||||
ynh_secure_remove "$config_path/gitlab.rb"
|
||||
}
|
||||
|
||||
|
@ -101,26 +105,27 @@ setup_source() {
|
|||
fi
|
||||
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${src_filename}"
|
||||
|
||||
if test -e "$local_src"
|
||||
then # Use the local source file if it is present
|
||||
ynh_print_info "Downloading Gitlab files..."
|
||||
|
||||
if test -e "$local_src"; then # Use the local source file if it is present
|
||||
cp $local_src $src_filename
|
||||
else # If not, download the source
|
||||
local out=`wget -nv -O $src_filename $src_url 2>&1` || ynh_print_err $out
|
||||
wget -q --show-progress -O $src_filename $src_url
|
||||
fi
|
||||
|
||||
# Check the control sum
|
||||
echo "${src_sum} ${src_filename}" | ${src_sumprg} -c --status \
|
||||
|| ynh_die "Corrupt source"
|
||||
echo "${src_sum} ${src_filename}" | ${src_sumprg} -c --status ||
|
||||
ynh_die "Corrupt source"
|
||||
|
||||
ynh_print_info "Installing Gitlab..."
|
||||
#Fix for the CI
|
||||
if sudo grep -qa container=lxc /proc/1/environ;
|
||||
then
|
||||
if sudo grep -qa container=lxc /proc/1/environ; 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
|
||||
dpkg --configure gitlab-ce || true
|
||||
else
|
||||
dpkg -i $src_filename || true
|
||||
fi;
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
@ -129,12 +134,11 @@ setup_source() {
|
|||
# This function is inspired by the ynh_systemd_action function
|
||||
waiting_to_start() {
|
||||
|
||||
echo "Start Waiting"
|
||||
ynh_print_info "Waiting for a response from Gitlab..."
|
||||
|
||||
log_path="/var/log/gitlab/unicorn/current"
|
||||
|
||||
if [ ! -f "$log_path" ]
|
||||
then
|
||||
if [ ! -f "$log_path" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
@ -153,10 +157,8 @@ waiting_to_start() {
|
|||
# get the PID of the tail command
|
||||
local pid_tail=$!
|
||||
|
||||
for i in $(seq 1 500)
|
||||
do
|
||||
if grep --quiet "${line_match_new}" $templog || grep --quiet "${line_match_existing}" $templog
|
||||
then
|
||||
for i in $(seq 1 500); do
|
||||
if grep --quiet "${line_match_new}" $templog || grep --quiet "${line_match_existing}" $templog; then
|
||||
echo "Gitlab has correctly started." >&2
|
||||
break
|
||||
fi
|
||||
|
@ -164,7 +166,5 @@ waiting_to_start() {
|
|||
echo -n "." >&2
|
||||
done
|
||||
|
||||
echo "Stop Waiting"
|
||||
|
||||
clean_check_starting
|
||||
}
|
|
@ -44,6 +44,8 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
# BACKUP GITLAB DATABASE
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Backuping of Gitlab..."
|
||||
|
||||
# Use gitlab-rake to backup
|
||||
gitlab-rake gitlab:backup:create
|
||||
|
||||
|
@ -53,5 +55,7 @@ ynh_backup "/var/opt/$app/backups/"
|
|||
# BACKUP CONF FILES
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Backuping configuration files of Gitlab..."
|
||||
|
||||
ynh_backup "$config_path/gitlab-secrets.json"
|
||||
ynh_backup "$config_path/gitlab.rb"
|
||||
|
|
|
@ -51,14 +51,12 @@ path_url="$new_path"
|
|||
#=================================================
|
||||
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
if [ "$old_domain" != "$new_domain" ]; then
|
||||
change_domain=1
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
if [ "$old_path" != "$new_path" ]; then
|
||||
change_path=1
|
||||
fi
|
||||
|
||||
|
@ -73,8 +71,9 @@ fi
|
|||
# Gitlab configuration
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
if [ $change_path -eq 1 ]; then
|
||||
ynh_print_info "Changing path..."
|
||||
|
||||
sudo gitlab-ctl stop unicorn
|
||||
sudo gitlab-ctl stop sidekiq
|
||||
|
||||
|
@ -88,8 +87,9 @@ then
|
|||
fi
|
||||
|
||||
# Change the domain for nginx
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
if [ $change_domain -eq 1 ]; then
|
||||
ynh_print_info "Changing domain..."
|
||||
|
||||
# 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
|
||||
|
@ -105,8 +105,7 @@ config_gitlab
|
|||
|
||||
sudo gitlab-ctl reconfigure
|
||||
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
if [ $change_path -eq 1 ]; then
|
||||
sudo gitlab-ctl restart
|
||||
sudo gitlab-ctl restart unicorn
|
||||
fi
|
||||
|
|
|
@ -40,8 +40,8 @@ ynh_webpath_register $app $domain $path_url
|
|||
#=================================================
|
||||
|
||||
# Check user parameter
|
||||
ynh_user_exists "$admin" \
|
||||
|| ynh_die "The chosen admin user does not exist."
|
||||
ynh_user_exists "$admin" ||
|
||||
ynh_die "The chosen admin user does not exist."
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
|
@ -58,6 +58,8 @@ ynh_app_setting_set $app use_web_account $use_web_account
|
|||
# FIND AND OPEN PORTS
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Getting ports..."
|
||||
|
||||
# Find free ports
|
||||
port=$(ynh_find_port 8080)
|
||||
portUnicorn=$(ynh_find_port $(($port + 1)))
|
||||
|
@ -99,6 +101,8 @@ setup_source $architecture
|
|||
# GETTING ADMIN INFO AND ADD AS A GITLAB USER AND CONFIGURE SIGN IN SYSTEM
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Creating an administrator user..."
|
||||
|
||||
mailadmin=$(ynh_user_get_info $admin mail)
|
||||
rdmPass=$(ynh_string_random 30)
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ portUnicorn=$(ynh_app_setting_get "$app" unicorn_port)
|
|||
# REMOVE GITLAB
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Removing Gitlab..."
|
||||
|
||||
# Remove gitlab
|
||||
dpkg --remove gitlab-ce
|
||||
|
||||
|
@ -59,14 +61,12 @@ ynh_secure_remove "/var/log/$app"
|
|||
# CLOSE PORTS
|
||||
#=================================================
|
||||
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
if yunohost firewall list | grep -q "\- $port$"; then
|
||||
echo "Close port $port" >&2
|
||||
yunohost firewall disallow TCP $port 2>&1
|
||||
fi
|
||||
|
||||
if yunohost firewall list | grep -q "\- $portUnicorn$"
|
||||
then
|
||||
if yunohost firewall list | grep -q "\- $portUnicorn$"; then
|
||||
echo "Close port $portUnicorn" >&2
|
||||
yunohost firewall disallow TCP $portUnicorn 2>&1
|
||||
fi
|
||||
|
|
|
@ -17,9 +17,9 @@ if [ ! -e _common.sh ]; then
|
|||
cp ../settings/scripts/_common.sh ./_common.sh
|
||||
mkdir ./upgrade.d
|
||||
mkdir ../conf
|
||||
cp ../settings/scripts/upgrade.d/*.sh ./upgrade.d/*.sh
|
||||
cp ../settings/scripts/upgrade.d/*.sh ./upgrade.d/
|
||||
cp ../settings/conf/*.default ../conf/
|
||||
chmod a+rx _common.sh upgrade.d/*.sh
|
||||
chmod a+rx _common.sh upgrade.d/*
|
||||
fi
|
||||
|
||||
# Load common variables and helpers
|
||||
|
@ -47,10 +47,10 @@ path_url=$(ynh_app_setting_get "$app" path_url)
|
|||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
|
||||
ynh_webpath_available $domain $path_url \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
ynh_webpath_available $domain $path_url ||
|
||||
ynh_die "Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path ||
|
||||
ynh_die "There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
@ -70,6 +70,8 @@ ynh_install_app_dependencies openssh-server
|
|||
# RESTORE CONF FILES
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Restoring configuration files of Gitlab..."
|
||||
|
||||
ynh_restore_file "$config_path/gitlab-secrets.json"
|
||||
ynh_restore_file "$config_path/gitlab.rb"
|
||||
|
||||
|
@ -87,6 +89,8 @@ ynh_restore_file "/var/opt/$app/backups/"
|
|||
# RESTORE GITLAB DATABASE
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Restoring Gitlab..."
|
||||
|
||||
fullfile=$(ls /var/opt/gitlab/backups/*_gitlab* --file -c1 | head -1)
|
||||
basename="/var/opt/gitlab/backups/"
|
||||
filename=$(basename -- "$fullfile")
|
||||
|
|
Loading…
Add table
Reference in a new issue