-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ceph#8317 from dreamhost/gentoo-python
Gentoo support for ceph-disk / ceph-detect-init; pip speedup Reviewed-by: Kefu Chai <[email protected]>
- Loading branch information
Showing
4 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
distro = None | ||
release = None | ||
codename = None | ||
|
||
|
||
# From ceph-disk, but there is no way to access it since it's not in a module | ||
def is_systemd(): | ||
""" | ||
Detect whether systemd is running; | ||
WARNING: not mutually exclusive with openrc | ||
""" | ||
with open('/proc/1/comm', 'rb') as i: | ||
for line in i: | ||
if 'systemd' in line: | ||
return True | ||
return False | ||
|
||
|
||
def is_openrc(): | ||
""" | ||
Detect whether openrc is running. | ||
""" | ||
OPENRC_CGROUP = '/sys/fs/cgroup/openrc' | ||
return os.path.isdir(OPENRC_CGROUP) | ||
|
||
|
||
def choose_init(): | ||
"""Select a init system | ||
Returns the name of a init system (upstart, sysvinit ...). | ||
""" | ||
if is_openrc(): | ||
return 'openrc' | ||
if is_systemd(): | ||
return 'systemd' | ||
return 'unknown' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters