Ubuntu Install Error: "main: line 1758: /opt/pihole/gravity.sh: No such file or directory"

Expected Behaviour:

Install is not proceeding on Ubuntu 18.04.4 LTS. Have tried 5 times and the same errors keep popping up.

Also mention here: https://www.reddit.com/r/pihole/comments/gkrf8p/pihole_installation_on_ubuntu_1804_fails/

Actual Behaviour:

  [✓] Root user check

        .;;,.
        .ccccc:,.
         :cccclll:.      ..,,
          :ccccclll.   ;ooodc
           'ccll:;ll .oooodc
             .;cll.;;looo:.
                 .. ','.
                .',,,,,,'.
              .',,,,,,,,,,.
            .',,,,,,,,,,,,....
          ....''',,,,,,,'.......
        .........  ....  .........
        ..........      ..........
        ..........      ..........
        .........  ....  .........
          ........,,,,,,,'......
            ....',,,,,,,,,,,,.
               .',,,,,,,,,'.
                .',,,,,,'.
                  ..'''.

  [i] Existing PHP installation detected : PHP version 7.2.24-0ubuntu0.18.04.4
  [✓] Disk space check
  [✓] Update local cache of available packages

  [✓] Checking apt-get for upgraded packages... up to date!

  [i] Installer Dependency checks...
  [✓] Checking for dhcpcd5
  [✓] Checking for git
  [✓] Checking for iproute2
  [✓] Checking for whiptail

  [i] SELinux not detected
  [i] Using upstream DNS: Google (ECS) (8.8.8.8, 8.8.4.4)
  [i] Static IP already configured
  [i] Found IPv6 GUA address, using it for blocking IPv6 ads
  [i] IPv4 address: 172.31.4.55/20
  [i] IPv6 address: 2406:da1c:e00:cf02:df91:c5a:bc3d:c39a
  [i] Web Interface On
  [i] Web Server On
  [i] Logging On.
  [✓] Check for existing repository in /etc/.pihole
  [i] Update repo in /etc/.pihole...HEAD is now at 4d25f69 Merge pull request #3321 from pi-hole/release/v5.0
  [✓] Update repo in /etc/.pihole

  [✓] Check for existing repository in /var/www/html/admin
  [i] Update repo in /var/www/html/admin...HEAD is now at b86e4a3 Merge pull request #1247 from pi-hole/release/v5.0
  [✓] Update repo in /var/www/html/admin

  [i] Main Dependency checks...
  [✓] Checking for cron
  [✓] Checking for curl
  [✓] Checking for dnsutils
  [✓] Checking for iputils-ping
  [✓] Checking for lsof
  [✓] Checking for netcat
  [✓] Checking for psmisc
  [✓] Checking for sudo
  [✓] Checking for unzip
  [✓] Checking for wget
  [✓] Checking for idn2
  [✓] Checking for sqlite3
  [✓] Checking for libcap2-bin
  [✓] Checking for dns-root-data
  [✓] Checking for libcap2
  [✓] Checking for lighttpd
  [✓] Checking for php7.2-common
  [✓] Checking for php7.2-cgi
  [✓] Checking for php7.2-sqlite3
  [✓] Checking for php7.2-xml
  [✓] Checking for php-intl

  [✓] Enabling lighttpd service to start on reboot...
  [i] Creating user 'pihole'...useradd: group pihole exists - if you want to add this user to that group, use -g.
  [✗] Creating user 'pihole'

  [i] FTL Checks...

  [✓] Detected x86_64 architecture
  [i] Checking for existing FTL binary...
  [i] Latest FTL Binary already installed (v5.0). Confirming Checksum...
  [i] Checksum correct. No need to download!
usermod: user 'pihole' does not exist
grep: /etc/pihole/setupVars.conf: No such file or directory
  [i] Testing if systemd-resolved is enabled
  [i] Systemd-resolved does not need to be restarted
  [✓] Restarting lighttpd service...
  [✓] Enabling lighttpd service to start on reboot...
  [i] Restarting services...
  [✓] Enabling pihole-FTL service to start on reboot...
  [✓] Restarting pihole-FTL service...
main: line 1758: /opt/pihole/gravity.sh: No such file or directory

I'm on Ubuntu 18.04.4 as well.

It's because of this error:

[i] Creating user 'pihole'...useradd: group pihole exists - if you want to add this user to that group, use -g.
[✗] Creating user 'pihole'

For some reason the script doesn't outright fail. I tried "useradd" directly and it wasn't a recognized command (and apparently deprecated), so I worked around it with "adduser":

sudo adduser --system --shell /usr/sbin/nologin pihole

But of course the two commands have different flags so the pihole group was butchered.

Strangely enough, after successfully installing with the workaround, uninstalling, rebooting... I now had "useradd" available and could reinstall without the workaround.

Also, if you're stuck in a half-installed limbo state where you can no longer curl the install script, try:

echo 'nameserver 8.8.8.8' | sudo tee /etc/resolv.conf

To add to confusion, for me, adduser depends on the passwd package that contains useradd already:

pi@ph5:~ $ hostnamectl | tail -3
  Operating System: Raspbian GNU/Linux 10 (buster)
            Kernel: Linux 4.19.97-v7+
      Architecture: arm

pi@ph5:~ $ apt depends adduser
adduser
  Depends: passwd
[..]

pi@ph5:~ $ which useradd
/usr/sbin/useradd

pi@ph5:~ $ dpkg -S /usr/sbin/useradd
passwd: /usr/sbin/useradd