10 More Discussions You Might Find Interesting
1. UNIX for Beginners Questions & Answers
What is the difference ../directory path and ./directory path in ksh? (1 Reply)
Discussion started by: TestKing
1 Replies
2. UNIX for Beginners Questions & Answers
Hello,
I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Discussion started by: Sekhar419
4 Replies
3. Solaris
Hi,
I am having some NFS directory consistency problems with the below setup on a local (192.) network:
1. Different permissions (chmod) for the same NFS dir are reflected on different clients.
2. (more serious) an NFS dir created on client1 cannot be accessed on client2; this applies to some... (10 Replies)
Discussion started by: cosmojetz
10 Replies
4. Shell Programming and Scripting
Hello everyone I am a newcomer to UNIX and I have hit a snag in something that would probably take experienced people about 30 seconds. Long story short I am trying to add a directory to my PATH and it is getting added but not working. I mean, the object of adding it to the path is so I can access... (2 Replies)
Discussion started by: tastybrownies
2 Replies
5. Shell Programming and Scripting
I'm trying to set the path permanently through a shell script. (/opt/quest/bin:/usr/bin/lab to /.profile.) I tired using echo option like below but it doesn't work. Please suggest me the right way to do so.
echo "PATH=$PATH:/opt/quest/bin:/usr/bin/lab" >> /.profile (6 Replies)
Discussion started by: pjeedu2247
6 Replies
6. UNIX for Dummies Questions & Answers
Guys,
I did a search on this but couldn't find any thing.
I need to add /home/scadm/scripts to the PATH. If I do the below it works for the session I'm in. If I close it and reopen it doesnt work.
PATH=$PATH\:/home/scadm/scripts ; export PATH
I also want this path added to all the... (3 Replies)
Discussion started by: miltonrods
3 Replies
7. Shell Programming and Scripting
Hi,
I have added the path variable as below
export... (4 Replies)
Discussion started by: burton
4 Replies
8. Shell Programming and Scripting
Hi,
I have a file abcd.txt which has contents in the form of full path file names i.e.
$home> vi abcd.txt
/a/b/c/r1.txt
/q/w/e/r2.txt
/z/x/c/r3.txt
Now I want to retrieve only the directory path name for each row
i.e
/a/b/c/
/q/w/e/
How to get the same through shell script?... (7 Replies)
Discussion started by: royzlife
7 Replies
9. IP Networking
Hello,
I want to add a port in the firewall exception list so that my application can be accessed over network even if firewall is disabled. I am using iptables command to add exception.
The problem is, after setting the rule if I change the firewall setting i.e. on/off then it is overwriting... (1 Reply)
Discussion started by: senrooy
1 Replies
10. Red Hat
I have a machine with an interface that has two different addresses on CentOS 5
eth0: 10.20.21.77
eth0:1 141.218.1.221
If I issue this command I get the result I'm looking for.
/sbin/route add -net 141.218.1.0 netmask 255.255.255.0 gw 10.20.21.77
ip route show dev eth0
141.218.1.0/24... (1 Reply)
Discussion started by: beaker457
1 Replies
SYSTEMD.ENVIRONMENT-GENERATOR(7) systemd.environment-generator SYSTEMD.ENVIRONMENT-GENERATOR(7)
NAME
systemd.environment-generator - systemd environment file generators
SYNOPSIS
/lib/systemd/system-environment-generators/some-generator
/usr/lib/systemd/user-environment-generators/some-generator
/run/systemd/system-environment-generators/*
/etc/systemd/system-environment-generators/*
/usr/local/lib/systemd/system-environment-generators/*
/lib/systemd/system-environment-generators/*
/run/systemd/user-environment-generators/*
/etc/systemd/user-environment-generators/*
/usr/local/lib/systemd/user-environment-generators/*
/usr/lib/systemd/user-environment-generators/*
DESCRIPTION
Generators are small executables that live in /lib/systemd/system-environment-generators/ and other directories listed above. systemd(1)
will execute those binaries very early at the startup of each manager and at configuration reload time, before running the generators
described in systemd.generator(7) and before starting any units. Environment generators can override the environment that the manager
exports to services and other processes.
Generators are loaded from a set of paths determined during compilation, as listed above. System and user environment generators are loaded
from directories with names ending in system-environment-generators/ and user-environment-generators/, respectively. Generators found in
directories listed earlier override the ones with the same name in directories lower in the list. A symlink to /dev/null or an empty file
can be used to mask a generator, thereby preventing it from running. Please note that the order of the two directories with the highest
priority is reversed with respect to the unit load path, and generators in /run overwrite those in /etc.
After installing new generators or updating the configuration, systemctl daemon-reload may be executed. This will re-run all generators,
updating environment configuration. It will be used for any services that are started subsequently.
Environment file generators are executed similarly to unit file generators described in systemd.generator(7), with the following
differences:
o Generators are executed sequentially in the alphanumerical order of the final component of their name. The output of each generator
output is immediately parsed and used to update the environment for generators that run after that. Thus, later generators can use
and/or modify the output of earlier generators.
o Generators are run by every manager instance, their output can be different for each user.
It is recommended to use numerical prefixes for generator names to simplify ordering.
EXAMPLES
Example 1. A simple generator that extends an environment variable if a directory exists in the file system
# 50-xdg-data-dirs.sh
#!/bin/bash
# set the default value
XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share/:/usr/share}"
# add a directory if it exists
if [[ -d /opt/foo/share ]]; then
XDG_DATA_DIRS=/opt/foo/share:${XDG_DATA_DIRS}
fi
# write our output
echo XDG_DATA_DIRS=$XDG_DATA_DIRS
Example 2. A more complicated generator which reads existing configuration and mutates one variable
# 90-rearrange-path.py
#!/usr/bin/env python3
"""
Proof-of-concept systemd environment generator that makes sure that bin dirs
are always after matching sbin dirs in the path.
(Changes /sbin:/bin:/foo/bar to /bin:/sbin:/foo/bar.)
This generator shows how to override the configuration possibly created by
earlier generators. It would be easier to write in bash, but let's have it
in Python just to prove that we can, and to serve as a template for more
interesting generators.
"""
import os
import pathlib
def rearrange_bin_sbin(path):
"""Make sure any pair of .../bin, .../sbin directories is in this order
>>> rearrange_bin_sbin('/bin:/sbin:/usr/sbin:/usr/bin')
'/bin:/sbin:/usr/bin:/usr/sbin'
"""
items = [pathlib.Path(p) for p in path.split(':')]
for i in range(len(items)):
if 'sbin' in items[i].parts:
ind = items[i].parts.index('sbin')
bin = pathlib.Path(*items[i].parts[:ind], 'bin', *items[i].parts[ind+1:])
if bin in items[i+1:]:
j = i + 1 + items[i+1:].index(bin)
items[i], items[j] = items[j], items[i]
return ':'.join(p.as_posix() for p in items)
if __name__ == '__main__':
path = os.environ['PATH'] # This should be always set.
# If it's not, we'll just crash, we is OK too.
new = rearrange_bin_sbin(path)
if new != path:
print('PATH={}'.format(new))
Example 3. Debugging a generator
SYSTEMD_LOG_LEVEL=debug VAR_A=something VAR_B="something else"
/lib/systemd/system-environment-generators/path-to-generator
SEE ALSO
systemd-environment-d-generator(8), systemd.generator(7), systemd(1), systemctl(1)
systemd 237 SYSTEMD.ENVIRONMENT-GENERATOR(7)