mirror of
https://github.com/YunoHost-Apps/gitlab_ynh.git
synced 2024-09-03 18:36:35 +02:00
General Upgrade
This commit is contained in:
parent
318bd2c508
commit
f9089c0dac
13 changed files with 508 additions and 349 deletions
|
@ -6,6 +6,7 @@
|
|||
path="/gitlab" (PATH)
|
||||
admin="john" (USER)
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
use_web_account=0
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
|
@ -17,20 +18,17 @@
|
|||
upgrade=1 from_commit=2cc84310aeff7055342b445c1aee01d4183d5ae2
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
incorrect_path=1
|
||||
port_already_use=1 (8080)
|
||||
change_url=1
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
# Level 4:
|
||||
Level 4=1
|
||||
# Level 5:
|
||||
Level 4=auto
|
||||
Level 5=auto
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
Level 8=0
|
||||
Level 8=auto
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
;;; Options
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
SOURCE_URL=https://packages.gitlab.com/gitlab/raspberry-pi2/packages/raspbian/stretch/gitlab-ce___VERSION__-ce.0_armhf.deb/download.deb
|
||||
SOURCE_SUM=__SHA256_SUM__
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitlab-ce___VERSION__-ce.0_armhf.deb
|
||||
SOURCE_FILENAME=__SOURCE_FILENAME__
|
||||
SOURCE_EXTRACT=false
|
||||
SOURCE_FORMAT=deb
|
|
@ -1,6 +1,6 @@
|
|||
SOURCE_URL=https://packages.gitlab.com/gitlab/gitlab-ce/packages/debian/stretch/gitlab-ce___VERSION__-ce.0_amd64.deb/download.deb
|
||||
SOURCE_SUM=__SHA256_SUM__
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FILENAME=gitlab-ce___VERSION__-ce.0_amd64.deb
|
||||
SOURCE_FILENAME=__SOURCE_FILENAME__
|
||||
SOURCE_EXTRACT=false
|
||||
SOURCE_FORMAT=deb
|
|
@ -2,7 +2,7 @@
|
|||
"name": "Gitlab",
|
||||
"id": "gitlab",
|
||||
"packaging_format": 1,
|
||||
"version": "11.8.2~ynh1",
|
||||
"version": "11.8.2~ynh2",
|
||||
"description": {
|
||||
"en": "GitLab is a Git-repository manager.",
|
||||
"fr": "GitLab est un gestionnaire de dépôts Git."
|
||||
|
|
23
pull_request_template.md
Normal file
23
pull_request_template.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
## Problem
|
||||
- *Description of why you made this PR*
|
||||
|
||||
## Solution
|
||||
- *And how do you fix that problem*
|
||||
|
||||
## PR Status
|
||||
- [ ] Code finished.
|
||||
- [ ] Tested with Package_check.
|
||||
- [ ] Fix or enhancement tested.
|
||||
- [ ] Upgrade from last version tested.
|
||||
- [ ] Can be reviewed and tested.
|
||||
|
||||
## Validation
|
||||
---
|
||||
- [ ] **Code review**
|
||||
- [ ] **Approval (LGTM)**
|
||||
*Code review and approval have to be from a member of @YunoHost/apps group*
|
||||
- **CI succeeded** :
|
||||
[](https://ci-apps-hq.yunohost.org/jenkins/job/gitlab_ynh%20-BRANCH-/)
|
||||
*Please replace '-BRANCH-' in this link by the name of the branch used.*
|
||||
*If the PR is from a forked repository. Please provide public results from package_check.*
|
||||
When the PR is marked as ready to merge, you have to wait for 3 days before really merging it.
|
|
@ -1,175 +1,111 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# SET ALL CONSTANTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
config_path="/etc/$app"
|
||||
final_path="/opt/$app"
|
||||
pkg_dependencies="openssh-server"
|
||||
|
||||
#=================================================
|
||||
# DETECT THE SYSTEM ARCHITECTURE
|
||||
# PACKAGE CHECK BYPASSING...
|
||||
#=================================================
|
||||
# Detect the system architecture to download the right file
|
||||
# NOTE: `uname -m` is more accurate and universal than `arch`
|
||||
# See https://en.wikipedia.org/wiki/Uname
|
||||
if [ -n "$(uname -m | grep 64)" ]; then
|
||||
architecture="x86-64"
|
||||
elif [ -n "$(uname -m | grep 86)" ]; then
|
||||
ynh_die "Gitlab is not compatible with x86 architecture"
|
||||
elif [ -n "$(uname -m | grep arm)" ]; then
|
||||
architecture="arm"
|
||||
else
|
||||
ynh_die "Unable to detect your achitecture, please open a bug describing \
|
||||
your hardware and the result of the command \"uname -m\"." 1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE FOLDERS
|
||||
#=================================================
|
||||
create_dir() {
|
||||
mkdir -p "$config_path"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# CONFIGURATION FILE FOR GITLAB
|
||||
#=================================================
|
||||
config_gitlab() {
|
||||
ynh_print_info "Configuring Gitlab..."
|
||||
|
||||
create_dir
|
||||
|
||||
gitlab_conf_path="$config_path/gitlab.rb"
|
||||
|
||||
ynh_backup_if_checksum_is_different $gitlab_conf_path
|
||||
|
||||
# Gitlab configuration
|
||||
cp -f ../conf/gitlab.rb $gitlab_conf_path
|
||||
|
||||
ynh_replace_string "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" $gitlab_conf_path
|
||||
ynh_replace_string "__PORT__" "$port" $gitlab_conf_path
|
||||
ynh_replace_string "__PORTUNICORN__" "$portUnicorn" $gitlab_conf_path
|
||||
|
||||
ynh_store_file_checksum $gitlab_conf_path
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE CONFIGURATION FILE FOR GITLAB
|
||||
#=================================================
|
||||
remove_config_gitlab() {
|
||||
ynh_print_info "Removing the configuration file..."
|
||||
|
||||
ynh_secure_remove "$config_path/gitlab.rb"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# UPDATE SOURCES FILES
|
||||
#=================================================
|
||||
update_src_version() {
|
||||
source ./upgrade.d/upgrade.last.sh
|
||||
cp ../conf/arm.src.default ../conf/arm.src
|
||||
ynh_replace_string "__VERSION__" "$gitlab_version" "../conf/arm.src"
|
||||
ynh_replace_string "__SHA256_SUM__" "$gitlab_arm_source_sha256" "../conf/arm.src"
|
||||
|
||||
cp ../conf/x86-64.src.default ../conf/x86-64.src
|
||||
ynh_replace_string "__VERSION__" "$gitlab_version" "../conf/x86-64.src"
|
||||
ynh_replace_string "__SHA256_SUM__" "$gitlab_x86_64_source_sha256" "../conf/x86-64.src"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# INSTALL GITLAB
|
||||
#=================================================
|
||||
# This function is inspired by the ynh_setup_source function, adapted to deal with .deb files
|
||||
setup_source() {
|
||||
local src_id=${1:-app} # If the argument is not given, source_id equals "app"
|
||||
|
||||
update_src_version # Update source file
|
||||
|
||||
# Load value from configuration file (see above for a small doc about this file
|
||||
# format)
|
||||
local src_url=$(grep 'SOURCE_URL=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
||||
local src_sum=$(grep 'SOURCE_SUM=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
||||
local src_sumprg=$(grep 'SOURCE_SUM_PRG=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
||||
local src_format=$(grep 'SOURCE_FORMAT=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
||||
local src_extract=$(grep 'SOURCE_EXTRACT=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
||||
local src_in_subdir=$(grep 'SOURCE_IN_SUBDIR=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
||||
local src_filename=$(grep 'SOURCE_FILENAME=' "$YNH_CWD/../conf/${src_id}.src" | cut -d= -f2-)
|
||||
|
||||
# Default value
|
||||
src_sumprg=${src_sumprg:-sha256sum}
|
||||
src_in_subdir=${src_in_subdir:-true}
|
||||
src_format=${src_format:-tar.gz}
|
||||
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
|
||||
src_extract=${src_extract:-true}
|
||||
if [ "$src_filename" = "" ]; then
|
||||
src_filename="${src_id}.${src_format}"
|
||||
fi
|
||||
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${src_filename}"
|
||||
|
||||
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
|
||||
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"
|
||||
|
||||
ynh_print_info "Installing Gitlab..."
|
||||
#Fix for the CI
|
||||
if 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
|
||||
IS_PACKAGE_CHECK () {
|
||||
return $(env | grep -c container=lxc)
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# WAIT
|
||||
#=================================================
|
||||
# This function is inspired by the ynh_systemd_action function
|
||||
waiting_to_start() {
|
||||
|
||||
ynh_print_info "Waiting for a response from Gitlab..."
|
||||
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
|
||||
#
|
||||
# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ]
|
||||
# | arg: -n, --service_name= - Name of the service to start. Default : $app
|
||||
# | arg: -a, --action= - Action to perform with systemctl. Default: start
|
||||
# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot.
|
||||
# If not defined it don't wait until the service is completely started.
|
||||
# WARNING: When using --line_match, you should always add `ynh_clean_check_starting` into your
|
||||
# `ynh_clean_setup` at the beginning of the script. Otherwise, tail will not stop in case of failure
|
||||
# of the script. The script will then hang forever.
|
||||
# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log
|
||||
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
|
||||
# | arg: -e, --length= - Length of the error log : Default : 20
|
||||
gitlab_ctl_action() {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= )
|
||||
local service_name
|
||||
local action
|
||||
local line_match
|
||||
local length
|
||||
local log_path
|
||||
local timeout
|
||||
|
||||
log_path="/var/log/gitlab/unicorn/current"
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
if [ ! -f "$log_path" ]; then
|
||||
return 0
|
||||
fi
|
||||
local service_name="${service_name:-$app}"
|
||||
local action=${action:-start}
|
||||
local log_path="${log_path:-/var/log/$service_name/$service_name.log}"
|
||||
local length=${length:-20}
|
||||
local timeout=${timeout:-300}
|
||||
|
||||
line_match_new="adopted new unicorn master"
|
||||
line_match_existing="adopted existing unicorn master"
|
||||
line_match_error="master failed to start"
|
||||
|
||||
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
|
||||
# Start to read the log
|
||||
if [[ -n "${line_match:-}" ]]
|
||||
then
|
||||
local templog="$(mktemp)"
|
||||
tail -F -n1 "$log_path" >"$templog" &
|
||||
# get the PID of the tail command
|
||||
# Following the starting of the app in its log
|
||||
if [ "$log_path" == "systemd" ] ; then
|
||||
# Read the systemd journal
|
||||
journalctl --unit=$service_name --follow --since=-0 --quiet > "$templog" &
|
||||
# Get the PID of the journalctl command
|
||||
local pid_tail=$!
|
||||
|
||||
if grep --quiet "${line_match_error}" $templog; then # error, so restart gitlab
|
||||
gitlab-ctl restart
|
||||
else
|
||||
# Read the specified log file
|
||||
tail -F -n0 "$log_path" > "$templog" 2>&1 &
|
||||
# Get the PID of the tail command
|
||||
local pid_tail=$!
|
||||
fi
|
||||
fi
|
||||
|
||||
for i in $(seq 1 3600); do
|
||||
if grep --quiet "${line_match_new}" $templog || grep --quiet "${line_match_existing}" $templog; then
|
||||
echo "Gitlab has correctly started." >&2
|
||||
ynh_print_info --message="${action^} gitlab"
|
||||
|
||||
gitlab-ctl $action $service_name \
|
||||
|| ( journalctl --no-pager --lines=$length -u $service_name >&2 \
|
||||
; test -e "$log_path" && echo "--" >&2 && tail --lines=$length "$log_path" >&2 \
|
||||
; false )
|
||||
|
||||
# Start the timeout and try to find line_match
|
||||
if [[ -n "${line_match:-}" ]]
|
||||
then
|
||||
local i=0
|
||||
for i in $(seq 1 $timeout)
|
||||
do
|
||||
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
|
||||
if grep --quiet "$line_match" "$templog"
|
||||
then
|
||||
ynh_print_info --message="The service $service_name has correctly started."
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
if [ $i -eq 3 ]; then
|
||||
echo -n "Please wait, the service $service_name is ${action}ing" >&2
|
||||
fi
|
||||
if [ $i -ge 3 ]; then
|
||||
echo -n "." >&2
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
clean_check_starting
|
||||
if [ $i -ge 3 ]; then
|
||||
echo "" >&2
|
||||
fi
|
||||
if [ $i -eq $timeout ]
|
||||
then
|
||||
ynh_print_warn --message="The service $service_name didn't fully started before the timeout."
|
||||
ynh_print_warn --message="Please find here an extract of the end of the log of the service $service_name:"
|
||||
journalctl --no-pager --lines=$length -u $service_name >&2
|
||||
test -e "$log_path" && echo "--" >&2 && tail --lines=$length "$log_path" >&2
|
||||
fi
|
||||
ynh_clean_check_starting
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -6,56 +6,65 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Load common variables and helpers
|
||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup() {
|
||||
|
||||
rm /var/opt/gitlab/backups/*_gitlab_backup.tar
|
||||
ynh_clean_setup () {
|
||||
### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
|
||||
# Copy NGINX configuration
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
config_path=$(ynh_app_setting_get $app config_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Backing up nginx web server configuration..."
|
||||
|
||||
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
|
||||
gitlab-rake gitlab:backup:create > backup.log
|
||||
|
||||
ynh_backup "/var/opt/$app/backups/"
|
||||
# Searching in backup logs the
|
||||
last_backup=$(grep _gitlab_backup.tar backup.log | cut -d' ' -f4)
|
||||
mv "/var/opt/$app/backups/$last_backup" "/var/opt/$app/backups/last_gitlab_backup.tar"
|
||||
|
||||
ynh_backup "/var/opt/$app/backups/last_gitlab_backup.tar"
|
||||
|
||||
#=================================================
|
||||
# BACKUP CONF FILES
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Backuping configuration files of Gitlab..."
|
||||
|
||||
ynh_backup "$config_path/gitlab-secrets.json"
|
||||
ynh_backup "$config_path/gitlab.rb"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -1,20 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# IMPORT GENERIC HELPERS
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
# Import common cmd
|
||||
source ./_common.sh
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
@ -30,12 +24,16 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
config_path=$(ynh_app_setting_get $app config_path)
|
||||
port=$(ynh_app_setting_get "$app" web_port)
|
||||
portUnicorn=$(ynh_app_setting_get "$app" unicorn_port)
|
||||
|
||||
#=================================================
|
||||
# CHECK PATHS SYNTAX
|
||||
# CHECK THE SYNTAX OF THE PATHS
|
||||
#=================================================
|
||||
|
||||
test -n "$old_path" || old_path="/"
|
||||
|
@ -43,9 +41,6 @@ test -n "$new_path" || new_path="/"
|
|||
new_path=$(ynh_normalize_url_path $new_path)
|
||||
old_path=$(ynh_normalize_url_path $old_path)
|
||||
|
||||
domain="$new_domain"
|
||||
path_url="$new_path"
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
#=================================================
|
||||
|
@ -63,17 +58,17 @@ fi
|
|||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_print_info "Updating nginx web server configuration..."
|
||||
|
||||
#doc in: https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
|
||||
|
||||
# Gitlab configuration
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
if [ $change_path -eq 1 ]; then
|
||||
ynh_print_info "Changing path..."
|
||||
|
||||
#doc in: https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
|
||||
|
||||
gitlab-ctl stop unicorn
|
||||
gitlab-ctl stop sidekiq
|
||||
|
||||
|
@ -97,29 +92,44 @@ if [ $change_domain -eq 1 ]; then
|
|||
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# CONFIGURE GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Configure gitlab..."
|
||||
|
||||
config_gitlab
|
||||
ynh_backup_if_checksum_is_different "$config_path/gitlab.rb"
|
||||
|
||||
mkdir -p $config_path
|
||||
|
||||
cp -f ../conf/gitlab.rb "$config_path/gitlab.rb"
|
||||
|
||||
ynh_replace_string "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__PORT__" "$port" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__PORTUNICORN__" "$portUnicorn" "$config_path/gitlab.rb"
|
||||
|
||||
ynh_store_file_checksum "$config_path/gitlab.rb"
|
||||
|
||||
#=================================================
|
||||
# RECONFIGURE GITLAB
|
||||
#=================================================
|
||||
|
||||
gitlab-ctl reconfigure
|
||||
|
||||
if [ $change_path -eq 1 ]; then
|
||||
gitlab-ctl restart
|
||||
gitlab-ctl restart unicorn
|
||||
fi
|
||||
gitlab_ctl_action --action=restart --line_match="adopted new unicorn master" --log_path="/var/log/gitlab/unicorn/current" --timeout=3600
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
#=================================================
|
||||
# WAIT
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
waiting_to_start
|
||||
ynh_print_info "Change of URL completed for $app"
|
||||
|
|
169
scripts/install
169
scripts/install
|
@ -6,101 +6,160 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_secure_remove "$tempdir" 2>&1
|
||||
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
# Load common variables and helpers
|
||||
source ./_common.sh
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
use_web_account=$YNH_APP_ARG_USE_WEB_ACCOUNT
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
|
||||
#=================================================
|
||||
# REGISTER DOMAIN
|
||||
#=================================================
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_print_info "Validating installation parameters..."
|
||||
|
||||
config_path=/etc/$app
|
||||
final_path=/opt/$app
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
|
||||
# Detect the system architecture
|
||||
if [ -n "$(uname -m | grep 64)" ]; then
|
||||
architecture="x86-64"
|
||||
elif [ -n "$(uname -m | grep 86)" ]; then
|
||||
ynh_die "Gitlab is not compatible with x86 architecture"
|
||||
elif [ -n "$(uname -m | grep arm)" ]; then
|
||||
architecture="arm"
|
||||
else
|
||||
ynh_die "Unable to detect your achitecture, please open a bug describing \
|
||||
your hardware and the result of the command \"uname -m\"." 1
|
||||
fi
|
||||
|
||||
# Normalize the url path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
|
||||
# This function check also the availability of this one
|
||||
# Register (book) web path
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
|
||||
#=================================================
|
||||
# REGISTER DOMAIN
|
||||
#=================================================
|
||||
|
||||
# Check user parameter
|
||||
ynh_user_exists "$admin" ||
|
||||
ynh_die "The chosen admin user does not exist."
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_print_info "Storing installation settings..."
|
||||
|
||||
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 use_web_account $use_web_account
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
ynh_app_setting_set $app config_path $config_path
|
||||
ynh_app_setting_set $app architecture $architecture
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# FIND AND OPEN PORTS
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Getting ports..."
|
||||
ynh_print_info "Configuring firewall..."
|
||||
|
||||
# Find free ports
|
||||
port=$(ynh_find_port 8080)
|
||||
portUnicorn=$(ynh_find_port $(($port + 1)))
|
||||
|
||||
# Open these port
|
||||
yunohost firewall allow --no-upnp TCP $port 2>&1
|
||||
yunohost firewall allow --no-upnp TCP $portUnicorn 2>&1
|
||||
ynh_app_setting_set $app web_port $port
|
||||
ynh_app_setting_set $app unicorn_port $portUnicorn
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Installing dependencies..."
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# PRECONFIGURE GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Preconfigure gitlab..."
|
||||
|
||||
mkdir -p $config_path
|
||||
|
||||
cp -f ../conf/gitlab.rb "$config_path/gitlab.rb"
|
||||
|
||||
ynh_replace_string "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__PORT__" "$port" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__PORTUNICORN__" "$portUnicorn" "$config_path/gitlab.rb"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
ynh_store_file_checksum "$config_path/gitlab.rb"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_print_info "Setting up source files..."
|
||||
|
||||
update_src_version() {
|
||||
source ./upgrade.d/upgrade.last.sh
|
||||
cp ../conf/arm.src.default ../conf/arm.src
|
||||
ynh_replace_string "__VERSION__" "$gitlab_version" "../conf/arm.src"
|
||||
ynh_replace_string "__SHA256_SUM__" "$gitlab_arm_source_sha256" "../conf/arm.src"
|
||||
ynh_replace_string "__SOURCE_FILENAME__" "$gitlab_filename" "../conf/arm.src"
|
||||
|
||||
cp ../conf/x86-64.src.default ../conf/x86-64.src
|
||||
ynh_replace_string "__VERSION__" "$gitlab_version" "../conf/x86-64.src"
|
||||
ynh_replace_string "__SHA256_SUM__" "$gitlab_x86_64_source_sha256" "../conf/x86-64.src"
|
||||
ynh_replace_string "__SOURCE_FILENAME__" "$gitlab_filename" "../conf/x86-64.src"
|
||||
}
|
||||
|
||||
update_src_version
|
||||
|
||||
tempdir="$(mktemp -d)"
|
||||
|
||||
ynh_setup_source $tempdir $architecture
|
||||
|
||||
if IS_PACKAGE_CHECK; then
|
||||
dpkg -i $tempdir/$gitlab_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
|
||||
else
|
||||
dpkg -i $tempdir/$gitlab_filename
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Configuring nginx web server..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE GITLAB
|
||||
#=================================================
|
||||
|
||||
# Configure gitlab with gitlab.rb file
|
||||
config_gitlab
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
ynh_install_app_dependencies openssh-server
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND INSTALL GITLAB
|
||||
#=================================================
|
||||
|
||||
setup_source $architecture
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# GETTING ADMIN INFO AND ADD AS A GITLAB USER AND CONFIGURE SIGN IN SYSTEM
|
||||
# ADD USER AND CONFIGURE SIGN IN SYSTEM
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Creating an administrator user..."
|
||||
|
||||
mailadmin=$(ynh_user_get_info $admin mail)
|
||||
|
@ -114,31 +173,41 @@ newuser.save
|
|||
ApplicationSetting.last.update_attributes(password_authentication_enabled_for_web: $use_web_account, signup_enabled: $use_web_account)" | gitlab-rails console
|
||||
|
||||
#=================================================
|
||||
# RESTART TO TAKE INTO ACCOUNT CHANGES
|
||||
# RECONFIGURE TO TAKE INTO ACCOUNT CHANGES
|
||||
#=================================================
|
||||
ynh_print_info "Reconfigure gitlab..."
|
||||
|
||||
gitlab-ctl reconfigure
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info "Configuring SSOwat..."
|
||||
|
||||
# If app is public, add url to SSOWat conf as skipped_uris
|
||||
if [[ $is_public -eq 1 ]]; then
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]; then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
# RESTART GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Restarting gitlab..."
|
||||
|
||||
gitlab_ctl_action --action=restart --line_match="adopted new unicorn master" --log_path="/var/log/gitlab/unicorn/current" --timeout=3600
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
#=================================================
|
||||
# WAIT
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
waiting_to_start
|
||||
ynh_print_info "Installation of $app completed"
|
||||
|
|
|
@ -6,81 +6,90 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Source YunoHost helpers
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Load common variables and helpers
|
||||
source ./_common.sh
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
|
||||
# See comments in install script
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
port=$(ynh_app_setting_get "$app" web_port)
|
||||
portUnicorn=$(ynh_app_setting_get "$app" unicorn_port)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
config_path=$(ynh_app_setting_get $app config_path)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE GITLAB
|
||||
# STOP GITLAB
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Removing Gitlab..."
|
||||
ynh_print_info "Stopping gitlab"
|
||||
|
||||
gitlab-ctl stop
|
||||
|
||||
# Remove gitlab
|
||||
#=================================================
|
||||
# REMOVE GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Removing Gitlab"
|
||||
|
||||
dpkg --remove gitlab-ce
|
||||
|
||||
#=================================================
|
||||
# REMOVE CONF GILE
|
||||
#=================================================
|
||||
|
||||
# Remove Config
|
||||
remove_config_gitlab
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Removing dependencies"
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Removing app main directory"
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove "$final_path"
|
||||
ynh_secure_remove "$config_path"
|
||||
ynh_secure_remove "/var/opt/$app"
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove "/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# CLOSE PORTS
|
||||
#=================================================
|
||||
|
||||
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
|
||||
echo "Close port $portUnicorn" >&2
|
||||
yunohost firewall disallow TCP $portUnicorn 2>&1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Removing nginx web server configuration"
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
# CLOSE A PORT
|
||||
#=================================================
|
||||
|
||||
#ynh_remove_logrotate
|
||||
if yunohost firewall list | grep -q "\- $port$"; then
|
||||
ynh_print_info "Closing port $port"
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||
fi
|
||||
|
||||
if yunohost firewall list | grep -q "\- $portUnicorn$"; then
|
||||
ynh_print_info "Closing port $portUnicorn"
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $portUnicorn
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE GITLAB FILES
|
||||
#=================================================
|
||||
|
||||
ynh_secure_remove "/var/opt/$app"
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove "/var/log/$app/"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Removal of $app completed"
|
||||
|
|
|
@ -6,52 +6,44 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Source YunoHost helpers
|
||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup() {
|
||||
|
||||
rm /var/opt/gitlab/backups/*_gitlab_backup.tar
|
||||
true
|
||||
ynh_clean_setup () {
|
||||
ynh_secure_remove "$tempdir" 2>&1
|
||||
}
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
if [ ! -e _common.sh ]; then
|
||||
# Get the _common.sh file if it's not in the current directory
|
||||
cp ../settings/scripts/_common.sh ./_common.sh
|
||||
mkdir ./upgrade.d
|
||||
mkdir ../conf
|
||||
cp ../settings/scripts/upgrade.d/*.sh ./upgrade.d/
|
||||
cp ../settings/conf/*.default ../conf/
|
||||
chmod a+rx _common.sh upgrade.d/*
|
||||
fi
|
||||
|
||||
# Load common variables and helpers
|
||||
source _common.sh
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading settings..."
|
||||
|
||||
# Copy NGINX configuration
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_app_setting_get "$app" path_url)
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
config_path=$(ynh_app_setting_get $app config_path)
|
||||
port=$(ynh_app_setting_get "$app" web_port)
|
||||
portUnicorn=$(ynh_app_setting_get "$app" unicorn_port)
|
||||
architecture=$(ynh_app_setting_get "$app" architecture)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_print_info "Validating restoration parameters..."
|
||||
|
||||
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
|
||||
|
@ -64,13 +56,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Reinstalling dependencies..."
|
||||
|
||||
ynh_install_app_dependencies openssh-server
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# RESTORE CONF FILES
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Restoring configuration files of Gitlab..."
|
||||
|
||||
ynh_restore_file "$config_path/gitlab-secrets.json"
|
||||
|
@ -79,23 +72,46 @@ ynh_restore_file "$config_path/gitlab.rb"
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Reinstalling gitlab..."
|
||||
|
||||
setup_source $architecture
|
||||
update_src_version() {
|
||||
source ../settings/scripts/upgrade.d/upgrade.last.sh
|
||||
mkdir -p ../conf/
|
||||
cp ../settings/conf/arm.src.default ../conf/arm.src
|
||||
ynh_replace_string "__VERSION__" "$gitlab_version" "../conf/arm.src"
|
||||
ynh_replace_string "__SHA256_SUM__" "$gitlab_arm_source_sha256" "../conf/arm.src"
|
||||
ynh_replace_string "__SOURCE_FILENAME__" "$gitlab_filename" "../conf/arm.src"
|
||||
|
||||
ynh_restore_file "/var/opt/$app/backups/"
|
||||
cp ../conf/x86-64.src.default ../conf/x86-64.src
|
||||
ynh_replace_string "__VERSION__" "$gitlab_version" "../conf/x86-64.src"
|
||||
ynh_replace_string "__SHA256_SUM__" "$gitlab_x86_64_source_sha256" "../conf/x86-64.src"
|
||||
ynh_replace_string "__SOURCE_FILENAME__" "$gitlab_filename" "../conf/x86-64.src"
|
||||
}
|
||||
|
||||
update_src_version
|
||||
|
||||
tempdir="$(mktemp -d)"
|
||||
|
||||
ynh_setup_source $tempdir $architecture
|
||||
|
||||
if IS_PACKAGE_CHECK; then
|
||||
dpkg -i $tempdir/$gitlab_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
|
||||
else
|
||||
dpkg -i $tempdir/$gitlab_filename
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# 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")
|
||||
last_backup="${filename%_gitlab_backup.tar}"
|
||||
ynh_restore_file "/var/opt/$app/backups/last_gitlab_backup.tar"
|
||||
|
||||
last_backup="last"
|
||||
|
||||
gitlab-ctl stop unicorn
|
||||
gitlab-ctl stop sidekiq
|
||||
|
@ -111,5 +127,12 @@ gitlab-rake gitlab:check SANITIZE=true
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Restoration completed for $app"
|
||||
|
|
134
scripts/upgrade
134
scripts/upgrade
|
@ -23,8 +23,11 @@ domain=$(ynh_app_setting_get "$app" domain)
|
|||
path_url=$(ynh_app_setting_get "$app" path_url)
|
||||
admin=$(ynh_app_setting_get "$app" admin)
|
||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
config_path=$(ynh_app_setting_get $app config_path)
|
||||
port=$(ynh_app_setting_get "$app" web_port)
|
||||
portUnicorn=$(ynh_app_setting_get "$app" unicorn_port)
|
||||
architecture=$(ynh_app_setting_get "$app" architecture)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
|
@ -39,6 +42,34 @@ elif [ "$is_public" = "No" ]; then
|
|||
is_public=0
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/opt/$app
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
fi
|
||||
|
||||
# If config_path doesn't exist, create it
|
||||
if [ -z "$config_path" ]; then
|
||||
config_path=/etc/$app
|
||||
ynh_app_setting_set $app config_path $config_path
|
||||
fi
|
||||
|
||||
# If architecture doesn't exist, create it
|
||||
if [ -z "$architecture" ]; then
|
||||
# Detect the system architecture
|
||||
if [ -n "$(uname -m | grep 64)" ]; then
|
||||
architecture="x86-64"
|
||||
elif [ -n "$(uname -m | grep 86)" ]; then
|
||||
ynh_die "Gitlab is not compatible with x86 architecture"
|
||||
elif [ -n "$(uname -m | grep arm)" ]; then
|
||||
architecture="arm"
|
||||
else
|
||||
ynh_die "Unable to detect your achitecture, please open a bug describing \
|
||||
your hardware and the result of the command \"uname -m\"." 1
|
||||
fi
|
||||
ynh_app_setting_set $app architecture $architecture
|
||||
fi
|
||||
|
||||
# If domain doesn't exist, retrieve it
|
||||
if [ -z "$domain" ]; then
|
||||
domain=$(grep "external_url" "/etc/gitlab/gitlab.rb" | cut -d'/' -f3) # retrieve $domain from conf file
|
||||
|
@ -75,14 +106,18 @@ fi
|
|||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_print_info "Backing up the app before upgrading (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup() {
|
||||
ynh_clean_setup () {
|
||||
ynh_secure_remove "$tempdir" 2>&1
|
||||
|
||||
ynh_clean_check_starting
|
||||
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
@ -95,33 +130,70 @@ path_url=$(ynh_normalize_url_path $path_url)
|
|||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Installing dependencies..."
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# PRECONFIGURE GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Preconfigure gitlab..."
|
||||
|
||||
ynh_backup_if_checksum_is_different "$config_path/gitlab.rb"
|
||||
|
||||
mkdir -p $config_path
|
||||
|
||||
cp -f ../conf/gitlab.rb "$config_path/gitlab.rb"
|
||||
|
||||
ynh_replace_string "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__PORT__" "$port" "$config_path/gitlab.rb"
|
||||
ynh_replace_string "__PORTUNICORN__" "$portUnicorn" "$config_path/gitlab.rb"
|
||||
|
||||
ynh_store_file_checksum "$config_path/gitlab.rb"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_print_info "Setting up source files..."
|
||||
|
||||
update_src_version() {
|
||||
source ./upgrade.d/upgrade.last.sh
|
||||
cp ../conf/arm.src.default ../conf/arm.src
|
||||
ynh_replace_string "__VERSION__" "$gitlab_version" "../conf/arm.src"
|
||||
ynh_replace_string "__SHA256_SUM__" "$gitlab_arm_source_sha256" "../conf/arm.src"
|
||||
ynh_replace_string "__SOURCE_FILENAME__" "$gitlab_filename" "../conf/arm.src"
|
||||
|
||||
cp ../conf/x86-64.src.default ../conf/x86-64.src
|
||||
ynh_replace_string "__VERSION__" "$gitlab_version" "../conf/x86-64.src"
|
||||
ynh_replace_string "__SHA256_SUM__" "$gitlab_x86_64_source_sha256" "../conf/x86-64.src"
|
||||
ynh_replace_string "__SOURCE_FILENAME__" "$gitlab_filename" "../conf/x86-64.src"
|
||||
}
|
||||
|
||||
update_src_version
|
||||
|
||||
tempdir="$(mktemp -d)"
|
||||
|
||||
ynh_setup_source $tempdir $architecture
|
||||
|
||||
if IS_PACKAGE_CHECK; then
|
||||
dpkg -i $tempdir/$gitlab_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
|
||||
else
|
||||
dpkg -i $tempdir/$gitlab_filename
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Configuring nginx web server..."
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE GITLAB
|
||||
#=================================================
|
||||
|
||||
# Configure gitlab with gitlab.rb file
|
||||
config_gitlab
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
ynh_install_app_dependencies openssh-server
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND INSTALL GITLAB
|
||||
#=================================================
|
||||
|
||||
# Update Gitlab
|
||||
setup_source $architecture
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
@ -134,15 +206,23 @@ if [[ $is_public -eq 1 ]]; then
|
|||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RESTART GITLAB
|
||||
#=================================================
|
||||
ynh_print_info "Restarting gitlab..."
|
||||
|
||||
gitlab_ctl_action --action=restart --line_match="adopted new unicorn master" --log_path="/var/log/gitlab/unicorn/current" --timeout=3600
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
|
||||
# Reload nginx service
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
#=================================================
|
||||
# WAIT
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
waiting_to_start
|
||||
ynh_print_info "Upgrade of $app completed"
|
||||
|
||||
|
|
|
@ -3,3 +3,5 @@ gitlab_version="11.8.2"
|
|||
gitlab_x86_64_source_sha256="c1ea774a39b14c57a0821916d6c75c1c8f757d3222f7d38e6c3270a47799a34f"
|
||||
|
||||
gitlab_arm_source_sha256="886193a183a642e662923c6590c07c3b3d5cc1c2108e3818bcd84ab628e00bc3"
|
||||
|
||||
gitlab_filename="gitlab-ce.deb"
|
Loading…
Add table
Reference in a new issue