Skip to content

Commit 7818e66

Browse files
committed
update assets
1 parent 9f5334b commit 7818e66

File tree

5 files changed

+76
-17
lines changed

5 files changed

+76
-17
lines changed

assets/gitlab.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,32 @@
22
## Prevent Postgres from trying to allocate 25% of total memory
33
postgresql['shared_buffers'] = '1MB'
44

5+
# Disable Prometheus node_exporter inside Docker.
6+
node_exporter['enable'] = false
7+
58
# Manage accounts with docker
69
manage_accounts['enable'] = false
710

811
# Get hostname from shell
912
host = `hostname`.strip
1013
external_url "http://#{host}"
1114

15+
# Explicitly disable init detection since we are running on a container
16+
package['detect_init'] = false
17+
1218
# Load custom config from environment variable: GITLAB_OMNIBUS_CONFIG
13-
eval ENV["GITLAB_OMNIBUS_CONFIG"].to_s
19+
# Disabling the cop since rubocop considers using eval to be security risk but
20+
# we don't have an easy way out, atleast yet.
21+
eval ENV["GITLAB_OMNIBUS_CONFIG"].to_s # rubocop:disable Security/Eval
1422

1523
# Load configuration stored in /etc/gitlab/gitlab.rb
1624
from_file("/etc/gitlab/gitlab.rb")
1725

1826
###! Minimum worker_processes is 2 at this moment
19-
###! See https://gitlab.com/gitlab-org/gitlab-ce/issues/18771
27+
###! See https://docs.gitlab.com/omnibus/settings/rpi.html
28+
# Reduce the number of running workers to the minimum in order to reduce memory usage
2029
unicorn['worker_processes'] = 2
30+
sidekiq['concurrency'] = 9
31+
32+
# Turn off monitoring to reduce idle cpu and disk usage
33+
prometheus_monitoring['enable'] = false

assets/setup

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
set -xe
44

55
source /RELEASE
6-
DISTRIB_CODENAME=jessie
76

