[systemd-devel] We are working on Secure Container Applications.
"Jóhann B. Guðmundsson"
johannbg at gmail.com
Tue Jan 10 17:25:51 PST 2012
On 01/10/2012 11:51 PM, Lennart Poettering wrote:
> Yes. Most likely you don't even have to create the file
> /etc/systemd/system/httpd at sanbox2.service at all, instead just symlink
> it from /lib/systemd/system/httpd at .service, i.e. the common template.
Dan to give you an example which I used test to run multiple instances
of vsftpd of an template unit a while back with quick and dirty
directions I had noted down while doing it...
First here is a httpd template unit file for you to start fiddling with
and tailor to your needs since this is rather lengthy post but should
give you the general idea of what needs to be done and what Lennart is
referring to....
### Sample httpd at .service template ###
[Unit]
Description=The Apache HTTP Server Instance %i
After=network.target
[Service]
Type=forking
PIDFile=/run/httpd/%i.pid
ExecStart=/usr/sbin/httpd -f /etc/httpd/conf.d/%i.conf -k start
ExecReload=/usr/sbin/httpd -t
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/usr/sbin/httpd -k stop
[Install]
WantedBy=multi-user.target
The VSFTPD template unit.
### vsftpd at .service ###
[Unit]
Description=Vsftpd FTP Daemon Server Instance %i
After=network.target
[Service]
Type=forking
ExecStart=/usr/sbin/vsftpd /etc/vsftpd/%i.conf
[Install]
WantedBy=multi-user.target
Next create a multiple copy's of the vsftpd.conf file
for i in 1 2 3 4;do cp /etc/vsftpd/vsftpd.conf
/etc/vsftpd/vsftpd$i.conf; done
Set different log file for each of them...
for i in 1 2 3 4;do echo "xferlog_file=/var/log/vsftpd$i.log" >>
/etc/vsftpd/vsftpd$i.conf; done
Set different listening port in each configuration file on them...
for i in 1 2 3 4;do echo "listen_port=200$i" >>
/etc/vsftpd/vsftpd$i.conf; done
Then symbolic link that template to the name of the each configuration file
ln -s /lib/systemd/system/vsftpd\@.service
/etc/systemd/system/vsftpd\@vsftpd1.service
ln -s /lib/systemd/system/vsftpd\@.service
/etc/systemd/system/vsftpd\@vsftpd2.service
ln -s /lib/systemd/system/vsftpd\@.service
/etc/systemd/system/vsftpd\@vsftpd3.service
ln -s /lib/systemd/system/vsftpd\@.service
/etc/systemd/system/vsftpd\@vsftpd4.service
Reload the systemd daemon
systemctl daemon-reload
Start each instance
systemctl start vsftpd at vsftpd1.service vsftpd at vsftpd2.service
vsftpd at vsftpd3.service vsftpd at vsftpd4.service
Check to see if each instance is running and listening on different
ports...
[root at localhost system]# systemctl status vsftpd at vsftpd1.service
vsftpd at vsftpd2.service vsftpd at vsftpd3.service vsftpd at vsftpd4.service
vsftpd at vsftpd1.service - Vsftpd FTP Daemon Server Instance vsftpd1
Loaded: loaded (/lib/systemd/system/vsftpd at .service; enabled)
Active: active (running) since Wed, 11 Jan 2012 01:22:46 +0000; 2s ago
Process: 7351 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/%i.conf
(code=exited, status=0/SUCCESS)
Main PID: 7358 (vsftpd)
CGroup: name=systemd:/system/vsftpd at .service/vsftpd1
└ 7358 /usr/sbin/vsftpd /etc/vsftpd/vsftpd1.conf
vsftpd at vsftpd2.service - Vsftpd FTP Daemon Server Instance vsftpd2
Loaded: loaded (/lib/systemd/system/vsftpd at .service; enabled)
Active: active (running) since Wed, 11 Jan 2012 01:22:46 +0000; 2s ago
Process: 7352 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/%i.conf
(code=exited, status=0/SUCCESS)
Main PID: 7357 (vsftpd)
CGroup: name=systemd:/system/vsftpd at .service/vsftpd2
└ 7357 /usr/sbin/vsftpd /etc/vsftpd/vsftpd2.conf
vsftpd at vsftpd3.service - Vsftpd FTP Daemon Server Instance vsftpd3
Loaded: loaded (/lib/systemd/system/vsftpd at .service; enabled)
Active: active (running) since Wed, 11 Jan 2012 01:22:46 +0000; 2s ago
Process: 7353 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/%i.conf
(code=exited, status=0/SUCCESS)
Main PID: 7355 (vsftpd)
CGroup: name=systemd:/system/vsftpd at .service/vsftpd3
└ 7355 /usr/sbin/vsftpd /etc/vsftpd/vsftpd3.conf
vsftpd at vsftpd4.service - Vsftpd FTP Daemon Server Instance vsftpd4
Loaded: loaded (/lib/systemd/system/vsftpd at .service; enabled)
Active: active (running) since Wed, 11 Jan 2012 01:22:46 +0000; 2s ago
Process: 7354 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/%i.conf
(code=exited, status=0/SUCCESS)
Main PID: 7356 (vsftpd)
CGroup: name=systemd:/system/vsftpd at .service/vsftpd4
└ 7356 /usr/sbin/vsftpd /etc/vsftpd/vsftpd4.conf
[root at localhost system]# netstat -pant | grep vsftpd
tcp 0 0 :::2001 :::* LISTEN 7358/vsftpd
tcp 0 0 :::2002 :::* LISTEN 7357/vsftpd
tcp 0 0 :::2003 :::* LISTEN 7355/vsftpd
tcp 0 0 :::2004 :::* LISTEN 7356/vsftpd
More information about the systemd-devel
mailing list