You are not logged in.
Pages: 1
Howdy all,
Trying to automate some setup - overriding systemd services;
~$ cat <<-'EOF' | sudo systemctl edit sabnzbd
[Service]
Group=media
EOF
Received SIGHUP or SIGTERM
Buffer written to /etc/systemd/system/sabnzbd.service.d/.override.confe61282feb5338872.save
editor failed with error code 1.
Edition of /etc/systemd/system/sabnzbd.service.d/override.conf canceled: temporary file empty
~$ cat /etc/systemd/system/sabnzbd.service.d/.override.confe61282feb5338872.save
[Service] Group=media
any tips for piping input into systemctl edit ?
Offline
I'm not sure I understand. Why not cat directly to /etc/systemd/system/sabnzbd.service.d/override.conf w/o systemctl?
Offline
systemctl edit uses $EDITOR (I believe - it does use vim here). So you are essentially piping into an editor. Does your editor allow this? Vim doesn't, as the following also fails:
cat <<EOF | vim
one line
another line
EOF
Most editors are made to edit, not to read input from stdin.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
advantage of using systemctl is I can do this for multiple services at the same time, and have it create the correct directories
EDITOR=nano
echo -e "[Service]\nGroup=media" | nano -
nano <(echo -e "[Service]\nGroup=media")
works
sudo systemctl edit sabnzbd <(echo -e "[Service]\nGroup=media")
doesn't
https://github.com/systemd/systemd/blob … tl.c#L5761
Last edited by bond (2015-04-08 01:22:33)
Offline
~$ echo -e '#!/bin/bash\nnano "$@" -' | sudo tee /usr/bin/nanopipe
~$ sudo chmod +x /usr/bin/nanopipe
~$ export SYSTEMD_EDITOR=nanopipe
~$ echo -e "[Service]\nGroup=media" | sudo systemctl edit sabnzbd
Received SIGHUP or SIGTERM
Buffer written to /etc/systemd/system/sabnzbd.service.d/.override.conf45bf955a37bdebe7.save
editor failed with error code 1.
bah
Offline
echo -e "[Service]\nGroup=media" | nano -
works
The "-" option specifies that the editted file should be constructed from stdin - so this is apples and oranges...
$ cat <<EOF | nano somefile
> one line
> another line
> EOF
Received SIGHUP or SIGTERM
Buffer written to somefile.save
$ cat somefile.save
one line another line
But you can write the same output to many files directly much easier that using systemctl
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
echo -e "[Service]\nGroup=media" | sudo systemctl edit sabnzbd sonarr couchpotato headphones transmission
is much cleaner than;
sudo mkdir -p /etc/systemd/system/{sabnzbd.service.d,sonarr.service.d,couchpotato.service.d,headphones.service.d,transmission.service.d}
echo -e "[Service]\nGroup=media" | sudo tee /etc/systemd/system/{sabnzbd.service.d,sonarr.service.d,couchpotato.service.d,headphones.service.d,transmission.service.d}/override.conf
sudo systemctl daemon-reload
Offline
echo -e "[Service]\nGroup=media" | sudo SYSTEMD_EDITOR=tee systemctl edit sabnzbd sonarr couchpotato headphones transmission
Offline
brilliant!
Offline
Pages: 1