Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Script input arguments
- user=$1
- server=$2
- # Tell the shell to quote your variables to be eval-safe!
- printf -v user_q '%q' "$user"
- printf -v server_q '%q' "$server"
- #
- SECONDS=0
- address="$user_q"@"$server_q"
- function run {
- ssh "$address" /bin/bash "$@"
- }
- run << SSHCONNECTION
- # Enable autostartup
- # systemd is required for the autostartup
- sudo dpkg-query -W -f='${Status}' systemd 2>/dev/null | grep -c "ok installed" > /home/$user_q/systemd-check.txt
- systemdInstalled=$(cat /home/$user_q/systemd-check.txt)
- if [[ $systemdInstalled -eq 0 ]]; then
- echo "Systemd is not currently installed. Installing..."
- # install systemd
- sudo apt-get update
- sudo apt-get -y install systemd
- else
- echo "systemd is already installed. Skipping this step."
- fi
- SSHCONNECTION
- sudo rm /run/nologin
Add Comment
Please, Sign In to add comment