tl-setup/basics.sh

38 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
ssh_command="ssh -i $key_file $tilde_username@$tilde_name"
check_key_file() {
if [ -f "$key_file" ]
then
while [ -z "$(cat $key_file | head -n1 | grep -- '-----BEGIN .* PRIVATE KEY-----')" ]
do
echo "$key_file does not look like a private key file, try again"
bash
done
fi
}
connection_test() {
while ! $ssh_command "true"
do
echo "There seems to be a problem connecting to the tilde"
echo "Use this shell to try and fix any problems, then try connecting again by exiting the shell"
bash
done
}
configure_user() {
mkdir "/home/$tilde_username"
useradd "$tilde_username" -d "/home/$tilde_username"
chown "$tilde_username:$tilde_username" "/home/$tilde_username"
sshfs "$tilde_username@$tilde_name:/home/$tilde_username /home/$tilde_username"
touch /usr/bin/sshshell
echo "#!/bin/sh" >> /usr/bin/sshshell
echo "ssh -i $key_file $tilde_username@$tilde_name" >> /usr/bin/sshshell
chmod +x /usr/bin/sshshell
echo "/usr/bin/sshshell" >> /etc/shells
chsh -s "/usr/bin/sshshell $tilde_username"
}