Skip to content
Snippets Groups Projects
Commit a0633dd8 authored by Thiago Abdo's avatar Thiago Abdo
Browse files

Update sketch_hd_user


Signed-off-by: default avatarThiago Abdo <tja14@inf.ufpr.br>
parent 5ba9d6e8
Branches
No related tags found
No related merge requests found
#!/bin/bash
#!/bin/ash
#Check if the user running this code has permissoes to run it
if [ "$(/usr/bin/id -r -u)" != "0" ]; then
......@@ -8,26 +8,95 @@ if [ "$(/usr/bin/id -r -u)" != "0" ]; then
#echo $0": Você tem permissoes para executar esse programa"
fi
if [ -z "$1" ];then
. /opt/openslx/config || { echo "Could not source config!"; exit 23; }
else
. "$1" || { echo "Could not source custom config!"; exit 23; }
fi
unset IFS
set $SLX_USERS
while (($#)); do
#Get infos from file
passwdf=$(echo $1 | cut -d'=' -f2)
shift
shadowf=$(echo $1 | cut -d'=' -f2)
shift
groupf=$(echo $1 | cut -d'=' -f2)
shift
username=$( echo $passwdf | cut -d':' -f1 )
uID=$( echo $passwdf | cut -d':' -f3 )
globalID=$( echo $uID | grep -e "^3....$" )
groupname=$( echo $groupf | cut -d':' -f1 )
gID=$( echo $groupf | cut -d':' -f3 )
globalGID=$( echo $gID | grep -e "^3....$" )
#group == username
if [ "$username" = "$groupname" ]; then
#id no range certo(local user)
if [ -n "$globalID" ] && [ -n "$globalGID" ]; then
#add to files;
./adduser.sh "$passwdf" "$groupf" "$shadowf" "global"
fi
fi
done
#add groups to global users
#for line in SLX_GROUPS; do
# IFS=,
# set $line
# username=$1
# shift
# while (($#)); do
# addusertogroup "$username" "$1"
# temp=$(mktemp)
# firstuser=$( echo /etc/group | grep -e '^$1:.*:.*:$' )
# if [ -n "$firstuser" ]; then
# sed -e 's/^$1.*/&$username/' /etc/group > $temp
# else
# sed -e 's/^$1.*/&,$username/' /etc/group > $temp
# fi
# cp $temp /etc/group
# chown root:root /etc/group
# chmod 644 /etc/group
# rm $temp
# shift
# done
# unset IFS
#done
#Instanciates the configuration file
unset IFS
users=$(cat config);
users=$(cat /home/openslx/config);
set $users
while (($#)); do
#Get infos from file
passwd=$(echo $1 | cut -d'=' -f2)
passwdf=$(echo $1 | cut -d'=' -f2)
shift
shadow=$(echo $1 | cut -d'=' -f2)
shadowf=$(echo $1 | cut -d'=' -f2)
shift
group=$(echo $1 | cut -d'=' -f2)
groupf=$(echo $1 | cut -d'=' -f2)
shift
#check for errors
username=$( echo $passwdf | cut -d':' -f1 )
uID=$( echo $passwdf | cut -d':' -f3 )
localID=$( echo $uID | grep -e "^2....$" -e "^1....$" )
groupname=$( echo $groupf | cut -d':' -f1 )
gID=$( echo $groupf | cut -d':' -f3 )
localGID=$( echo $gID | grep -e "^2....$" -e "^1....$" )
#group == username
if [ "$username" = "$groupname" ]; then
#id no range certo(local user)
if [ -n "$localID" ] && [ -n "$localGID" ]; then
#add to files;
#adduser.sh "$passwd" "$shadow" "$group"
./adduser.sh "$passwdf" "$groupf" "$shadowf"
fi
fi
done
#if [ -d /home/openslx ]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment