this post was submitted on 21 May 2025
26 points (90.6% liked)

linux4noobs

2051 readers
21 users here now

linux4noobs


Noob Friendly, Expert Enabling

Whether you're a seasoned pro or the noobiest of noobs, you've found the right place for Linux support and information. With a dedication to supporting free and open source software, this community aims to ensure Linux fits your needs and works for you. From troubleshooting to tutorials, practical tips, news and more, all aspects of Linux are warmly welcomed. Join a community of like-minded enthusiasts and professionals driving Linux's ongoing evolution.


Seeking Support?

Community Rules

founded 2 years ago
MODERATORS
 

thoughts, comments, concerns on systemd? was having a convo w someone that's on mx linux & it piqued my interest.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 12 points 1 day ago* (last edited 1 day ago)

If you are new to Linux I think it makes sense to use systemd. It’s the default for a reason. All major distros use it for a reason. It’s only a really small minority of very vocal people who are against it.

If Debian and Fedora and Ubuntu and All the enterprise linuxes use the same thing, I think that says something.

Despite claims to the contrary systemd is substantially faster and easier to use than its predecessor.

It’s simpler and easier to use. Take a look at these examples. Service files are so so much easier to use and are much more robust than hundred line bash scripts.

Systemd:

[Unit]
Description=OpenVPN tunnel for %i
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/usr/sbin/openvpn --config /etc/openvpn/%i.conf
Restart=on-failure

[Install]
WantedBy=multi-user.target

Sysvinit

#!/bin/sh
### BEGIN INIT INFO
# Provides:          openvpn
# Required-Start:    $network $remote_fs
# Required-Stop:     $network $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: OpenVPN service
# Description:       Start or stop OpenVPN tunnels.
### END INIT INFO

DAEMON=/usr/sbin/openvpn
CONFIG_DIR=/etc/openvpn
PID_DIR=/run/openvpn
DESC="OpenVPN service"
NAME=openvpn

. /lib/lsb/init-functions

start() {
    log_daemon_msg "Starting $DESC"

    mkdir -p "$PID_DIR"

    for conf in "$CONFIG_DIR"/*.conf; do
        [ -e "$conf" ] || continue
        inst=$(basename "$conf" .conf)
        pidfile="$PID_DIR/$inst.pid"

        if start-stop-daemon --start --quiet --background \
            --pidfile "$pidfile" --make-pidfile \
            --exec "$DAEMON" -- --daemon ovpn-$inst --writepid "$pidfile" --config "$conf"; then
            log_progress_msg "$inst"
        else
            log_warning_msg "Failed to start $inst"
        fi
    done
    log_end_msg 0
}

stop() {
    log_daemon_msg "Stopping $DESC"
    for pid in "$PID_DIR"/*.pid; do
        [ -e "$pid" ] || continue
        inst=$(basename "$pid" .pid)
        if start-stop-daemon --stop --quiet --pidfile "$pid"; then
            rm -f "$pid"
            log_progress_msg "$inst"
        else
            log_warning_msg "Failed to stop $inst"
        fi
    done
    log_end_msg 0
}

status() {
    for conf in "$CONFIG_DIR"/*.conf; do
        [ -e "$conf" ] || continue
        inst=$(basename "$conf" .conf)
        pidfile="$PID_DIR/$inst.pid"
        if [ -e "$pidfile" ] && kill -0 "$(cat "$pidfile" 2>/dev/null)" 2>/dev/null; then
            echo "$inst is running (pid $(cat "$pidfile"))"
        else
            echo "$inst is not running"
        fi
    done
}

case "$1" in
    start) start ;;
    stop) stop ;;
    restart) stop; start ;;
    status) status ;;
    *) echo "Usage: $0 {start|stop|restart|status}"; exit 1 ;;
esac

exit 0