Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Commit

Permalink
afinger & user update
Browse files Browse the repository at this point in the history
  • Loading branch information
gylfirst committed Jan 4, 2023
1 parent 4fe0600 commit d8d4310
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
22 changes: 19 additions & 3 deletions commands/afinger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,25 @@ do
name=$(echo $ligne | cut -d' ' -f1 )
if [ "$name" = "$user_name" ]; then
echo -e "The information of $user_name is:\n$(echo $ligne | cut -d':' -f2)"
nb_ligne=$nb_tot_ligne
else
echo "The user $name is not registered."
compt=1
fi
done < $file
#TODO @Gylfirst - @zalk0 Il faut maintenant ajouter/réécrire les infos avec un read et à la bonne position

if [[ $compt -eq 1 ]]; then
read -p "Do you want to add or edit informations? " choise
case $choise in
"add" )
read -p "What do you want to add: " text
info=$(grep "^$user_name info:" $file)
sed -i "s/$info/$info,$text/" $file;;
"edit" )
read -p "What do you want to edit: " text
read -p "Remplace by: " replace
sed -ri "s/^($user_name info:.*)$text/\1$replace/" $file;;
* )
echo "Wrong argument"
esac
else
echo "$user_name is not registered"
fi
2 changes: 2 additions & 0 deletions commands/user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ case $? in
case ${choice,,} in
"yes" )
sed -i "/^$user_name\b/d" $file
sed -i "/^$user_name\b/d" "./finger"
echo "User $user_name deleted"
break;;
"no" )
Expand Down Expand Up @@ -90,6 +91,7 @@ case $? in
3 )
if [[ ${option,,} == "add" ]]; then
echo "$user_name::" >> $file
echo "$user_name info: " >> "./finger"
while [[ true ]]; do
read -p "Do you want to add a machine or set a password to $user_name? " choice
case ${choice,,} in
Expand Down
10 changes: 5 additions & 5 deletions finger
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
user1 info: Matthieu T alias Gylfirst
user2 info: Alexis
user3 info: test
user info: ceci est un test
loan info: Loan est sympa
user1 info:Matthieu T alias Gylfirst
user2 info:Alexis
user3 info:test
user info:ceci est un test
loan info:Loan est sympa
2 changes: 1 addition & 1 deletion users
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
root:fc8252c8dc55839967c58b9ad755a59b61b67c13227ddae4bd3f78a38bf394f7:hostroot #pass is admin
user1:6d9010b2b7a1483b256ae7477738dba7c530bd9ba53db1d6691441e74b83608a:machine1,machine6 #pass is user
user3::machine42,machine6
user6::machine1,machine32
user2:lapd:machine4
loan:f40cd21f276e47d533371afce1778447e858eb5c9c0c0ed61c65f5c5d57caf63:machine4,machine1 #pass is wow
root:fc8252c8dc55839967c58b9ad755a59b61b67c13227ddae4bd3f78a38bf394f7:hostroot #pass is admin
user18:fc4b5fd6816f75a7c81fc8eaa9499d6a299bd803397166e8c4cf9280b801d62c:

0 comments on commit d8d4310

Please sign in to comment.