--- /dev/null
+#!/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
# to do in a shell script. Perhaps in the python code for the actual release.
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)"
fi
# stem includes all characters up to the first '-'
-stem=$(/usr/local/bin/user-stem)
+if [ -z "$stem" ]; then
+ stem=$(/usr/local/bin/user-stem)
+fi
-user_subu="$stem-$subu"
-user_admin="$stem-admin"
+subu_username="$stem-$subu"
+admin_username="$stem-admin"
-subu_root="/home/$stem/$subu"_root
-subu_home="$subu_root"/"$subu"
+subu_home="/home/$stem/$subu"
+subu_user="$subu_home"/user
-admin_home="/home/$stem/admin"
+admin_root="/home/$stem/admin"
+subu_initial_files="$admin_root"/user/library/subu_initial_files
-sudo useradd --home-dir "$subu_root" "$user_subu"
-sudo usermod -aG "$user_subu" "$user_admin"
-sudo find "$admin_home/subu_root" -mindepth 1 -execdir cp -p {} "$subu_root" \;
-sudo find "$subu_root" -execdir chown "$user_subu":"$user_subu" {} \;
+sudo useradd --home-dir "$subu" "$subu_username"
+sudo usermod -aG "$subu_username" "$admin_username"
-if [[ ! -d "$subu_home" ]]; then
- sudo mkdir "$subu_home"
- chown "$user_subu":"$user_subu" "$subu_home"
+if [[ ! -d "$subu_user" ]]; then
+ sudo mkdir "$subu_user"
+ chown "$subu_username":"$subu_username" "$subu_user"
fi
+subu_initialize subu stem
+
#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)"
fi
# stem includes all characters up to the first '-'
-stem=$(/usr/local/bin/user-stem)
-subu_user="$stem-$subu"
-admin_user="$stem-admin"
-subu_root="/home/$stem/$subu"_root
+if [ -z "$stem" ]; then
+ stem=$(/usr/local/bin/user-stem)
+fi
+
+subu_username="$stem-$subu"
+admin_username="$stem-admin"
+subu_home="/home/$stem/$subu"_root
archive_suffix=";1"
-archive_root="$subu_root$archive_suffix"
+archive_home="$subu_home$archive_suffix"
mail_source_dir="/var/spool/mail"
-mail_source_file="$mail_source_dir/$subu_user"
-mail_target_file="$subu_root/mail_spool"
+mail_source_file="$mail_source_dir/$subu_username"
+mail_target_file="$subu_home/mail_spool"
-if [ -e "$archive_root" ]; then
- echo "there is already a saved directory for a deleted subu with this name, move this out of the way first: $archive_root"
+if [ -e "$archive_home" ]; then
+ echo "there is already a saved directory for a deleted subu with this name, move this out of the way first: $archive_home"
exit 1
fi
if [ ! -d "$mail_source_dir" ]; then
fi
if [ -e "$mail_target_file" ]; then
- echo "there is already file system object where we planned to move the deleted user's mail spool, which is here: $subu_root/mail_spool"
+ echo "there is already file system object where we planned to move the deleted user's mail spool, which is here: $subu_home/mail_spool"
exit 1
fi
-sudo killall --signal 5 --wait --user "$subu_user"
+sudo killall --signal 5 --wait --user "$subu_username"
sudo mv "$mail_source_file" "$mail_target_file"
-sudo chmod -R go-rwx "$subu_root"
-sudo chown -R "$admin_user":"$admin_user" "$subu_root"
-mv "$subu_root" "$archive_root"
-sudo groupdel -f "$subu_user"
-sudo userdel "$subu_user"
+sudo chmod -R go-rwx "$subu_home"
+sudo chown -R "$admin_username":"$admin_username" "$subu_home"
+mv "$subu_home" "$archive_home"
+sudo groupdel -f "$subu_username"
+sudo userdel "$subu_username"
#set +x
+++ /dev/null
-#!/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
-
-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=$(/usr/local/bin/user-stem)
-user_subu="$stem-$subu"
-home_subu=/home/"$stem"/"$subu"_root/"$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 -l "$user_subu" -c "$script0"
-
-#just hangs
-#sudo -u "$user_subu" sh -c "$script0"
-
-#set +x
--- /dev/null
+#!/bin/bash
+# symbolic links made this complicated
+#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
+
+# stem includes all characters up to the first '-'
+if [ -z "$stem" ]; then
+ stem=$(/usr/local/bin/user-stem)
+fi
+
+subu_username="$stem-$subu"
+subu_home="/home/$stem/$subu"
+subu_initial_files="/home/$stem/subu_initial_files"
+
+# install always derefs sym links ... actually it didn't work at all here
+#shopt -s dotglob
+#sudo install -o "$subu_username" -g "$subu_username" -t "$subu_home" "$subu_initial_files"/*
+
+# free a brief moment, files that appear in the initial subu will have their subu_initial
+# ownership instead of being owned by the subu
+#find "$subu_initial_files" -mindepth 1 -exedir copy({}
+# -execdir cp -a {} "$subu_home" \; \
+# -execdir chown -h "$subu_username":"$subu_username" "$subu_home"/{} \;
+# cp --remove-destination -RP "$1" "$2"
+
+function copy {
+ s0="$1"
+ filename="${s0:2}"
+ destination_directory="$2"
+ username="$3"
+
+ source_directory=$(pwd)
+ source_path="$source_directory"/"$filename"
+ destination_path="$destination_directory"/"$filename"
+ echo "ln -fs" "$source_path" "$destination_path"
+ #ln -f did work when the existing object was a file rather than anotehr link so ..
+ rm -f "$destination_path"
+ ln -s "$source_path" "$destination_path"
+ chown -h "$username":"$username" "$destination_path"
+}
+export -f copy
+
+find "$subu_initial_files" -mindepth 1 -execdir \
+ bash -c 'copy "$1" "$2" "$3"' _ {} "$subu_home" "$subu_username" \;
+
+
+#set +x