Skip to content

Commit

Permalink
Podman detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylviettee authored and navi-desu committed Jul 25, 2024
1 parent bd18358 commit b94dc7d
Show file tree
Hide file tree
Showing 30 changed files with 34 additions and 26 deletions.
1 change: 1 addition & 0 deletions etc/rc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
#
# "" - nothing special
# "docker" - Docker container manager (Linux)
# "podman" - Podman container manager (Linux)
# "jail" - Jail (DragonflyBSD or FreeBSD)
# "lxc" - Linux Containers
# "openvz" - Linux OpenVZ
Expand Down
2 changes: 1 addition & 1 deletion init.d/binfmt.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ depend()
{
after clock procfs
use modules devfs
keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver
keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -vserver
}

start()
Expand Down
2 changes: 1 addition & 1 deletion init.d/cgroups.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ description="Mount the control groups."

depend()
{
keyword -docker -prefix -systemd-nspawn -vserver
keyword -docker -podman -prefix -systemd-nspawn -vserver
after sysfs
}

Expand Down
2 changes: 1 addition & 1 deletion init.d/consolefont.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ depend()
{
need termencoding
after hotplug bootmisc modules
keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
}

start()
Expand Down
2 changes: 1 addition & 1 deletion init.d/devfs.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ depend()
{
provide dev-mount
before dev
keyword -docker -prefix -systemd-nspawn -vserver
keyword -docker -podman -prefix -systemd-nspawn -vserver
}

mount_dev()
Expand Down
2 changes: 1 addition & 1 deletion init.d/dmesg.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ description="Set the dmesg level for a cleaner boot"
depend()
{
before dev modules
keyword -docker -lxc -prefix -systemd-nspawn -vserver
keyword -docker -podman -lxc -prefix -systemd-nspawn -vserver
}

start()
Expand Down
2 changes: 1 addition & 1 deletion init.d/fsck.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ depend()
{
after clock
use dev clock modules
keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -timeout -vserver -uml
keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn -timeout -vserver -uml
}

_abort() {
Expand Down
2 changes: 1 addition & 1 deletion init.d/hostname.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ description="Sets the hostname of the machine."
depend()
{
after clock
keyword -docker -lxc -prefix -systemd-nspawn
keyword -docker -podman -lxc -prefix -systemd-nspawn
}

start()
Expand Down
2 changes: 1 addition & 1 deletion init.d/hwclock.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ depend()
if yesno $clock_adjfile; then
use root
fi
keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
}

setupopts()
Expand Down
2 changes: 1 addition & 1 deletion init.d/keymaps.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ depend()
{
need termencoding
after devfs
keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
}

start()
Expand Down
2 changes: 1 addition & 1 deletion init.d/localmount.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ depend()
need fsck root
use lvm modules
after clock lvm modules
keyword -docker -jail -lxc -prefix -systemd-nspawn -vserver
keyword -docker -podman -jail -lxc -prefix -systemd-nspawn -vserver
}

start()
Expand Down
2 changes: 1 addition & 1 deletion init.d/modules.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ depend()
{
use isapnp
provide modules-load
keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver
keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -vserver
}

find_modfiles()
Expand Down
2 changes: 1 addition & 1 deletion init.d/mount-ro.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ description="Re-mount filesystems read-only for a clean reboot."
depend()
{
after killprocs savecache
keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver
keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -vserver
}

start()
Expand Down
2 changes: 1 addition & 1 deletion init.d/net-online.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ depend()
after modules net
need sysfs
provide network-online
keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -uml -vserver
keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn -uml -vserver
}

get_interfaces()
Expand Down
2 changes: 1 addition & 1 deletion init.d/netmount.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ depend()
use afc-client amd openvpn
use dns
use root
keyword -docker -jail -lxc -prefix -systemd-nspawn -vserver
keyword -docker -podman -jail -lxc -prefix -systemd-nspawn -vserver
}

start()
Expand Down
2 changes: 1 addition & 1 deletion init.d/numlock.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}

depend()
{
keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver
keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -vserver
}

_setleds()
Expand Down
2 changes: 1 addition & 1 deletion init.d/procfs.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ depend()
after clock
use devfs
want modules
keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver
keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -vserver
}

