tl-setup/basics.sh

46 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
ssh_command=""
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
ssh_command="ssh -i $key_file $tilde_username@$tilde_name"
fi
}
connection_test() {
while ! $ssh_command 'exit'
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"
echo "Mounting sshfs filesystem..."
sshfs "$tilde_username@$tilde_name":"/home/$tilde_username" "/home/$tilde_username" -o ssh_command="ssh -i $key_file"
# 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"
}
configure_network() {
echo "Press ENTER to configure network"
read dummy_var
nmtui
}