Linux Labs

Bash: text processing and scripts / Stage 2 of 9

sed and awk: editing and fields of a stream

Not running Starting usually ~20 s
Leave the lesson

Step 8 of 9 · lab · 25 minmedium

Change an address in every config

The backend has moved: thirty configs with the address written in different ways, and the comments and similar addresses must stay.

Situation

The store runs thirty instances of its application, each with its own settings file in /etc/app.d/ — lines of the form key=value. The orders backend has moved: it was 10.20.0.15:8080, now it is 10.20.0.40:8080. The old server goes off tonight, and by then the instances that talk to it must talk to the new one. The key holding the backend address is upstream.

Different people have edited these configs by hand for years.

Task

Make sure that in every /etc/app.d/*.conf:

  1. each upstream line that pointed to 10.20.0.15:8080 points to 10.20.0.40:8080;
  2. the comments stay as they were, including commented-out settings: your colleagues read the history from them;
  3. the other lines don't change — other keys and the upstream lines that point to other addresses.

There is no need to restart the application, it rereads its settings by itself. Editing thirty files by hand takes long — edit them as a stream, but first look at how upstream is written in different files.

Lab · on your own

No commands are given in this lab: type them in the terminal yourself. Goals are checked on the machine after every command.

Goals

0 of 3
  • In every /etc/app.d/*.conf the upstream lines that pointed to 10.20.0.15:8080 point to 10.20.0.40:8080 — not done yet
  • The comments and commented-out settings are as they were — not done yet
  • The other lines are as they were, including upstream lines with other addresses — not done yet
Ctrl+Enter
Starts the machine node1 · Ubuntu 24.04

The machine is starting

Hints

0 of 3

Lab goals

0 of 3
  • In every /etc/app.d/*.conf the upstream lines that pointed to 10.20.0.15:8080 point to 10.20.0.40:8080 — not done yet
  • The comments and commented-out settings are as they were — not done yet
  • The other lines are as they were, including upstream lines with other addresses — not done yet
node1 Ubuntu 24.04

Lab goals

0 of 3
  • In every /etc/app.d/*.conf the upstream lines that pointed to 10.20.0.15:8080 point to 10.20.0.40:8080 — not done yet
  • The comments and commented-out settings are as they were — not done yet
  • The other lines are as they were, including upstream lines with other addresses — not done yet
Loading…