Merge pull request #1 from scoronado12/stefano-tweaks
Portability tweaks
This commit is contained in:
commit
f97b5d2afa
2 changed files with 62 additions and 12 deletions
37
dockergui
37
dockergui
|
@ -26,13 +26,45 @@ xephyrpid=$!
|
||||||
if command -v ratpoison; then
|
if command -v ratpoison; then
|
||||||
sleep 1
|
sleep 1
|
||||||
ratpoison -d :$DNum &
|
ratpoison -d :$DNum &
|
||||||
else # Use the default x window manager installed
|
else # Use the default x window manager installed based on lsb_release id
|
||||||
|
|
||||||
DISPLAY=:$DNum
|
DISPLAY=:$DNum
|
||||||
|
distro_id=$(lsb_release -i | awk '{print($3)}')
|
||||||
|
|
||||||
|
if [ "${distro_id}" == "Ubuntu" ] || [ "${distro_id}" == "Debian" ]; then
|
||||||
x-window-manager &
|
x-window-manager &
|
||||||
|
else
|
||||||
|
if [ "${XDG_SESSION_DESKTOP}" == "KDE" ]; then
|
||||||
|
startplasma-x11 &
|
||||||
|
elif [ "${XDG_SESSION_DESKTOP}" == "GNOME" ]; then
|
||||||
|
mutter &
|
||||||
|
else
|
||||||
|
printf "%s\n" "Could not find a suitable Window Manager"
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
windowmanagerpid=$!
|
windowmanagerpid=$!
|
||||||
|
|
||||||
docker run --net=host \
|
#detect podman or docker
|
||||||
|
|
||||||
|
if command -v docker; then
|
||||||
|
engine_of_choice="docker"
|
||||||
|
|
||||||
|
elif command -v podman; then
|
||||||
|
engine_of_choice="podman"
|
||||||
|
else
|
||||||
|
printf "%s\n" "Docker/Podman are not installed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# then run the detected container engine
|
||||||
|
|
||||||
|
$engine_of_choice run --net=host \
|
||||||
--rm \
|
--rm \
|
||||||
-e DISPLAY=:$DNum \
|
-e DISPLAY=:$DNum \
|
||||||
-v /tmp/.X11-unix/X$DNum:/tmp/.X11-unix/X$DNum:rw \
|
-v /tmp/.X11-unix/X$DNum:/tmp/.X11-unix/X$DNum:rw \
|
||||||
|
@ -41,6 +73,7 @@ docker run --net=host \
|
||||||
--cap-drop=ALL \
|
--cap-drop=ALL \
|
||||||
--shm-size 2g \
|
--shm-size 2g \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
kill $windowmanagerpid
|
kill $windowmanagerpid
|
||||||
kill $xephyrpid
|
kill $xephyrpid
|
||||||
|
|
||||||
|
|
19
pkg-install
19
pkg-install
|
@ -3,6 +3,7 @@
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from getpass import getuser
|
from getpass import getuser
|
||||||
from os import getuid, getgid, getlogin
|
from os import getuid, getgid, getlogin
|
||||||
|
from shutil import which
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
parser = ArgumentParser(description="Install AUR packages into a Docker container")
|
parser = ArgumentParser(description="Install AUR packages into a Docker container")
|
||||||
|
@ -45,4 +46,20 @@ RUN yay -S --noconfirm {package_name}
|
||||||
ENTRYPOINT [\"/usr/bin/env\", \"{command}\"]"
|
ENTRYPOINT [\"/usr/bin/env\", \"{command}\"]"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
subprocess.run(["docker", "build", "-t", command, "-"], input = dockerfile, encoding = 'UTF-8')
|
# check if either docker or podman are installed
|
||||||
|
|
||||||
|
try:
|
||||||
|
if which("docker") is None:
|
||||||
|
print("Docker not installed, building with Podman")
|
||||||
|
engine = "podman"
|
||||||
|
elif which("podman") is None:
|
||||||
|
engine = "docker"
|
||||||
|
else:
|
||||||
|
print("Podman/Docker are not installed! Exiting...")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
subprocess.run([engine, "build", "-t", command, "-"], input = dockerfile, encoding = 'UTF-8')
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("An Error has occured while attempting to build the image.")
|
||||||
|
exit(1)
|
||||||
|
|
Loading…
Reference in a new issue