Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion add_users.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#! /bin/bash

exec > /var/log/adduser_service.log
exec 2>&1


echo "add_user.sh at: $(date)"

#only execute if root
if [ $(id -u) -eq 0 ]; then
cd /xal/internal
Expand All @@ -9,8 +15,10 @@ if [ $(id -u) -eq 0 ]; then
do
dir=${dir%*/}
username=${dir##*/}
echo "add_user.sh: check ${username} for dir ${dir}"
egrep "$username" /etc/passwd >/dev/null
if [ ! $? -eq 0 ]; then
echo "add_user.sh: create user ${username}"
useradd -m -s /bin/bash $username
mkdir /home/$username/.ssh
chown -R $username /home/$username
Expand All @@ -26,8 +34,9 @@ if [ $(id -u) -eq 0 ]; then
# fi
fi
fi
echo "add_user.sh: update ssh for ${username}"
bash /xal/user_services/enable_ssh.sh $username
done
else
echo script must be run as root, exting
echo "script must be run as root, exting"
fi
2 changes: 1 addition & 1 deletion enable_ssh.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#! /bin/bash
cp /xal/internal/pub_keys/$1/* /home/$1/.ssh/authorized_keys
chown $1 /home/$1/.ssh/*
chown $1.$1 /home/$1/.ssh/*