20 lines
670 B
Bash
Executable File
20 lines
670 B
Bash
Executable File
#!/bin/sh
|
|
SLBRUSER=$1
|
|
PUBKEY=$2
|
|
test -z "$SLBRUSER" && echo "no user provided" && exit
|
|
|
|
echo "Creating homedir..."
|
|
mkdir "/home/slbr/$SLBRUSER"
|
|
echo "$SLBRUSER" >> users
|
|
echo "lxc exec $SLBRUSER bash" > "/home/slbr/$SLBRUSER/.profile"
|
|
chmod -w "/home/slbr/$SLBRUSER/.profile"
|
|
echo "Creating user..."
|
|
sudo useradd "$SLBRUSER" -d "/home/slbr/$SLBRUSER"
|
|
sudo usermod -a -G lxd "$SLBRUSER"
|
|
sudo chown "$SLBRUSER:$SLBRUSER" "/home/slbr/$SLBRUSER"
|
|
sudo chsh "$SLBRUSER" -s /home/slbr/login.sh
|
|
echo "Creating container..."
|
|
sudo su "$SLBRUSER" -s /bin/sh -c "/home/slbr/lxcinit.sh"
|
|
mkdir "/home/slbr/$SLBRUSER/.ssh"
|
|
echo "$PUBKEY" >> "/home/slbr/$SLBRUSER/.ssh/authorized_keys"
|