gitlab.com/jfprevost/gitlab-runner-notlscheck@v11.11.4+incompatible/docs/install/freebsd.md (about)

     1  ---
     2  last_updated: 2017-10-09
     3  ---
     4  
     5  # Install GitLab Runner on FreeBSD
     6  
     7  NOTE: **Note:**
     8  The FreeBSD version is also available as a [bleeding edge](bleeding-edge.md)
     9  release. Make sure that you read the [FAQ](../faq/README.md) section which
    10  describes some of the most common problems with GitLab Runner.
    11  
    12  CAUTION: **Important:**
    13  If you are using or upgrading from a version prior to GitLab Runner 10, read how
    14  to [upgrade to the new version](#upgrading-to-gitlab-runner-10). If you want
    15  to install a version prior to GitLab Runner 10, [visit the old docs](old.md).
    16  
    17  ## Installing GitLab Runner
    18  
    19  Here are the steps to install and configure GitLab Runner under FreeBSD:
    20  
    21  1. Create the `gitlab-runner` user and group:
    22  
    23      ```sh
    24      sudo pw group add -n gitlab-runner
    25      sudo pw user add -n gitlab-runner -g gitlab-runner -s /usr/local/bin/bash
    26      sudo mkdir /home/gitlab-runner
    27      sudo chown gitlab-runner:gitlab-runner /home/gitlab-runner
    28      ```
    29  
    30  1. Download the binary for your system:
    31  
    32      ```sh
    33      # For amd64
    34      sudo fetch -o /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-freebsd-amd64
    35  
    36      # For i386
    37      sudo fetch -o /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-freebsd-386
    38      ```
    39  
    40      You can download a binary for every available version as described in
    41      [Bleeding Edge - download any other tagged release](bleeding-edge.md#download-any-other-tagged-release).
    42  
    43  1. Give it permissions to execute:
    44  
    45      ```sh
    46      sudo chmod +x /usr/local/bin/gitlab-runner
    47      ```
    48  
    49  1. Create an empty log file with correct permissions:
    50  
    51      ```sh
    52      sudo touch /var/log/gitlab_runner.log && sudo chown gitlab-runner:gitlab-runner /var/log/gitlab_runner.log
    53      ```
    54  
    55  1. Create the `rc.d` directory in case it doesn't exist:
    56  
    57      ```sh
    58      mkdir -p /usr/local/etc/rc.d
    59      ```
    60  
    61  1. Create the `rc.d` script:
    62  
    63      ```sh
    64      sudo bash -c 'cat > /usr/local/etc/rc.d/gitlab_runner' << "EOF"
    65      #!/bin/sh
    66      # PROVIDE: gitlab_runner
    67      # REQUIRE: DAEMON NETWORKING
    68      # BEFORE:
    69      # KEYWORD:
    70  
    71      . /etc/rc.subr
    72  
    73      name="gitlab_runner"
    74      rcvar="gitlab_runner_enable"
    75  
    76      load_rc_config $name
    77  
    78      user="gitlab-runner"
    79      user_home="/home/gitlab-runner"
    80      command="/usr/local/bin/gitlab-runner run"
    81      pidfile="/var/run/${name}.pid"
    82  
    83      start_cmd="gitlab_runner_start"
    84      stop_cmd="gitlab_runner_stop"
    85      status_cmd="gitlab_runner_status"
    86  
    87      gitlab_runner_start()
    88      {
    89          export USER=${user}
    90          export HOME=${user_home}
    91          if checkyesno ${rcvar}; then
    92              cd ${user_home}
    93              /usr/sbin/daemon -u ${user} -p ${pidfile} ${command} > /var/log/gitlab_runner.log 2>&1
    94          fi
    95      }
    96  
    97      gitlab_runner_stop()
    98      {
    99          if [ -f ${pidfile} ]; then
   100              kill `cat ${pidfile}`
   101          fi
   102      }
   103  
   104      gitlab_runner_status()
   105      {
   106          if [ ! -f ${pidfile} ] || kill -0 `cat ${pidfile}`; then
   107              echo "Service ${name} is not running."
   108          else
   109              echo "${name} appears to be running."
   110          fi
   111      }
   112  
   113      run_rc_command $1
   114      EOF
   115      ```
   116  
   117  1. Make it executable:
   118  
   119      ```sh
   120      sudo chmod +x /usr/local/etc/rc.d/gitlab_runner
   121      ```
   122  
   123  1. [Register the Runner](../register/index.md)
   124  1. Enable the `gitlab-runner` service and start it:
   125  
   126      ```sh
   127      sudo sysrc -f /etc/rc.conf "gitlab_runner_enable=YES"
   128      sudo service gitlab_runner start
   129      ```
   130  
   131      If you don't want to enable the `gitlab-runner` service to start after a
   132      reboot, use:
   133  
   134      ```sh
   135      sudo service gitlab_runner onestart
   136      ```
   137  
   138  ## Upgrading to GitLab Runner 10
   139  
   140  To upgrade GitLab Runner from a version prior to 10.0:
   141  
   142  1. Stop the Runner:
   143  
   144      ```sh
   145      sudo service gitlab_runner stop
   146      ```
   147  
   148  1. Optionally, preserve the previous version of the Runner just in case:
   149  
   150      ```sh
   151      sudo mv /usr/local/bin/gitlab-ci-multi-runner{,.$(/usr/local/bin/gitlab-ci-multi-runner --version| grep Version | cut -d ':' -f 2 | sed 's/ //g')}
   152      ```
   153  
   154  1. Download the new Runner and make it executable:
   155  
   156      ```sh
   157      # For amd64
   158      sudo fetch -o /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-freebsd-amd64
   159  
   160      # For i386
   161      sudo fetch -o /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-freebsd-386
   162  
   163      sudo chmod +x /usr/local/bin/gitlab-runner
   164      ```
   165  
   166  1. Edit `/usr/local/etc/rc.d/gitlab_runner` and change:
   167  
   168      ```
   169      command="/usr/local/bin/gitlab-ci-multi-runner run"
   170      ```
   171  
   172      to:
   173  
   174      ```
   175      command="/usr/local/bin/gitlab-runner run"
   176      ```
   177  
   178  1. Start the Runner:
   179  
   180      ```sh
   181      sudo service gitlab_runner start
   182      ```
   183  
   184  1. After you confirm all is working correctly, you can remove the old binary:
   185  
   186      ```sh
   187      sudo rm /usr/local/bin/gitlab-ci-multi-runner.*
   188      ```