From: Thomas Walker Lynch Date: Wed, 13 Apr 2022 17:43:23 +0000 (+0200) Subject: make a separate _root directory for the system files X-Git-Url: https://git.reasoningtechnology.com/style/static/git-favicon.png?a=commitdiff_plain;h=fa6b69c7b2559328545ec58003d7ace9f36198d7;p=subu make a separate _root directory for the system files --- diff --git a/executable/subu_add b/executable/subu_add index abd732e..5cd4fbe 100755 --- a/executable/subu_add +++ b/executable/subu_add @@ -24,12 +24,17 @@ stem=$(/usr/local/bin/user-stem) user_subu="$stem-$subu" user_admin="$stem-admin" -home_subu="/home/$stem/$subu" -home_admin="/home/$stem/admin" +subu_root="/home/$stem/$subu"_root +subu_home="$subu_root"/"$subu" -sudo useradd --home-dir "$home_subu" "$user_subu" +admin_home="/home/$stem/admin" + +sudo useradd --home-dir "$subu_root" "$user_subu" sudo usermod -aG "$user_subu" "$user_admin" -sudo find "$home_admin/subu_default" -mindepth 1 -execdir cp -p {} "$home_subu" \; -sudo find "$home_subu" -execdir chown "$user_subu":"$user_subu" {} \; +sudo find "$admin_home/subu_default" -mindepth 1 -execdir cp -p {} "$subu_root" \; +sudo find "$subu_root" -execdir chown "$user_subu":"$user_subu" {} \; +if [[ ! -d "$subu_home" ]]; then + mkdir "$subu_home" +fi diff --git a/executable/subu_del b/executable/subu_del index 98fc7c4..a68d190 100755 --- a/executable/subu_del +++ b/executable/subu_del @@ -29,17 +29,17 @@ fi # stem includes all characters up to the first '-' stem=$(/usr/local/bin/user-stem) -user_subu="$stem-$subu" -user_admin="$stem-admin" -home_subu="/home/$stem/$subu" -archive_suffix=_former_subu -archive_subu="$home_subu$archive_suffix" +subu_user="$stem-$subu" +admin_user="$stem-admin" +subu_root="/home/$stem/$subu"_root +archive_suffix=";1" +archive_root="$subu_root$archive_suffix" mail_source_dir="/var/spool/mail" -mail_source_file="$mail_source_dir/$user_subu" -mail_target_file="$home_subu/mail_spool" +mail_source_file="$mail_source_dir/$subu_user" +mail_target_file="$subu_root/mail_spool" -if [ -e "$archive_subu" ]; then - echo "there is already a saved directory for a deleted subu with this name, move this out of the way first: $archive_subu" +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" exit 1 fi if [ ! -d "$mail_source_dir" ]; then @@ -48,16 +48,16 @@ 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: $home_subu/mail_spool" + 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" exit 1 fi -sudo killall --signal 5 --wait --user "$user_subu" +sudo killall --signal 5 --wait --user "$subu_user" sudo mv "$mail_source_file" "$mail_target_file" -sudo chmod -R go-rwx "$home_subu" -sudo chown -R "$user_admin":"$user_admin" "$home_subu" -mv "$home_subu" "$archive_subu" -sudo groupdel -f "$user_subu" -sudo userdel "$user_subu" +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" #set +x diff --git a/executable/subu_env b/executable/subu_env index b54968e..5a0c3e9 100755 --- a/executable/subu_env +++ b/executable/subu_env @@ -31,7 +31,7 @@ fi stem=$(/usr/local/bin/user-stem) user_subu="$stem-$subu" -home_subu="/home/$stem/$subu" +home_subu=/home/"$stem"/"$subu"_root/"$subu" bashrc="$home_subu/.bashrc" xauthority="$home_subu/.Xauthority"