From 4bea468c64fb89ab24e0f8ce315761589ce63a1c Mon Sep 17 00:00:00 2001 From: Thomas Walker Lynch Date: Tue, 8 Mar 2022 10:01:21 -0500 Subject: [PATCH] adds ch_subu subu_add subu_del --- executable/ch_subu | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) mode change 100644 => 100755 executable/ch_subu diff --git a/executable/ch_subu b/executable/ch_subu old mode 100644 new mode 100755 index c7298fa..0252a3f --- a/executable/ch_subu +++ b/executable/ch_subu @@ -1,21 +1,48 @@ #!/bin/bash # -# This must be sourced + +# to make audio work will need to do this: +# > sudo dnf install pulseaudio-utils +# > pactl load-module module-native-protocol-tcp + +#set -x subu=$1 + +if [ ! -x "/usr/local/bin/user-stem" ]; then + echo "no /usr/local/bin/user-stem program found (it is in the system repo)" + exit 1 +fi + if [ -z "$subu" ]; then echo "no subuser name supplied" exit 1 fi machine="$(hostname)" -xkey=$(xauth list | grep Turbine | awk '{print $3}') +xkey=$(xauth list | grep "$machine" | head -1 | awk '{print $3}') -if [ -z "$key" ]; then +if [ -z "$xkey" ]; then echo "xauth key not found" exit 1 fi -sudo su "$subu" +stem=$(/usr/local/bin/user-stem) +user_subu="$stem-$subu" +home_subu="/home/$stem/$subu" +bashrc="$home_subu/.bashrc" +xauthority="$home_subu/.Xauthority" + +read -r -d '' script0 <<-EOF + cd "$home_subu" \ + ;export DISPLAY=$DISPLAY \ + ;export NO_AT_BRIDGE=1 \ + ;export PULSE_SERVER=localhost \ + ;touch "$xauthority" \ + ;xauth add "$DISPLAY" . "$xkey" \ + ;gnome-terminal +EOF + +sudo su "$user_subu" -c "$script0" -xauth \ No newline at end of file +#set +x -- 2.20.1