Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect syntax if-condition S99pollDHCP.sh, line 42 #19

Open
Valenorious opened this issue Feb 21, 2017 · 2 comments
Open

incorrect syntax if-condition S99pollDHCP.sh, line 42 #19

Valenorious opened this issue Feb 21, 2017 · 2 comments

Comments

@Valenorious
Copy link

Valenorious commented Feb 21, 2017

When I tried to execute the S99pollDHCP.sh script to stop it from the commandline I got back:

root@Synna:/usr/local/etc/rc.d# ./S99pollDHCP.sh stop
./S99pollDHCP.sh: line 42: [: : integer expression expected

Looking at that line it seems the text quotation marks are improperly placed. (But I'm a noob at linux scripting) Correcting the conditional statement as follows made it work:
if [ "$MYPID -gt 1" ]; then

I tried also as followed (akin to line 29)
if [ $MYPID -gt "1" ]; then
but this results in error:

root@Synna:/usr/local/etc/rc.d# ./S99pollDHCP.sh stop
./S99pollDHCP.sh: line 42: [: -gt: unary operator expected

Oddly enough this line 29 executes normally when starting the script with:

root@Synna:/usr/local/etc/rc.d# ./S99pollDHCP.sh start
2017-02-21_18:12:35 - is poll-dhcp-changes.sh running?
2017-02-21_18:12:35 - starting poll-dhcp-changes

I'm still a noob when it comes to github and linux scripting so I didn't want to try and make a fork or whatever is needed to make a change in the code. Please verify if this is correct, and not break some other consideration.

Also, I noticed this script only works for the default case of a administrative user "admin". For security reasons I disabled that user and made a custom administrator user. Can these scripts be made more flexible in this regard? Or was there some reason to not deviate from default?

@gclayburg
Copy link
Owner

Hi - it looks like the first error you reported (line 42) happened for you because you ran "S99pollDHCP.sh stop" when poll-dhcp-changes was not running. The script should probably be fixed to deal with this situation better.

You are correct about the permissions issue. These scripts assume everything is run as root. This is because the script needs to modify DNS files that the DNS service also reads and writes to, and it runs as root. It might be possible to modify how these services work, but it would probably involve changing how DNS and DHCP services work in synology? If this is something you'd like to do, I'll take a look at a pull request

gclayburg added a commit that referenced this issue Feb 22, 2017
…ously running

added status command to check current status of poll-dhcp-changes
#19
@gclayburg
Copy link
Owner

Actually I looked into this a little more it might have been due to multiple poll-dhcp-changes.sh processes running. I fixed the script to deal with this better. This is what I get for output when I run this manually:

DiskStation> ./S99pollDHCP.sh status
2017-02-22_09:34:48 - poll-dhcp-changes is running:
21465 root      3768 S    /bin/sh /var/services/homes/admin/poll-dhcp-changes.sh
DiskStation> 
DiskStation> ./S99pollDHCP.sh stop
2017-02-22_09:34:59 - killing PID: 21465
DiskStation> 
DiskStation> ./S99pollDHCP.sh start
2017-02-22_09:35:03 - is poll-dhcp-changes.sh running?
2017-02-22_09:35:03 - starting poll-dhcp-changes
DiskStation> 
DiskStation> pwd
/usr/local/etc/rc.d

gclayburg added a commit that referenced this issue Mar 6, 2017
…ously running

added status command to check current status of poll-dhcp-changes
#19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants