Remove underscore from usernames

Cleanup init scripts, use $USERNAME and $HOMDIR variables
This commit is contained in:
badaix 2019-11-20 22:25:41 +01:00
parent 5a68f95828
commit 09bd4c3bf7
8 changed files with 19 additions and 17 deletions

View file

@ -16,6 +16,7 @@
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Snapcast client"
NAME=snapclient
USERNAME=snapclient
DAEMON=/usr/bin/$NAME
PIDFILE=/var/run/$NAME/pid
SCRIPTNAME=/etc/init.d/$NAME
@ -47,15 +48,15 @@ do_start()
PIDDIR=$(dirname "$PIDFILE")
if [ ! -d "$PIDDIR" ]; then
mkdir -m 0755 $PIDDIR
chown _snapclient:_snapclient $PIDDIR
chown $USERNAME:$USERNAME $PIDDIR
fi
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile "$PIDFILE" --chuid "_snapclient:_snapclient" --exec "$DAEMON" --test > /dev/null || return 1
start-stop-daemon --start --quiet --pidfile "$PIDFILE" --chuid "_snapclient:_snapclient" --exec "$DAEMON" -- $SNAPCLIENT_OPTS > /dev/null || return 2
start-stop-daemon --start --quiet --pidfile "$PIDFILE" --chuid "$USERNAME:$USERNAME" --exec "$DAEMON" --test > /dev/null || return 1
start-stop-daemon --start --quiet --pidfile "$PIDFILE" --chuid "$USERNAME:$USERNAME" --exec "$DAEMON" -- $SNAPCLIENT_OPTS > /dev/null || return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.

View file

@ -2,12 +2,12 @@
set -e
USERNAME=_snapclient
USERNAME=snapclient
HOMEDIR=/var/lib/snapclient
if [ "$1" = configure ]; then
if ! getent passwd _snapclient >/dev/null; then
adduser --system --quiet --group --home /var/lib/snapclient --no-create-home --force-badname $USERNAME
if ! getent passwd $USERNAME >/dev/null; then
adduser --system --quiet --group --home $HOMEDIR --no-create-home --force-badname $USERNAME
adduser $USERNAME audio
fi

View file

@ -4,7 +4,7 @@ set -e
#DEBHELPER#
USERNAME=_snapclient
USERNAME=snapclient
HOMEDIR=/var/lib/snapclient
if [ "$1" = "purge" ]; then

View file

@ -7,8 +7,8 @@ After=network.target time-sync.target sound.target avahi-daemon.service
[Service]
EnvironmentFile=-/etc/default/snapclient
ExecStart=/usr/bin/snapclient $SNAPCLIENT_OPTS
User=_snapclient
Group=_snapclient
User=snapclient
Group=snapclient
# very noisy on stdout
StandardOutput=null
Restart=on-failure

View file

@ -16,6 +16,7 @@
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Snapcast server"
NAME=snapserver
USERNAME=snapserver
DAEMON=/usr/bin/$NAME
PIDFILE=/var/run/$NAME/pid
SCRIPTNAME=/etc/init.d/$NAME
@ -47,15 +48,15 @@ do_start()
PIDDIR=$(dirname "$PIDFILE")
if [ ! -d "$PIDDIR" ]; then
mkdir -m 0755 $PIDDIR
chown _snapserver:_snapserver $PIDDIR
chown $USERNAME:$USERNAME $PIDDIR
fi
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile "$PIDFILE" --chuid "_snapclient:_snapclient" --exec "$DAEMON" --test > /dev/null || return 1
start-stop-daemon --start --quiet --pidfile "$PIDFILE" --chuid "_snapclient:_snapclient" --exec "$DAEMON" -- $SNAPSERVER_OPTS || return 2
start-stop-daemon --start --quiet --pidfile "$PIDFILE" --chuid "$USERNAME:$USERNAME" --exec "$DAEMON" --test > /dev/null || return 1
start-stop-daemon --start --quiet --pidfile "$PIDFILE" --chuid "$USERNAME:$USERNAME" --exec "$DAEMON" -- $SNAPSERVER_OPTS || return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.

View file

@ -2,11 +2,11 @@
set -e
USERNAME=_snapserver
USERNAME=snapserver
HOMEDIR=/var/lib/snapserver
if [ "$1" = configure ]; then
adduser --system --quiet --group --home /var/lib/snapserver --no-create-home --force-badname $USERNAME
adduser --system --quiet --group --home $HOMEDIR --no-create-home --force-badname $USERNAME
if [ ! -d $HOMEDIR ]; then
mkdir -m 0750 $HOMEDIR

View file

@ -4,7 +4,7 @@ set -e
#DEBHELPER#
USERNAME=_snapserver
USERNAME=snapserver
HOMEDIR=/var/lib/snapserver
if [ "$1" = "purge" ]; then

View file

@ -7,8 +7,8 @@ After=network.target time-sync.target avahi-daemon.service
[Service]
EnvironmentFile=-/etc/default/snapserver
ExecStart=/usr/bin/snapserver $SNAPSERVER_OPTS
User=_snapserver
Group=_snapserver
User=snapserver
Group=snapserver
Restart=on-failure
[Install]