[Alpine] - rc-service constantly says ddclient it crashed
Hey y'all,
So i am using ddclient v3.9.1 on Alpine v3.13.5 and for whatever reason i consistently get a crashed status when including ddclient in rc-service. Essentially i will start ddclient with rc-service ddclient start and it will spit out * Starting ddclient ... with no errors or failures printed, but when i enter rc-status ddclient says that it has crashed: ddclient [ crashed ].
I have ran ddclient with ddclient -daemon=0 -verbose -noquiet -debug and all requests are completed with 200 status codes. Furthermore, it says that it was able to fetch the public IP and set it within cloudflare. So no issues running the command like that.
Even when i check the syslogs at /var/log/messages with cat messages | grep 'ddclient' i see no errors at all on the start call. The only errors i can see are when it call to stop the service once it has already crashed with rc-service ddclient stop and it outputs:
NGINX user.debug : Will stop /usr/bin/ddclient
NGINX daemon.err /etc/init.d/ddclient[1325]: start-stop-daemon: no matching processes found
Below is my /etc/init.d/ddclient config. I am not the best with Alpine and this is one of the first times i am using it so i apologize if I am missing something trivial, I just cant figure this out.
#!/sbin/openrc-run
description="ddclient Daemon for Alpine"
command="/usr/bin/ddclient"
config_file="/etc/ddclient/ddclient.conf"
command_args=""
pidfile=$(grep -v '^\s*#' "${config_file}" | grep -i -m 1 pid= | awk -F '=' '{print $2}')
delay=$(grep -v '^\s*#' "${config_file}" | grep -i -m 1 "daemon" | awk -F '=' '{print $2}')
if [ -z "${delay}" ]
then
command_args="-daemon 300"
else
command_args=""
fi
depend() {
use logger
need net
after firewall
}
start() {
ebegin "Starting ddclient"
start-stop-daemon --start \
--exec "${command}" \
--pidfile "${pidfile}" \
-- \
${command_args}
eend $?
}
stop() {
ebegin "Stopping ddclient"
start-stop-daemon --stop --exec "${command}" \
--pidfile "${pidfile}"
eend $?
}
You need to start ddclient with -daemon=0 or otherwise it forks to background.
You need to start ddclient with
-daemon=0or otherwise it forks to background.
So i would need to set daemon=0 in my /etc/ddclient/ddclient.conf in order to have it run correctly with alpine?
I have tried this and i still get the same status with rc-status of ddclient being crashed.
Also, to provide more info, here is my /etc/ddclient/ddclient.conf right now (with redacted login, password, and zone) and it still outputs crashed in rc-status
# Global settings
use=web
web=checkip.dyndns.com/
syslog=yes
ssl=yes
daemon=300
# CloudFlare
protocol=cloudflare
login=[my login]
password=[my password]
zone=domain.com
sub1.domain.com
sub2.domain.com
So i would need to set
daemon=0in my/etc/ddclient/ddclient.confin order to have it run correctly with alpine?
I don't know if that works. Just modify the command that is run.
I have tried this and i still get the same status with rc-status of ddclient being crashed.
No idea what rc-status is doing.
Also I am not sure if you need pid=/var/run/ddclient.pid.
Long time since I looked at the code and I don't remember all the details anymore.
So i would need to set
daemon=0in my/etc/ddclient/ddclient.confin order to have it run correctly with alpine?I don't know if that works. Just modify the command that is run.
I have tried this and i still get the same status with rc-status of ddclient being crashed.
No idea what rc-status is doing.
Also I am not sure if you need
pid=/var/run/ddclient.pid.Long time since I looked at the code and I don't remember all the details anymore.
Hmm yea ive tried all the above and none seem to work. I really wanted to use ddclient as a daemon task however alpine doesn't seem to like it. I still cant find a single error as to why it is showing crashed.
One thing that i could always do is use a cron job to run ddclient every day to check for IP changes. As this is not ideal since IP changes can happen sporadically, I think its the best option for now.
I will continue to leave this issue open since i think that there may be an error here with the alpine version of ddclient and maybe someone has some ideas as to why it might be happening.
Hi! I probably stumbled on the same issue and I think I got a fix.
TLDR
Check the permissions on /var/cache/ddclient/ddclient.cache; if it's owned by root and not by ddclient run:
# chown ddclient:ddclient /var/cache/ddclient/ddclient.cache
Now you should be able to run ddclient with rc-service with success.
But why
Alpine is trying to run the ddclient service as its dedicated user and needs access to the cache file for that user (you can verify this by reading /etc/init.d/ddclient).
When you run (as I did) ddclient as root first, to test it out, the cache file was owned by root; now, when the user ddclient tries to run the program it fails without proper access to the cache file.
You can verify all of this by following these steps:
- temporarily enable shell access for the
ddclientuser: edit theddclientline in/etc/passwdlike this:
ddclient:x:100:101:ddclient:/var/lib/ddclient:/sbin/nologin
# should turn into:
ddclient:x:100:101:ddclient:/var/lib/ddclient:/bin/ash
- log in as ddclient:
su -l ddclient - Run ddclient with
ddclient --foreground. It will complain that it can't access the cache file and it will fail - Fix the permission on the cache file as described above (remember: you need to be root for that)
- Run ddclient again: it will work now
- When you are done testing, disable login for ddclient user by reverting the edit on
/etc/passwd