Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
7
votes
1
answers
18829
views
systemd // failed with result 'dependency'
I'm quite new to this `systemd` topic. I have some Units with varios Requires, After and Before. On some Units I got messages like: tinc.service: Job tinc.service/start failed with result 'dependency'. But which dependency in detail? This is how I tried to drill down to the problem: core@chimp ~ $ s...
I'm quite new to this
systemd
topic. I have some Units with varios Requires, After and Before. On some Units I got messages like:
tinc.service: Job tinc.service/start failed with result 'dependency'.
But which dependency in detail? This is how I tried to drill down to the problem:
core@chimp ~ $ systemctl status tinc.service
● tinc.service - Tinc VPN Service
Loaded: loaded (/etc/systemd/system/tinc.service; static; vendor preset: disabled)
Active: inactive (dead)
May 04 18:09:18 chimp systemd: Dependency failed for Tinc VPN Service.
May 04 18:09:18 chimp systemd: tinc.service: Job tinc.service/start failed with result 'dependency'.
Take a look which service is required...
core@chimp ~ $ cat /etc/systemd/system/tinc.service
[Unit]
Description=Tinc VPN Service
Requires=flannel-wait.service
After=flanneld.service tinc-env.service flannel-wait.service
#Before=early-docker.target
[Service]
Restart=always
RestartSec=3
Environment="DOCKER_HOST=unix:///var/run/early-docker.sock"
EnvironmentFile=/etc/tinc-env
EnvironmentFile=/etc/environment
ExecStartPre=/usr/bin/docker pull jenserat/tinc
ExecStartPre=/usr/bin/rm -rf /srv/tinc
ExecStartPre=/usr/bin/mkdir -p /srv/tinc
ExecStartPre=/bin/sh -c "/usr/bin/docker run --rm --volume /srv/tinc:/etc/tinc jenserat/tinc init $TINC_HOSTNAME"
ExecStartPre=/bin/sh -c "/usr/bin/docker run --rm --volume /srv/tinc:/etc/tinc jenserat/tinc add Address = $COREOS_PUBLIC_IPV4"
EnvironmentFile=/run/flannel/subnet.env
ExecStartPre=/bin/sh -c "/usr/bin/docker run --rm --volume /srv/tinc:/etc/tinc jenserat/tinc add Subnet = echo $FLANNEL_SUBNET | sed -e 's/1\\/24/0\\/24/'
"
ExecStartPre=/bin/sh -c "/usr/bin/docker run --rm --volume /srv/tinc:/etc/tinc jenserat/tinc add Mode = switch"
ExecStartPre=/bin/sh -c "/usr/bin/docker run --rm --volume /srv/tinc:/etc/tinc jenserat/tinc add DeviceType = tap"
ExecStartPre=-/usr/bin/docker rm -f tinc
ExecStartPre=/usr/bin/docker run --name tinc -d --volume /srv/tinc:/etc/tinc --net=host --device=/dev/net/tun --cap-add NET_ADMIN jenserat/tinc start -D
ExecStart=/bin/sh -c "while true; do etcdctl set /services/tinc/$TINC_HOSTNAME \"\\\" cat /srv/tinc/hosts/$TINC_HOSTNAME
\"\\\" --ttl 60;sleep 45;done"
#ExecStop=/usr/bin/docker rm -f tinc
ExecStopPost=/bin/sh -c "etcdctl rm /services/tinc/$TINC_HOSTNAME"
Move on to flannel-wait.service
:
core@chimp ~ $ systemctl status flannel-wait.service
● flannel-wait.service - Wait For Flannel
Loaded: loaded (/etc/systemd/system/flannel-wait.service; static; vendor preset: disabled)
Active: inactive (dead)
May 04 18:09:18 chimp systemd: Dependency failed for Wait For Flannel.
May 04 18:09:18 chimp systemd: flannel-wait.service: Job flannel-wait.service/start failed with result 'dependency'.
core@chimp ~ $ cat /etc/systemd/system/flannel-wait.service
[Unit]
Description=Wait For Flannel
Requires=flanneld.service
After=flanneld.service
[Service]
Type=oneshot
ExecStart=/bin/sh -c "echo \"TINC_HOSTNAME=hostname | sed -e 's/-/_/g'
\" > /etc/tinc-env"
ExecStartPre=/bin/sh -c "while [ ! -f /run/flannel/subnet.env ] ; do sleep 1; done"
Drill depper..
core@chimp ~ $ systemctl status flanneld.service
● flanneld.service - Network fabric for containers
Loaded: loaded (/usr/lib64/systemd/system/flanneld.service; static; vendor preset: disabled)
Drop-In: /etc/systemd/system/flanneld.service.d
└─50-network-config.conf
Active: active (running) since Wed 2016-05-04 18:09:24 CEST; 12min ago
Docs: https://github.com/coreos/flannel
Process: 929 ExecStartPost=/usr/bin/docker run --net=host --rm -v /run:/run quay.io/coreos/flannel:${FLANNEL_VER} /opt/bin/mk-docker-opts.sh -d /run/flannel_docker_opts.env -i (code=exited, status=0/SUCCESS)
Process: 879 ExecStartPre=/usr/bin/etcdctl set /coreos.com/network/config { "Network": "10.1.0.0/16", "Backend": { "Type": "alloc"} } (code=exited, status=0/SUCCESS)
Process: 877 ExecStartPre=/usr/bin/touch ${FLANNEL_ENV_FILE} (code=exited, status=0/SUCCESS)
Process: 875 ExecStartPre=/usr/bin/mkdir -p ${ETCD_SSL_DIR} (code=exited, status=0/SUCCESS)
Process: 873 ExecStartPre=/usr/bin/mkdir -p /run/flannel (code=exited, status=0/SUCCESS)
Process: 871 ExecStartPre=/sbin/modprobe ip_tables (code=exited, status=0/SUCCESS)
Main PID: 886 (sdnotify-proxy)
Memory: 12.0M
CPU: 93ms
CGroup: /system.slice/flanneld.service
├─886 /usr/libexec/sdnotify-proxy /run/flannel/sd.sock /usr/bin/docker run --net=host --privileged=true --rm --volume=/run/flannel:/run/flannel --env=NOTIFY_SOCKET=/run/flannel/sd.sock --env=AW...
└─889 /usr/bin/docker run --net=host --privileged=true --rm --volume=/run/flannel:/run/flannel --env=NOTIFY_SOCKET=/run/flannel/sd.sock --env=AWS_ACCESS_KEY_ID= --env=AWS_SECRET_ACCESS_KEY= --e...
May 04 18:09:24 chimp sdnotify-proxy: I0504 16:09:24.131290 00001 main.go:275] Installing signal handlers
May 04 18:09:24 chimp sdnotify-proxy: I0504 16:09:24.139346 00001 main.go:188] Using 178.XXXXXX as external interface
May 04 18:09:24 chimp sdnotify-proxy: I0504 16:09:24.139363 00001 main.go:189] Using 178.XXXXX as external endpoint
May 04 18:09:24 chimp sdnotify-proxy: I0504 16:09:24.140740 00001 etcd.go:129] Found lease (10.1.6.0/24) for current IP (178.XXXX), reusing
May 04 18:09:24 chimp sdnotify-proxy: I0504 16:09:24.176357 00001 etcd.go:84] Subnet lease acquired: 10.1.6.0/24
May 04 18:09:24 chimp sdnotify-proxy: I0504 16:09:24.234997 00001 ipmasq.go:50] Adding iptables rule: FLANNEL -d 10.1.0.0/16 -j ACCEPT
May 04 18:09:24 chimp sdnotify-proxy: I0504 16:09:24.237095 00001 ipmasq.go:50] Adding iptables rule: FLANNEL ! -d 224.0.0.0/4 -j MASQUERADE
May 04 18:09:24 chimp sdnotify-proxy: I0504 16:09:24.256054 00001 ipmasq.go:50] Adding iptables rule: POSTROUTING -s 10.1.0.0/16 -j FLANNEL
May 04 18:09:24 chimp sdnotify-proxy: I0504 16:09:24.258241 00001 ipmasq.go:50] Adding iptables rule: POSTROUTING ! -s 10.1.0.0/16 -d 10.1.0.0/16 -j MASQUERADE
May 04 18:09:24 chimp systemd: Started Network fabric for containers.
As far as I understand this, the flannel-wait.service
relies on the flanneld.service
-which is running. But after all, why does it fail?
Thanks in advance!
Norman
(71 rep)
May 4, 2016, 04:32 PM
• Last activity: Jun 25, 2025, 03:04 AM
0
votes
1
answers
148
views
Starting user units from custom path
I have successfully enabled user units in RHEL 8 under ~/.config/systemd/user directory. Enabling linger also gives me the option to start the service without having to login. My question, is it possible to have user units, namely .service files, located at a different path other than ~/.config/syst...
I have successfully enabled user units in RHEL 8 under ~/.config/systemd/user directory. Enabling linger also gives me the option to start the service without having to login. My question, is it possible to have user units, namely .service files, located at a different path other than ~/.config/systemd/user and still be able to start these user units just like I am able to do now?
Casper Netherlands
(1 rep)
Nov 3, 2023, 04:09 AM
• Last activity: Nov 3, 2023, 09:12 AM
1
votes
1
answers
3654
views
Mounting options with Systemd Mount Units
I used to use the fstab file for mounting drives. This time i wanted to use Units instead and created a .mount file. However i wonder how i would set a file system check option and umask settings there. For example in a fstab file you would do that by adding (just as an example) `umask=000 0 1` I'm...
I used to use the fstab file for mounting drives. This time i wanted to use Units instead and created a .mount file. However i wonder how i would set a file system check option and umask settings there.
For example in a fstab file you would do that by adding (just as an example)
umask=000 0 1
I'm not sure if i can just use the same options in a .mount file?
Noobman
(63 rep)
Aug 6, 2023, 12:52 PM
• Last activity: Aug 7, 2023, 04:38 AM
0
votes
1
answers
584
views
Interact with Linux service via SSH
I've rented a server which I access using the Terminus SSH terminal. I've created a program that has prompts and takes input and works as intended when started normally. But I've created a service to automatically launch it at startup, or when it crashes, but when it's launched from the service it d...
I've rented a server which I access using the Terminus SSH terminal. I've created a program that has prompts and takes input and works as intended when started normally. But I've created a service to automatically launch it at startup, or when it crashes, but when it's launched from the service it doesn't print any output to the terminal or take any input.
If I leave the Standardinput and Standardoutput blank in the unit file, and use the systemctl status command, I can see the prompts that the program is supposed to print when it's started, but I still cant give it any commands.
I've tried setting the Standardinput and Standardoutput to tty and also tty-force and the TTYPath to /dev/pts/0, because it says thats the tty I'm using. When I do that though it still doesn't give any output or take any input, and also doesn't even give any of the starting output when I use the systemctl status command, same when I use the /dev/console as the TTYPath, which I read is supposed to be the default. So I don't know why it would display those prompts in the systemd status when no standardinput or ouput are set but not display them when they're set to /dev/console, if that's the default.
I've also tried several other ttys like ptyp0, ptyp1, tty0, tty2, and stdin/stdout, but still can't get it to work. Any suggestions?
I've realised there may be issues if it
tries to connect to the SSH terminal when I'm not connected to it, if that's the case is there a way to setup a virtual terminal that stays open and use that for the input and output, then just connect to that terminal whenever I log in via SSH?
How would I go about creating the virtual terminal via SSH, and also connecting to it? I've tried chvt 0 and chvt 1 but got "Couldn't get a file descriptor referring to the console.", also tried it using sudo su -, but still the same response.
Here's the unit code
[Unit]
Description= Makes sure server stays running
[Service]
Type=simple
TTYPath=/dev/pts/0
StandardInput=tty
StandardOutput=tty
ExecStart=/usr/lib/jvm/jdk-19/bin/java -cp /apps/server/lib/*:/apps/server/src packages/Server
Restart=always
RestartSec= 30
[Install]
WantedBy=default.target
Michael
(1 rep)
Jan 9, 2023, 02:32 AM
• Last activity: Jan 9, 2023, 06:50 PM
182
votes
20
answers
94693
views
A standard tool to convert a byte-count into human KiB MiB etc; like du, ls1
Is there a *standard tool* which converts an integer count of Bytes into a human-readable count of the largest possible unit-size, while keeping the numeric value between 1.00 and 1023.99 ? I have my own bash/awk script, but I am looking for a *standard* tool, which is found on many/most distros......
Is there a *standard tool* which converts an integer count of Bytes into a human-readable count of the largest possible unit-size, while keeping the numeric value between 1.00 and 1023.99 ?
I have my own bash/awk script, but I am looking for a *standard* tool, which is found on many/most distros... something more generally available, and ideally has simple command line args, and/or can accept piped input.
Here are some examples of the type of output I am looking for.
1 Byt
173.00 KiB
46.57 MiB
1.84 GiB
29.23 GiB
265.72 GiB
1.63 TiB
Here is the *bytes-human* script (used for the above output)
awk -v pfix="$1" -v sfix="$2" 'BEGIN {
split( "Byt KiB MiB GiB TiB PiB", unit )
uix = uct = length( unit )
for( i=1; i=1024 && length(s)>1)
{x/=1024; s=substr(s,5)}
s=substr(s,1,4)
xf=(s==" B ")?"%5d ":"%8.2f"
return sprintf( xf"%s\n", x, s)
}
{gsub(/^[0-9]+/, human($1)); print}'
Peter.O
(33644 rep)
Jul 26, 2012, 03:03 PM
• Last activity: Aug 25, 2022, 10:33 AM
0
votes
1
answers
36
views
Issues creating boot and shutdown systemd daemon
I'm trying to create a config file for my unit but when I start the daemon after enabling and shutdown the computer it doesnt works. The script only executes the ExecStart line after network.target on boot. Edit: Code: [Unit] Description="Service that executes Discord Bot at Boot and Shutdown." Afte...
I'm trying to create a config file for my unit but when I start the daemon after enabling and shutdown the computer it doesnt works. The script only executes the ExecStart line after network.target on boot.
Edit:
Code:
[Unit]
Description="Service that executes Discord Bot at Boot and Shutdown."
After=network.target
Before=poweroff.target
[Service]
ExecStart=/usr/bin/mi_script_bash.sh start
ExecStop=/usr/bin/mi_script_bash.sh stop
Type=oneshot
RemainAfterExit=true
[Install]
WantedBy= default.target poweroff.target
The ExecStart and ExecStop Calls are for the bash script mi_script_bash.sh (simple string comparison for calling to a NodeJs script):
#!/bin/bash
[ "$1" == "start" ] && node /home/ser356/Escritorio/discordjs/app.js start
[ "$1" == "stop" ] && node /home/ser356/Escritorio/discordjs/app.js stop
And then the node script:
const {Client,Intents} = require("discord.js");
require('dotenv').config();
var hora=new Date();
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
var argumentos=process.argv;
console.log(argumentos)
//client.login("OTUwNTQyNDQ5MzYzODA4MzA2.YiabpA.bulmNmwGgz9s8kOPyvjngR_rSbo");
client.on('ready', () => {
var canal = client.channels.cache.get("950644612517724171")
if(argumentos==='start'){
canal.send("Mi dueño me ha arrancado "+hora);
}
else if(argumentos==='stop'){
canal.send("Mi dueño me requiere "+hora);
}
else{
canal.send("nada")
}
});
client.login('token')
ser356
(68 rep)
Mar 9, 2022, 09:07 PM
• Last activity: Mar 10, 2022, 09:47 AM
2
votes
1
answers
2479
views
Gnome (Debian 11): How to install en_DK formats (date, numbers, units)?
I switched my system from Debian 10 to 11 (new computer), so I'm trying to revert to my normal settings. I have installed with en_US locale, which I do want for UI texts, but I need to revert to ISO formats, like "normal" dates with 4-digit years, 24 hours, millimetres, centimetres, A4 page format e...
I switched my system from Debian 10 to 11 (new computer), so I'm trying to revert to my normal settings. I have installed with en_US locale, which I do want for UI texts, but I need to revert to ISO formats, like "normal" dates with 4-digit years, 24 hours, millimetres, centimetres, A4 page format etc. I open the Gnome "Region & Language" settings, but I can't seem to be able to install a new format. IIRC, I had used
en_DK
before, which is basically a neutral English but good date, time, and unit formats. How do I add en_DK
in my new system for Gnome - only the formats part of Region & Language?

0__
(724 rep)
Nov 27, 2021, 03:55 PM
• Last activity: Nov 27, 2021, 04:06 PM
0
votes
2
answers
72
views
How to get just the number from units?
The default output of `units` seems to be a bit verbose: ``` $ units "2 fortnight" seconds * 2419200 / 4.1335979e-07 ``` Suppose I just want the number only, so that I can do things like `sleep $(units "2 fortnight" seconds)`. Is there a formatting argument for `units` that I'm missing? Or is there...
The default output of
units
seems to be a bit verbose:
$ units "2 fortnight" seconds
* 2419200
/ 4.1335979e-07
Suppose I just want the number only, so that I can do things like sleep $(units "2 fortnight" seconds)
. Is there a formatting argument for units
that I'm missing? Or is there some simple way to pipe it into something and get just the number? I can see that $ units "2 fortnight" seconds | head -n 1
would at least get rid of the factor, but I still have the extra whitespace and *
.
Haterind
(189 rep)
Aug 25, 2021, 06:40 PM
• Last activity: Aug 25, 2021, 06:59 PM
302
votes
18
answers
338898
views
How do you sort du output by size?
How do you sort `du -sh /dir/*` by size? I read one site that said use `| sort -n` but that's obviously not right. Here's an example that is wrong. [~]# du -sh /var/* | sort -n 0 /var/mail 1.2M /var/www 1.8M /var/tmp 1.9G /var/named 2.9M /var/run 4.1G /var/log 8.0K /var/account 8.0K /var/crash 8.0K...
How do you sort
du -sh /dir/*
by size? I read one site that said use | sort -n
but that's obviously not right. Here's an example that is wrong.
[~]# du -sh /var/* | sort -n
0 /var/mail
1.2M /var/www
1.8M /var/tmp
1.9G /var/named
2.9M /var/run
4.1G /var/log
8.0K /var/account
8.0K /var/crash
8.0K /var/cvs
8.0K /var/games
8.0K /var/local
8.0K /var/nis
8.0K /var/opt
8.0K /var/preserve
8.0K /var/racoon
12K /var/aquota.user
12K /var/portsentry
16K /var/ftp
16K /var/quota.user
20K /var/yp
24K /var/db
28K /var/empty
32K /var/lock
84K /var/profiles
224M /var/netenberg
235M /var/cpanel
245M /var/cache
620M /var/lib
748K /var/spool
xenoterracide
(61203 rep)
Dec 9, 2010, 11:17 AM
• Last activity: Nov 25, 2020, 07:37 AM
2
votes
1
answers
104
views
How do I tell the "units" command to use a different length unit by default?
By default, the GNU `units` command outputs length units in meters. If I want to use a different unit, I have to specify this manually at the `You want:` prompt. Is there a way to change the default from meters to something else? $ units Currency exchange rates from FloatRates (USD base) on 2020-07-...
By default, the GNU
units
command outputs length units in meters. If I want to use a different unit, I have to specify this manually at the You want:
prompt. Is there a way to change the default from meters to something else?
$ units
Currency exchange rates from FloatRates (USD base) on 2020-07-08
3496 units, 109 prefixes, 109 nonlinear units
You have: (1gallon)^(1/3)
You want:
Definition: 0.15584913 m
In the above example, I might want this interaction, with empty You want:
input, to produce the output Definition: 0.51131604 ft
or Definition: 6 in + 1.0863395 * 1|8 in
. At present, I only know how to get these outputs by specifying ft
or ftin
explicitly:
You have: (1gallon)^(1/3)
You want: ft
* 0.51131604
/ 1.9557376
You have: (1gallon)^(1/3)
You want: ftin
6 in + 1.0863395 * 1|8 in
It seems like it should also be possible to configure these as defaults using a command line option like --units
, or an environment variable like UNITS_SYSTEM
, or an entry in ~/.units
.
Metamorphic
(1219 rep)
Oct 5, 2020, 08:27 PM
• Last activity: Oct 6, 2020, 08:27 PM
3
votes
1
answers
3817
views
What units are the values in /proc/partitions and /sys/dev/block/<block>/size?
I have a sample emmc block info from an android device >From `/proc/partitions` major minor #blocks name 179 1 5120 mmcblk0p1 Using my little intelligence I am assuming `/proc/partitions` uses blocks since it says partition 1 has 5120 blocks >From `/sys/dev/block/179:0/mmcblk0p1/size` 10240 It is se...
I have a sample emmc block info from an android device
>From
/proc/partitions
major minor #blocks name
179 1 5120 mmcblk0p1
Using my little intelligence I am assuming /proc/partitions
uses blocks since it says partition 1 has 5120 blocks
>From /sys/dev/block/179:0/mmcblk0p1/size
10240
It is seeming the partition values in /sys/…/size are double the values of /proc/partitions. Hence why are they different hence what the units in both of them?
Bret Joseph
(491 rep)
Apr 17, 2019, 08:32 AM
• Last activity: Apr 17, 2019, 02:24 PM
5
votes
1
answers
1487
views
Logging interactive input and output without capturing all typed input and control characters
I am trying to log output from an interactive command-line program; [`units`](https://www.gnu.org/software/units/), specifically. I have tried using `tee` like this: units | tee units.log or script like this: script -c units units.log but they both log all the backspaces and tab completions as speci...
I am trying to log output from an interactive command-line program; [
units
](https://www.gnu.org/software/units/) , specifically.
I have tried using tee
like this:
units | tee units.log
or script like this:
script -c units units.log
but they both log all the backspaces and tab completions as special characters like this:
You have: 55 horsepower ^G/^H^[[K^M
You want: wat^Gt ^M
* 41013.493^M
/ 2.438222e-05^M
The manpage for script
mentions this issue.
> **BUGS**
>
> Script places everything in the log file, including linefeeds and backspaces.
> This is not what the naive user expects.
I am aware of the work-around with viewing the file using cat
and more
or stripping the escape characters with col
as mentioned here:
https://stackoverflow.com/questions/7152339/format-output-from-unix-script-command-remove-backspaces-linefeeds-and-delet
As well as the perl script here:
http://log.guidoderosa.net/2009/05/another-old-post-which-may-be-useful.html
But I don't especially want to fix an existing log file: I want to avoid creating new log files garbled with deleted input and control characters.
I thought I had fixed the problem using rlwrap
, but it conflicts with the units
readline functionality, so that it either fails to capture the output, or with rlwrap -a
it captures the output but negates the ability of units
to use tab-completion. rlwrap -a -N
does not help. This is well-documented in the man page:
> **BUGS and LIMITATIONS**
>
> Though it is flexible, delivers the goods (readline functionality), and
> adheres to the Unix "many small tools" paradigm, rlwrap is a kludge. It
> cannot know anything about command's internal state, which makes
> context-sensitive completion impossible. Using the readline library from
> within command is still the best option.
Is there any way to cleanly log interactive input and output that doesn't mess with the existing readline
functionality?
Update: I would be happy with something like
units | col -b | tee units.log
but that hangs while waiting for interactive input. Can this be fixed?
Nathaniel M. Beaver
(1398 rep)
Nov 15, 2013, 04:30 AM
• Last activity: Feb 6, 2019, 05:42 PM
-1
votes
1
answers
683
views
Human-readable `du` with finer grain
I sometimes wish human-readable `du -h` option to be more *fine-grained* while still human-readable. Instead of showing: 14G it would show something like: 14G 236M 788k 110b Is there an easy / straightforward / standard way to get this?
I sometimes wish human-readable
du -h
option to be more *fine-grained* while still human-readable.
Instead of showing:
14G
it would show something like:
14G 236M 788k 110b
Is there an easy / straightforward / standard way to get this?
iago-lito
(2931 rep)
Dec 27, 2017, 03:57 PM
• Last activity: Dec 28, 2017, 09:55 AM
5
votes
0
answers
1869
views
Polkit rule for systemd template unit files
I'm trying to figure out how to write a polkit rule for a systemd template file. The rule is triggered when I use the actual service that will be instantiated (`openvpn-client@miami.service`) but not when I leave out the instance identifier string (`openvpn-client@.service`). Here is the complete wo...
I'm trying to figure out how to write a polkit rule for a systemd template file. The rule is triggered when I use the actual service that will be instantiated (
openvpn-client@miami.service
) but not when I leave out the instance identifier string (openvpn-client@.service
).
Here is the complete working rule:
polkit.addRule(function(action, subject) {
if ( action.id == "org.freedesktop.systemd1.manage-units") {
if (action.lookup("unit") == "openvpn-client@miami.service" && subject.isInGroup("wheel")) {
var verb = action.lookup("verb");
if (verb == "start" || verb == "stop" || verb == "restart") {
return polkit.Result.YES;
}
}
}
polkit.log("action=" + action);
polkit.log("subject=" + subject);
});
My hunch is that I could use javascript regex to just glob the string between "@" and ".service" but I can't quite figure it out.
My vpn provider has many possible servers, each with its own config (referenced by the openvpn-client@.service template unit file), so I'd really like to not have to write a polkit rule for each instance of the template.
Thanks a lot!
**Update:**
I solved this according to my hunch above, using regex to test for template file. This is maybe unsafe?
polkit.addRule(function(action, subject) {
if ( action.id == "org.freedesktop.systemd1.manage-units") {
var instance = /openvpn-client@[a-z]+.service/.test(action.lookup("unit"));
if ( instance === true && subject.isInGroup("wheel")) {
var verb = action.lookup("verb");
if (verb == "start" || verb == "stop" || verb == "restart") {
return polkit.Result.YES;
}
}
}
polkit.log("action=" + action);
polkit.log("subject=" + subject);
});
Worried in Denver
(51 rep)
Mar 13, 2017, 03:15 AM
• Last activity: Nov 7, 2017, 10:51 PM
4
votes
4
answers
7454
views
Filesystems Size Single Letter Abbreviation
In many file system related man page, the units are represented by single letters [bBsSkKmMgGtTpPeE]. What do the upper case and lower case mean? I.e. megabyte, megabit, mebiyte, mebibit, which one is which?
In many file system related man page, the units are represented by single letters [bBsSkKmMgGtTpPeE]. What do the upper case and lower case mean? I.e. megabyte, megabit, mebiyte, mebibit, which one is which?
jackluo923
(141 rep)
Dec 6, 2016, 05:40 AM
• Last activity: Feb 6, 2017, 04:05 AM
2
votes
1
answers
859
views
What is wrong with my systemd unit file?
Here is my unit file: [Unit] Description=Backend Service After=mariadb.service Requires=mariadb.service [Service] Type=simple ExecStart=/var/www/html/pythonscripts/Backend.py [Install] Alias=BEd WantedBy=basic.target Here is what I previous wrote that used to work (instructions for setting up the se...
Here is my unit file:
[Unit]
Description=Backend Service
After=mariadb.service
Requires=mariadb.service
[Service]
Type=simple
ExecStart=/var/www/html/pythonscripts/Backend.py
[Install]
Alias=BEd
WantedBy=basic.target
Here is what I previous wrote that used to work (instructions for setting up the service):
BEd.service must be moved to /etc/systemd/system
systemctl daemon-reload
systemctl enable BEd
systemctl start BEd
Here is what the /etc/systemd/system folder currently contains:
basic.target.wants dbus-org.freedesktop.NetworkManager.service default.target.wants sockets.target.wants
BEd dbus-org.freedesktop.nm-dispatcher.service getty.target.wants sysinit.target.wants
BEd.service default.target multi-user.target.wants system-update.target.wants
Here is the error message after rebooting:
[root@BEKappa ~]# systemctl status -l BHd
BEd.service - Backend Service
Loaded: loaded (/etc/systemd/system/BEd.service; enabled)
Active: failed (Result: exit-code) since Sat 2016-01-16 18:39:27 EST; 34s ago
Process: 3852 ExecStart=/var/www/html/pythonscripts/BEd.py (code=exited, status=1/FAILURE)
Main PID: 3852 (code=exited, status=1/FAILURE)
CGroup: /system.slice/BEd.service
Jan 16 18:39:27 BEKappa BEd.py: Traceback (most recent call last):
Jan 16 18:39:27 BEKappa BEd.py: File "/var/www/html/pythonscripts/BEd.py", line 147, in
Jan 16 18:39:27 BEKappa BEd.py: cur.execute(network_adapters_sql)
Jan 16 18:39:27 BEKappa BEd.py: File "/usr/lib64/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
Jan 16 18:39:27 BEKappa BEd.py: self.errorhandler(self, exc, value)
Jan 16 18:39:27 BEKappa BEd.py: File "/usr/lib64/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
Jan 16 18:39:27 BEKappa BEd.py: raise errorclass, errorvalue
Jan 16 18:39:27 BEKappa BEd.py: _mysql_exceptions.ProgrammingError: (1064, 'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \'\'IP\', \'ethernet\', \'connecting\', \'(getting\', \'enp7s0\', \'yes\', \'1000\', \'"dhcp"\', )\' at line 1')
Jan 16 18:39:27 BEKappa systemd: BEd.service: main process exited, code=exited, status=1/FAILURE
Jan 16 18:39:27 BEKappa systemd: Unit BEd.service entered failed state.
I am 100% sure it isn't the service code, since it starts just fine after reboot manually (i.e. systemctl start BEd).
Based on the error I'm 90% sure mariaDB isn't finished loading when BEd starts, it fails on the first SQL statement of the program. Yet, this unit file worked before, and it's currently working on another server. So I am baffled.
gunslingor
(149 rep)
Jan 17, 2016, 12:13 AM
• Last activity: May 27, 2016, 05:41 PM
2
votes
0
answers
1340
views
Systemd doesn't start a timer unit
I would like to create a timer that launch a command every 2 months (the first of the month) I already do that with a cron, but I would like to do the same with systemd and get rid of cron. I have a problem because when I start my timer, systemd refused to activate it with the following error: syste...
I would like to create a timer that launch a command every 2 months (the first of the month)
I already do that with a cron, but I would like to do the same with systemd and get rid of cron.
I have a problem because when I start my timer, systemd refused to activate it with the following error:
systemd: Starting Start my timer.
systemd: myservice.timer failed to enter waiting state: Invalid argument
systemd: Failed to start Start my timer
systemd: Unit myservice.timer entered failed state.
I used the two following units:
*myservice.timer*
[Unit]
Description=Start my timer
[Timer]
OnCalendar=*-01/2-01 00:00:01
Persistent=true
WakeSystem=true
[Install]
WantedBy=timers.target
*myservice.service*
[Unit]
Description=Start my command
[Service]
Type=oneshot
ExecStart=/usr/local/mycommand.sh
[Install]
WantedBy=multi-user.target
I suppose it doesn't work because it miss a parameter or the OnCalendar parameter is not good. I am on Debian Jessie.
Thank you.
Guillaume
(121 rep)
Feb 16, 2016, 09:18 PM
1
votes
3
answers
1146
views
CSV Units Conversion
I've got a CSV file that looks like the following: miami,20,in lansing,2,cm austin,3,mm chicago,5,miles phoenix,2,feet The first field is the name, the next field is the numeric value and the third field indicates the units. I've listed all the units that my dataset currently has however it is not l...
I've got a CSV file that looks like the following:
miami,20,in
lansing,2,cm
austin,3,mm
chicago,5,miles
phoenix,2,feet
The first field is the name, the next field is the numeric value and the third field indicates the units. I've listed all the units that my dataset currently has however it is not limited to these as I expect the dataset to change and require different units of measurement over time.
I want to be able to process this CSV file in a script so that all my values are converted to one common unit, inches, and are listed alongside the name. So it should look something like this:
miami,20
lansing,0.78740157
austin,0.11811024
chicago,316800
phoenix,24
I've figured out that there's a unit conversion tool
units
which is precisely what I'm looking for to use to convert my units as my data contains a mixture of metric and imperial units.
For example, if I wanted to convert my last line of data into inches I would do this
units 2cm in -t
Which would give me
0.78740157
What I'm currently seeking help on is how to go about using this command in a script and outputting it in the format I described (2nd code block). The CSV data is currently stored in a variable called $citydata
in a bash script. It is currently a string.
Varludea
(13 rep)
Mar 26, 2015, 11:00 AM
• Last activity: Mar 26, 2015, 10:16 PM
1
votes
0
answers
75
views
Tool to convert between human-readable byte sizes and bare byte counts
Can you recommend a Unix-style tool that converts between human-readable bytesizes (e.g., 10KiB->10240, 10240->10KiB)? By Unix-style I mean that it should do just this (i.e., be just a simple filter without any GUI or other cruft) and do it well (i.e., handle different units, behave intelligently by...
Can you recommend a Unix-style tool that converts between human-readable bytesizes (e.g., 10KiB->10240, 10240->10KiB)?
By Unix-style I mean that it should do just this (i.e., be just a simple filter without any GUI or other cruft) and do it well
(i.e., handle different units, behave intelligently by default while allowing optional settings, such as different interpretation of non-IT units (k==1000 OR 1024), optional custom rounding, optional conversion to units that aren't the most fitting ones, etc.).
Petr Skocik
(29590 rep)
Apr 15, 2013, 03:40 PM
Showing page 1 of 19 total questions