179
179
auth_token: AUTH_TOKEN
180
180
runner:
181
181
name: RUNNER_NAME
182
- command_prefix: ["/opt/ circleci/launch-task "]
182
+ command_prefix: ["sudo", "-niHu", " circleci", "-- "]
183
183
working_directory: /opt/circleci/workdir/%s
184
184
cleanup_working_directory: true
185
185
```
@@ -195,7 +195,7 @@ sudo chmod 600 /opt/circleci/launch-agent-config.yaml
195
195
196
196
=== Create the circleci user & working directory
197
197
198
- These will be used when executing the `build- agent` .
198
+ These will be used when executing the task agent. These commands must be run as a user with permissions to create other users (e.g. `root`) .
199
199
200
200
```bash
201
201
id -u circleci &>/dev/null || adduser --uid 1500 --disabled-password --gecos GECOS circleci
@@ -204,40 +204,6 @@ mkdir -p /opt/circleci/workdir
204
204
chown -R circleci /opt/circleci/workdir
205
205
```
206
206
207
- === Install the launch script
208
-
209
- This wrapper script will be used by launch agent to execute the task agent, while ensuring appropriate sandboxing and a clean shutdown.
210
-
211
- Create `/opt/circleci/launch-task` owned by `root` with permissions `755`
212
-
213
- ```bash
214
- #!/bin/bash
215
-
216
- set -euo pipefail
217
-
218
- ## This script launches the build-agent using systemd-run in order to create a
219
- ## cgroup which will capture all child processes so they're cleaned up correctly
220
- ## on exit.
221
-
222
- # The user to run the build-agent as - must be numeric
223
- USER_ID=$(id -u circleci)
224
-
225
- # Give the transient systemd unit an inteligible name
226
- unit="circleci-$CIRCLECI_LAUNCH_ID"
227
-
228
- # When this process exits, tell the systemd unit to shut down
229
- abort() {
230
- if systemctl is-active --quiet "$unit"; then
231
- systemctl stop "$unit"
232
- fi
233
- }
234
- trap abort EXIT
235
-
236
- systemd-run \
237
- --pipe --collect --quiet --wait \
238
- --uid "$USER_ID" --unit "$unit" -- "$@"
239
- ```
240
-
241
207
=== Enable the `systemd` unit
242
208
243
209
Create `/opt/circleci/circleci.service` owned by `root` with permissions `755`.
0 commit comments