Changed the startup script to be able to work together with cbsd.

Parts of it where written by Oleg Ginzburg I only had to do some small modifications, thanks for this support.

Submitted by:	Oleg Ginzburg
This commit is contained in:
Matthias Fechner 2021-02-16 22:22:27 +00:00
parent 00773c6a97
commit c1b4dec5af
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=565466
2 changed files with 89 additions and 85 deletions

View file

@ -3,7 +3,7 @@
PORTNAME?= gitlab-ce
PORTVERSION?= 13.8.4
PORTREVISION?= 0
PORTREVISION?= 1
CATEGORIES= www devel
MAINTAINER= mfechner@FreeBSD.org

View file

@ -36,6 +36,10 @@ status_cmd="print_status"
start_cmd="start_gitlab"
stop_cmd="stop_gitlab"
restart_cmd="restart_gitlab"
service_args="$@"
restart_precmd=${name}_init
start_precmd=${name}_init
stop_precmd=${name}_init
: ${gitlab_enable:="NO"}
: ${gitlab_authBackend:="http://127.0.0.1:8080"}
@ -97,72 +101,6 @@ gitaly_dir="%%PREFIX%%/share/gitaly"
gitaly_pid_path="$pid_path/gitaly.pid"
gitaly_log="$app_root/log/gitaly.log"
# Read configuration variable file if it is present
test -f /etc/default/gitlab && . /etc/default/gitlab
# Check if other colliding packages are installed
if `/usr/sbin/pkg -N info -e gogs` && [ $? -eq 0 ]; then
echo "WARNING: Gitlab cannot run together with gogs as both of them modify .ssh/authorized_keys"
if checkyesno gitlab_allow_conflicts; then
echo "but start as overwritten"
else
echo "you can overwrite this with: sysrc gitlab_allow_conflicts=YES"
exit 1
fi
fi
if `/usr/sbin/pkg -N info -e "gitolite*"` && [ $? -eq 0 ]; then
echo "WARNING: Gitlab cannot run together with gitolite as both of them modify .ssh/authorized_keys"
if checkyesno gitlab_allow_conflicts; then
echo "but start as overwritten"
else
echo "you can overwrite this with: sysrc gitlab_allow_conflicts=YES"
exit 1
fi
fi
if `/usr/sbin/pkg -N info -e "*gitosis*"` && [ $? -eq 0 ]; then
echo "WARNING: Gitlab cannot run together with py-gitosis as both of them modify .ssh/authorized_keys"
if checkyesno gitlab_allow_conflicts; then
echo "but start as overwritten"
else
echo "you can overwrite this with: sysrc gitlab_allow_conflicts=YES"
exit 1
fi
fi
if `/usr/sbin/pkg -N info -e gitea` && [ $? -eq 0 ]; then
echo "WARNING: Gitlab cannot run together with gitea as both of them modify .ssh/authorized_keys"
if checkyesno gitlab_allow_conflicts; then
echo "but start as overwritten"
else
echo "you can overwrite this with: sysrc gitlab_allow_conflicts=YES"
exit 1
fi
fi
# Switch to the app_user if it is not he/she who is running the script.
if [ "$USER" != "$app_user" ]; then
# Regenerate the Gemfile.lock for all related products
# echo "Regenerate Gitlab Gemfile.lock"
rm -f "${app_root}"/Gemfile.lock
if ! su -l root -c "cd ${app_root} && %%LOCALBASE%%/bin/bundle install --local --quiet"; then
echo "Could not create Gemfile.lock for gitlab, please report this using FreeBSD Bugtracker, https://bugs.freebsd.org/"
exit 1
fi
chown git "${app_root}"/Gemfile.lock
# echo "Regenerate Gitaly Gemfile.lock"
rm -f "${gitaly_dir}"/ruby/Gemfile.lock
if ! su -l root -c "cd ${gitaly_dir}/ruby && %%LOCALBASE%%/bin/bundle install --local --quiet"; then
echo "Could not create Gemfile.lock for gitaly, please report this using FreeBSD Bugtracker, https://bugs.freebsd.org/"
exit 1
fi
eval su - "$app_user" -c $(echo \")%%LOCALBASE%%/etc/rc.d/gitlab "$@"$(echo \"); exit;
fi
# Switch to the gitlab path, exit on failure.
if ! cd "$app_root" ; then
echo "Failed to cd into $app_root, exiting!"; exit 1
fi
if [ -z "$SIDEKIQ_WORKERS" ]; then
sidekiq_pid_path="$pid_path/sidekiq.pid"
else
@ -170,7 +108,6 @@ else
fi
### Init Script functions
## Gets the pids from the files
check_pids(){
if ! mkdir -p "$pid_path"; then
@ -216,6 +153,79 @@ check_pids(){
fi
}
gitlab_init(){
# Read configuration variable file if it is present
test -f /etc/default/gitlab && . /etc/default/gitlab
# Check if other colliding packages are installed
if `/usr/sbin/pkg -N info -e gogs` && [ $? -eq 0 ]; then
echo "WARNING: Gitlab cannot run together with gogs as both of them modify .ssh/authorized_keys"
if checkyesno gitlab_allow_conflicts; then
echo "but start as overwritten"
else
echo "you can overwrite this with: sysrc gitlab_allow_conflicts=YES"
exit 1
fi
fi
if `/usr/sbin/pkg -N info -e "gitolite*"` && [ $? -eq 0 ]; then
echo "WARNING: Gitlab cannot run together with gitolite as both of them modify .ssh/authorized_keys"
if checkyesno gitlab_allow_conflicts; then
echo "but start as overwritten"
else
echo "you can overwrite this with: sysrc gitlab_allow_conflicts=YES"
exit 1
fi
fi
if `/usr/sbin/pkg -N info -e "*gitosis*"` && [ $? -eq 0 ]; then
echo "WARNING: Gitlab cannot run together with py-gitosis as both of them modify .ssh/authorized_keys"
if checkyesno gitlab_allow_conflicts; then
echo "but start as overwritten"
else
echo "you can overwrite this with: sysrc gitlab_allow_conflicts=YES"
exit 1
fi
fi
if `/usr/sbin/pkg -N info -e gitea` && [ $? -eq 0 ]; then
echo "WARNING: Gitlab cannot run together with gitea as both of them modify .ssh/authorized_keys"
if checkyesno gitlab_allow_conflicts; then
echo "but start as overwritten"
else
echo "you can overwrite this with: sysrc gitlab_allow_conflicts=YES"
exit 1
fi
fi
# Switch to the app_user if it is not he/she who is running the script.
if [ "$USER" != "$app_user" ]; then
# Regenerate the Gemfile.lock for all related products
# echo "Regenerate Gitlab Gemfile.lock"
rm -f "${app_root}"/Gemfile.lock
if ! su -l root -c "cd ${app_root} && %%LOCALBASE%%/bin/bundle install --local --quiet"; then
echo "Could not create Gemfile.lock for gitlab, please report this using FreeBSD Bugtracker, https://bugs.freebsd.org/"
exit 1
fi
chown git "${app_root}"/Gemfile.lock
# echo "Regenerate Gitaly Gemfile.lock"
rm -f "${gitaly_dir}"/ruby/Gemfile.lock
if ! su -l root -c "cd ${gitaly_dir}/ruby && %%LOCALBASE%%/bin/bundle install --local --quiet"; then
echo "Could not create Gemfile.lock for gitaly, please report this using FreeBSD Bugtracker, https://bugs.freebsd.org/"
exit 1
fi
eval su - "$app_user" -c $(echo \")%%LOCALBASE%%/etc/rc.d/gitlab "${service_args}"$(echo \"); exit;
fi
# Switch to the gitlab path, exit on failure.
if ! cd "$app_root" ; then
echo "Failed to cd into $app_root, exiting!"; exit 1
fi
# We use the pids in so many parts of the script it makes sense to always check them.
# Only after start() is run should the pids change. Sidekiq sets its own pid.
check_pids
}
## Called when we have started the two processes and are waiting for their pid files.
wait_for_pids(){
# We are sleeping a bit here mostly because sidekiq is slow at writing its pid
@ -234,11 +244,6 @@ wait_for_pids(){
echo "Started in ${i}s."
}
# We use the pids in so many parts of the script it makes sense to always check them.
# Only after start() is run should the pids change. Sidekiq sets its own pid.
check_pids
## Checks whether the different parts of the service are already running or not.
check_status(){
check_pids
@ -573,7 +578,6 @@ restart_gitlab(){
start_gitlab
}
run_rc_command "$1"
exit