.. _rst_version_of_Programming_Journal: ################### Programming Journal ################### This document started off as a LibreOffice Writer document in odt format. The original can still be found at the top level of '04-Computing'. ***** To Do ***** Raspberry Pi ============ User for Unison --------------- • Create a user with full sudo capability and no need to enter password but that can only run the unison command. Check that this enables unison to run for the MySQL databases directory. I guess will need this user on both pibow and b4Pio • Organisation Mindmapping =========== • Work out how to use the new VYM mindmapping programme • Maybe investigate the website qt5 === Check out qt5_tutorial_ for using Visual Studio for QT5 development on a raspberry pi .. _qt5_tutorial: https://visualgdb.com/tutorials/raspberry/qt5/ MariaDB ======= Installation ------------ Sort out what is going wrong with the MariaDB installation: • secure installation • use sudo for first call of ‘mysql -u user -p’ The following links might help: * stackoverflow-rootaccessdenied_ * percona-mysqlchangepassword_ * mysql-resettingpermissions_ .. _stackoverflow-rootaccessdenied: https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost .. _percona-mysqlchangepassword: https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/ .. _mysql-resettingpermissions: https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html Issues with apt =============== Record what went wrong when I deleted the /etc/mysql directory This link might help: dpkg-errorcode1_ .. _dpkg-errorcode1: https://itsfoss.com/dpkg-returned-an-error-code-1/ Home Automation =============== Outline possibilities Count radiators Cost? The following links might help: * energenie-rpi1_ * energenie-rpi2_ .. _energenie-rpi1: https://www.element14.com/community/community/raspberry-pi/blog/2017/06/23/home-automation-in-the-uk-simplified-part-1-energenie-mihome .. _energenie-rpi2: https://www.element14.com/community/community/raspberry-pi/blog/2017/10/08/home-automation-in-the-uk-simplified-part-2-raspberry-pi-and-touch-display ********************* Miscellaneous ‘stuff’ ********************* Python Related ============== Python Tutorials ---------------- Best general python tutorial website that I’ve found yet (with clear Qt5 info) pythonbasics_ MySQL Connector ^^^^^^^^^^^^^^^ Very clear example fo MySQL Connector usage from pynative_ The main learning point from pynative is that as well as opening a connection in order to read/update a database, you also have to close it afterwards … and another one, this time from mysqltutorial_ .. _mysqltutorial: https://www.mysqltutorial.org/python-connecting-mysql-databases/ .. _pythonbasics: https://pythonbasics.org/ .. _pynative: https://pynative.com/python-mysql-database-connection/ Parameterised Query • https://pynative.com/python-mysql-execute-parameterized-query-using-prepared-statement/ Passing a cursor into a function • https://robertheaton.com/2014/02/09/pythons-pass-by-object-reference-as-explained-by-philip-k-dick/ Interesting MySQL connector websites: • https://dev.mysql.com/doc/connector-python/en/connector-python-introduction.htm • https://www.mysqltutorial.org/python-connecting-mysql-databases/ Mainloop, main and name • https://www.tutorialspoint.com/name-a-special-variable-in-python Tkinter • https://tutorialspoint.dev/language/python/python-gui-tkinter • https://www.w3schools.in/python-tutorial/gui-programming/ Class and Instance Attributes • https://www.toptal.com/python/python-class-attributes-an-overly-thorough-guide MySQL Related ============= Installing MariaDB ------------------ • Install mariadb-server • Run sudo mysql_secure_installation • install mysql-connector using pip3 install mysql-connector :: sudo apt install mariadb-server Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: galera-3 gawk libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libencode-locale-perl libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmariadb3 libreadline5 libsigsegv2 libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common mariadb-server-10.3 mariadb-server-core-10.3 mysql-common socat Suggested packages: gawk-doc libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx mariadb-test tinyca The following NEW packages will be installed: galera-3 gawk libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libencode-locale-perl libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmariadb3 libreadline5 libsigsegv2 libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common mariadb-server mariadb-server-10.3 mariadb-server-core-10.3 mysql-common socat 0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded. Need to get 18.2 MB of archives. After this operation, 150 MB of additional disk space will be used. How to change the directory under which a MariaDB database is stored -------------------------------------------------------------------- https://mariadb.com/kb/en/default-data-directory-for-mariadb/ https://www.tecmint.com/change-default-mysql-mariadb-data-directory-in-linux/ I want to change this directory from /var/lib/mysql to mnt/harddrive1/pibow/34-MySQL_Databases. To do this you first have to stop the mysql service. For MariaDB-server-10.3 on Raspbian it would appear that this is done by typing:: sudo systemctl stop mariadb Then you have to copy all the data from the original directory in to the new one. Assuming the new one already exists this is done by:: sudo cp -R -p /var/lib/mysql/* /mnt/harddrive1/pibow/34-MySQL_Databases Everything should be owned by the user and group ``mysql:mysql``. Having got the data set up, you need to sort the configuration files. The mysqld programme (which to all intents and purposes is the mysql server) needs to know where to find it’s ‘socket’ and - whether by convention or necessity - the suggestions for the location of that socket always seem to be in the same directory as that to be used to store the databases themselves. The data directory to be used needs to be specified. The two config files to be updated are: #. /etc/mysql/mariadb.conf.d/50-client.cnf #. /etc/mysql/mariadb.conf.d/50-server.cnf The client.cnf file only needs the location of the socket:: sudo nano /etc/mysql/mariadb.conf.d/50-client.cnf [client] # Default is Latin1, if you need UTF-8 set this (also in server section) default-character-set = utf8mb4 # socket location #socket = /var/lib/mysql/mysqld.sock socket = /mnt/harddrive1/pibow/34-MySQL_Databases/mysqld.sock The server.cnf file needs both the socket and the data directory:: sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf # this is read by the standalone daemon and embedded servers [server] # this is only for the mysqld standalone daemon [mysqld] # # * Basic Settings # user = mysql pid-file = /run/mysqld/mysqld.pid #socket = /var/lib/mysql/mysqld.sock socket = /mnt/harddrive1/pibow/34-MySQL_Databases/mysqld.sock #port = 3306 basedir = /usr #datadir = /var/lib/mysql datadir = /mnt/harddrive1/pibow/34-MySQL_Databases tmpdir = /tmp lc-messages-dir = /usr/share/mysql #skip-external-locking # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 127.0.0.1 All this having been done all you need to do is restart mariadb and away you go:: sudo systemctl restart mariadb sudo mysql -u root -p -e "SELECT @@datadir;" +-------------------------------------------+ | @@datadir | +-------------------------------------------+ | /mnt/harddrive1/pibow/34-MySQL_Databases/ | +-------------------------------------------+ How to restart MariaDB (for new configuration to apply):: service mysqld start service mysqld stop service mysqld restart OR:: service mysql start service mysql stop service mysql restart Granting remote access to MySQL databases ----------------------------------------- MySQL-remote_access_ Dropping a database ------------------- MySQL-drop_dB Setting permissions for the apache files ---------------------------------------- Excellent article by ThomasWard_ can be found on StackExchange here TW-PermissionProblems_. Cut down version of this is: Set up www-data as the group with appropriate access privileges to the www directory:: sudo chgrp -R www-data /var/www/html sudo find /var/www/html -type d -exec chmod g+rx {} + sudo find /var/www/html -type f -exec chmod g+r {} + Set up andrew as the owning user with appropriate access privileges to the www directory:: sudo chown -R USER /var/www/html/ sudo find /var/www/html -type d -exec chmod u+rwx {} + sudo find /var/www/html -type f -exec chmod u+rw {} + Make sure every new file after this is created with www-data as the 'access' user:: sudo find /var/www/html -type d -exec chmod g+s {} + Final security cleanup, if you don't want other users to be able to see the data:: sudo chmod -R o-rwx /var/www/html/ Raspberry Pi Related ==================== Setting up a Pi from scratch ---------------------------- My recommended steps for doing this are: 1. Obvious, new SD card, etc 2. update and upgrade 3. Reset hostname as required 4. reset pi password 5. Set up SSH server 6. When trying to SSH into pi, you get this for any recognised address (i.e. IP address AND server name): :: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the ECDSA key sent by the remote host is SHA256:IbmfGElVgxR1032/HJDjn/ywRSyJdCB7exJEMA78KUE. Please contact your system administrator. Add correct host key in /home/andrew/.ssh/known_hosts to get rid of this message. Offending ECDSA key in /home/andrew/.ssh/known_hosts:4 remove with: ssh-keygen -f "/home/andrew/.ssh/known_hosts" -R "192.168.1.139" ECDSA host key for 192.168.1.139 has changed and you have requested strict checking. Host key verification failed. OR :: … Offending ECDSA key in /home/andrew/.ssh/known_hosts:3 remove with: ssh-keygen -f "/home/andrew/.ssh/known_hosts" -R "c3pio.local" ECDSA host key for c3pio.local has changed and you have requested strict checking. Host key verification failed. 7. Set up bluetooth 8. For Raid array, install mdadm :: sudo apt install mdadm Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: exim4-base exim4-config exim4-daemon-light guile-2.2-libs libgc1c2 libgnutls-dane0 libgsasl7 libkyotocabinet16v5 libltdl7 liblzo2-2 libmailutils5 libmariadb3 libntlm0 libpython2.7 libunbound8 mailutils mailutils-common mariadb-common mysql-common Suggested packages: exim4-doc-html | exim4-doc-info eximon4 spf-tools-perl swaks dns-root-data mailutils-mh mailutils-doc dracut-core The following NEW packages will be installed: exim4-base exim4-config exim4-daemon-light guile-2.2-libs libgc1c2 libgnutls-dane0 libgsasl7 libkyotocabinet16v5 libltdl7 liblzo2-2 libmailutils5 libmariadb3 libntlm0 libpython2.7 libunbound8 mailutils mailutils-common mariadb-common mdadm mysql-common 0 upgraded, 20 newly installed, 0 to remove and 0 not upgraded. Need to get 12.3 MB of archives. After this operation, 58.4 MB of additional disk space will be used. Do you want to continue? [Y/n] Need to be root to run mdadm New User -------- When setting up the Pi in the first place, want to create a new user with all of the same access privileges as the pi user. The pi user itself can then be deleted. My recommended steps for doing this are: 1. Make any changes required to the /etc/skel directory, so that the new user is created with the required profile and home directory structure. i. Probably want to add bin, Desktop, Documents and Downloads – bin is then included in $PATH the next time .profile is run. 2. Use ‘groups pi’ to get a list of the groups of which pi is a member 3. Use ‘sudo adduser’ to create the new user (can also add to one of the ‘pi’ groups with this command) 4. Repeat ‘sudo adduser’ to add the rest of the ‘pi’ groups 5. Use raspi-config to ensure that the pi will auto-login to the GUI as the new user 6. Auto-login to the GUI as the new user 7. From the terminal, use ‘sudo deluser -r’ to delete the pi user and its associated home directory. 8. (Optional) IF you want the new user to be able to use the ‘sudo’ command without typing a password, then use:: echo ' ALL=(ALL) NOPASSWD: ALL' | sudo tee /etc/sudoers.d/010_-nopasswd 9. (Optional) Copying privileges to the new user can be done in a single line using:: for GROUP in adm dialout cdrom sudo audio video plugdev games users netdev input spi i2c gpio; do sudo adduser username $GROUP; done More details at: * RPiOrg-users_ * StckEx-RPi-userPriv_ Setting up a user with ‘sudo’ access to a specific command: ----------------------------------------------------------- Edit the ``sudoers`` file with:: sudo visudo ... then:: joe ALL=(ALL) NOPASSWD: /full/path/to/command see sudo-specific-command_ .. _sudo-specific-command: https://www.atrixnet.com/allow-an-unprivileged-user-to-run-a-certain-command-with-sudo/ .. _RPiOrg-users: https://www.raspberrypi.org/documentation/linux/usage/users.md .. _StckEx-RPi-userPriv: https://raspberrypi.stackexchange.com/questions/36168/how-to-create-new-user-in-raspberry-pi-who-has-equal-privileges-as-default-user .. _ThomasWard: https://askubuntu.com/users/10616/thomas-ward .. _TW-PermissionProblems: https://askubuntu.com/questions/767504/permissions-problems-with-var-www-html-and-my-own-home-directory-for-a-website .. _MySQL-drop_dB: https://www.tutorialkart.com/mysql/delete-a-database-in-mysql/ .. _MySQL-remote_access: https://linuxize.com/post/mysql-remote-access/ Linking USB harddrive --------------------- Setting up a USB hard drive involves creating the ‘mount point’ at which you want the hard drive to appear (step 1 below), then editing the /etc/fstab file to mount the hard drive (step 2 below). You can then reboot the pi (step 3 below) before finally setting up a symlink to point the Documents directory at the new drive (steps 4 and 5 below) 1. mkdir /mnt/harddrive1 2. /dev/sda1 /mnt/harddrive1 ext4 defaults,noatime 0 0 3. sudo reboot 4. rmdir Documents 5. ln -s /mnt/harddrive1/pibow Documents Unison ------ Whilst unison can be installed in both command-line and GUI modes using ‘sudo apt’, you (currently) end up with version 2.48 which is not the one that I want. So, to install unison first you need to install the OCAML compiler (which ‘apt’ installs to version 4.05 which is fine). :: sudo apt install ocaml [sudo] password for andrew: Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: ledit libpthread-stubs0-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev ocaml-base ocaml-base-nox ocaml-compiler-libs ocaml-interp ocaml-nox x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev Suggested packages: libx11-doc libxcb-doc ocaml-doc tuareg-mode | ocaml-mode The following NEW packages will be installed: ledit libpthread-stubs0-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev ocaml ocaml-base ocaml-base-nox ocaml-compiler-libs ocaml-interp ocaml-nox x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev 0 upgraded, 16 newly installed, 0 to remove and 0 not upgraded. Need to get 50.2 MB of archives. After this operation, 209 MB of additional disk space will be used. Then you need to compile the unison code from source. The source code can be downloaded from: • https://github.com/bcpierce00/unison/archive/v2.51.2.tar.gz There is a copy here To compile unison, simply * extract the contents of the zip file under the home directory (e.g. tar -zxvf Downloads/unison-2.51.2.tar.gz -C ~/unison-2.51.2/), * cd into the src directory under the new unison directory and use ‘make’ to compile the program. * Type ‘./unison -version’ to check that it has worked. * The new unison binary can then be copied into /home/andrew/bin/ from where it will be on $PATH locally (check by typing ‘unison -version’). However this won’t work for remote access, so it really needs to be copied into /usr/bin. * Can then delete the unison directory * Need to redo the ‘ssh-copy-id’ from pibow to b4Pio. * Need to sort out changes in .ssh/known_hosts, which most recently involved running ssh-keygen twice on pibow: 1. ssh-keygen -f "/home/andrew/.ssh/known_hosts" -R b4pio 2. ssh-keygen -f "/home/andrew/.ssh/known_hosts" -R 192.168.1.238 Using Unison ^^^^^^^^^^^^ Here's the unison manual: unison-manual_ .. _unison-manual: https://www.cis.upenn.edu/~bcpierce/unison/download/releases/beta/unison-manual.html Example Unison preference files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ auto-b4Pio.prf :: # Unison preferences file root = /mnt/raid1/ root = ssh://pisync@b4Pio//mnt/harddrive1/pibow/ confirmbigdel = true batch = true Fanshim ------- All covered at this pimoroni-fanshim_ page. .. _pimoroni-fanshim: https://learn.pimoroni.com/tutorial/sandyj/getting-started-with-fan-shim Installing the Fan SHIM software ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ For this part of the tutorial, you'll need a micro-SD card that's been set up with the Raspbian operating system, and to be connected to Wi-Fi. It's also really handy to have a display, keyboard, and mouse connected to your Pi for these next bits. Open a terminal (press control-alt-t or find it in the Raspberry Pi menu) and then type the following to install the Fan SHIM Python library:: git clone https://github.com/pimoroni/fanshim-python cd fanshim-python sudo ./install.sh That installs the Python library itself, but we've put together a nice Python script that sets temperature thresholds (along with a couple of other options) and then turns the fan on automatically when it reaches a threshold and back off when it drops back below a second threshold. The installer accepts three values, the first for the on threshold temperature at which the fan kicks in, the second for the off threshold temperature at which the fan stops again, and the third for the delay between each temperature reading. In our testing, an on threshold of 65°C, an off threshold of 55°C, and a delay of 2 work pretty well. Type the following in the terminal to run the installer for the automatic script:: cd examples sudo ./install-service.sh --on-threshold 65 --off-threshold 55 --delay 2 This installer will run the automatic script in the background, and it should even start running again if you shutdown and boot up again, or reboot. The LED indicates the CPU temperature, with green being cooler and red being hotter. A long press on the button put the fan into manual mode and then a short press will stop or start the fan. Long pressing again will re-enable automatic mode. If you ever need to stop the script running in the background, you can type in the terminal:: sudo systemctl stop pimoroni-fanshim.service If you want to change the thresholds, e.g to change the on temperature to 75, the off temperature to 60, and the delay to 5 seconds, then you can type the following in the terminal:: sudo systemctl stop pimoroni-fanshim.service sudo ./install-service.sh --on-threshold 75 --off-threshold 60 --delay 5 If you want to permanently disable the background script, you can type in the terminal:: sudo systemctl stop pimoroni-fanshim.service sudo systemctl disable pimoroni-fanshim.service Or to re-enable it:: sudo systemctl enable pimoroni-fanshim.service sudo systemctl start pimoroni-fanshim.service More examples ^^^^^^^^^^^^^ We've provided a few other examples that demonstrate the functionality of the Fan SHIM Python library, i.e. the RGB LED, and the tactile switch/button. You can find the examples at this link fse_ along with short descriptions of what each one does. .. _fse: https://github.com/pimoroni/fanshim-python/tree/master/examples Batch Files ----------- A general article on batch-files_. ... and the more complex site referenced from this article that goes into a great deal more detail_. .. _batch-files: https://www.linux.com/training-tutorials/writing-simple-bash-script/ .. _detail: http://tldp.org/LDP/Bash-Beginners-Guide/html/ auto_ffmpeg.sh ^^^^^^^^^^^^^^ :: #!/bin/bash cd /home/andrew/Documents/00-landing_stage for f in *.m4a; do ffmpeg -i "$f" -codec:v copy -codec:a libmp3lame -n -q:a 2 newfiles/"${f%.m4a}.mp3"; done && rm * Because I want this to be able to delete files 'owned' by the pisync user I have created this file under /home/pisync/ as pisync and given it permissions 744. I have then run the crontab -e command (still as pisync) and called auto_ffmpeg.sh at 5am every morning. spb ^^^ :: #!/bin/bash make clean && make html && unison sphinx.prf This is saved as an executable programme under /home/andrew/Documents/36-Sphinx, and when called (./spb) will update the c3Pio website with any sphinx updates that have been done. Setting Background Picture -------------------------- Default location of background pictures is ``usershare/rpd-wallpaper`` To change the background picture in the GUI, it is ``Preferences/Appearance Settings`` and choose the picture. New background pictures at ``Pictures/Backgrounds``. All the files are sym links. Not sure if it’s worked with the sym links! Setting up the printer ---------------------- Easy once you’ve worked out how! The problem is that the HP PhotoSmart C309M does not come up on the list of standard HP printers available with CUPS, so it’s not just a simple matter of installing CUPS, rather you also have to install hplip (which adds the C309 printer driver to the list). There are all sorts of other ‘recommended’ packages that come too so I’ve ended up with the following:: sudo apt install cups hplip hplip-doc hplip-gui python3-notify2 system-config-printer python-pexpect-doc exiv2 python3-pyqt5-dbg gnome-software (problems with this) gimp gocr gimp-help-en gimp-data-extras gimp-python apt-config-icons-hidpi (There were problems with ``gnome-software``) I doubt all of these were necessary but they’re all there now (on b4Pio) so I’m sort of stuck with them. There is some issue with the ‘recommended packages’ - some no longer exist, others use a ‘pipe’ format that I think is pointing at specific sub-sections of a package but that apt does not seem to recognise. Ah well. .. todo:: I think I should read hplip-doc and see if it sheds any light ... Setting up a RAID Array ----------------------- When restarting, and get the guff about drives being busy, the solution is to use the ``--force`` option:: mdadm --stop /dev/md0 mdadm --assemble --force /dev/md0 /dev/sd[abc]1 echo 1 > /sys/module/raid0/parameters/default_layout mdadm --stop /dev/md0 mdadm --assemble --force /dev/md0 /dev/sd[abc]1 Summarized from level1techs-RaidIssue_ .. _level1techs-RaidIssue: https://forum.level1techs.com/t/raid-dead-please-help/134653 What I’d been used to under more normal circumstances: Step 1: Format the usb drives that I’m going to use. * See ‘Reformat Memory Sticks’ section below. .. todo:: Find out how to do internal links in reST and update the above accordingly Step 2: Install mdadm:: sudo apt install mdadm I entered ‘None’ as the option that the mdadm configuration screen asked for. Step 3: Set up the array using mdadm:: sudo su mdadm --create --verbose /dev/md0 --level=raid0 --raid-devices=2 /dev/sd?1 /dev/sd?1 (which results in a failure, but creates the ``/sys/module/raid0/parameters/default_layout`` file.) echo 1 > /sys/module/raid0/parameters/default_layout mdadm --create --verbose /dev/md0 --level=raid0 --raid-devices=2 /dev/sd?1 /dev/sd1 (which works this time!) if this is a newly created array need to create a files system by running mkfs.ext4 /dev/md0 mount /dev/md0 /mnt/harddrive1 which is quick if setting up the array for the first time, but if you’re rebuilding an array with existing disks with lots of ‘stuff’ on them (which you need to do after rebooting the pi) it can take an age. To store the configuration details to help with the next reboot:: mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf To get the details of the raid array once it is up and running:: mdadm --detail dev/md0 To get the details of any existing drive:: cat /proc/mdstat mdadm --detail –scan mdadm --examine /dev/sdb1 Notes on current RAID arrays: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pibow: """""" RAID0 (striped array) across two 256G memory sticks (AT04 and AT07) to form /dev/md0. /dev/md0 is mounted as /mnt/harddrive1 This had to be done using the mount command after 1. the system had booted 2. the mdadm --create --verbose /dev/md0 --level=raid0 --raid-devices=2 /dev/sd?1 /dev/sd?1 command run and failed 3. the echo 1 > /sys/module/raid0/parameters/default_layout command run, and finally 4. the mdadm --create --verbose /dev/md0 --level=raid0 --raid-devices=2 /dev/sd?1 /dev/sd?1 command run for a second time (successfully this time) There is a softlink (ln -s) created that maps /home/andrew/Documents on to /mnt/harddrive1, so that under Documents you find 00-landing_stage, 01-Primary, etc – all of which is actually stored on the RAID0 array. Current pibow setup (using a mobile phone charger as a power supply) results in under-voltage problems if trying to drive 3 memory sticks. These problems are impossible to miss if you look at the ‘dmesg’ output. It seems that most of the time it is all ‘managed’ but after running for a couple of weeks it cause a problem that resulted in parts of the filesystem hosted on the RAID0 array coming up as ‘Read Only’ - the symptoms begin that a unison run between pibow and b4Pio failed, trying to reload a file with get-iplayer on pibow failed, and this led to the discovery of the ‘read only’ issue. So I’ve made sure it’s only trying to drive two memory sticks and that has worked with no problems to date. Not tried using a meatier power supply. pibow /etc/fstab currently looks like this:: proc /proc proc defaults 0 0 /dev/mmcblk0p6 /boot vfat defaults 0 2 /dev/mmcblk0p7 / ext4 defaults,noatime 0 1 #/dev/md/0 /mnt/harddrive2 ext4 defaults,noatime 0 1 #/dev/sdc1 /mnt/harddrive1 ext4 defaults,noatime 0 0 # a swapfile is not a swap partition, no line here # use dphys-swapfile swap[on|off] for that c3Pio: """""" No problem driving three memory sticks and a USB bluetooth adaptor. Two 256G memory stick (AT05 & AT06) and a 128G memory stick (AT01) form a RAID0 array to form dev/md0. This has been mapped to /mnt/harddrive1 (using mount), and a softlink has been created from ~/Music pointing to the directories under 05-Audio_Recordings which is copied onto /mnt/harddrive2/Music c3Pio /etc/fstab currently looks like this:: proc /proc proc defaults 0 0 /dev/mmcblk0p6 /boot vfat defaults 0 2 /dev/mmcblk0p7 / ext4 defaults,noatime 0 1 #/dev/sda1 /mnt/harddrive1 ext4 defaults 0 0 #/dev/sdb1 /mnt/harddrive2 ext4 defaults 0 0 # a swapfile is not a swap partition, no line here # use dphys-swapfile swap[on|off] for that If ``Documents`` has been created as a softlink to ``/mnt/harddrive1`` then this all works automatically Reformat memory sticks: ^^^^^^^^^^^^^^^^^^^^^^^ :: sudo fdisk /dev/sd{whichever} Having entered the sudo password the system responds with:: Welcome to fdisk (util-linux 2.25.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): If you enter ‘o’ at this stage you get something like:: Command (m for help): o Created a new DOS disklabel with disk identifier 0xefc7e2a0. Next up, type ‘n’ for a new partition and then ‘p’ to specify that it should be a primary partition. Then hit ‘return a couple of times to select the default partition number, First sector and last sector. System responds with:: Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): Using default response p:: Partition number (1-4, default 1): First sector (2048-483418111, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-483418111, default 483418111): Created a new partition 1 of type 'Linux' and of size 230.5 GiB. Command (m for help): Finally, if you enter ‘w’ it will write these changes to the disk and respond with:: Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. ‘Correct’ default layout ^^^^^^^^^^^^^^^^^^^^^^^^ REALLY IMPORTANT!:: root@piBow:/home/andrew# echo 1 > /sys/module/raid0/parameters/default_layout Needed because of some problem introduced in Linux 3.14 – see linus-note1_ .. _linus-note1: https://github.com/torvalds/linux/commit/c84a1372df929033cb1a0441fb57bd3932f39ac9 It seems that when the system is rebooted the file ``sys/module/raid0/parameters/default_layout`` is deleted! So needs to be recreated on a reboot :( eclipse ------- Installed by:: sudo apt install eclipse Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: binfmt-support default-jdk default-jdk-headless eclipse-jdt eclipse-pde eclipse-platform eclipse-platform-data eclipse-rcp fastjar gconf-service gconf2-common jarwrapper junit junit4 libasm3-java libcommons-beanutils-java libcommons-dbcp-java libcommons-digester-java libcommons-httpclient-java libcommons-pool-java libdb-java libdb-je-java libdb5.3-java libdb5.3-java-jni libecj-java libequinox-osgi-java libfelix-bundlerepository-java libfelix-gogo-command-java libfelix-gogo-runtime-java libfelix-gogo-shell-java libgconf-2-4 libhamcrest-java libice-dev libicu4j-4.2-java libicu4j-49-java libjavascriptcoregtk-1.0-0 libjetty9-java libjline-java libjsch-java libjtidy-java libjzlib-java liblucene2-java libosgi-annotation-java libosgi-compendium-java libosgi-core-java libregexp-java libsm-dev libswt-cairo-gtk-3-jni libswt-glx-gtk-3-jni libswt-gtk-3-java libswt-gtk-3-jni libswt-webkit-gtk-3-jni libtomcat8-java libwebkitgtk-1.0-0 libxt-dev openjdk-11-jdk openjdk-11-jdk-headless sat4j Suggested packages: junit-doc libcommons-beanutils-java-doc libcommons-dbcp-java-doc libgeronimo-jta-1.1-spec-java libcommons-digester-java-doc libcommons-httpclient-java-doc ecj libfelix-osgi-obr-java libfelix-shell-java libfelix-utils-java libkxml2-java libfelix-bundlerepository-java-doc libfelix-gogo-command-java-doc libfelix-gogo-runtime-java-doc libfelix-gogo-shell-java-doc libice-doc jetty9 libjline-java-doc libjtidy-java-doc libosgi-annotation-java-doc libosgi-compendium-java-doc libosgi-core-java-doc libsm-doc tomcat8 libxt-doc openjdk-11-demo openjdk-11-source visualvm Recommended packages: libswt-gnome-gtk-3-jni The following NEW packages will be installed: binfmt-support default-jdk default-jdk-headless eclipse eclipse-jdt eclipse-pde eclipse-platform eclipse-platform-data eclipse-rcp fastjar gconf-service gconf2-common jarwrapper junit junit4 libasm3-java libcommons-beanutils-java libcommons-dbcp-java libcommons-digester-java libcommons-httpclient-java libcommons-pool-java libdb-java libdb-je-java libdb5.3-java libdb5.3-java-jni libecj-java libequinox-osgi-java libfelix-bundlerepository-java libfelix-gogo-command-java libfelix-gogo-runtime-java libfelix-gogo-shell-java libgconf-2-4 libhamcrest-java libice-dev libicu4j-4.2-java libicu4j-49-java libjavascriptcoregtk-1.0-0 libjetty9-java libjline-java libjsch-java libjtidy-java libjzlib-java liblucene2-java libosgi-annotation-java libosgi-compendium-java libosgi-core-java libregexp-java libsm-dev libswt-cairo-gtk-3-jni libswt-glx-gtk-3-jni libswt-gtk-3-java libswt-gtk-3-jni libswt-webkit-gtk-3-jni libtomcat8-java libwebkitgtk-1.0-0 libxt-dev openjdk-11-jdk openjdk-11-jdk-headless sat4j 0 upgraded, 59 newly installed, 0 to remove and 120 not upgraded. Need to get 366 MB of archives. After this operation, 434 MB of additional disk space will be used. Do you want to continue? [Y/n] But I get an error whey I try to start eclipse:: !SESSION Tue May 26 16:20:55 BST 2020 ------------------------------------------ !ENTRY org.eclipse.equinox.launcher 4 0 2020-05-26 16:20:55.485 !MESSAGE Exception launching the Eclipse Platform: !STACK java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:626) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584) at org.eclipse.equinox.launcher.Main.run(Main.java:1438) I've done a quick search on the error and found Stack_Exchange-EclipseError1_. I've not yet followed it up! .. _Stack_Exchange-EclipseError1: https://stackoverflow.com/questions/3412617/java-lang-classnotfoundexception-org-eclipse-core-runtime-adaptor-eclipsestarte Cron ---- crontab -e That’s all there is to it! For more, look at this crontab-ref_. To get a cron job to run the auto-ffmpeg.sh file as pisync I had to include the whole path name for that file; having just the filename didn't work, despite the file being in pisync's home directory. So the relevant file looks like:: # Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any'). # # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command 0 5 * * * /home/pisync/auto_ffmpeg.sh .. _crontab-ref: https://www.adminschoice.com/crontab-quick-reference linux eMail ----------- To read linux mail, just type mail. A useful guide to linux-mail_ .. _linux-mail: https://lowfatlinux.com/linux-send-email.html eMail Related ------------- Configuring an eMail client for BT eMail ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ All of the following is taken from the BT-eMail-settings_ page. .. _BT-eMail-settings: https://www.bt.com/help/email/manage-email-account/manual-settings/what-are-the-settings-for-outgoing-and-incoming-bt-email-servers IMAP settings """"""""""""" • Incoming Mail Server: mail.btinternet.com • Port: 993 (this should be automatically populated by selecting the SSL encryption) • SSL Encryption: Enabled (but not STARTTLS) • Username: your email address including the @btinternet or @btopenworld.com part • Password: your btinternet or btopenworld password • Root folder/path: • Folder separator: . (full stop) Please do NOT enable "secure password authentication" (SPA). It's not needed when you use SSL encryption and won't work. If your IMAP client supports it, we recommend you also set up the following folders: • Trash • Sent Items • Drafts POP3 settings """"""""""""" • Incoming Mail Server: mail.btinternet.com • Port: 995 (this should be automatically populated by slecting the SSL encryption) • SSL Encryption: Enabled (but not STARTTLS) • Username: your email address including the @btinternet.com or @btopenworld.com part • Password: your btinternet or btopenworld password • POP from folder: by default, POP will pull emails from your inbox SMTP settings """"""""""""" • Outgoing Mail Server: mail.btinternet.com • Port: 465 (this may not be automatically populated on selecting SSL, so you'll need to check) • SSL Encryption: Enabled (but not STARTTLS) • Authentication: PLAIN • Username: your email address including the @btinternet or @btopenworld.com part • Password: your btinternet or btopenworld password