Skip to content

Commit 8fab752

Browse files
committed
smartdns: change pid file path from /var/run to /run
1 parent d3a6d46 commit 8fab752

File tree

6 files changed

+24
-7
lines changed

6 files changed

+24
-7
lines changed

Diff for: Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ RUN cd /build/smartdns && \
3232
\
3333
( cd package && tar -xvf *.tar.gz && chmod a+x smartdns/etc/init.d/smartdns ) && \
3434
\
35-
mkdir -p /release/var/log /release/var/run && \
35+
mkdir -p /release/var/log /release/run && \
3636
cp package/smartdns/etc /release/ -a && \
3737
cp package/smartdns/usr /release/ -a && \
3838
cd / && rm -rf /build

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ DESTDIR :=
1818
PREFIX := /usr
1919
SBINDIR := $(PREFIX)/sbin
2020
SYSCONFDIR := /etc
21-
RUNSTATEDIR := /var/run
21+
RUNSTATEDIR := /run
2222
SYSTEMDSYSTEMUNITDIR := $(shell ${PKG_CONFIG} --variable=systemdsystemunitdir systemd)
2323
SMARTDNS_SYSTEMD = systemd/smartdns.service
2424

Diff for: etc/init.d/smartdns

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin
2828

2929
. /etc/default/smartdns
3030
SMARTDNS=/usr/sbin/smartdns
31-
PIDFILE=/var/run/smartdns.pid
31+
PIDFILE=/run/smartdns.pid
32+
if [ ! -d "/run" ]; then
33+
PIDFILE=/var/run/smartdns.pid
34+
fi
3235

3336
test -x $SMARTDNS || exit 5
3437

Diff for: package/openwrt/files/etc/init.d/smartdns

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ USE_PROCD=1
2222
SERVICE_USE_PID=1
2323
SERVICE_WRITE_PID=1
2424
SERVICE_DAEMONIZE=1
25-
SERVICE_PID_FILE="/var/run/smartdns.pid"
25+
SERVICE_PID_FILE="/run/smartdns.pid"
26+
if [ ! -d "/run" ]; then
27+
SERVICE_PID_FILE="/var/run/smartdns.pid"
28+
fi
29+
2630
SMARTDNS_CONF_DIR="/etc/smartdns"
2731
SMARTDNS_CONF_DOWNLOAD_DIR="$SMARTDNS_CONF_DIR/conf.d"
2832
SMARTDNS_DOMAIN_LIST_DOWNLOAD_DIR="$SMARTDNS_CONF_DIR/domain-set"

Diff for: package/optware/S50smartdns

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
SMARTDNS_BIN=/opt/usr/sbin/smartdns
1919
SMARTDNS_CONF=/opt/etc/smartdns/smartdns.conf
2020
DNSMASQ_CONF="/etc/dnsmasq.conf /var/etc/dnsmasq.conf /etc/storage/dnsmasq/dnsmasq.conf"
21-
SMARTDNS_PID=/var/run/smartdns.pid
21+
SMARTDNS_PID=/run/smartdns.pid
22+
if [ ! -d "/run" ]; then
23+
SMARTDNS_PID=/var/run/smartdns.pid
24+
fi
2225
SMARTDNS_PORT=535
2326
SMARTDNS_OPT=/opt/etc/smartdns/smartdns-opt.conf
2427
# workmode

Diff for: src/smartdns.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
#include <ucontext.h>
4848

4949
#define MAX_KEY_LEN 64
50-
#define SMARTDNS_PID_FILE "/var/run/smartdns.pid"
50+
#define SMARTDNS_PID_FILE "/run/smartdns.pid"
51+
#define SMARTDNS_LEGACY_PID_FILE "/var/run/smartdns.pid"
5152
#define TMP_BUFF_LEN_32 32
5253

5354
static int verbose_screen;
@@ -696,9 +697,15 @@ int main(int argc, char *argv[])
696697
char pid_file[MAX_LINE_LEN];
697698
int signal_ignore = 0;
698699
sigset_t empty_sigblock;
700+
struct stat sb;
699701

700702
safe_strncpy(config_file, SMARTDNS_CONF_FILE, MAX_LINE_LEN);
701-
safe_strncpy(pid_file, SMARTDNS_PID_FILE, MAX_LINE_LEN);
703+
704+
if (stat("/run", &sb) == 0 && S_ISDIR(sb.st_mode)) {
705+
safe_strncpy(pid_file, SMARTDNS_PID_FILE, MAX_LINE_LEN);
706+
} else {
707+
safe_strncpy(pid_file, SMARTDNS_LEGACY_PID_FILE, MAX_LINE_LEN);
708+
}
702709

703710
/* patch for Asus router: unblock all signal*/
704711
sigemptyset(&empty_sigblock);

0 commit comments

Comments
 (0)