fix home directory creation bug
This commit is contained in:
parent
adc9b9d57a
commit
f0c4df0f90
|
@ -2,17 +2,23 @@
|
||||||
|
|
||||||
_home_dir="/home/$user"
|
_home_dir="/home/$user"
|
||||||
|
|
||||||
echo "Configuring ssh keys .."
|
ssh -T $ssh << EOSSH
|
||||||
|
echo "Creating user .."
|
||||||
|
useradd -m -d "$_home_dir" "$user"
|
||||||
|
echo "$user:$user_pass" | chpasswd
|
||||||
|
usermod -aG sudo "$user"
|
||||||
|
EOSSH
|
||||||
|
|
||||||
ssh $ssh mkdir -p "$_home_dir/.ssh"
|
echo "Configuring ssh .."
|
||||||
|
|
||||||
|
ssh $ssh mkdir -v -p "$_home_dir/.ssh"
|
||||||
scp files/private/id_rsa "$ssh:$_home_dir/.ssh/"
|
scp files/private/id_rsa "$ssh:$_home_dir/.ssh/"
|
||||||
scp files/id_rsa.pub "$ssh:$_home_dir/.ssh/"
|
scp files/id_rsa.pub "$ssh:$_home_dir/.ssh/"
|
||||||
scp files/known_hosts "$ssh:$_home_dir/.ssh/"
|
scp files/known_hosts "$ssh:$_home_dir/.ssh/"
|
||||||
|
|
||||||
ssh -T $ssh << EOSSH
|
ssh -T $ssh << EOSSH
|
||||||
cp /root/.ssh/authorized_keys "$_home_dir/.ssh/authorized_keys"
|
cp -v /root/.ssh/authorized_keys "$_home_dir/.ssh/authorized_keys"
|
||||||
chown -R "$user:$group" "$_home_dir/.ssh"
|
chown -v -R "$user:$group" "$_home_dir/.ssh"
|
||||||
# add git.rayelliott.dev to known hosts
|
|
||||||
|
|
||||||
echo "Adding user: $user"
|
echo "Adding user: $user"
|
||||||
|
|
||||||
|
@ -28,31 +34,26 @@ ssh -T $ssh << EOSSH
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
apt-get --assume-yes install sudo git tmux zsh curl
|
apt-get --assume-yes install sudo git tmux zsh curl
|
||||||
|
|
||||||
echo "Creating user .."
|
|
||||||
useradd -m -d "$_home_dir" "$user"
|
|
||||||
echo "$user:$user_pass" | chpasswd
|
|
||||||
usermod -aG sudo "$user"
|
|
||||||
|
|
||||||
echo "Cloning configuration files .."
|
echo "Cloning configuration files .."
|
||||||
su --login "$user"
|
su --login "$user"
|
||||||
git config --global user.name rayelliott
|
git config --global user.name rayelliott
|
||||||
git config --global user.email dev@rayelliott.dev
|
git config --global user.email dev@rayelliott.dev
|
||||||
mkdir -p "$_home_dir/.config"
|
mkdir -v -p "$_home_dir/.config"
|
||||||
|
|
||||||
if [ -e "$_home_dir/.config/profile" ] ; then
|
if [ -e "$_home_dir/.config/profile" ] ; then
|
||||||
mv "$_home_dir/.config/profile" "$_home_dir/.config/profile-original-$(date +%s)"
|
mv -v "$_home_dir/.config/profile" "$_home_dir/.config/profile-original-$(date +%s)"
|
||||||
fi
|
fi
|
||||||
git clone ssh://git@git.rayelliott.dev:3222/dots/profile.git "$_home_dir/.config/profile"
|
git clone ssh://git@git.rayelliott.dev:3222/dots/profile.git "$_home_dir/.config/profile"
|
||||||
"$_home_dir/.config/profile/install.sh"
|
"$_home_dir/.config/profile/install.sh"
|
||||||
|
|
||||||
if [ -e "$_home_dir/.config/tmux" ] ; then
|
if [ -e "$_home_dir/.config/tmux" ] ; then
|
||||||
mv "$_home_dir/.config/tmux" "$_home_dir/.config/tmux-original-$(date +%s)"
|
mv -v "$_home_dir/.config/tmux" "$_home_dir/.config/tmux-original-$(date +%s)"
|
||||||
fi
|
fi
|
||||||
git clone ssh://git@git.rayelliott.dev:3222/dots/tmux.git "$_home_dir/.config/tmux"
|
git clone ssh://git@git.rayelliott.dev:3222/dots/tmux.git "$_home_dir/.config/tmux"
|
||||||
"$_home_dir/.config/tmux/install.sh"
|
"$_home_dir/.config/tmux/install.sh"
|
||||||
|
|
||||||
if [ -e "$_home_dir/.config/zsh" ] ; then
|
if [ -e "$_home_dir/.config/zsh" ] ; then
|
||||||
mv "$_home_dir/.config/zsh" "$_home_dir/.config/zsh-original-$(date +%s)"
|
mv -v "$_home_dir/.config/zsh" "$_home_dir/.config/zsh-original-$(date +%s)"
|
||||||
fi
|
fi
|
||||||
git clone ssh://git@git.rayelliott.dev:3222/dots/zsh.git "$_home_dir/.config/zsh"
|
git clone ssh://git@git.rayelliott.dev:3222/dots/zsh.git "$_home_dir/.config/zsh"
|
||||||
"$_home_dir/.config/zsh/install.sh"
|
"$_home_dir/.config/zsh/install.sh"
|
||||||
|
|
Loading…
Reference in New Issue