own-your-cloudkey
A script to take a Ubiquity CloudKey Gen2+ and make as damn near vanilla Debian as possible, as well as a bunch of other useful scripts and guides to help you repurpose an old CloudKey and give it a new life in your homelab.
I plan to add to this repo as I go. But for now you can follow the below steps to get started. Send me a Chat Request on Reddit (u/thisiszeev) if you need more steps or something didn't work.
Getting Started
So first hing, take out the harddrive, factory reset it with a pin... then connect to it like you were setting it up with a harddrive except since the drive is not in, it will not configure the drive with it's dozens of partitions. Trust me, you will thank me later.
Do not give the Cloud Key a static IP, rather us reserved IP assignment based on Mac Address with your Router.
Then, in the webgui, update the UniFi system but uninstall any UniFi apps like WiFi, CCTV etc.
Then in one of the areas you get to enable SSH (accept the warning) and give it a password for SSH. I think it is fussy and you need to be 12 character or more, caps, smalls, numbers and symbols.
Then from your linux terminal if you are sane and choose not to use windows, or from an SSH client like putty, ssh into the cloudkey as root@{router_assigned_ip_address}
Now you are passed the easy part. From this point on you are going to question your decisions in life... lol
The cool thing is the CloudKey runs Debian. It's only versiion 11 and can't be upgrade to version 12 or 13 without bricking it, but at least it's Debian so you have a lot of freedom.
You may need to install curl or wget using apt. Use curl or wget to downlad the script file called own.sh to the root folder of the cloudkey. then run the script using bash own.sh
You can read through the script if you want, but everyone always says it's more efficient to uninstall packages in bulk. No it's not, not in this case, as my script covers multiple versions of the UniFi software so there are different packages with different versions. If you remove them in bulk and apt can't find one of them installed, then it fails. So let the script remove one by one, the stuff that is not on your version will fail, ignore it. The stuff that is on your version will uninstall.
Do not try and uninstall any of the UniFi packages left on the cloudkey. It will become unstable and crash and you will have to start again.
I do not uninstall the LED firmware and software and I also leave behind the OLED formware and software. Chat to me when you up and running and I will show you how to make use of the LED for warning/notification lights, and the OLED for displaying status messages of your choosing. Hell I even got it to play a Rick Astley Video.
And this is the part where you ask me "But can it play doom?"
Yes, yes it can, but you have to install x11, sddm, lxqt (or qtlx I can't rememver), and x2go server. Then you need to setup a user login so that you can use an x2go client to open a remote desktop session on the cloudkey via SSH tunneling. Then you can install chocolate and your favourite WAD files. I got about 22-24 frames per second playing doom this way.
Right. Now let's get back to the that harddrive.
Connect it via a USB adapter to a linux system and partition it as a single ext4 partition. If you are brave you can connect it back into the could key and partition it over an SSH session. This is how I did it.
Once partitioned and fitted back into the cloud key we need to create a mount for it so that it mounts at boot.
I created a mountpoint /volume1 owned and grouped by root, perms as 755. Trust me it works this way.
Now your next instinct will be to edit /etc/fstab. Don't. I spent weeks trying to reverse engineer the OverlayFS so that my changes to fstab would be persistent. But sadly, fstab is generated dynamically each time the fucking cloudkey boots. So we need a solution.
create a new fstab file at /root/fstab and I have uploaded a bootup script and service file along with a sample fstab and other goodies to this repo. This will mount the harddrive at boot by reading /root/fstab - you will find it all in folder fstab
When you get this all working and it boots and mounts the drive no problem, contact me again and I will take you down a deeper rabbit hole.
FYI, BTW and Just So You know.... this git repo is hosted on one of my lovely cloudkeys. Giving new life to old, overpriced and redundant technology
DONATIONS
This is the part where I tell you that your donations are how I afford to eat drink pay rent etc. And we will get to that. But I am now all out of CloudKeys and if you have one you can spare, please send me a Chat Request on Reddit (u/thisiszeev) so we can arrange to get it to me in South Africa. I need a spare on so that I can keep testing this own.sh script as with every update, Ubituity changes stuff and I would like to keep experimenting and testing with each new version of UniFi.
On to the begging for money part.
Please consider making me small donation. Even though my scripts are open source and free to use, I still need to eat. And the occasional bottle of wine also goes down well.
- $5 buys me a cup of coffee
- $10 buys me a nice burger
- $20 buys me a bottle of wine
- Anything above that will be awesome as well.
You can send me a donation via Paypal https://www.paypal.com/paypalme/thisiszeev
Drop me a message on Reddit if you do make a donation. u/thisiszeev
Support is only offered freely to those who donate $20 or more. In other words, you would get my direct WhatsApp or Telegram details.