LINUX.ORG.RU

История изменений

Исправление ubik, (текущая версия) :

мне нужен один юнит.

В итоге получилось такое:

[Unit]
Description=Foo %i

[Service]
Type=simple
Environment="SCRIPT_NAME=path/to/script_%i.py"
WorkingDirectory=/home/ubik/anal
ExecStartPre=/bin/bash -c '(( $(date +%u) < 5 )) && STREAM_T="3000 * 2" || STREAM_T="10*3*15"; sed -ri "s|^(stream_t[[:space:]]+=[[:space:]])[0-9*]+|\1$${STREAM_T}|" "${SCRIPT_NAME}"'
ExecStart=/home/ubik/anal/e.bash -s ${SCRIPT_NAME} -b ${BOOBS}
${BOOBS}

берётся из drop-in файла

Правда в journalctl есть такая строка:

systemd[1]: /etc/systemd/system/test@.service:12: Ignoring unknown escape sequences: "(( $(date +%u) < 5 )) && STREAM_T="3000 * 2" || STREAM_T="10*3*15"; sed -ri "s|^(stream_t[[:space:]]+=[[:space:]])[0-9*]+|\1$${STREAM_T}|" "${SCRIPT_NAME}""

Но скрипт модифицируется и запускается о_О

P.S. ещё узнал такую штуку:

The $$ in the string will become a single $ in the result passed to bash, but more importantly will stop ${…} from being interpolated by systemd. (Earlier versions of systemd did not document the use of $$, so I don’t know if it was supported then).

Исправление ubik, :

мне нужен один юнит.

В итоге получилось такое:

[Unit]
Description=Foo %i

[Service]
Type=simple
Environment="SCRIPT_NAME=path/to/script_%i.py"
WorkingDirectory=/home/ubik/anal
ExecStartPre=/bin/bash -c '(( $(date +%u) < 5 )) && STREAM_T="3000 * 2" || STREAM_T="10*3*15"; sed -ri "s|^(stream_t[[:space:]]+=[[:space:]])[0-9*]+|\1$${STREAM_T}|" "${SCRIPT_NAME}"'
ExecStart=/home/ubik/anal/e.bash -s ${SCRIPT_NAME} -b ${BOOBS}
${BOOBS}

берётся из drop-in файла

Правда в journalctl есть такая строка:

systemd[1]: /etc/systemd/system/test@.service:12: Ignoring unknown escape sequences: "(( $(date +%u) < 5 )) && STREAM_T="3000 * 2" || STREAM_T="10*3*15"; sed -ri "s|^(traffic_time[[:space:]]+=[[:space:]])[0-9*]+|\1$${STREAM_T}|" "${SCRIPT_NAME}""

Но скрипт модифицируется и запускается о_О

P.S. ещё узнал такую штуку:

The $$ in the string will become a single $ in the result passed to bash, but more importantly will stop ${…} from being interpolated by systemd. (Earlier versions of systemd did not document the use of $$, so I don’t know if it was supported then).

Исходная версия ubik, :

мне нужен один юнит.

В итоге получилось такое:

[Unit]
Description=Foo %i

[Service]
Type=simple
Environment="SCRIPT_NAME=path/to/script_%i.py"
WorkingDirectory=/home/ubik/anal
ExecStartPre=/bin/bash -c '(( $(date +%u) < 5 )) && STREAM_T="3000 * 2" || STREAM_T="10*3*15"; sed -ri "s|^(stream_t[[:space:]]+=[[:space:]])[0-9*]+|\1$${STREAM_T}|" "${SCRIPT_NAME}"'
ExecStart=/home/ubik/anal/e.bash -s ${SCRIPT_NAME} -b ${BOOBS}
${BOOBS}

берётся из drop-in файла

P.S. ещё узнал такую штуку:

The $$ in the string will become a single $ in the result passed to bash, but more importantly will stop ${…} from being interpolated by systemd. (Earlier versions of systemd did not document the use of $$, so I don’t know if it was supported then).