chroot-manager: X PORT selection added

This commit is contained in:
itdominator 2024-07-06 19:57:52 -05:00
parent 47f3df35d7
commit ca0980c416
1 changed files with 19 additions and 6 deletions

View File

@ -17,9 +17,7 @@ DEV_BASHRC_FILE="/home/developer/.bashrc"
DEV_PASSWORD="password" DEV_PASSWORD="password"
SCREEN_W=1600 SCREEN_W=1600
SCREEN_H=900 SCREEN_H=900
X_PORT=:10 X_PORT=10
#X_PORT=:11
#X_PORT=:12
@ -42,6 +40,13 @@ function _select_chroot_folder() {
echo "${CHROOT_FOLDERS_PATH}/${name}-chroot" echo "${CHROOT_FOLDERS_PATH}/${name}-chroot"
} }
function _get_x_port() {
read -p 'X Server Port: ' name
port=`sed -e s'| |10|'g <<< "${name}"`
echo "${port}"
}
function _get_chroot_env() { function _get_chroot_env() {
if [ ! -z "${1}" -a "${1}" != " " ]; then if [ ! -z "${1}" -a "${1}" != " " ]; then
chroot_env="${1}" chroot_env="${1}"
@ -402,6 +407,8 @@ function load_chroot() {
cd "${CHROOT_FOLDERS_PATH}" cd "${CHROOT_FOLDERS_PATH}"
chroot_env=$(_get_chroot_env " " "Load Chroot Venv:") chroot_env=$(_get_chroot_env " " "Load Chroot Venv:")
chroot_env=${chroot_env%/} # If ends with slash remove
X_PORT=$(_get_x_port)
cd "${chroot_env}" cd "${chroot_env}"
@ -409,7 +416,8 @@ function load_chroot() {
sudo cp /etc/hosts etc/hosts sudo cp /etc/hosts etc/hosts
sudo cp /etc/machine-id etc/machine-id sudo cp /etc/machine-id etc/machine-id
Xephyr -resizeable -screen "${SCREEN_W}"x"${SCREEN_H}" "${X_PORT}" & sed -i "/DISPLAY=/c\export DISPLAY=:${X_PORT}" "${chroot_env}"/home/developer/.bashrc
Xephyr -resizeable -screen "${SCREEN_W}"x"${SCREEN_H}" ":${X_PORT}" &
XEPHYR_PID=$! XEPHYR_PID=$!
_bind_mounts "${chroot_env}" _bind_mounts "${chroot_env}"
@ -426,6 +434,8 @@ function load_chroot_arch() {
cd "${CHROOT_FOLDERS_PATH}" cd "${CHROOT_FOLDERS_PATH}"
chroot_env=$(_get_chroot_env " " "Load Chroot Venv:") chroot_env=$(_get_chroot_env " " "Load Chroot Venv:")
chroot_env=${chroot_env%/} # If ends with slash remove
X_PORT=$(_get_x_port)
cd "${chroot_env}" cd "${chroot_env}"
@ -433,7 +443,8 @@ function load_chroot_arch() {
sudo cp /etc/hosts etc/hosts sudo cp /etc/hosts etc/hosts
sudo cp /etc/machine-id etc/machine-id sudo cp /etc/machine-id etc/machine-id
Xephyr -resizeable -screen "${SCREEN_W}"x"${SCREEN_H}" "${X_PORT}" & sed -i "/DISPLAY=/c\export DISPLAY=:${X_PORT}" "${chroot_env}"/home/developer/.bashrc
Xephyr -resizeable -screen "${SCREEN_W}"x"${SCREEN_H}" ":${X_PORT}" &
XEPHYR_PID=$! XEPHYR_PID=$!
sudo arch-chroot . bash sudo arch-chroot . bash
@ -450,6 +461,7 @@ function load_chroot_sysd() {
chroot_env=$(_get_chroot_env " " "Load Chroot Venv:") chroot_env=$(_get_chroot_env " " "Load Chroot Venv:")
chroot_env=${chroot_env%/} # If ends with slash remove chroot_env=${chroot_env%/} # If ends with slash remove
X_PORT=$(_get_x_port)
cd "${chroot_env}" cd "${chroot_env}"
@ -457,7 +469,8 @@ function load_chroot_sysd() {
sudo cp /etc/hosts etc/hosts sudo cp /etc/hosts etc/hosts
sudo cp /etc/machine-id etc/machine-id sudo cp /etc/machine-id etc/machine-id
Xephyr -resizeable -screen "${SCREEN_W}"x"${SCREEN_H}" "${X_PORT}" & sed -i "/DISPLAY=/c\export DISPLAY=:${X_PORT}" "${chroot_env}"/home/developer/.bashrc
Xephyr -resizeable -screen "${SCREEN_W}"x"${SCREEN_H}" ":${X_PORT}" &
XEPHYR_PID=$! XEPHYR_PID=$!
sudo systemd-nspawn -D . /sbin/init sudo systemd-nspawn -D . /sbin/init