start()
Expand Down
2 changes: 1 addition & 1 deletion init.d/root.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ depend()
{
after clock
need fsck
keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -vserver
keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn -vserver
}

start()
Expand Down
2 changes: 1 addition & 1 deletion init.d/save-keymaps.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ depend()
{
need termencoding
after bootmisc clock keymaps
keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
}

start()
Expand Down
2 changes: 1 addition & 1 deletion init.d/save-termencoding.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}

depend()
{
keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
use root
after bootmisc clock termencoding
}
Expand Down
2 changes: 1 addition & 1 deletion init.d/seedrng.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ depend()
{
after clock
need localmount
keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn
keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn
provide urandom
}

Expand Down
2 changes: 1 addition & 1 deletion init.d/swap.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ depend()
{
after clock root
before localmount
keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -vserver
keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn -vserver
}

start()
Expand Down
2 changes: 1 addition & 1 deletion init.d/swclock.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ swclock_file="${swclock_file:-/var/lib/misc/openrc-shutdowntime}"
depend()
{
provide clock
keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
}

# swclock is an OpenRC built in
Expand Down
2 changes: 1 addition & 1 deletion init.d/sysfs.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sysfs_opts=nodev,noexec,nosuid

depend()
{
keyword -docker -lxc -prefix -systemd-nspawn -vserver
keyword -docker -podman -lxc -prefix -systemd-nspawn -vserver
}

mount_sys()
Expand Down
2 changes: 1 addition & 1 deletion init.d/termencoding.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}

depend()
{
keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
after devfs
}

Expand Down
2 changes: 1 addition & 1 deletion init.d/urandom.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ depend()
{
after clock
need localmount
keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn
keyword -docker -podman -jail -lxc -openvz -prefix -systemd-nspawn
}

save_seed()
Expand Down
2 changes: 2 additions & 0 deletions man/openrc-run.8
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ Same as -jail, but for Xen DOM0 systems.
Same as -jail, but for Xen DOMU systems.
.It Dv -docker
Same as -jail, but for docker systems.
.It Dv -podman
Same as -jail, but for podman systems.
.It Dv -containers
Same as -jail, but for all relevant container types on the operating
system.
Expand Down
2 changes: 1 addition & 1 deletion sh/rc-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ _get_containers() {
c="-jail"
;;
Linux)
c="-docker -lxc -openvz -rkt -systemd-nspawn -uml -vserver"
c="-docker -podman -lxc -openvz -rkt -systemd-nspawn -uml -vserver"
;;
esac
echo $c
Expand Down
4 changes: 4 additions & 0 deletions src/librc/librc.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ detect_container(const char *systype RC_UNUSED)
return RC_SYS_SYSTEMD_NSPAWN;
if (strcmp(systype, RC_SYS_DOCKER) == 0)
return RC_SYS_DOCKER;
if (strcmp(systype, RC_SYS_PODMAN) == 0)
return RC_SYS_PODMAN;
}
if (file_regex("/proc/cpuinfo", "UML"))
return RC_SYS_UML;
Expand All @@ -306,6 +308,8 @@ detect_container(const char *systype RC_UNUSED)
return RC_SYS_SYSTEMD_NSPAWN;
else if (exists("/.dockerenv"))
return RC_SYS_DOCKER;
else if (exists("/run/.containerenv"))
return RC_SYS_PODMAN;
/* old test, I'm not sure when this was valid. */
else if (file_regex("/proc/1/environ", "container=docker"))
return RC_SYS_DOCKER;
Expand Down
1 change: 1 addition & 0 deletions src/librc/rc.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ bool rc_service_daemons_crashed(const char *);
* OpenRC can support some special sub system types, normally virtualization.
* Some services cannot work in these systems, or we do something else. */
#define RC_SYS_DOCKER "DOCKER"
#define RC_SYS_PODMAN "PODMAN"
#define RC_SYS_JAIL "JAIL"
#define RC_SYS_NONE ""
#define RC_SYS_OPENVZ "OPENVZ"
Expand Down

0 comments on commit b94dc7d

Please sign in to comment.