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

Error in hostsblock on Ubuntu #69

Open
glitsj16 opened this issue Jul 28, 2017 · 5 comments
Open

Error in hostsblock on Ubuntu #69

glitsj16 opened this issue Jul 28, 2017 · 5 comments
Assignees
Labels
annoyance A "bug" that doesn't affect performance or functionality, but looks bad.

Comments

@glitsj16
Copy link

Hi, using latest hostsblock on Ubuntu returns an error. The same version on Archlinux does not. Seems not critical, hosts.block is updated as expected.

Ubuntu 16.04.2 LTS

$ sudo systemctl start hostsblock

$ systemctl status hostsblock
...
Jul 28 04:14:44 crow16 hostsblock[8448]: /usr/bin/hostsblock: line 442: [: /var/lib/hostsblock/hosts.head: integer expression expected
...

Regards

@gaenserich
Copy link
Owner

gaenserich commented Jul 28, 2017 via email

@glitsj16
Copy link
Author

Thanks for the hint. I couldn't get rid of the stderr using your suggested change. But as I always use the hosthead functionality I got away with:

if [ "$hostshead" == 0 ]; then

@gaenserich gaenserich self-assigned this Mar 25, 2018
@gaenserich gaenserich added the annoyance A "bug" that doesn't affect performance or functionality, but looks bad. label Mar 25, 2018
@MrCowKing
Copy link

I've run into a few issues with shell scripts. Shellcheck is a good resource to help refine/fix any naggling issues. I'd offer to push my "fixed" scripts, but I'm not sure if this would have any negative effect on other distros. I'm using Ubuntu 16.04

@gaenserich
Copy link
Owner

gaenserich commented Apr 4, 2018 via email

@MrCowKing
Copy link

Here's the output of shellcheck on "install.sh" of the master branch:

In install.sh line 11:
if $(which $dep) &>/dev/null; then
^-- SC2091: Remove surrounding $() to avoid executing output.

In install.sh line 22:
if [ "$d" != "" ] || [ -n $d ]; then
^-- SC2070: Always true because you failed to quote. Use [[ ]] instead.
^-- SC2086: Double quote to prevent globbing and word splitting.

In install.sh line 32:
if [ "$h" != "" ] || [ -n $h ]; then
^-- SC2070: Always true because you failed to quote. Use [[ ]] instead.
^-- SC2086: Double quote to prevent globbing and word splitting.

In install.sh line 49:
if ps aux | grep [d]nsmasq | tr -s ' ' | cut -d' ' -f 11- | grep -q [d]nsmasq; then
^-- SC2009: Consider using pgrep instead of grepping ps output.
^-- SC2062: Quote the grep pattern so the shell won't interpret it.
^-- SC2062: Quote the grep pattern so the shell won't interpret it.

In install.sh line 50:
dnsmasq_user=$(ps aux | grep [d]nsmasq | tr -s ' ' | cut -d' ' -f 1)
^-- SC2009: Consider using pgrep instead of grepping ps output.
^-- SC2062: Quote the grep pattern so the shell won't interpret it.

In install.sh line 60:
if [ "$dns" != "" ] || [ -n $dns ]; then
^-- SC2070: Always true because you failed to quote. Use [[ ]] instead.
^-- SC2086: Double quote to prevent globbing and word splitting.

Here's the output of running "sudo ./install.sh" without modifications:

getent utility missing. Please install before running this script. Exiting...

Here's the output of the same command after fixing only the first warning:

Destination directory for hostsblock is /usr/bin/. Enter a new path or press Enter to keep as is.
/usr/bin/
Using preexisting user 'hostsblock'
Using preexisting group 'hostsblock'
Adding user hostsblock to group hostsblock
You appear to be running dnsmasq under user libvirt+
root
dnsmasq. If you will be using hostsblock
with dnsmasq as a caching daemon, dnsmasq needs read access to hostsblock's home directory.
To do so, should I add libvirt+
root
dnsmasq to the hostblock group?
y/N y
gpasswd: user 'libvirt+
root
dnsmasq' does not exist
gpasswd: user 'libvirt+
root
dnsmasq' does not exist
In order to manage hostsblock correctly, you must run the script as the user 'hostsblock',
even when using the 'hostsblock-urlcheck' script (aka 'hostsblock -c').
To do so, type 'sudo -u hostsblock hostsblock' or 'sudo -u hostsblock hostsblock-urlcheck', etc.
Before you can do this, however, the following line must be added to sudoers:

jake ALL = (hostsblock) NOPASSWD: /hostsblock,/hostsblock-urlcheck

where 'jake' is the user from which you want to manage hostsblock.
Do you want to add this line to the bottom of sudoers right now? (if so, make sure to copy the text now).
[y/N]
Setting up permissions for hostsblock home directory ...
chown: cannot access '': No such file or directory
chmod: cannot access '': No such file or directory
Should I enable and/or start the hostsblock service? (Requires systemd)
1) Only Enable
2) Only Start
3)Start and Enable
4) Do Nothing (Default)
[1-4]
hostsblock is now installed. Check out the configuration file under /hostsblock.conf.
By default, hostsblock does not directly write to /etc/hosts or manipulate your dnsmasq daemon.
To make it do so, see the instructions included in /hostsblock.conf

I hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
annoyance A "bug" that doesn't affect performance or functionality, but looks bad.
Projects
None yet
Development

No branches or pull requests

3 participants