Score:0

how to make an installed package as a service in ubuntu?

nc flag

I've installed ocserv package using these commands on Ubuntu22:

mkdir /usr/local/src/ocserv
cd /usr/local/src/ocserv
wget ftp://ftp.infradead.org/pub/ocserv/ocserv-0.10.9.tar.xz
unxz ocserv-0.10.9.tar.xz
tar xvf ocserv-0.10.9.tar
cd ocserv-0.10.9
./configure --sysconfdir=/etc/ && make && make install

The ocserv package is installed and it run and works with this command:

ocserv -c /etc/ocserv/ocserv.conf

I need it to run as a service. can you please help me doing this?

  • I couldn't use the linux repository to install this package because of some considerations.
Score:0
ly flag

systemctl status ocserv it should automatically create service for you. if you are talking about openconnect server.

however if you are talking about vpn client and you want the client to automatically connect to vpn server at startup do the steps below

nano /etc/systemd/system/openconnect.service

[Unit]
Description=Connect to VPN
After=network.target

[Service]
Type=simple
Environment=password=correcthorsebatterystaple
ExecStart=/bin/sh -c 'echo password | sudo openconnect -u username --passwd-on-stdin vpn.dixmata.com'
Restart=always

[Install]
WantedBy=multi-user.target


sudo systemctl daemon-reload
sudo systemctl enable openconnect.service --now
Ethan_m avatar
nc flag
no I'm talking about openconnect server (ocserv).
Hoodad Tabibi avatar
ly flag
`systemctl status ocserv` what is the result of this command ?
Score:0
nc flag

Thanks to Sergiu, with some modification to his instructions, I finally managed to run ocserv as a system service in ubuntu.

First I wanted to edit Sergiu's post but then I thought it may not be right. So I put the edited instruction here.

First create a systemd unit for this service:

systemctl edit --force --full ocserv.service

With these contents:

[Unit]
Description=OCServ service
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=on-failure
RestartSec=1
User=root
ExecStart=/usr/local/sbin/ocserv --foreground --pid-file /var/run/ocserv.pid --config /etc/ocserv/ocserv.conf

[Install]
WantedBy=multi-user.target

Save it and enable the new service:

systemctl enable --now ocserv.service

You can view its status with this command:

systemctl status ocserv.service

If the service was inactive or had any error:

systemctl restart ocserv.service

And recheck the service status:

systemctl status ocserv.service
Score:0
ru flag

First create a systemd unit for this service:

systemctl edit --force --full ocserv.service

With these contents:

[Unit]
Description=OCServ service
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=on-failure
RestartSec=1
User=root
ExecStart=/usr/local/sbin/ocserv -c /etc/ocserv/ocserv.conf

[Install]
WantedBy=multi-user.target

Save it and enable the new service:

systemctl enable --now ocserv.service

You can view its status with this command:

systemctl status ocserv.service
Ethan_m avatar
nc flag
Hello and thanks for the explanation. I did all the steps but service remains inactive. I'll share some logs in a new post
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.