Put this in the file /etc/systemd/system/[email protected]
[Unit]
Description=irssiscreen
After=network.target
[Service]
Type=forking
User=%i
ExecStart=/usr/bin/screen -dmS ircsess irssi
ExecStop=/usr/bin/screen -S ircsess -X quit
[Install]
WantedBy=multi-user.target
Enable the service with:
sudo systemctl enable [email protected]
To reattach, simply run:
screen -rd
If you replace
ExecStop=/usr/bin/screen -S ircsess -X quit
with
ExecStop=/usr/bin/screen -S ircsess -X stuff '/quit\n'
irssi will receive and process the /quit command, meaning the client will cleanly disconnect from connected services. I find this to be a nicer way of shutting down.