#!/bin/sh
#
# containerd   A daemon to control runc.
#
# chkconfig: - 90 10
# description: A daemon to control runc.

# Source function library.
. /etc/init.d/functions

OPTIONS=

LOCKFILE=/var/lock/subsys/containerd
RETVAL=0

start()
{
	start_daemon --background --lockfile "$LOCKFILE" --expect-user root -- containerd --config /etc/containerd/config.toml
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --lockfile "$LOCKFILE" --expect-user root --retry 60 -- containerd
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	reload|restart)
		restart
		;;
	status)
		status --pidfile "$PIDFILE" -- containerd
		RETVAL=$?
		;;
	*)
		msg_usage "${0##*/} {start|stop|restart|status}"
		RETVAL=1
esac

exit $RETVAL
