Slackware init script for guix deamon
by M0M0 from LinuxQuestions.org on (#5J7KG)
I recently discovered the guix package manager
https://guix.gnu.org/
It's similar to nix, (I think it builds everything from source) and provides some packages I need and that are difficult to build from source.
If you use their install script on Slackware it won't recognize the init system and therefore you have to run the daemon manually. So I decided to write an init script that works on Slackware. I modified a script that someone wrote for Devuan and came up with this:
Code:#!/bin/bash -e
### BEGIN INIT INFO
# Provides: guix-daemon
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Guix build daemon
# Description: Provides a daemon that does builds for Guix
### END INIT INFO
case "$1" in
start)
daemonize -a -e /var/log/guix-daemon-stderr.log -o /var/log/guix-daemon-stdout.log -E GUIX_LOCPATH=/var/guix/profiles/per-user/root/guix-profile/lib/locale -E LC_ALL=en_US.utf8 -p /var/run/guix-daemon.pid ~root/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild
;;
stop)
pid="`cat /var/run/guix-daemon.pid`"
if [ ! -z "${pid}" ]
then
kill "${pid}"
# sleep 10
# kill -9 "${pid}"
> /var/run/guix-daemon.pid
fi
# TODO: Maybe remove /var/run/guix-daemon.pid ?
;;
status)
pid="`cat /var/run/guix-daemon.pid`"
if [ ! -z "${pid}" ]
then
if ps "${pid}" > /dev/null 2> /dev/null
then
echo "running"
else
echo "stale pid file"
fi
else
echo "not running"
fi
;;
*)
echo "Usage: $0 (start|stop|status)"
;;
esacI named it rc.guix-daemon and placed it under /etc/rc.d I than added
Code:# Added by user
# Start the guix-daemon
if [ -x /etc/rc.d/rc.guix-daemon ]; then
/etc/rc.d/rc.guix-daemon start
fito /etc/rc.d/rc.M
note that the script depends on daemonize, which has to be installed from slackbuilds.org . I don't claim that this is brilliant but it works and maybe someone will find it useful now or in the future :)
https://guix.gnu.org/
It's similar to nix, (I think it builds everything from source) and provides some packages I need and that are difficult to build from source.
If you use their install script on Slackware it won't recognize the init system and therefore you have to run the daemon manually. So I decided to write an init script that works on Slackware. I modified a script that someone wrote for Devuan and came up with this:
Code:#!/bin/bash -e
### BEGIN INIT INFO
# Provides: guix-daemon
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Guix build daemon
# Description: Provides a daemon that does builds for Guix
### END INIT INFO
case "$1" in
start)
daemonize -a -e /var/log/guix-daemon-stderr.log -o /var/log/guix-daemon-stdout.log -E GUIX_LOCPATH=/var/guix/profiles/per-user/root/guix-profile/lib/locale -E LC_ALL=en_US.utf8 -p /var/run/guix-daemon.pid ~root/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild
;;
stop)
pid="`cat /var/run/guix-daemon.pid`"
if [ ! -z "${pid}" ]
then
kill "${pid}"
# sleep 10
# kill -9 "${pid}"
> /var/run/guix-daemon.pid
fi
# TODO: Maybe remove /var/run/guix-daemon.pid ?
;;
status)
pid="`cat /var/run/guix-daemon.pid`"
if [ ! -z "${pid}" ]
then
if ps "${pid}" > /dev/null 2> /dev/null
then
echo "running"
else
echo "stale pid file"
fi
else
echo "not running"
fi
;;
*)
echo "Usage: $0 (start|stop|status)"
;;
esacI named it rc.guix-daemon and placed it under /etc/rc.d I than added
Code:# Added by user
# Start the guix-daemon
if [ -x /etc/rc.d/rc.guix-daemon ]; then
/etc/rc.d/rc.guix-daemon start
fito /etc/rc.d/rc.M
note that the script depends on daemonize, which has to be installed from slackbuilds.org . I don't claim that this is brilliant but it works and maybe someone will find it useful now or in the future :)