loblab / noip-renew

Auto renew (confirm) noip.com free hosts
Apache License 2.0
435 stars 138 forks source link

Necessary changes to noip-renew-skd.sh #51

Open mengelsen opened 3 years ago

mengelsen commented 3 years ago

The following file creates the cron job that allows noip-renew to run once every 4 days: noip-renew-skd.sh

However, this file contains 1 error and 1 suggested improvement.

The Error

The INSTEXE variable points to a file that does not exist. The variable must include the .sh file extension. Wrong: INSTEXE=$INSTDIR/noip-renew-$USER Correct: INSTEXE=$INSTDIR/noip-renew-$USER.sh

Suggested Improvement

I was unable to get the cron job working, until I omitted the $USER parameter from the cron job. I use a raspberry pi. Here are the values that I assigned to the CRONJOB and NEWCJOB variables.

CRONJOB="30 0 * * * $INSTEXE $LOGDIR"
NEWCJOB="30 0 $1 $2 * $INSTEXE $LOGDIR"
requa3r0 commented 3 years ago

cron will not work without a user...but...in debian using the "user" to run the cron job will not work either.

The sudo commend is never executed! Also it would demand the user to be in the sudoers file!

Replace the user with root instead!!! like this CRONJOB="30 0 * * * root $INSTEXE $LOGDIR" NEWCJOB="30 0 $1 $2 * root $INSTEXE $LOGDIR"

NB:

I run the script as several users...because I maintain several noip.com logins

The code does not support this, but you can rename all files + -someuser...and extend for several users. (there are more edits here and there...i should make a pull req. to add multi-users..but im sure loblab can make a better solution for that anyway.)

noip-renew-skd-SOMEUSER.sh noip-renew-SOMEUSER.sh noip-renew-SOMEUSER.py (edit all files for user specific code)

Also make sure your cron detection in all the noip-renew-skd-SOMEUSER.sh is including the user in the sed commenad..like this.

` CRONJOB="33 3 root $INSTEXE $LOGDIR" NEWCJOB="33 3 $1 $2 root $INSTEXE $LOGDIR"

$SUDO sed -i '/noip-renew-'$USER'/d' /etc/crontab

if [ $3 = "True" ]; then echo "$NEWCJOB" | $SUDO tee -a /etc/crontab else echo "$CRONJOB" | $SUDO tee -a /etc/crontab fi

exit 0 `

Sopor commented 3 years ago

I have added exit 0 at the beginning of noip-renew-skd.sh because it will add a cron job that won't work.

This is what i can read in the cron job:

username    /usr/local/bin/noip-renew-username.sh /var/log/noip-renew/username

And if i look in my inbox i can read: /bin/sh: 1: username: not found

I don't understand why it will add my username at the beginning of the command line? I'm running Ubuntu ...

Update: If i remove $USER from these two lines, it seems to work:

CRONJOB="30 0 * * * $INSTEXE $LOGDIR"
NEWCJOB="30 0 $1 $2 * $INSTEXE $LOGDIR"