[CentOS] Starting stunnel on boot with CentOS7

Wed Dec 23 10:08:31 UTC 2015
James Hogarth <james.hogarth at gmail.com>

On 23 December 2015 at 05:38, Kahlil Hodgson <kahlil.hodgson at dealmax.com.au>
wrote:

> On my CenOS7 system with stunnel from base
>
>     stunnel-4.56-4.el7.x86_64
>
> there's a systemd service file
>
>     /etc/systemd/system/stunnel.service
>
> try
>
> sudo systemctl enable stunnel.service
>
>
>
Packaged unit files are in /usr/lib/systemd/system ... someone put that
there as a local configuration (rpm -qf /path/to/file to it to verify)

Of course this is what the OP should do too ...  a very simple unit file
that matches his needs...

cat > /etc/systemd/system/stunnel.service <<EOF
[Unit]
Description=My stunnel

[Service]
ExecStart=/usr/bin/stunnel /etc/stunnel/myconf.conf

[Install]
WantedBy=multi-user.target
EOF

In the config file set foreground to yes ....

For a more advanced setup use a template like:

cat > /etc/systemd/stunnel at .service <<<EOF
[Unit]
Description=Stunnel config for %i

[Service]
ExecStart=/usr/bin/stunnel /etc/stunnel/%i.conf

[Install]
WantedBy=multi-user.target
EOF

Don't forget to systemctl daemon-reload after adding one of these...

Using the template method you'd enable it with the name of the config file
of interest ... remember to have foreground=yes ...

Given the config /etc/stunnel/snowflake.conf ...

systemctl enable stunnel at snowflake.service

systemctl start stunnel at snowflake.service