adds ch_subu subu_add subu_del
authorThomas Walker Lynch <thomas.walker.lynch@gmail.com>
Tue, 8 Mar 2022 15:01:21 +0000 (10:01 -0500)
committerThomas Walker Lynch <thomas.walker.lynch@gmail.com>
Tue, 8 Mar 2022 15:01:21 +0000 (10:01 -0500)
executable/ch_subu [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index c7298fa..0252a3f
@@ -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