diff options
| author | salmon <salmonik@tuta.io> | 2026-08-09 23:57:02 +0200 |
|---|---|---|
| committer | salmon <salmonik@tuta.io> | 2026-08-09 23:57:02 +0200 |
| commit | fb487a7d78276322ec5d5b60f0020a2bd48ed42a (patch) | |
| tree | 6f1510eac89caa0d918125728b8f46b938691d45 | |
| parent | Make daemon socket/PID paths environment-independent; fix rc service HOME (diff) | |
| download | rsplayer-fb487a7d78276322ec5d5b60f0020a2bd48ed42a.tar.gz rsplayer-fb487a7d78276322ec5d5b60f0020a2bd48ed42a.zip | |
rc service: create state dir and log before daemon(8) starts
| -rwxr-xr-x | rsplayer.rc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/rsplayer.rc b/rsplayer.rc index 706387b..ccc2bc9 100755 --- a/rsplayer.rc +++ b/rsplayer.rc | |||
| @@ -63,6 +63,14 @@ rsplayer_start() | |||
| 63 | echo " connect to the daemon socket. Set rsplayer_user in rc.conf." | 63 | echo " connect to the daemon socket. Set rsplayer_user in rc.conf." |
| 64 | fi | 64 | fi |
| 65 | 65 | ||
| 66 | # daemon(8) opens the log file (-o) before exec'ing rsp and before | ||
| 67 | # dropping privileges, but the state dir is only created by rsp itself — | ||
| 68 | # create both up front so the log can open and stays user-owned/readable. | ||
| 69 | install -d -o "${rsplayer_user}" -g "${rsplayer_group}" -m 700 "${state_dir}" | ||
| 70 | if [ ! -e "${state_dir}/rsplayer.log" ]; then | ||
| 71 | install -o "${rsplayer_user}" -g "${rsplayer_group}" -m 600 /dev/null "${state_dir}/rsplayer.log" | ||
| 72 | fi | ||
| 73 | |||
| 66 | echo "Starting rsplayer as ${rsplayer_user} (HOME=${rsplayer_home})." | 74 | echo "Starting rsplayer as ${rsplayer_user} (HOME=${rsplayer_home})." |
| 67 | /usr/bin/env HOME="${rsplayer_home}" \ | 75 | /usr/bin/env HOME="${rsplayer_home}" \ |
| 68 | /usr/sbin/daemon -u "${rsplayer_user}" -o "${state_dir}/rsplayer.log" \ | 76 | /usr/sbin/daemon -u "${rsplayer_user}" -o "${state_dir}/rsplayer.log" \ |
