Guest User

Untitled

a guest
Feb 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Script input arguments
  4. user=$1
  5. server=$2
  6.  
  7. # Tell the shell to quote your variables to be eval-safe!
  8.  
  9. printf -v user_q '%q' "$user"
  10. printf -v server_q '%q' "$server"
  11. #
  12.  
  13. SECONDS=0
  14. address="$user_q"@"$server_q"
  15.  
  16. function run {
  17. ssh "$address" /bin/bash "$@"
  18. }
  19.  
  20. run << SSHCONNECTION
  21. # Enable autostartup
  22.  
  23. # systemd is required for the autostartup
  24. sudo dpkg-query -W -f='${Status}' systemd 2>/dev/null | grep -c "ok installed" > /home/$user_q/systemd-check.txt
  25. systemdInstalled=$(cat /home/$user_q/systemd-check.txt)
  26.  
  27. if [[ $systemdInstalled -eq 0 ]]; then
  28. echo "Systemd is not currently installed. Installing..."
  29.  
  30. # install systemd
  31. sudo apt-get update
  32. sudo apt-get -y install systemd
  33.  
  34. else
  35. echo "systemd is already installed. Skipping this step."
  36. fi
  37.  
  38. SSHCONNECTION
  39.  
  40. sudo rm /run/nologin
Add Comment
Please, Sign In to add comment