UniFi CK-G2-Plus Rotate LCD script
Long time no post. I managed to pick up a Unifi Cloud Key rackmount kit off eBay recently for a fair bit cheaper than the crazy RRP ($189.00AUD). Not entirely sure if it was DOA or if I managed to damage it inserting/removing the Cloud Key upon install but I am leaning more towards DOA.
Anyway, when inserting the CK into the rackmount it mounts upside down. This then means that the LCD display also displays upside down. When the CK rackmount functions correctly, there are pins that connect the rackmount to the CK which then enables the front mount ethernet port & powers the LED Unifi logo along with rotating the screen to the correct orientation.
Unfortunately, in my situation neither of these are working - regardless, I wanted to have the LCD display the correct way up. There is a simple command that will change the orientation of the screen along with some other settings such as brightness and power source.
In order to achieve this, you can simply issue the command below, however upon reboot the Cloud Key doesn’t retain this. To resolve this problem, I setup a cron job to issue the command after every reboot.
Rotation commands;
Rotate to correct orientation (180 when rack mounted)
echo 0 > /sys/class/graphics/fb0/rotate
Rotate to correct orientation when standalone/desktop mount
echo 1 > /sys/class/graphics/fb0/rotate
First step was to create a shell script that would be executed upon startup of the Cloud Key, I found that it couldn’t be located in the /home directory as this wasn’t mounted when the cron task executed. The solution to this was to save the script into “/srv/unifi/data” this should also remain intact upon Cloud Key firmware updates.
Open your editor of choice,
Sudo nano /srv/unifi/data/roratescreen.sh
#!/bin/bash
echo 0 > /sys/class/graphics/fb0/rotate
Exit Nano saving changes. We then need to make the shell script executable, to do this we need to use CHMOD.
chmod u+x /srv/unifidata/rotatescreen.sh
Now that our shell script is executable it’s a just a process of creating the cronjob to execute the script each time that the Cloud Key boots. To do this we use crontab
sudo crontab -e
Add a new like referencing the script using the following parameters
@reboot /srv/unifi/data/rotatescreen.sh
Once that is complete, save the config and reboot to test.