This article is my notes for step by step to install and configure set top box Armbian into kiosk device.
Contents
List of Bugs
- browser failed to launch immediately
solution :
add sleep 60 before launching the browser - display need to restart or reattach the hdmi cable if system rebooted.
solution:
use xrandr to relaunch the display driver. Jump to bash part - system boot failur after installing teamviewer.
not fixed yet, maybe because 8GB SD card is insufficient because teamviewer dependencies is really big (800mb++).
- kiosk bash script fail to launch?
maybe because main monitor is turned off when device restarted. For now we try to add cron with xrandr to detect main monitor.
INSTALL LAMP
To install the LAMP stack (Linux, Apache, MySQL, PHP) on Armbian, you can follow these general steps:
-
Update your package list:
sudo apt update
-
Install Apache:
sudo apt install apache2
-
Install MySQL (MariaDB):
sudo apt install mariadb-server
-
Secure your MySQL installation:
sudo mysql_secure_installation
-
Install PHP and necessary modules:
sudo apt install php php-mysql
-
Restart Apache for the changes to take effect:
sudo systemctl restart apache2
After completing these steps, you should have the LAMP stack installed on your Armbian system. Please note that the instructions might vary slightly depending on the version of Armbian you're using. If you encounter any issues, refer to the Armbian documentation or community for further assistance.
Install PHPMYADMIN
To install phpMyAdmin on your Armbian system with the LAMP stack, follow these steps:
-
Install phpMyAdmin and PHP extensions:
sudo apt install phpmyadmin php-mbstring php-*gettext
-
During the installation, you'll be prompted to choose a web server to configure. Select
apache2
by pressing the spacebar and then hit Enter. -
Choose 'Yes' when asked if you want to use dbconfig-common to set up the database. You'll be prompted to provide a MySQL application password.
-
Configure Apache to recognize phpMyAdmin. Create a symbolic link:
sudo ln -s /usr/share/phpmyadmin /var/www/html
-
Edit the Apache configuration file to allow access to phpMyAdmin. Open the file for editing:
sudo nano /etc/apache2/apache2.conf
-
Add the following lines at the end of the file:
Include /etc/phpmyadmin/apache.conf
-
Save and exit the text editor (Ctrl+O, Enter, Ctrl+X).
-
Restart Apache to apply the changes:
sudo systemctl restart apache2
-
If you cant log in to mysql trought phpmyadmin without password, easiest way is adding pasword to your mysql user.
You should now be able to access phpMyAdmin by opening your web browser and navigating to http://your_server_ip/phpmyadmin
.
Please replace your_server_ip
with the actual IP address or hostname of your Armbian system. If you encounter any issues, refer to the phpMyAdmin documentation or Armbian community for assistance.
setting up MySQL user Password
For example, to change the root password for MySQL, follow these steps:
-
Log in to MySQL:
Open a terminal and log in to the MySQL server as the root user. You will be prompted for the current root password:mysql -u root -p
-
Change Password:
Once logged in, you can change the root password using the following MySQL command. Replace'newpassword'
with your desired new password:ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' BY 'newpassword';
if above not working, use this
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
-
Flush Privileges and Exit:
After changing the password, you need to flush privileges for the changes to take effect and then exit MySQL:FLUSH PRIVILEGES; EXIT;
-
Restart MySQL:
Restart the MySQL service to apply the changes:sudo systemctl restart mysql
-
Test New Password:
Verify that the new password works by logging in to MySQL with the new password:mysql -u root -p
Please make sure to choose a strong password and keep it secure. Changing the root password enhances the security of your MySQL installation.
If you encounter any issues during this process, please let me know, and I'll be happy to assist you further.
Install Teamviewer
you can use TeamViewer to access your Armbian device from a remote computer, including a Windows computer. Here's how to set it up:
-
Install TeamViewer on Armbian:
You'll need to download and install TeamViewer on your Armbian device. TeamViewer provides a Linux version for ARM devices. You can download it from the TeamViewer website or use the following commands in the terminal:wget https://download.teamviewer.com/download/linux/teamviewer-host_armhf.deb sudo dpkg -i teamviewer-host_armhf.deb sudo apt-get install -f
-
Start TeamViewer:
After installation, start the TeamViewer service on your Armbian device:sudo teamviewer --daemon start
please note that teamviewer cant use sudo for security concern.
-
Connect to Teamviewer account
After running above command, a TeamViewer dialog will open, asking you to connect your TeamViewer account.
For remote access using TeamViewer on Linux, connecting the TeamViewer application to an account is a prerequisite. -
Obtain TeamViewer ID and Password:
Once the TeamViewer service is running, you'll need to obtain the TeamViewer ID and temporary password for your Armbian device. You can find this information by running:sudo teamviewer info
-
Troubleshooting error installation
- if you encounter issues during accoutn connection, easies way are reinstalling.
sudo apt-get remove teamviewer-host sudo apt-get purge teamviewer-host sudo rm -rf /opt/teamviewer sudo rm -rf ~/.config/teamviewer sudo apt-get install teamviewer-host
- if you encounter issues during accoutn connection, easies way are reinstalling.
-
Install TeamViewer on Windows:
Download and install the TeamViewer application on your Windows computer from the TeamViewer website. -
Connect to Armbian from Windows:
Open TeamViewer on your Windows computer and enter the TeamViewer ID of your Armbian device. If prompted, enter the temporary password you obtained earlier. -
Remote Access:
You should now be able to remotely access your Armbian device from your Windows computer using TeamViewer.
Please keep in mind that using remote desktop applications like TeamViewer might involve sharing your device's screen and control over the internet, which may have security and privacy implications. Be sure to use secure passwords and follow best practices for securing remote access.
If you encounter any issues during the setup, refer to the TeamViewer documentation or community for assistance.
Launch Firefox on reboot
easiest way
sudo crontab -e
then
@reboot sleep 60 && su {user} -c "DISPLAY=:0.0 /usr/bin/firefox --new-window http://www.google.com"
This cron job directive, @reboot sleep 60 && su $user -c "DISPLAY=:0.0 /usr/bin/firefox --new-window http://www.google.com"
, ensures that upon system reboot (@reboot
), a delay of 60 seconds (sleep 60
) is applied before executing a command.
The command uses the su
utility to run a specific command as the user $user
. The -c
flag allows the subsequent command to be executed. The command being executed is designed to launch Firefox (/usr/bin/firefox
) with the specified URL (http://www.google.com
) in a new window, making it automatically open after the system restarts. The DISPLAY=:0.0
part is used to specify the display environment for the graphical application to appear on the primary display.
Other way to open firefox on launch
Introduction:
This guide outlines a step-by-step process to automatically launch Firefox and open a specific URL when your Armbian device reboots. This can be useful for various purposes, such as displaying information on a dedicated screen.
Prerequisites:
- Basic familiarity with the Linux command line.
- Access to your Armbian device.
Steps:
-
Create a Script:
- Open a terminal on your Armbian device.
- Create a script file, for example,
start_firefox.sh
:nano start_firefox.sh
- Add the following lines to the script file. Replace
https://www.example.com
with the desired URL:#!/bin/bash sleep 60 # Delay for 1 minute DISPLAY=:0.0 /usr/bin/firefox --new-window http://www.google.com
- Save the file and exit (
Ctrl + O
, thenEnter
, followed byCtrl + X
).
-
Make Script Executable:
- Make the script executable:
chmod +x start_firefox.sh
- Make the script executable:
-
Move Script to a Suitable Location:
Move the script to a suitable location, such as /usr/local/bin/ to make it easily accessible:sudo mv start_firefox.sh /usr/local/bin/
-
Edit Cron Jobs:
- Open the crontab file for editing:
crontab -e
- Open the crontab file for editing:
-
Add Cron Job with Delay:
- Add the following line to the crontab file to schedule the script with a delay after reboot (e.g., 2 minutes in this example):
*/2 * * * * /usr/local/bin/start_firefox.sh
- Add the following line to the crontab file to schedule the script with a delay after reboot (e.g., 2 minutes in this example):
-
Save and Exit:
- Save the crontab file and exit the text editor.
-
Reboot:
- Reboot your Armbian device to test the setup:
sudo reboot
- Reboot your Armbian device to test the setup:
Explanation:
- The script
start_firefox.sh
is created to launch Firefox with the specified URL. - The
@reboot
cron job with a delay is set to run the script after a specified period when the system reboots. - The delay ensures that the system fully initializes before executing the script.
Using Chromium
-
fullscreen no restore
@reboot sleep 60 && su {user} -c "DISPLAY=:0.0 /usr/bin/chromium-browser --new-window --start-fullscreen --no-restore-session http://www.google.com"
-
no cursor (kiosk mode)
- install unclutter to hide mouse cursor
sudo apt-get install unclutter
- launch in kiosk mode and unclutter
@reboot sleep 30 && su {user} -c "DISPLAY=:0.0 unclutter -idle 0.1 -root"
@reboot sleep 60 && su {user} -c "DISPLAY=:0.0 /usr/bin/chromium-browser --noerrdialogs --disable-infobars --kiosk --incognito --disable-session-crashed-bubble --disable-session-restore http://www.google.com"
- install unclutter to hide mouse cursor
change {user} to the active user
in kiosk mode, to exit the fullscreen, use ctrl+w
Conclusion:
By following these steps, you can configure your Armbian device to automatically launch Firefox and open a specific URL upon reboot. This can be useful for displaying information, dashboards, or other web-based content.
Please remember that automatically launching applications on startup may have security and performance implications, so use these instructions responsibly and ensure your device's security.
bash script launch chromium
for the xrandr line, first we need to know which display is detected, then we can move on to relaunch the display
-
list detected display
export DISPLAY=:0.0 xrandr
-
then we can continue to make bash script for cron
#!/bin/bash # Give some time for the X server to start sleep 60 # fix for armbian not detecting hdmi device on boot export DISPLAY=:0.0 XAUTHORITY=/HOME/${user/.Xauthority xrandr --output HDMI-1 --auto # Give some time for the display to settle sleep 10 # launch chromiun as kiosk mode export DISPLAY=:0.0 XAUTHORITY=/HOME/${user}/.Xauthority /usr/bin/chromium --noerrdialogs --disable-infobars --kiosk --incognito --disable-session-crashed-bubble --disable-session-restore https://google.com
change
${user}
to the logged in user -
script to relaunch display if no display avtive (but connected).
I personally use below script on cron with interval 10 minutes
#!/bin/bash # Set main monitor and X display authority main_monitor="HDMI-1" export DISPLAY=:0.0 XAUTHORITY=/home/$USER/.Xauthority chromium_command="/usr/bin/chromium --noerrdialogs --disable-infobars --kiosk --incognito --disable-session-crashed-bubble --disable-session-restore https://my.masaj.id/view.masjid?preview=3032084D38" # Function to restart Chromium restart_chromium() { pkill chromium $chromium_command } # Get current date and time timestamp=$(date "+%Y-%m-%d %H:%M:%S") # Check if HDMI-1 is found in the xrandr output if /usr/bin/xrandr | grep -q "$main_monitor connected"; then # Get the currently active display active_display=$(/usr/bin/xrandr | awk '/\ connected/ && /[[:digit:]]x[[:digit:]].*+/{print $1}') # Check if the active display is the main monitor if [ "$active_display" = "$main_monitor" ]; then echo "$timestamp - Active Display: $active_display" # Check if Chromium is running using top isthere=$(top -b -n 1 | grep -w chromium) if [ -n "$isthere" ]; then echo "$timestamp - Chromium is already running on $main_monitor" else echo "$timestamp - Chromium is not running on $main_monitor, launching..." restart_chromium fi else # Switch to the main monitor if it's not the active display export DISPLAY=:0.0 XAUTHORITY=/home/$USER/.Xauthority echo "$timestamp - Active Display: $active_display" # Turn off the current display, switch to the main monitor, and restart it xrandr --output $active_display --off xrandr --output $main_monitor --auto echo "$timestamp - $main_monitor restarted" # Wait for the changes to take effect sleep 5 # Terminate any existing Chromium processes and launch a new instance restart_chromium fi else # If HDMI-1 is not found, terminate Chromium and log the monitor status pkill chromium echo "$timestamp - $main_monitor monitor is down" fi