Problem: unexpected operator in init.d script

Posted by tsmg 
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Now, this forum is in read-only mode. You find details Details hereContinue on /r/PirateBox
Problem: unexpected operator in init.d script
October 05, 2016 01:29PM
Hi people!

I'm trying to install Piratebox in a old laptop with Ubuntu 16.04 "Xenial Xerus", following the steps shown here:

https://piratebox.cc/laptop
http://www.raspibo.org/wiki/index.php/ChiPirate-BOX:_the_chipest_and_cheapest_Pirate-BOX_ever

but I have a problem with the init.d script. When I try to boot the service, this is the result:

$ sudo /etc/init.d/piratebox start
  * Starting script piratebox                                                               
Generating hosts file .... 
Generating dnsmasq.conf .....
Generating Environment-config for lighttpd .....
Empty tmp folder
rm: I can't remove  '/opt/piratebox/tmp/': is a directory
Copy over directory design files
/opt/piratebox/bin/json_generation.sh: 7: [: yes: unexpected operator
/opt/piratebox/bin/json_generation.sh: 7: [: yes: unexpected operator
Generating json configuration file: /opt/piratebox/www/piratebox_config.json
/opt/piratebox/bin/json_generation.sh: 34: [: yes: unexpected operator
 *   Probing wlan                            Probing interface wlx00116bc295a3 
 *   Starting hostap...                              [ OK ] 
 *   Setting up wlan                         Bringing up wifi interface wlx00116bc295a3  
                                                          Setting up wlx00116bc295a3
 * Starting dnsmasq...                                                              [ OK ] 
 * Setting up firewall rules...                                                     [ OK ] 
/etc/init.d/piratebox: 158: [: no: unexpected operator
 * Starting droopy...                                                               [ OK ] 
Generated HTML-Shoutbox File.
CRITICAL: /opt/piratebox/share/Shared modified 4 minutes ago. Threshold set to 5 minutes. Cannot update.
Generated HTML-DiskUsage File.
 * Starting lighttpd...                                                [OK]

It seems that the syntax of the script is wrong or is no compatible with systemd, among other things.
It has also happened to me in a AntiX distro (based in Debian).

Anyone would think how to solve it?

Thanks in advance.



Edited 2 time(s). Last edit at 10/05/2016 08:22PM by tsmg.
Re: Problem: unexpected operator in init.d script
October 05, 2016 06:55PM
Hi,
this is a classical issue between shell compatibility.
Because of the fact, that I hadn't much time I didn't made a cross check.. so a script called on archlinux (bash) and Openwrt (ash?) works. AntiX distro seems to use something different, which is a bit more picky in that particular case.

As long as you don't want to use IPv6 or the JSON config-info file, you don't need to worry.

The fix looks like this:
[github.com]

I won't release a 1.1.3 now for that, but it is queued for the next hotfix release.

Thanks for reporting smiling smiley

best regards
Matthias
To fix tmp folder error
sudo nano /opt/piratebox/init.d/piratebox

Line ~94
Change:
find   $ARKBOX/tmp/ -exec rm {} \;
to:
find   $ARKBOX/tmp/* -exec rm {} \;"

-------------------------------------------------------

To fix json_generation.sh error

sudo nano /opt/piratebox/bin/json_generation.sh

Line 1
Change:
#!/bin/sh
To:
#!/bin/bash

-------------------------------------------------------

Hope this helps!