summaryrefslogtreecommitdiff
path: root/config/files/.bashrc
blob: 7017be55cd34b0860301e0decf38da3af94eac40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash

export ASDF_DATA_DIR="/opt/asdf"
export PATH="${ASDF_DATA_DIR}/shims:${ASDF_DATA_DIR}/bin:/opt/gitlab/.local/bin:${PATH}"
export HOME="/opt/gitlab"

alias nuget='mono /usr/local/bin/nuget.exe'
set -o vi

function inflate() {
  local file=$1
  local to_dir=$2
  if [ -f "$file" ]; then
    tar --use-compress-program zstd -xf "$file" -C "$to_dir"
    rm "$file"
  fi
}

update_java_home() {
  local java_path
  java_path="$(asdf which java)"
  if [[ -n "${java_path}" ]]; then
    export JAVA_HOME
   JAVA_HOME="$(dirname "$(dirname "$(realpath "${java_path}")")")"
  fi
}

function switch_to_exact() {
  local tool=$1
  local version=$2

  asdf shell "$tool" "$version"
  if [[ "$tool" = "java" ]]; then
    update_java_home
  fi
}

function switch_to() {
  local tool=$1
  local major_version=$2
  local version
  version="$(grep "$tool" "/opt/gitlab/.tool-versions"| tr ' ' '\n' | grep "^$major_version")"

  switch_to_exact "$tool" "$version"
}

function major_version_from() {
  echo "$1" | cut -d'.' -f1
}

function enable_dev_mode() {
  unset HISTFILESIZE
  unset HISTSIZE
  export EDITOR=vim
  export LOG_LEVEL=debug
  set -o vi
  apt-get update -y
  apt-get install -y --no-install-recommends vim less shellcheck
}

if [ ! -d "/opt/asdf" ]; then
  dpkg -i /opt/toolcache/asdf_*.deb
fi
inflate /opt/gitlab/.config.tar.zst /opt/gitlab
inflate /opt/gitlab/.m2.tar.zst /opt/gitlab
inflate /opt/gitlab/embedded.tar.zst /opt/gitlab
inflate /usr/include.tar.zst /usr
inflate /usr/lib/gcc.tar.zst /usr/lib
inflate /usr/lib/git-core.tar.zst /usr/lib
inflate /usr/lib/llvm-7.tar.zst /usr/lib
inflate /usr/share.tar.zst /usr

# shellcheck source=/dev/null
. "$ASDF_DATA_DIR/asdf.sh"
# shellcheck source=/dev/null
. "$ASDF_DATA_DIR/completions/asdf.bash"