Olimex-A20: Difference between revisions

From Geitenpad
Jump to navigation Jump to search
 
(10 intermediate revisions by the same user not shown)
Line 11: Line 11:
* Connect with ssh, user root, passwd is in filename.
* Connect with ssh, user root, passwd is in filename.
* Change password (passwd) for root
* Change password (passwd) for root
* Install utilities: vim htop usbutils screen locate
* Install utilities: wget vim htop usbutils screen locate
* Change hostname (/etc/hostname) to olimex
* Change hostname (/etc/hostname) to olimex
* Add user olimex
root@debian:~# adduser olimex
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for olimex
Enter the new value, or press ENTER for the default
        Full Name []:
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n]


== Wifi ==
== Wifi ==
  https://wiki.debian.org/WiFi/HowToUse#IWCtl
  https://wiki.debian.org/WiFi/HowToUse#IWCtl
* export wlan0=wlx00e1b0860271
* add non-free to sources list:
* export ssid=Geitenpad
root@olimex:~# cat /etc/apt/sources.list
* apt install -y iwd
deb http://deb.debian.org/debian trixie main contrib non-free
deb-src http://deb.debian.org/debian trixie main contrib non-free
deb http://deb.debian.org/debian trixie-updates main contrib non-free
deb-src http://deb.debian.org/debian trixie-updates main contrib non-free
deb http://security.debian.org/debian-security trixie-security main contrib non-free
deb-src http://security.debian.org/debian-security trixie-security main contrib non-free
* Install driver:
wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/rt2870.bin
root@olimex:~# cp rt2870.bin /lib/firmware/
root@olimex:~# chmod 644 /lib/firmware/rt2870.bin
root@olimex:~# chown root:root /lib/firmware/rt2870.bin
* apt install -y iwd iproute2
* vim /etc/iwd/main.conf to enable networking
EnableNetworkConfiguration=true
* Add olimext to netdev group
root@olimex:~# groupadd netdev
root@olimex:~# usermod -aG netdev olimex
* create config file:
root@olimex:~# cat /etc/dbus-1/system.d/iwd.conf
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
    <!-- Allow members of group 'netdev' to talk to iwd -->
    <policy group="netdev">
        <allow send_destination="net.connman.iwd"/>
    </policy>
    <!-- Root always allowed -->
    <policy user="root">
        <allow own="net.connman.iwd"/>
        <allow send_destination="net.connman.iwd"/>
    </policy>
</busconfig>
* systemctl --now enable iwd
* systemctl --now enable iwd
* vim /etc/iwd/main.conf
* systemctl restart iwd
* service iwd restart
* systemctl restart iwd
* exit to olimex !!!
* exit to olimex !!!
* iwctl (configure, type help for commands)
* iwctl (configure, type help for commands)
* reboot, unplug wired network
* reboot, unplug wired network
* systemctl enable --now systemd-resolved
* ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
* reboot


== Snapcast ==
== Snapcast ==
* apt install mlocate snapserver snapclient
* apt install snapclient
* systemctl --now disable snapserver
* vim /etc/default/snapclient
* vim /etc/default/snapclient
  SNAPCLIENT_OPTS="-h 192.168.2.70"
  SNAPCLIENT_OPTS="-h 192.168.2.70"

Latest revision as of 16:01, 2 December 2025

Type

A20-OLinuXino-MICRO

Als snapcast client

