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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,11 +2,11 @@
set -e set -e
USERNAME=_snapserver USERNAME=snapserver
HOMEDIR=/var/lib/snapserver HOMEDIR=/var/lib/snapserver
if [ "$1" = configure ]; then 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 if [ ! -d $HOMEDIR ]; then
mkdir -m 0750 $HOMEDIR mkdir -m 0750 $HOMEDIR

View file

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

View file

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