Skip to content

Instantly share code, notes, and snippets.

@arthurwolf
Created April 13, 2023 20:00
Show Gist options
  • Save arthurwolf/b262f284104188443bbb2a6a10947343 to your computer and use it in GitHub Desktop.
Save arthurwolf/b262f284104188443bbb2a6a10947343 to your computer and use it in GitHub Desktop.
Screen session setup for Wire test deploy
#!/bin/bash
# Usage:
# chmod +x screen.sh
# ./screen.sh
# Allow password-less sudo
# This is necessary for the virsh commands to work without password input for the sudo, or they break.
sudo sed -i 's/\(^%sudo\s\+ALL=(ALL[:]\?ALL)\s\+\)/\1NOPASSWD: /' /etc/sudoers
# Create a new screen session with a specific name
screen -dmS wire-deploy bash
# Wait for the session to start up
sleep 1
# Create tabs/screens in the session and set their titles
screen -S wire-deploy -X screen -t "Admin host" 0
screen -S wire-deploy -X screen -t "[VM]: Asset host" 1
screen -S wire-deploy -X screen -t "[VM]: Kubenode1" 2
screen -S wire-deploy -X screen -t "[VM]: Kubenode2" 3
screen -S wire-deploy -X screen -t "[VM]: Kubenode3" 4
screen -S wire-deploy -X screen -t "[VM]: Ansnode1" 5
screen -S wire-deploy -X screen -t "[VM]: Ansnode2" 6
screen -S wire-deploy -X screen -t "[VM]: Ansnode3" 7
# Wait for the tabs to start up
sleep 1
# Set the startup commands for each tab/screen
screen -S wire-deploy -p 1 -X stuff "cd ~/^M"
screen -S wire-deploy -p 2 -X stuff "sudo -S virsh console assethost^M"
screen -S wire-deploy -p 3 -X stuff "sudo -S virsh console kubenode1^M"
screen -S wire-deploy -p 4 -X stuff "sudo -S virsh console kubenode2^M"
screen -S wire-deploy -p 5 -X stuff "sudo -S virsh console kubenode3^M"
screen -S wire-deploy -p 6 -X stuff "sudo -S virsh console ansnode1^M"
screen -S wire-deploy -p 7 -X stuff "sudo -S virsh console ansnode2^M"
screen -S wire-deploy -p 8 -X stuff "sudo -S virsh console ansnode3^M"
# Set other configuration options, some fancy screen stuff.
screen -S wire-deploy -X defscrollback 20000
screen -S wire-deploy -X startup_message off
screen -S wire-deploy -X hardstatus on
screen -S wire-deploy -X hardstatus alwayslastline
screen -S wire-deploy -X hardstatus string "%{.kW}%-w%{.bW}%t [%n]%{-}%+w %=%{..G} %H %{..Y} %Y/%m/%d %c"
# Disable password-less sudo:
sudo sed -i 's/NOPASSWD:\s*//g' /etc/sudoers
# Join the session.
screen -r wire-deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment