Reinstall UniFi Network on OpenHABian

This how to helps you to learn how to reinstall UniFi Network on OpenHABian. This might be necessary in case you have a installation that does not work properly anymore or you simply like to get rid of UniFi Network. In this scenario we have installed OpenHABian.  

Reinstall UniFi Network on OpenHABian

Reinstall UniFi Network on OpenHABian

Index Of How To Reinstall UniFi Network on OpenHABian

Background

In this scenario i am using

  • Debian Linux 11 (bullseye), 32 Bit
  • Raspberry Pi 4 Model B Rev 1.5
  • UniFi 7.3.83 
  • MongoDB
  • OpenHAB 4.1.0

This information is relevant for you, as maybe you have an other environment and the below how to might slightly needs to be changed to work for you. For this reason you like to not simply copy and paste the comments, but also consider your situation carefully and adapt where necessary.

Note: Before executing the below, you should make a backup! This is especially needed, if after re-installation you like to grap your old configuration again!

How To Reinstall UniFi Network on OpenHABian 

Check

First of all, we gone to check if UniFi Network is running and whether it is installed. To do so, fire the below command:

sudo service unifi status

This should output something like this:

● unifi.service - unifi
     Loaded: loaded (/lib/systemd/system/unifi.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2023-10-21 11:27:07 CEST; 2h 47min ago
    Process: 5956 ExecStartPre=/usr/sbin/unifi-network-service-helper init (code=exited, status=0/SUCCESS)
    Process: 5991 ExecStartPre=/usr/sbin/unifi-network-service-helper init-uos (code=exited, status=0/SUCCESS)
    Process: 6001 ExecStartPost=/usr/sbin/unifi-network-service-helper healthcheck (code=exited, status=0/SUCCESS)
   Main PID: 6000 (java)
      Tasks: 84 (limit: 4915)
        CPU: 15min 1.599s
     CGroup: /system.slice/unifi.service
             ├─6000 /usr/bin/java -Dfile.encoding=UTF-8 -Djava.awt.headless=true -Dapple.awt.UIElement=true -Dunifi.core.enabled=false -Xmx1024M -XX:+UseParallel>
             └─6112 bin/mongod --dbpath /usr/lib/unifi/data/db --port 27117 --unixSocketPrefix /usr/lib/unifi/run --logappend --logpath /usr/lib/unifi/logs/mongo>

If that’s the case, than you know, UniFi Network is installed on your device. In the above you even can see that it is running.

Deactivate and Unistall

Note: Before executing the below, you should make a backup! This is especially needed, if after re-installation you like to grap your old configuration again!

In my case, i am leveraging on systemctl. For this reason, i am gonna to remove this first. Check if UniFi is enabled. This you do by

systemctl is-enabled unifi

In case its enabled, it simply would say “enabled”:

$ systemctl is-enabled unifi
enabled

Now lets disable, to do so fire the “sudo systemctl disable Unifi” command. Something like the below should be printed on your screen: 

$ sudo systemctl disable unifi
Synchronizing state of unifi.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable unifi
Removed /etc/systemd/system/multi-user.target.wants/unifi.service.

Lets uninstall UniFi Network now. This is simple, fire “apt remove unifi”

sudo apt remove unifi
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
  unifi
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 272 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 99516 files and directories currently installed.)
Removing unifi (7.3.83-19645-1) ...
Updating FireMotD available updates count ...

Reinstall UniFi Network

To do so i am leveraging on a script available by UniFi Community. Alternatively, you can also leverage on the apt install option. However, the script helps you to further configure your installation.

Simply download the script, or alternatively, copy the content and put it into a file on your computer. I have chosen the second option, created a file by executing:

vi install-unifi-script7.5.187.sh

Into this file i have copied the full content. To make the file work, i did the following:

install-unifi-script7.5.187.sh

Now i execute it by the below command and follow the guidance as needed:

sudo ./install-unifi-script7.5.187.sh

Once done, the script should tell you something like the below (note: i have changed the ports. If you have not done this, than you might see a different result):

#########################################################################

# UniFi Network Application 7.3.83 has been installed successfully
# Your application address: https://192.168.2.50:8444

# UniFi is active ( running )

---- NOTE ----

# Your default application port(s) have changed!

# Device Inform port: 8081
# Management Dashboard port: 8444

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

# Author   |  Glenn R.
# Email    |  glennrietveld8@hotmail.nl
# Website  |  https://GlennR.nl

Check if UniFi is running

Of course, once the above is done, you like to double check if your UniFi network is running. To do so, fire 

systemctl is-enabled unifi

In case its enabled, it simply would say “enabled”:

$ systemctl is-enabled unifi
enabled

Once it is enabled, you surf with your browser to https://YOUR IP ADDRESS:YOUR PORT/ . This gives you your login screen:

UniFi Network 7.3.83

UniFi Network 7.3.83

In case you like to restore your previous configuration, then its time to login and the the backup file that you made before. With this you should be able to restore your previous configuration.

Additional Information

Follow me

It would be amazing if you follow my myhowto.blog. To my blog is actually easy! You can leverage on

  • Click to follow me on Twitter
  • Bookmark this page and comeback from time to time

Help and Comments

I am really looking forward for you to contact me if for example you found a better option or other idea then in this how to. Also, please touch base if you found an error or anything not working or if you have something that you would love to be added to the myhowto.blog. Simply click this link to touch base with me.

Linking Or Recommending The How To Or The myhowto.blog

I would love to see you are recommending this how to or link it to your website. Also, I would love if you link or recommend the whole myhowto.blog. Please feel free to do so! In case you like to touch base regarding this topic with me, then simply click this link. I look forward!