mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-20 04:26:16 +02:00
Snapserver is running as snapcast user
This commit is contained in:
parent
b82970fab4
commit
adcb19ee3f
3 changed files with 27 additions and 11 deletions
|
@ -44,7 +44,7 @@ void daemonize(const std::string& user, const std::string& group, const std::str
|
|||
mkdirRecursive(pidfileDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
|
||||
/// Ensure only one copy
|
||||
pidFilehandle = open(pidfile.c_str(), O_RDWR|O_CREAT, 0600);
|
||||
pidFilehandle = open(pidfile.c_str(), O_RDWR|O_CREAT, 0644);
|
||||
if (pidFilehandle == -1 )
|
||||
{
|
||||
/// Couldn't open lock file
|
||||
|
|
|
@ -65,6 +65,7 @@ endif
|
|||
|
||||
BIN = snapserver
|
||||
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJ)
|
||||
|
@ -86,8 +87,7 @@ dpkg:
|
|||
ifdef DESTDIR
|
||||
|
||||
install:
|
||||
install -D -g root -o root $(BIN) $(TARGET_DIR)/bin/$(BIN)
|
||||
install -D -g root -o root $(BIN).1 $(TARGET_DIR)/share/man/man1/$(BIN).1
|
||||
$(MAKE) installfiles
|
||||
|
||||
else ifeq ($(TARGET), FREEBSD)
|
||||
|
||||
|
@ -109,8 +109,10 @@ install:
|
|||
else
|
||||
|
||||
install:
|
||||
install -D -g root -o root $(BIN) $(TARGET_DIR)/bin/$(BIN)
|
||||
install -D -g root -o root $(BIN).1 $(TARGET_DIR)/share/man/man1/$(BIN).1
|
||||
$(MAKE) adduser
|
||||
$(MAKE) installfiles
|
||||
install -g audio -o snapcast -d /var/run/$(BIN)
|
||||
|
||||
@if [[ `systemctl` =~ -\.mount ]]; then \
|
||||
$(MAKE) installsystemd; \
|
||||
elif [[ `/sbin/init --version` =~ upstart ]]; then \
|
||||
|
@ -123,6 +125,10 @@ install:
|
|||
|
||||
endif
|
||||
|
||||
installfiles:
|
||||
install -D -g root -o root $(BIN) $(TARGET_DIR)/bin/$(BIN)
|
||||
install -D -g root -o root $(BIN).1 $(TARGET_DIR)/share/man/man1/$(BIN).1
|
||||
|
||||
installsystemd:
|
||||
@echo using systemd; \
|
||||
cp debian/$(BIN).service /lib/systemd/system/$(BIN).service; \
|
||||
|
@ -142,6 +148,11 @@ installbsd:
|
|||
@echo using bsd; \
|
||||
cp debian/$(BIN).bsd /usr/local/etc/rc.d/$(BIN); \
|
||||
|
||||
adduser:
|
||||
@if ! getent passwd snapcast >/dev/null; then \
|
||||
adduser --quiet --ingroup audio --system --no-create-home --home /var/lib/snapcast snapcast; \
|
||||
fi; \
|
||||
|
||||
|
||||
ifeq ($(TARGET), FREEBSD)
|
||||
|
||||
|
@ -174,6 +185,8 @@ uninstall:
|
|||
else \
|
||||
echo cannot tell; \
|
||||
fi; \
|
||||
rm -rf /var/run/$(BIN)
|
||||
$(MAKE) deluser
|
||||
|
||||
endif
|
||||
|
||||
|
@ -194,3 +207,6 @@ uninstallsystemd:
|
|||
rm -f /etc/default/$(BIN); \
|
||||
systemctl daemon-reload; \
|
||||
|
||||
deluser:
|
||||
@deluser --quiet --system snapcast > /dev/null || true
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ int main(int argc, char* argv[])
|
|||
if (daemonOption.isSet())
|
||||
{
|
||||
#ifdef HAS_DAEMON
|
||||
daemonize("snapcast", "audio", "/var/run/snapserver.pid");
|
||||
daemonize("snapcast", "audio", "/var/run/snapserver/pid");
|
||||
if (processPriority < -20)
|
||||
processPriority = -20;
|
||||
else if (processPriority > 19)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue