diff --git a/hetzner_ddns.openwrt.rc b/hetzner_ddns.openwrt.rc index e1bdc0a..f6bdb92 100644 --- a/hetzner_ddns.openwrt.rc +++ b/hetzner_ddns.openwrt.rc @@ -4,9 +4,24 @@ START=99 USE_PROCD=1 +_LOG_FILE=/var/log/hetzner_ddns.log +_PID_FILE=/var/run/hetzner_ddns.pid + +fix_permissions() { + touch "${_LOG_FILE}" + touch "${_PID_FILE}" + + chown nobody:nogroup "${_LOG_FILE}" + chown nobody:nogroup "${_PID_FILE}" + + chmod u+w "${_LOG_FILE}" + chmod u+w "${_PID_FILE}" +} + start_service() { + fix_permissions procd_open_instance [hetzner_ddns] - procd_set_param command /usr/bin/hetzner_ddns -d /etc/config/hetzner_ddns.conf + procd_set_param command /usr/bin/hetzner_ddns -d # respawn automatically if something died, be careful if you have an alternative process supervisor # if process exits sooner than respawn_threshold, it is considered crashed and after 5 retries the service is stopped diff --git a/release/OpenWrt/Makefile b/release/OpenWrt/Makefile index 6eae647..9203462 100644 --- a/release/OpenWrt/Makefile +++ b/release/OpenWrt/Makefile @@ -50,22 +50,22 @@ endef define Package/$(PKG_NAME)/install # copy shell script, init.d file and conf as preparation mkdir -p files - cp $(PKG_BUILD_DIR)/hetzner_ddns.sh ./files/ + cp $(PKG_BUILD_DIR)/hetzner_ddns.sh ./files/hetzner_ddns cp $(PKG_BUILD_DIR)/hetzner_ddns.conf ./files/ cp $(PKG_BUILD_DIR)/hetzner_ddns.openwrt.rc ./files/ # modify conf dir to match openwrt defaults /etc/config - sed -i 's|/usr/local/etc|/etc/config|g' ./files/hetzner_ddns.sh + sed -i 's|/usr/local/etc|/etc/config|g' ./files/hetzner_ddns # install shell script, conf and service $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) ./files/hetzner_ddns.sh $(1)/usr/bin + $(INSTALL_BIN) ./files/hetzner_ddns $(1)/usr/bin $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/hetzner_ddns.openwrt.rc $(1)/etc/init.d/hetzner_ddns $(INSTALL_DIR) $(1)/etc/config - $(INSTALL_CONF) ./files/hetzner_ddns.conf $(1)/etc/config/hetzner_ddns.conf + $(INSTALL_DATA) ./files/hetzner_ddns.conf $(1)/etc/config/hetzner_ddns.conf endef define Package/$(PKG_NAME)/prerm