From 95425ae76cdab676f9e37f274fbe9a48e88f4566 Mon Sep 17 00:00:00 2001 From: Thomas Walker Lynch Date: Fri, 21 Jul 2023 20:07:33 +0000 Subject: [PATCH] iseq nomenclature --- user/cantari/subu | 60 ---------------- user/document/todo.txt | 9 +++ user/{cantari => iseq_loadable}/fix_mode | 0 user/iseq_loadable/subu | 68 +++++++++++++++++++ user/{cantari => iseq_loadable}/subu_add | 9 ++- user/{cantari => iseq_loadable}/subu_del | 0 .../subu_initialize | 0 user/library/bashrc | 43 ++++++++++++ 8 files changed, 127 insertions(+), 62 deletions(-) delete mode 100755 user/cantari/subu rename user/{cantari => iseq_loadable}/fix_mode (100%) create mode 100755 user/iseq_loadable/subu rename user/{cantari => iseq_loadable}/subu_add (90%) rename user/{cantari => iseq_loadable}/subu_del (100%) rename user/{cantari => iseq_loadable}/subu_initialize (100%) create mode 100644 user/library/bashrc diff --git a/user/cantari/subu b/user/cantari/subu deleted file mode 100755 index f601bb6..0000000 --- a/user/cantari/subu +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# - -# to make audio work will need to do this: -# > sudo dnf install pulseaudio-utils -# > pactl load-module module-native-protocol-tcp -# To load a specific module to the PA server, you add it to /etc/pulse/default.pa: -# I created the file because it was not there... - -#set -x - -subu=$1 -stem=$2 - - -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 "$machine" | head -1 | awk '{print $3}') - -if [ -z "$xkey" ]; then - echo "xauth key not found" - exit 1 -fi - -# stem includes all characters up to the first '-' -if [ -z "$stem" ]; then - stem=$(/usr/local/bin/user-stem) -fi - -subu_username="$stem-$subu" -subu_user_directory=/home/"$stem"/"$subu"/user -bashrc="$subu_user_directory/.bashrc" -xauthority="$subu_user_directory/.Xauthority" - -read -r -d '' script0 <<-EOF - cd "$subu_user_directory" \ - ;export DISPLAY=$DISPLAY \ - ;export NO_AT_BRIDGE=1 \ - ;export PULSE_SERVER=localhost \ - ;touch "$xauthority" \ - ;xauth add "$DISPLAY" . "$xkey" \ - ;gnome-terminal --title="$subu" -EOF - - -sudo su -l "$subu_username" -c "$script0" - -#just hangs -#sudo -u "$subu_username" sh -c "$script0" - -#set +x diff --git a/user/document/todo.txt b/user/document/todo.txt index 96099e2..7ccdf1e 100644 --- a/user/document/todo.txt +++ b/user/document/todo.txt @@ -13,5 +13,14 @@ not adjust their permissions. Hence, if the admin owns a file, though it is group of the subu, the subu can not change permissions (can not make them more permissive, or not change them at all?). +2022-10-05T12:24:06Z +Combine the repo and subu commands into one. activate becomes bashrc? add an archive script +for each subu, and a push script for each repo. +repo is similar to subu, but it does not login. Thus the environment of the caller is +still available. subu handles environment sharing through a shared bashrc file. This would +also work for repo. + +perhaps leave repo as a script, then source the script as part of the bashrc of a subu. I.e. +each repo would be a subu, only different due to running the repo script. diff --git a/user/cantari/fix_mode b/user/iseq_loadable/fix_mode similarity index 100% rename from user/cantari/fix_mode rename to user/iseq_loadable/fix_mode diff --git a/user/iseq_loadable/subu b/user/iseq_loadable/subu new file mode 100755 index 0000000..efabbe6 --- /dev/null +++ b/user/iseq_loadable/subu @@ -0,0 +1,68 @@ +#!/bin/bash +# + +# did not have to do this for F37, seems the pactl was already there +# to make audio work will need to do this: +# > sudo dnf install pulseaudio-utils +# > pactl load-module module-native-protocol-tcp +# To load a specific module to the PA server, you add it to /etc/pulse/default.pa: +# I created the file because it was not there... + +#set -x + +subu="$1" +shell="${@:2}" + +export HOME=$(/usr/local/bin/home) +export PATH=/usr/bin + +error=false +user=$(/usr/local/bin/user) +if [ ! $? ]; then + echo "/usr/local/bin/user failed" + error=true +fi +if [ -z "$subu" ]; then + echo "no subuser name supplied" + error=true +fi + +machine="$(hostname)" +xkey=$(xauth list | grep "$machine" | head -1 | awk '{print $3}') +if [ -z "$xkey" ]; then + echo "xauth key not found" + error=true +fi +if $error; then + exit 1 +fi + +if [ -z "$shell" ]; then + shell="gnome-terminal --title="$subu"" +fi +if [ "$shell" == "emacs" ]; then + shell="emacs --title $subu" +fi + +# SUBU_SHARE_DIR has files optionally shared among subu, e.g. bashrc +read -r -d '' script0 <<-EOF + export NO_AT_BRIDGE=1 \ + ;touch .Xauthority \ + ;xauth add "$DISPLAY" . "$xkey" \ + ;$shell +EOF + +subu_username="$user-$subu" +sudo -E su \ + -l \ + -w SUBU_SHARE_DIR,DISPLAY,PULSE_SERVER \ + -c "$script0" \ + "$subu_username" + + + + +#just hangs +#sudo -u "$subu_username" sh -c "$script0" + +#set +x diff --git a/user/cantari/subu_add b/user/iseq_loadable/subu_add similarity index 90% rename from user/cantari/subu_add rename to user/iseq_loadable/subu_add index 4179307..5148b0a 100755 --- a/user/cantari/subu_add +++ b/user/iseq_loadable/subu_add @@ -7,6 +7,11 @@ #set -x + echo "deprecated due to moving to the /var/user_data/ model" + exit 1 + + + subu=$1 stem=$2 @@ -26,9 +31,9 @@ if [ -z "$stem" ]; then fi subu_username="$stem-$subu" -admin_username="$stem-admin" +admin_username="$stem" -subu_home="/home/$stem" +subu_home="/home" subu_dir="$subu_home/$subu" subu_user="$subu_dir"/user diff --git a/user/cantari/subu_del b/user/iseq_loadable/subu_del similarity index 100% rename from user/cantari/subu_del rename to user/iseq_loadable/subu_del diff --git a/user/cantari/subu_initialize b/user/iseq_loadable/subu_initialize similarity index 100% rename from user/cantari/subu_initialize rename to user/iseq_loadable/subu_initialize diff --git a/user/library/bashrc b/user/library/bashrc new file mode 100644 index 0000000..eb62f44 --- /dev/null +++ b/user/library/bashrc @@ -0,0 +1,43 @@ +# note ssh will fail if .bashrc writes to stdout +# set -x +# in F37 something seems to be caching PATH, which is requiring logging in again or there will be redundant paths + +umask 0007 +export HOME=$(/usr/local/bin/home) + +# it is nearly impossible to get Linux to use ISO8601 +export TZ=UTC +export TIME_STYLE=long-iso +export LC_ALL=en_DK.UTF-8 + +export EDITOR=emacs +export PS_FORMAT=user:15,pid,%cpu,%mem,vsz,rss,tty,stat,start,time,command + +# without -i bash clear PS1, just because, so we set PPS1, etc. +# use $(pwd) instead of \w or it will prefix ~ which confuses dirtrack when the user is changed using su +export PPS1='\n$(/usr/local/bin/Z)[$PROJECT]\n\u@\h§$(pwd)§\n> ' +export PPS2='>> ' +export PS1="$PPS1" +export PS2="$PPS2" + +# No sound in subu shells without this +# as of F37, group audio and video work for speakers and camera, but this is still needed for the mic +# often fails with unknown code, yet is needed for the mic to work ... +pactl load-module module-native-protocol-tcp >& /dev/null + +# suppresses the no at bridge error .. no one seems to know why ... +# now built into the subu command +# export NO_AT_BRIDGE=1 + +for p in "$SUBU_HOME" "$RESOURCE_HOME" "$HOME";do + if [ -d "$p/user/cantari" ]; then + PATH="$p/user/cantari:$PATH" + fi +done + +alias emacs="emacs --title='$(/usr/local/bin/user-subu $(/usr/local/bin/user))'" +alias pstree='pstree -lp' +alias printenv='printenv | sort' +alias cd='HOME=$HOME/user cd' +alias ls='ls -a' + -- 2.20.1