From b6d87f0183e52a93a211ef73b25828a9ae1e272c Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Tue, 29 Sep 2015 02:24:18 +0200
Subject: [PATCH] In server config, fix auto start up of irssi screen.

---
 jessie_start_server.sh | 25 ++++++++++++++++++-------
 other/screen-irssi.sh  |  3 +++
 2 files changed, 21 insertions(+), 7 deletions(-)
 create mode 100644 other/screen-irssi.sh

diff --git a/jessie_start_server.sh b/jessie_start_server.sh
index fe08c0e..bf56165 100755
--- a/jessie_start_server.sh
+++ b/jessie_start_server.sh
@@ -78,21 +78,32 @@ su plom -c 'mkdir -p /home/plom/.vimbackups/'
 # Set up openssh-server.
 apt-get -y install openssh-server
 
+# Set up mail client system.
+apt-get -y install getmail4 procmail mutt
+su plom -c 'mkdir -p /home/plom/mail'
+su plom -c 'mkdir -p /home/plom/mail/inbox/{cur,new,tmp}'
+
 # Set up screen.
 apt-get -y install screen
 
 # Set up irssi.
 apt-get -y install irssi
-su plom -c 'screen -S irssi'
-su plom -c 'screen -S irssi -X stuff "irssi\n"'
-
-# Set up mail client system.
-apt-get -y install getmail4 procmail mutt
-su plom -c 'mkdir -p /home/plom/mail'
-su plom -c 'mkdir -p /home/plom/mail/inbox/{cur,new,tmp}'
 
 # Clean up.
 rm jessie_start_server.sh
+cat > /etc/systemd/system/irssi.service << EOF
+[Unit]
+Description=irssi screen
+
+[Service]
+Type=forking
+User=plom
+ExecStart=/bin/sh /home/plom/config/other/screen-irssi.sh
+
+[Install]
+WantedBy=multi-user.target
+EOF
+systemctl enable /etc/systemd/system/irssi.service
 
 # Set password for user.
 passwd plom
diff --git a/other/screen-irssi.sh b/other/screen-irssi.sh
new file mode 100644
index 0000000..0bfdd4a
--- /dev/null
+++ b/other/screen-irssi.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+screen -d -m -S irssi
+screen -S irssi -X stuff 'irssi\n'
-- 
2.30.2