Installation

  • Download Debian image (https://sd-card-images.johang.se/boards/a20_olinuxino_micro.html -> follow instructions).
  • Boot from card with HDMI and Network connected.
  • No partition enlargement necessary.
  • Connect with ssh, user root, passwd is in filename.
  • Change password (passwd) for root
  • Install utilities: wget vim htop usbutils screen locate
  • Change hostname (/etc/hostname) to olimex
  • Add user olimex
root@debian:~# adduser olimex
New password: 
Retype new password: 
passwd: password updated successfully
Changing the user information for olimex
Enter the new value, or press ENTER for the default
       Full Name []: 
       Room Number []: 
       Work Phone []: 
       Home Phone []: 
       Other []: 
Is the information correct? [Y/n]

Wifi

https://wiki.debian.org/WiFi/HowToUse#IWCtl
  • add non-free to sources list:
root@olimex:~# cat /etc/apt/sources.list
deb http://deb.debian.org/debian trixie main contrib non-free
deb-src http://deb.debian.org/debian trixie main contrib non-free

deb http://deb.debian.org/debian trixie-updates main contrib non-free
deb-src http://deb.debian.org/debian trixie-updates main contrib non-free 

deb http://security.debian.org/debian-security trixie-security main contrib non-free
deb-src http://security.debian.org/debian-security trixie-security main contrib non-free
  • Install driver:
wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/rt2870.bin
root@olimex:~# cp rt2870.bin /lib/firmware/
root@olimex:~# chmod 644 /lib/firmware/rt2870.bin
root@olimex:~# chown root:root /lib/firmware/rt2870.bin
  • apt install -y iwd iproute2
  • vim /etc/iwd/main.conf to enable networking
EnableNetworkConfiguration=true
  • Add olimext to netdev group
root@olimex:~# groupadd netdev
root@olimex:~# usermod -aG netdev olimex
  • create config file:
root@olimex:~# cat /etc/dbus-1/system.d/iwd.conf
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>

   <policy group="netdev">
       <allow send_destination="net.connman.iwd"/>
   </policy>

   <policy user="root">
       <allow own="net.connman.iwd"/>
       <allow send_destination="net.connman.iwd"/>
   </policy>

</busconfig> 
  • systemctl --now enable iwd
  • systemctl restart iwd
  • systemctl restart iwd
  • exit to olimex !!!
  • iwctl (configure, type help for commands)
  • reboot, unplug wired network

Snapcast

  • apt install snapclient
  • vim /etc/default/snapclient
SNAPCLIENT_OPTS="-h 192.168.2.70"

Verouderd, als server

Burn card

rijk@rijksUreich:~$ dd bs=4M oflag=sync if=A20_debian_kernel_3_4_LAN_USBx2_Cards_LCD_HDMI_SATA_TS_X_GPIO_OTG_MIC_Video_accel_release7.img of=/dev/mmcblk0

Enlarge root partition

I use an 8GB card but the image is only 4GB, in order to use everything I have to enlarge the partition.

  • Put Card in cardreader of my laptop
rijk@rijksUreich:~$ cfdisk -Ps /dev/mmcblk0
Partition Table for /dev/mmcblk0
                First        Last
# Type         Sector      Sector   Offset    Length Filesystem Type (ID) Flag
  Pri/Log           0        2047      0#       2048 Free Space           None
1 Primary        2048       34815      0       32768 Linux (83)           None
2 Primary       34816     7774207      0     7739392 Linux (83)           None
  Pri/Log     7774208    15644671      0     7870464 Free Space           None
rijk@rijksUreich:~$ sudo cfdisk /dev/mmcblk0
  • Remove Partition 2 and create new one with filesystem 83
  • Boot from disk and run
root@a20-OLinuXino:~# resize2fs /dev/mmcblk0p2

Later with debian 8 Olimex provided a script:

resize_sd.sh /dev/mmcblk0 2

Start network on eth0

root@a20-OLinuXino:~# dhclient eth0

Install vim

root@a20-OLinuXino:~# aptitude install vim

Start eth0 on boot

root@a20-OLinuXino:~# vim /etc/network/interfaces
  • Add lines:
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

Install MySQL

root@a20-OLinuXino:~# aptitude install mysql-server mysql-client
  • Configure caching:
root@paardenpad:/etc/mysql/conf.d# vim paardenpad.cnf
[mysqld]
max_connections=500
key_buffer_size=384M
max_allowed_packet=16M
table_cache=256
sort_buffer_size=2M
read_buffer_size=2M
join_buffer_size=2M 
# if you are performing GROUP BY or ORDER BY queries on tables that # are much larger than your available memory, you should increase # the value of read_rnd_buffer_size to speed up the reading of rows # following sorting operations. # but: change the session variable only from within those clients # that need to run large queries read_rnd_buffer_size=2M
max_heap_table_size=256M tmp_table_size=256M
myisam_sort_buffer_size=64M
# increase until threads_created doesnt grow anymore thread_cache=256
query_cache_type=1 query_cache_limit=1M query_cache_size=32M
# Try number of CPU's*2 for thread_concurrency thread_concurrency=4

Install Apache

root@a20-OLinuXino:~# aptitude install apache2
root@a20-OLinuXino:~# aptitude install apache2-threaded-dev debhelper cdbs dpatch libtool
root@a20-OLinuXino:~# vim /etc/apache2/mods-enabled/userdir.conf
<IfModule mod_userdir.c>
       UserDir public_html
       UserDir disabled root
       <Directory /home/*/public_html>
               AllowOverride All
               Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
               <Limit GET POST OPTIONS>
                       Order allow,deny
                       Allow from all
               </Limit>
               <LimitExcept GET POST OPTIONS>
                       Order deny,allow
                       Deny from all
               </LimitExcept>
       </Directory>
</IfModule>
root@a20-OLinuXino:/root/build# apt-get -b source libapache-mod-fastcgi
root@a20-OLinuXino:/root/build# dpkg -i libapache2-mod-fastcgi_2.4.7~0910052141-1_armhf.deb
root@a20-OLinuXino:/root/build# a2enmod fastcgi actions
root@a20-OLinuXino:/var/www/fastcgi# chown www-data:www-data /var/www/fastcgi
root@a20-OLinuXino:/var/www/fastcgi# vim /etc/apache2/mods-available/fastcgi.conf 
<IfModule mod_fastcgi.c>
 AddHandler fastcgi-script .fcgi
 #FastCgiWrapper /usr/lib/apache2/suexec
 FastCgiIpcDir /var/lib/apache2/fastcgi
 Alias /php5.fastcgi /var/www/fastcgi/php5.fastcgi
 AddHandler php-script .php
 FastCGIExternalServer /var/www/fastcgi/php5.fastcgi -socket /var/run/php5-fpm.sock
 Action php-script /php5.fastcgi virtual
</IfModule>

Install PHP

root@a20-OLinuXino:~# aptitude install php5 php5-mysql libapache2-mod-php5
root@a20-OLinuXino:~# vim /etc/apache2/mods-available/php5.conf
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
   SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
   SetHandler application/x-httpd-php-source
   # Deny access to raw php sources by default
   # To re-enable it's recommended to enable access to the files
   # only in specific virtual host or directory
   Order Deny,Allow
   Deny from all
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(p[345]?|t|tml|ps)$">
   Order Deny,Allow
   Deny from all
</FilesMatch> 
# Running PHP scripts in user directories is disabled by default # # To re-enable PHP in user directories comment the following lines # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it # prevents .htaccess files from disabling it. #<IfModule mod_userdir.c> # <Directory /home/*/public_html> # php_admin_value engine Off # </Directory> #</IfModule>

Install phpMyAdmin

root@a20-OLinuXino:/var/www# aptitude install phpmyadmin
  • Deny external access
root@paardenpad:/etc/apache2/conf.d# vim phpmyadmin.conf
  • Add lines:
Order Allow,Deny
Allow from 127.0.0.1       
Allow from 192.168.2.0/24

Install Apc

root@a20-OLinuXino:/var/www# apt-get install php-apc
root@a20-OLinuXino:~# vim /etc/php5/conf.d/20-apc.ini
extension=apc.so 
apc.enabled=1 apc.shm_size=128M apc.ttl=3600 apc.user_ttl=7200 apc.gc_ttl=3600 apc.max_file_size=1M apc.stat=0

Install Tomcat

root@a20-OLinuXino:/var/www# apt-get install tomcat7
root@a20-OLinuXino:/var/www# aptitude install tomcat7-admin
  • Add roles manager-gui and admin-gui to user tomcat /etc/tomcat7/tomcat-users.xml

Remove xscreensaver from autostart in LXDE

root@a20-OLinuXino:~# vim /etc/xdg/lxsession/LXDE/autostart
  • Remove line with xscreensaver.

Disable graphical login

root@a20-OLinuXino:~# rm /etc/rc2.d/S01slim
root@a20-OLinuXino:/etc/rc2.d# vim /etc/rc.local
  • comment line:
chmod 777 /dev/disp  /dev/cedar_dev /dev/ump  /dev/mali

Later with Debian 8 change line in /etc/X11/default-display-manager

/usr/sbin/lightdm

to

/usr/bin/true
root@A20-OLinuXino:~# vim /etc/X11/default-display-manager

Move /var to ssd

  • Create partition on ssd using GParted
root@a20-OLinuXino:~# mount /dev/sda1 /mnt/sd
root@a20-OLinuXino:~# rsync -aHAX /var/ /mnt/sd
  • Shutdown and remove contents of /var from sdcard

Remove user olimex

root@a20-OLinuXino:~# userdel -r olimex

Push public key to olimex

rijk@rijksUreich:~$ cat .ssh/id_rsa.pub | ssh olimex 'cat >> .ssh/authorized_keys'

Change root password

root@a20-OLinuXino:/home/rijk# passwd

Prevent root login over ssh

root@a20-OLinuXino:/home/rijk# vim /etc/ssh/sshd_config
set value for PermitRootLogin: PermitRootLogin no

Setup nfs server

root@a20-OLinuXino:/home/rijk# aptitude install nfs-kernel-server nfs-common
root@a20-OLinuXino:/home/rijk# vim /etc/exports
  • Add line:
/home/rijk/Documents	192.168.2.0/24(crossmnt,rw,no_root_squash,sync,no_subtree_check)
root@a20-OLinuXino:/home/rijk# /etc/init.d/nfs-kernel-server start

Setup userdir for apache

rijk@a20-OLinuXino:~$ mkdir public_html
  • Copy content with Nautilus

Sync documents from server to olimex

rijk@paardenpad:~> rsync -aze /home/rijk/Documents/* -e ssh olimex:/home/rijk/Documents

Configure https (https://wiki.debian.org/Self-Signed_Certificate)

root@a20-OLinuXino:/etc/ssl/localcerts# openssl req -new -x509 -days 1095 -nodes -out /etc/ssl/localcerts/paardenpad.pem -keyout /etc/ssl/localcerts/paardenpad.key
root@a20-OLinuXino:/etc/ssl/localcerts# chmod 600 /etc/ssl/localcerts/paardenpad.*
root@a20-OLinuXino:/etc/apache2/sites-available# a2enmod ssl
root@a20-OLinuXino:/etc/apache2/sites-available# cp default-ssl paardenpad-ssl
vim paardenpad-ssl
  • Add lines:
NameVirtualHost *:443
SSLCertificateFile    /etc/ssl/localcerts/paardenpad.pem
SSLCertificateKeyFile /etc/ssl/localcerts/paardenpad.key

root@a20-OLinuXino:/etc/apache2/sites-available# a2ensite paardenpad-ssl

Change hostname

root@a20-OLinuXino:/home/rijk# vim /etc/hostname
root@a20-OLinuXino:/home/rijk# vim /etc/hosts
  • Change both values to paardenpad.xs4all.nl

Limit access to apache applications and modules

root@paardenpad:/etc/apache2/mods-available# vim userdir.conf
root@paardenpad:/etc/phpmyadmin# vim apache.conf
  • Change access to:
Allow from 192.168.2.0/24

Locale

root@paardenpad:/home/rijk# dpkg-reconfigure locales
  • Choose NL-UTF-8
root@paardenpad:/home/rijk# dpkg-reconfigure tzdata
  • Choose Amsterdam

Install Sendmail

root@paardenpad:/var/www/upload# apt-get install sendmail

Colored prompt

  • Set colors in .bashrc
Root: PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
User: PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
  • For user add file .bash_profile:
rijk@paardenpad:~$ cat .bash_profile 
# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
   . ~/.bashrc
fi

Install DenyHosts

root@paardenpad:/home/rijk# aptitude install denyhosts
  • Configure in /etc/denyhosts.conf

Install Mutt

root@paardenpad:/var/log# aptitude install mutt

Install gtkterm

root@a20:~# aptitude install intltool gcc libvte-2.90-dev libvte-dev libgtk-3-dev libgtk2.0-dev
root@a20Lime:~# git clone https://github.com/jiankangshiye/gtkterm
root@a20Lime:~# cd gtkterm
root@a20:~# ./autogen
root@a20:~# ./configure
root@a20:~# make
root@a20:~# make install

Disable mail messages by cron

Add >/dev/null 2>&1 to cronjob. E.g.

*/15  * * * *   root php -f /var/www/owncloud/cron.php >/dev/null 2>&1
*/5   * * * *   root fswebcam -r 1920x540 --jpeg 85 -D 3 /var/www/webcam/photo0.jpg >/dev/null 2>&1

Install Samba

root@paardenpad:/var/log# aptitude install samba
root@paardenpad:/etc/samba# mv smb.conf smb.conf.org
root@paardenpad:/etc/samba# vim smb.conf
[global]
   netbios name = SAMBASERVER
   workgroup = PAARDENPAD
   server string = Samba %v on (%L)
   encrypt passwords = Yes
   name resolve order = bcast host
   local master = Yes
   os level = 33
   load printers = no
   printing = bsd
   printcap name = /dev/null
   disable spoolss = yes
[rijk]
   path = /home/rijk/Documents
   guest ok = No
   comment = Rijks documents
   writable = Yes
[miel]
   path = /home/miel
   guest ok = No
   comment = Miels documents
   writable = Yes
[oosterhoff]
   path = /home/oosterhoff
   guest ok = No
   comment = Shared documents
   writable = yes


root@paardenpad:/etc/samba# pdbedit -a -u rijk
root@paardenpad:/etc/samba# pdbedit -a -u miel
root@paardenpad:/etc/samba# pdbedit -a -u oosterhoff

Disabling / Enabling services

root@paardenpad:/etc/rc5.d# update-rc.d samba remove
root@paardenpad:/etc/rc5.d# update-rc.d samba defaults

Install NFS

root@paardenpad:/#aptitude install nfs-kernel-server nfs-common
root@paardenpad:/etc/init.d# vim /etc/exports 
  • Add line
/home/rijk/Documents    192.168.2.0/24(crossmnt,rw,no_root_squash,sync,no_subtree_check)

Userrights and groups

root@paardenpad:/etc/rc5.d# addgroup oosterhoff
root@paardenpad:/etc/rc5.d# usermod -g oosterhoff rijk
root@paardenpad:/etc/rc5.d# usermod -g oosterhoff miel
root@paardenpad:~/scripts# vim setUserRights
#!/bin/bash
chown -R rijk:oosterhoff /home/rijk
chmod -R 755 /home/rijk/*
chmod -R 775 /home/rijk/Documents/Pictures
chown -R miel:users /home/miel
chmod -R 755 /home/miel/*
chmod -R 775 /home/oosterhoff/
root@paardenpad:~/scripts# mkdir /home/oosterhoff
root@paardenpad:~/scripts# chown rijk:oosterhoff /home/oosterhoff
root@paardenpad:~/scripts# ./setUserRights

Push ssh key on server

rijk@paardenpad:~/.ssh$ ssh-keygen -t rsa
  • Alle enters, no passphrase
rijk@paardenpad:~/.ssh$ ssh-copy-id rijk@server

/etc/hosts

root@paardenpad:/home/rijk/.ssh# cat /etc/hosts
127.0.0.1 localhost paardenpad.xs4all.nl
192.168.2.20 server

/etc/crontab

root@paardenpad:~/scripts# cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) #
*/15 * * * * root php -f /var/www/owncloud/cron.php >/dev/null 2>&1 */5 * * * * root /root/scripts/takePicture >/dev/null 2>&1 0 2 * * * rijk mysqldump --lock-tables -u owncloud --password='owndropagua' owncloud > /home/rijk/Documents/Backups/oc.sql 5 2 * * * rijk mysqldump --lock-tables -u rainloop --password='mdswawdez$%' rainloop > /home/rijk/Documents/Backups/rl.sql 10 2 * * * rijk mysqldump --lock-tables -u mediawiki --password='twiamfhhh' mediawiki > /home/rijk/Documents/Backups/mw.sql 15 2 * * * root /root/scripts/setUserRights 0 4 * * * root /root/scripts/preCacheSFPG.py >> /var/log/preCacheSFPG.log 0 * * * * root /root/scripts/wakeOpenShift >/dev/null 2>&1

/etc/fstab

root@paardenpad:/home/rijk# cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/root      /           ext4     noatime,errors=remount-ro         0 1
tmpfs          /run/shm    tmpfs    defaults                          0 0
tmpfs          /tmp        tmpfs    defaults                          0 0
tmpfs          /var/tmp    tmpfs    defaults                          0 0
#/dev/sda1 /var ext4 noatime,discard,errors=remount-ro 0 2 #/dev/sda2 /home/rijk ext4 noatime,discard,errors=remount-ro 0 2 #/dev/sda3 /home/miel ext4 noatime,discard,errors=remount-ro 0 2