From b0bbb9cfc3858b1538a44b3e7afdb351c529cb81 Mon Sep 17 00:00:00 2001 From: Victor Mocelin <vm13@inf.ufpr.br> Date: Tue, 5 Jul 2016 09:16:32 -0300 Subject: [PATCH] Updated local-accounts to new folder organization There is one config for each user now. Get all configs with a find and join it in one variable, after that it's all the same as before. --- .../opt/openslx/scripts/local-accounts_insert-data.sh | 7 ++++--- .../opt/openslx/scripts/local-accounts_mount-home.sh | 6 ++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/server/modules/local-accounts/opt/openslx/scripts/local-accounts_insert-data.sh b/server/modules/local-accounts/opt/openslx/scripts/local-accounts_insert-data.sh index d7d3973b..90d4f3b1 100755 --- a/server/modules/local-accounts/opt/openslx/scripts/local-accounts_insert-data.sh +++ b/server/modules/local-accounts/opt/openslx/scripts/local-accounts_insert-data.sh @@ -41,7 +41,7 @@ prepare_usb () { fi # checks if usb has an openslx config - if [ -e "$mountpath/Openslx/.config" ]; then + if [ -n "$(find $mountpath/Openslx/ -maxdepth 2 -iname .config)" ]; then echo "$0: /dev/$dev is an openslx ready drive" else echo "$0: /dev/$dev is not ready to be used as an openslx drive" @@ -67,7 +67,8 @@ fi touch "/home/openslx/usb_slx/$dev" unset IFS -users=$(cat "$mountpath/Openslx/.config"); +users=$(for i in $(find "$mountpath/Openslx" -iname .config); do cat $i; done) +#users=$(cat "$mountpath/Openslx/.config"); if [ -z "$users" ]; then echo "$0: $dev has an empty config file" exit 3 # stops openslx users_pendrive execution for this dev @@ -109,7 +110,7 @@ while (( [ $# -gt 0 ] )); do if [ -n "$localID" ] && [ -n "$localGID" ]; then /opt/openslx/scripts/adduser.sh "$passwdf" "$groupf" "$shadowf" #Add to a file what pendrive this user is from - mount --bind $mountpath/Openslx/$username /home/$username + mount --bind $mountpath/Openslx/$username/home /home/$username echo "/dev/$dev" > "/home/openslx/usb_users/$username" #if ext4, change owner to new user and create ecrypted diff --git a/server/modules/local-accounts/opt/openslx/scripts/local-accounts_mount-home.sh b/server/modules/local-accounts/opt/openslx/scripts/local-accounts_mount-home.sh index 6db32a16..4654f747 100755 --- a/server/modules/local-accounts/opt/openslx/scripts/local-accounts_mount-home.sh +++ b/server/modules/local-accounts/opt/openslx/scripts/local-accounts_mount-home.sh @@ -31,7 +31,7 @@ if ( [ "$user_drive_type" = "vfat" ] ); then else #this is a user #save user_names that are mounted to make binding easier after - user_name=$(echo $i | cut -d' ' -f4 | rev | cut -d'/' -f1 | rev ) + user_name=$(echo $i | cut -d' ' -f4 | rev | cut -d'/' -f2 | rev ) users=$(echo "$users $user_name") #check if there is something mounted in this user home( $user_name ) #if so, umount it @@ -49,7 +49,7 @@ if ( [ "$user_drive_type" = "vfat" ] ); then #rebind stuff for i in $users; do - mount --bind ${drive_mount_point}/Openslx/$i /home/$i + mount --bind ${drive_mount_point}/Openslx/$i/home /home/$i done #significatlçy improves speed and leaves the user pendrive without useless files @@ -60,5 +60,3 @@ if ( [ "$user_drive_type" = "ext4" ] ); then echo $0": user drive type is ext4" #do encryption fi - - -- GitLab