mirror of
https://github.com/YunoHost-Apps/gitlab_ynh.git
synced 2024-09-03 18:36:35 +02:00
Check if we can change some values in the kernel, and handle the case where we can't
This commit is contained in:
parent
a5b8f47e25
commit
61b9ada2c0
6 changed files with 56 additions and 7 deletions
|
@ -2212,7 +2212,7 @@ nginx['listen_https'] = false
|
||||||
|
|
||||||
##! Attempt to modify kernel paramaters. To skip this in containers where the
|
##! Attempt to modify kernel paramaters. To skip this in containers where the
|
||||||
##! relevant file system is read-only, set the value to false.
|
##! relevant file system is read-only, set the value to false.
|
||||||
# package['modify_kernel_parameters'] = true
|
package['modify_kernel_parameters'] = __MODIFY_KERNEL_PARAMETERS__
|
||||||
|
|
||||||
##! Specify maximum number of tasks that can be created by the systemd unit
|
##! Specify maximum number of tasks that can be created by the systemd unit
|
||||||
##! Will be populated as TasksMax value to the unit file if user is on a systemd
|
##! Will be populated as TasksMax value to the unit file if user is on a systemd
|
||||||
|
|
|
@ -89,6 +89,20 @@ fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC MODIFICATIONS
|
# SPECIFIC MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
# CHECK IF KERNEL IS READ-ONLY
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
modify_kernel_parameters="true"
|
||||||
|
|
||||||
|
for value_to_check in "kernel.shmall" "kernel.shmmax" "kernel.sem" "net.core.somaxconn"
|
||||||
|
do
|
||||||
|
if ! ynh_exec_fully_quiet sysctl --write $value_to_check="$(sysctl --value $value_to_check)"; then
|
||||||
|
modify_kernel_parameters="false"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE GITLAB
|
# CONFIGURE GITLAB
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -113,6 +127,7 @@ ynh_replace_string --match_string="__PUMA_MAX_THREADS__" --replace_string="$puma
|
||||||
ynh_replace_string --match_string="__CLIENT_MAX_BODY_SIZE__" --replace_string="$client_max_body_size" --target_file="$config_path/gitlab.rb"
|
ynh_replace_string --match_string="__CLIENT_MAX_BODY_SIZE__" --replace_string="$client_max_body_size" --target_file="$config_path/gitlab.rb"
|
||||||
ynh_replace_string --match_string="__SSH_PORT__" --replace_string="$ssh_port" --target_file="$config_path/gitlab.rb"
|
ynh_replace_string --match_string="__SSH_PORT__" --replace_string="$ssh_port" --target_file="$config_path/gitlab.rb"
|
||||||
ynh_replace_string --match_string="__SIDEKIQ_PORT__" --replace_string="$portSidekiq" --target_file="$config_path/gitlab.rb"
|
ynh_replace_string --match_string="__SIDEKIQ_PORT__" --replace_string="$portSidekiq" --target_file="$config_path/gitlab.rb"
|
||||||
|
ynh_replace_string --match_string="__MODIFY_KERNEL_PARAMETERS__" --replace_string="$modify_kernel_parameters" --target_file="$config_path/gitlab.rb"
|
||||||
|
|
||||||
ynh_store_file_checksum --file="$config_path/gitlab.rb"
|
ynh_store_file_checksum --file="$config_path/gitlab.rb"
|
||||||
|
|
||||||
|
|
|
@ -145,6 +145,20 @@ if [ $swap_needed -gt 0 ]; then
|
||||||
ynh_add_swap --size=$swap_needed
|
ynh_add_swap --size=$swap_needed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK IF KERNEL IS READ-ONLY
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
modify_kernel_parameters="true"
|
||||||
|
|
||||||
|
for value_to_check in "kernel.shmall" "kernel.shmmax" "kernel.sem" "net.core.somaxconn"
|
||||||
|
do
|
||||||
|
if ! ynh_exec_fully_quiet sysctl --write $value_to_check="$(sysctl --value $value_to_check)"; then
|
||||||
|
modify_kernel_parameters="false"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PRECONFIGURE GITLAB
|
# PRECONFIGURE GITLAB
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -167,6 +181,7 @@ ynh_replace_string --match_string="__PUMA_MAX_THREADS__" --replace_string="$puma
|
||||||
ynh_replace_string --match_string="__CLIENT_MAX_BODY_SIZE__" --replace_string="$client_max_body_size" --target_file="$config_path/gitlab.rb"
|
ynh_replace_string --match_string="__CLIENT_MAX_BODY_SIZE__" --replace_string="$client_max_body_size" --target_file="$config_path/gitlab.rb"
|
||||||
ynh_replace_string --match_string="__SSH_PORT__" --replace_string="$ssh_port" --target_file="$config_path/gitlab.rb"
|
ynh_replace_string --match_string="__SSH_PORT__" --replace_string="$ssh_port" --target_file="$config_path/gitlab.rb"
|
||||||
ynh_replace_string --match_string="__SIDEKIQ_PORT__" --replace_string="$portSidekiq" --target_file="$config_path/gitlab.rb"
|
ynh_replace_string --match_string="__SIDEKIQ_PORT__" --replace_string="$portSidekiq" --target_file="$config_path/gitlab.rb"
|
||||||
|
ynh_replace_string --match_string="__MODIFY_KERNEL_PARAMETERS__" --replace_string="$modify_kernel_parameters" --target_file="$config_path/gitlab.rb"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE THE CONFIG FILE CHECKSUM
|
# STORE THE CONFIG FILE CHECKSUM
|
||||||
|
@ -190,11 +205,7 @@ tempdir="$(mktemp -d)"
|
||||||
|
|
||||||
ynh_setup_source --dest_dir=$tempdir --source_id=$architecture
|
ynh_setup_source --dest_dir=$tempdir --source_id=$architecture
|
||||||
|
|
||||||
if ! ynh_exec_warn_less dpkg -i $tempdir/$gitlab_filename ;
|
ynh_exec_warn_less dpkg -i $tempdir/$gitlab_filename
|
||||||
then # This command will fail in lxc env
|
|
||||||
package_check_action # defined in upgrade.d/upgrade.last.sh
|
|
||||||
ynh_exec_warn_less dpkg --configure gitlab-ce
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
|
|
@ -285,6 +285,20 @@ then
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK IF KERNEL IS READ-ONLY
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
modify_kernel_parameters="true"
|
||||||
|
|
||||||
|
for value_to_check in "kernel.shmall" "kernel.shmmax" "kernel.sem" "net.core.somaxconn"
|
||||||
|
do
|
||||||
|
if ! ynh_exec_fully_quiet sysctl --write $value_to_check="$(sysctl --value $value_to_check)"; then
|
||||||
|
modify_kernel_parameters="false"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECONFIGURE GITLAB
|
# RECONFIGURE GITLAB
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -306,6 +320,7 @@ ynh_replace_string --match_string="__PUMA_MAX_THREADS__" --replace_string="$puma
|
||||||
ynh_replace_string --match_string="__CLIENT_MAX_BODY_SIZE__" --replace_string="$client_max_body_size" --target_file="$config_path/gitlab.rb"
|
ynh_replace_string --match_string="__CLIENT_MAX_BODY_SIZE__" --replace_string="$client_max_body_size" --target_file="$config_path/gitlab.rb"
|
||||||
ynh_replace_string --match_string="__SSH_PORT__" --replace_string="$ssh_port" --target_file="$config_path/gitlab.rb"
|
ynh_replace_string --match_string="__SSH_PORT__" --replace_string="$ssh_port" --target_file="$config_path/gitlab.rb"
|
||||||
ynh_replace_string --match_string="__SIDEKIQ_PORT__" --replace_string="$portSidekiq" --target_file="$config_path/gitlab.rb"
|
ynh_replace_string --match_string="__SIDEKIQ_PORT__" --replace_string="$portSidekiq" --target_file="$config_path/gitlab.rb"
|
||||||
|
ynh_replace_string --match_string="__MODIFY_KERNEL_PARAMETERS__" --replace_string="$modify_kernel_parameters" --target_file="$config_path/gitlab.rb"
|
||||||
|
|
||||||
ynh_store_file_checksum --file="$config_path/gitlab.rb"
|
ynh_store_file_checksum --file="$config_path/gitlab.rb"
|
||||||
|
|
||||||
|
|
|
@ -21,5 +21,10 @@ gitlab_filename="gitlab-ce-${gitlab_version}.deb"
|
||||||
|
|
||||||
# Action to do in case of failure of the package_check
|
# Action to do in case of failure of the package_check
|
||||||
package_check_action() {
|
package_check_action() {
|
||||||
ynh_replace_string --match_string="# package\['modify_kernel_parameters'\] = true" --replace_string="package['modify_kernel_parameters'] = false" --target_file="$config_path/gitlab.rb"
|
ynh_backup_if_checksum_is_different --file="$config_path/gitlab.rb"
|
||||||
|
cat <<EOF >> "$config_path/gitlab.rb"
|
||||||
|
# Last chance to fix Gitlab
|
||||||
|
package['modify_kernel_parameters'] = false
|
||||||
|
EOF
|
||||||
|
ynh_store_file_checksum --file="$config_path/gitlab.rb"
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,4 +122,7 @@ EOS"
|
||||||
sed -i "s/# nginx\['client_max_body_size'\] = .*/nginx['client_max_body_size'] = '__CLIENT_MAX_BODY_SIZE__'/" $conf_file
|
sed -i "s/# nginx\['client_max_body_size'\] = .*/nginx['client_max_body_size'] = '__CLIENT_MAX_BODY_SIZE__'/" $conf_file
|
||||||
sed -i "s/# nginx\['listen_port'\] = .*/nginx['listen_port'] = __PORT__/" $conf_file
|
sed -i "s/# nginx\['listen_port'\] = .*/nginx['listen_port'] = __PORT__/" $conf_file
|
||||||
sed -i "s/# nginx\['listen_https'\] = .*/nginx['listen_https'] = false/" $conf_file
|
sed -i "s/# nginx\['listen_https'\] = .*/nginx['listen_https'] = false/" $conf_file
|
||||||
|
|
||||||
|
# Change modify kernel parameters settings
|
||||||
|
sed -i "s/# package\['modify_kernel_parameters'\] = .*/package['modify_kernel_parameters'] = __MODIFY_KERNEL_PARAMETERS__/" $conf_file
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue