Skip to content

Commit

Permalink
Merge pull request #11103 from fzakaria/issue-10795
Browse files Browse the repository at this point in the history
lint: fix shellcheck for misc/systemv/nix-daemon
  • Loading branch information
edolstra authored Jul 17, 2024
2 parents b23da1c + 104aba0 commit 6867cb1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@
++ pkgs.nixComponents.nix-external-api-docs.nativeBuildInputs
++ [
pkgs.buildPackages.cmake
pkgs.shellcheck
modular.pre-commit.settings.package
(pkgs.writeScriptBin "pre-commit-hooks-install"
modular.pre-commit.settings.installationScript)
Expand Down
1 change: 0 additions & 1 deletion maintainers/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@
excludes = [
# We haven't linted these files yet
''^config/install-sh$''
''^misc/systemv/nix-daemon$''
''^misc/bash/completion\.sh$''
''^misc/fish/completion\.fish$''
''^misc/zsh/completion\.zsh$''
Expand Down
17 changes: 12 additions & 5 deletions misc/systemv/nix-daemon
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,28 @@ else
fi

# Source function library.
# shellcheck source=/dev/null
. /etc/init.d/functions

LOCKFILE=/var/lock/subsys/nix-daemon
RUNDIR=/var/run/nix
PIDFILE=${RUNDIR}/nix-daemon.pid
RETVAL=0

base=${0##*/}
# https://www.shellcheck.net/wiki/SC3004
# Check if gettext exists
if ! type gettext > /dev/null 2>&1
then
# If not, create a dummy function that returns the input verbatim
gettext() { printf '%s' "$1"; }
fi

start() {

mkdir -p ${RUNDIR}
chown ${NIX_DAEMON_USER}:${NIX_DAEMON_USER} ${RUNDIR}

echo -n $"Starting nix daemon... "
printf '%s' "$(gettext 'Starting nix daemon... ')"

daemonize -u $NIX_DAEMON_USER -p ${PIDFILE} $NIX_DAEMON_BIN $NIX_DAEMON_OPTS
RETVAL=$?
Expand All @@ -58,7 +65,7 @@ start() {
}

stop() {
echo -n $"Shutting down nix daemon: "
printf '%s' "$(gettext 'Shutting down nix daemon: ')"
killproc -p ${PIDFILE} $NIX_DAEMON_BIN
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
Expand All @@ -67,7 +74,7 @@ stop() {
}

reload() {
echo -n $"Reloading nix daemon... "
printf '%s' "$(gettext 'Reloading nix daemon... ')"
killproc -p ${PIDFILE} $NIX_DAEMON_BIN -HUP
RETVAL=$?
echo
Expand Down Expand Up @@ -105,7 +112,7 @@ case "$1" in
fi
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
printf '%s' "$(gettext "Usage: $0 {start|stop|status|restart|condrestart}")"
exit 2
;;
esac
Expand Down

0 comments on commit 6867cb1

Please sign in to comment.