-
Notifications
You must be signed in to change notification settings - Fork 35
/
cobadduser
executable file
·41 lines (32 loc) · 1.15 KB
/
cobadduser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
if [ "$USER" != "robot" ]; then
echo 'FATAL: CAN ONLY BE EXECUTED AS "robot" USER'
exit
fi
if [ "$HOSTNAME" != "$ROBOT-pc2" ]; then
echo "FATAL: CAN ONLY BE EXECUTED ON PC2"
exit
fi
echo "Executing adduser"
sudo /usr/sbin/adduser $1 --home /u/$1
echo "Syncing passwd file to other cob-pcs"
sudo rsync -e ssh -avz /etc/passwd /etc/shadow /etc/group root@$ROBOT-pc1:/etc/
sudo rsync -e ssh -avz /etc/passwd /etc/shadow /etc/group root@$ROBOT-pc3:/etc/
if [ "$1" != "" ]; then
echo "setup bash environment"
sudo cp /u/robot/git/setup/cob-pcs/user.bashrc /u/$1/.bashrc
sudo sed -i "s/myrobot/$ROBOT/g" /u/$1/.bashrc
sudo sed -i "s/mydistro/$ROS_DISTRO/g" /u/$1/.bashrc
if [ ! -d /u/$1/.ssh ]; then
echo "create new ssh key"
sudo -u $1 ssh-keygen -f /u/$1/.ssh/id_rsa
fi
echo "copying ssh-keys to other pcs, please enter password of new user"
sudo -u $1 ssh-copy-id -i /u/$1/.ssh/id_rsa $1@$ROBOT-pc1
sudo -u $1 ssh $1@$ROBOT-pc1 -e "logout"
sudo -u $1 ssh $1@$ROBOT-pc2 -e "logout"
sudo -u $1 ssh $1@$ROBOT-pc3 -e "logout"
sudo su -c "rosdep update" $1
sudo su -c "mkdir -p ~/git/care-o-bot" $1
fi
echo "done adding user"