ssh-setup.sh
· 969 B · Bash
Raw
#!/bin/bash -x
# curl s.aly.pet/ssh-setup | GIT_HOSTNAME=dotfiles.example.com GIT_USERNAME=you GIT_PASSWORD=password bash -x
if [ -z $GIT_HOSTNAME ]; then
echo -n "Git hostname: "
read -s GIT_HOSTNAME
fi
if [ -z $GIT_USERNAME ]; then
echo -n "Git username: "
read -s GIT_USERNAME
fi
if [ -z $GIT_PASSWORD ]; then
echo -n "Git password: "
read -s GIT_PASSWORD
fi
git --version || sudo apt install -y git || pkg install -y git || sudo pacman -Sy git || apk add git
git clone https://$GIT_USERNAME:$GIT_PASSWORD@$GIT_HOSTNAME/.ssh.git $TMPDIR/ssh_git
if [ -d $HOME/.ssh ]; then
find $HOME/.ssh -type f -not -name authorized_keys -not -name config -not -name .gitignore -not -path "$HOME/.ssh/.git*" -exec mv -t $TMPDIR/ssh_git/ {} + && rm -rf $HOME/.ssh
fi
chown -R $UID $TMPDIR/ssh_git
find $TMPDIR/ssh_git -type f -exec chmod 600 {} +
find $TMPDIR/ssh_git -type d -exec chmod 700 {} +
mv $TMPDIR/ssh_git $HOME/.ssh
| 1 | #!/bin/bash -x |
| 2 | # curl s.aly.pet/ssh-setup | GIT_HOSTNAME=dotfiles.example.com GIT_USERNAME=you GIT_PASSWORD=password bash -x |
| 3 | if [ -z $GIT_HOSTNAME ]; then |
| 4 | echo -n "Git hostname: " |
| 5 | read -s GIT_HOSTNAME |
| 6 | fi |
| 7 | if [ -z $GIT_USERNAME ]; then |
| 8 | echo -n "Git username: " |
| 9 | read -s GIT_USERNAME |
| 10 | fi |
| 11 | if [ -z $GIT_PASSWORD ]; then |
| 12 | echo -n "Git password: " |
| 13 | read -s GIT_PASSWORD |
| 14 | fi |
| 15 | git --version || sudo apt install -y git || pkg install -y git || sudo pacman -Sy git || apk add git |
| 16 | git clone https://$GIT_USERNAME:$GIT_PASSWORD@$GIT_HOSTNAME/.ssh.git $TMPDIR/ssh_git |
| 17 | if [ -d $HOME/.ssh ]; then |
| 18 | find $HOME/.ssh -type f -not -name authorized_keys -not -name config -not -name .gitignore -not -path "$HOME/.ssh/.git*" -exec mv -t $TMPDIR/ssh_git/ {} + && rm -rf $HOME/.ssh |
| 19 | fi |
| 20 | chown -R $UID $TMPDIR/ssh_git |
| 21 | find $TMPDIR/ssh_git -type f -exec chmod 600 {} + |
| 22 | find $TMPDIR/ssh_git -type d -exec chmod 700 {} + |
| 23 | mv $TMPDIR/ssh_git $HOME/.ssh |