87
# Download & Install GitLab
9-
# echo "deb https://packages.gitlab.com/gitlab/${PACKAGECLOUD_REPO}/raspbian/ ${DISTRIB_CODENAME} main" > /etc/apt/sources.list.d/gitlab_${RELEASE_PACKAGE}.list
10-
# wget -q -O - https://packages.gitlab.com/gpg.key | apt-key add -
11-
# apt-get update
128
curl -s https://packages.gitlab.com/install/repositories/gitlab/raspberry-pi2/script.deb.sh | bash
139
apt-get install -yq --no-install-recommends ${RELEASE_PACKAGE}=${RELEASE_VERSION}
1410
rm -rf /var/lib/apt/lists/*
@@ -19,7 +15,6 @@ mkfifo /opt/gitlab/sv/sshd/supervise/ok /opt/gitlab/sv/sshd/log/supervise/ok
1915
printf "#!/bin/sh\nexec 2>&1\numask 077\nexec /usr/sbin/sshd -D -f /assets/sshd_config -e" > /opt/gitlab/sv/sshd/run
2016
printf "#!/bin/sh\nexec svlogd -tt /var/log/gitlab/sshd" > /opt/gitlab/sv/sshd/log/run
2117
chmod a+x /opt/gitlab/sv/sshd/run /opt/gitlab/sv/sshd/log/run
22-
mkdir -p /var/run/sshd
2318

2419
# Remove current gitlab.rb file
2520
rm -f /etc/gitlab/gitlab.rb
@@ -29,6 +24,9 @@ sed -i "s/external_url 'GENERATED_EXTERNAL_URL'/# external_url 'GENERATED_EXTERN
2924
sed -i "s/\/etc\/gitlab\/gitlab.rb/\/assets\/gitlab.rb/" /opt/gitlab/embedded/cookbooks/gitlab/recipes/show_config.rb
3025
sed -i "s/\/etc\/gitlab\/gitlab.rb/\/assets\/gitlab.rb/" /opt/gitlab/embedded/cookbooks/gitlab/recipes/config.rb
3126

27+
# Set install type to docker
28+
echo 'gitlab-docker' > /opt/gitlab/embedded/service/gitlab-rails/INSTALLATION_TYPE
29+
3230
# Create groups
3331
groupadd -g 998 git
3432
groupadd -g 999 gitlab-www

assets/sshd_config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ PrintMotd no
1212
PrintLastLog no
1313
PubkeyAuthentication yes
1414
AuthorizedKeysFile %h/.ssh/authorized_keys /gitlab-data/ssh/authorized_keys
15+
AuthorizedKeysCommand /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-shell-authorized-keys-check git %u %k
16+
AuthorizedKeysCommandUser git
1517

1618
# Fix: User username not allowed because account is locked
1719
# With "UsePAM yes" the "!" is seen as a password disabled account and not fully locked so ssh public key login works
1820
UsePAM yes
1921

2022
# Disabling use DNS in ssh since it tends to slow connecting
2123
UseDNS no
24+
25+
# Enable the use of Git protcol v2
26+
AcceptEnv GIT_PROTOCOL

assets/update-permissions

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,24 @@ chown_if_exists()
1717
fi
1818
}
1919

20+
chmod_if_exists()
21+
{
22+
# the last argument of chown is the file or path
23+
path="${@:${#@}}"
24+
if [ -e "$path" ]; then
25+
chmod $@
26+
else
27+
echo "skipping, path does not exist: $path"
28+
fi
29+
}
30+
2031
# Fix GitLab permissions
2132
if id -u git; then
2233
# Fix data storage
2334
chown_if_exists -R git:git /var/opt/gitlab/.ssh
2435
chown_if_exists -R git:git /var/opt/gitlab/.gitconfig
2536
chown_if_exists -R git:git /var/opt/gitlab/git-data
37+
chmod_if_exists 2770 /var/opt/gitlab/git-data/repositories
2638
chown_if_exists -R git:git /var/opt/gitlab/gitlab-ci/builds
2739
chown_if_exists -R git:git /var/opt/gitlab/gitlab-rails
2840
chown_if_exists -R git:git /var/opt/gitlab/gitlab-shell
@@ -31,7 +43,7 @@ if id -u git; then
3143
fi
3244

3345
# Fix log storage
34-
chown_if_exists git /var/opt/gitlab/gitlab-workhorse
46+
chown_if_exists git /var/log/gitlab/gitlab-workhorse
3547
chown_if_exists git /var/log/gitlab/gitlab-rails
3648
chown_if_exists git /var/log/gitlab/gitlab-shell
3749
chown_if_exists git /var/log/gitlab/sidekiq
@@ -59,6 +71,8 @@ fi
5971
if id -u gitlab-prometheus; then
6072
chown_if_exists -R gitlab-prometheus:gitlab-prometheus /var/opt/gitlab/prometheus
6173
chown_if_exists gitlab-prometheus /var/log/gitlab/prometheus
74+
chown_if_exists -R gitlab-prometheus:gitlab-prometheus /var/opt/gitlab/alertmanager
75+
chown_if_exists gitlab-prometheus /var/log/gitlab/alertmanager
6276
fi
6377

6478
# Fix redis storage and logs
@@ -74,3 +88,8 @@ fi
7488
if id -u registry; then
7589
chown_if_exists -R registry:git /var/opt/gitlab/gitlab-rails/shared/registry
7690
fi
91+
92+
# Fix mattermost storage
93+
if id -u mattermost; then
94+
chown_if_exists -R mattermost /var/opt/gitlab/mattermost
95+
fi

assets/wrapper

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,33 @@ function failed_pg_upgrade() {
1717
exit 1
1818
}
1919

20+
function clean_stale_pids() {
21+
# cleanup known pid/socket files
22+
for x in /opt/gitlab/sv /run $(ls -d /tmp/gitaly-ruby* 2>/dev/null) ; do
23+
# find
24+
# - any (s)ocket or regular (f)ile
25+
# - by the name of "*.pid" or "socket.?"
26+
# - and delete them
27+
find $x \
28+
\( \
29+
-type f \
30+
-o -type s \
31+
\) \(\
32+
-name pid \
33+
-o -name "*.pid" \
34+
-o -name "socket.?" \
35+
\) \
36+
-delete ;
37+
done
38+
}
39+
40+
function detect_unclean_start() {
41+
set +e
42+
echo "Cleaning stale PIDs & sockets"
43+
clean_stale_pids
44+
set -e
45+
}
46+
2047
trap "sigterm_handler; exit" TERM
2148

2249
source /RELEASE
@@ -44,6 +71,9 @@ echo " docker restart gitlab"
4471
echo
4572
sleep 3s
4673

74+
# Run unclean start detection & cleanup
75+
detect_unclean_start
76+
4777
# Copy gitlab.rb for the first time
4878
if [[ ! -e /etc/gitlab/gitlab.rb ]]; then
4979
echo "Installing gitlab.rb config..."
@@ -73,20 +103,14 @@ echo "Preparing services..."
73103
rm -f /opt/gitlab/service/*
74104
ln -s /opt/gitlab/sv/sshd /opt/gitlab/service
75105
ln -sf /opt/gitlab/embedded/bin/sv /opt/gitlab/init/sshd
106+
mkdir -p /var/run/sshd
76107
mkdir -p /var/log/gitlab/sshd
108+
mkdir -p /var/log/gitlab/reconfigure
77109

78110
# Start service manager
79111
echo "Starting services..."
80112
GITLAB_OMNIBUS_CONFIG= /opt/gitlab/embedded/bin/runsvdir-start &
81113

82-
# Configure gitlab package
83-
# WARNING:
84-
# the preinst script has the database backup
85-
# It will not be executed, because all services are not yet started
86-
# They will be started when `reconfigure` is executed
87-
echo "Configuring GitLab package..."
88-
/var/lib/dpkg/info/${RELEASE_PACKAGE}.preinst upgrade
89-
90114
echo "Configuring GitLab..."
91115
gitlab-ctl reconfigure
92116

@@ -97,7 +121,7 @@ if [ "${GITLAB_SKIP_PG_UPGRADE}" != true ]; then
97121
fi
98122

99123
if [ -n "${GITLAB_POST_RECONFIGURE_SCRIPT+x}" ]; then
100-
echo "Runnning Post Reconfigure Script..."
124+
echo "Running Post Reconfigure Script..."
101125
eval "${GITLAB_POST_RECONFIGURE_SCRIPT}"
102126
fi
103127

0 commit comments

Comments
 (0)