Pages

Εμφάνιση αναρτήσεων με ετικέτα Linux. Εμφάνιση όλων των αναρτήσεων
Εμφάνιση αναρτήσεων με ετικέτα Linux. Εμφάνιση όλων των αναρτήσεων

Δευτέρα 31 Αυγούστου 2026

Εγκατάσταση klipper σε Odroid-U2/U3Klipper installation on ODroid-U2/U3

Εισαγωγή

Introduction

Τον τελευταίο καιρό ασχολούμαι αρκετά και με τη 3D σχεδίαση κι εκτύπωση. Έχω στη διάθεσή μου έναν εκτυπωτή της Creality, τον Ender-5 Plus, ο οποίος είναι ένας τίμιος εκτυπωτής για την ηλικία του. Για την ώρα του έχω αλλάξει το build plate, ως πρώτη "αναβάθμιση" και του έχω εγκαταστήσει έναν Direct Drive Extruder, ενώ έχω αλλάξει και το σωληνάκι του νήματος σε capricorn tube. Ακόμα και πριν αυτές τις αναβαθμίσεις στο hardware οι εκτυπώσεις που έκανε ήταν καλές! Φυσικά έπρεπε να ασχοληθώ αρκετά με την τοποθέτηση των αντικειμένων στο build plate και το slicing ώστε να μην έχω προβλήματα στην εκτύπωση, αλλά ακόμα και δύσκολες εκτυπώσεις τις κατάφερνε κι ας μην ήταν πάντα με την πρώτη. Όλη αυτή η τριβή με έμαθε πολλά πράγματα επάνω στην τρισδιάστατη FDM εκτύπωση, αλλά το γεγονός πως αρκετό νήμα πήγαινε στα... σκουπίδια με ενοχλούσε. Κάνοντας τις αναβαθμίσεις του hardware πέτυχα να μειώσω δραστικά τα απορρίματα, αλλά ένα πράγμα που έχουν αυτοί οι παλιοί εκτυπωτες, είναι πως υπάρχει χώρος για περισσότερες αναβαθμίσεις και πειραματισμό. Αυτό με τη σειρά του σημαίνει πως τα πάντα πρέπει να τα προετοιμάζεις, γιατί αν είναι ο μόνος εκτυπωτής που διαθέτεις τότε μπορείς εύκολα να βρεθείς χωρίς αυτόν :).

Lately I've been quite involved with 3D design and printing as well. I have at my disposal a Creality printer, model Ender-5 Plus, which is a decent printer for its age. For now, I've changed the build plate as a first "upgrade" and installed a Direct Drive Extruder, while I've also swapped the filament tube to a Capricorn one. Even before these hardware upgrades, the prints it made were good! Of course, I had to spend quite a bit of time on placing objects on the build plate and slicing so that I wouldn't have printing issues, but it managed even difficult prints, even if not always on the first try. All this friction taught me many things about FDM 3D printing, but the fact that quite a bit of filament went to... waste bothered me. By making the hardware upgrades, I managed to drastically reduce waste, but one thing these old printers have is that there is room for more upgrades and experimentation. This in turn means that you have to prepare everything, because if it's the only printer you have, you can easily find yourself without it :).

Όμως ένας εκτυπωτής δεν είναι μόνο το hardware. Έχει μικροελεγκτή, που σημαίνει πως και το software του είναι ένας σημαντικός κρίκος (αν όχι αλυσίδα ολόκληρη) που εργάζεται στο θέμα της εκτύπωσης. Έτσι, παίζοντας πάντα, προσπάθησα να εγκαταστήσω όλα τα stock firmwares της Creality, αλλά πάντα υπήρχε κάποια αποτυχία λειτουργίας και κατέληγα στο firmware που είχε αρχικά. Τελικά, έπειτα από προτροπές ατόμων που ασχολούνται με το θέμα αυτό, μπήκα στη διαδικασία να εγκαταστήσω το τελευταίο Marlin (2.1.3b) που βρίσκεται εδώ και πολύ πολύ καιρό σε beta έκδοση. Έχει κι αυτό τα προβληματάκια του, αλλά... είπαμε, beta έκδοση, άρα αναμενόμενο. Από το σημείο που όλες αυτές οι αναβαθμίσεις (hardware και software) ολοκληρώθηκαν είχα αρξετά καλά αποτελέσματα με λιγότερο κόπο (από τον αρχικό), αλλά πάντα κάτι έλλειπε!

But a printer is not just hardware. It has a microcontroller, which means its software is also an important link (if not an entire chain) working on the printing matter. So, always playing, I tried to install all of Creality's stock firmwares, but there was always some functional failure and I ended up back at the firmware it originally had. Eventually, after encouragement from people involved with this topic, I got into the process of installing the latest Marlin (2.1.3b), which has been in beta for a very long time. It has its little issues too, but... we said it's beta, so expected. From the point where all these upgrades (hardware and software) were completed, I had quite good results with less effort (than the initial), but something was always missing!

Τελικά η ιδέα του να πειράξω αρκετά το hardware πέρασε από το μυαλό μου, μέχρι και το σημείο να τον μετατρέψω σε Core-XY, αλλά για την ώρα δεν το έχω κάνει. Όμως, αυτό που βλέπω πως δίνει καλύτερα αποτελέσματα από όλες τις απόψεις, δεν είναι το Marlin, αλλά ένα άλλο firmware για 3D εκτυπωτές, το Klipper. Έτσι, πήρα την απόφαση να προσπαθήσω να γυρίσω σε klipper το όλο σύστημα. Αυτό με τη σειρά του, είναι μια μεγάλη αναβάθμιση και απαιτεί πολλή δουλειά, προγραμματισμό των βημάτων που θα ακολουθήσω για να το πετύχω και πάντα να υπάρχει η δυνατότητα να το επαναφέρω στο Marlin ώστε αν χρειαστώ κάποια εκτύπωση να μπορώ να την κάνω. Αλλά για να μη μακρυγορούμε, ας μπούμε στο ψητό!

Finally, the idea of tinkering with the hardware a lot crossed my mind, up to the point of converting it to Core-XY, but for now I haven't done it. However, what I see giving better results from all perspectives is not Marlin, but another firmware for 3D printers, Klipper. So, I decided to try to convert the whole system to Klipper. This in turn is a big upgrade and requires a lot of work, planning of the steps I will follow to achieve it, and always having the possibility to revert to Marlin so that if I need a print I can do it. But to cut the long story short, let's get to the point!

Τι θα δούμε (και τι δε θα δούμε) σε αυτό το άρθρο

What is (and what's not) in this article

Σκοπός της ανάρτησης είναι να περιγράψω τον τρόπο με τον οποίο εγκατέστησα το klipper σε ένα ODroid-U2/U3. Η διαδικασία περιλαμβάνει αρχικά την εγκατάσταση του λειτουργικού σε αυτό και στη συνέχεια την εγκατάσταση του klipper. Εκεί είναι που τελειώνει η περιγραφή. Δεν είναι σκοπός μου ούτε να περιγράψω τη διαδικασία ρύθμισης, ούτε τον τρόπο που θα λειτουργήσει το ODroid σε έναν τρισδιάστατο εκτυπωτή.

The purpose of this post is to describe how I installed Klipper on an ODroid-U2/U3. The process involves first installing the operating system on it and then installing Klipper. That is where the description ends. It is not my intention to describe the configuration process, nor the way the ODroid will operate on a 3D printer.

Πιο αναλυτικά:

More specifically:

Γιατί ODroid-U2/U3

Why ODroid-U2/U3

Γενικά θαυμάζω τους υπολογιστές μιας πλακέτας (SBCs - Single Board Computers). Η έντονη άνθισή τους στο χώρο ξεκίνησε από το Raspberry Pi. Στη συνέχεια ακολούθησαν κι άλλοι που δημιουργούσαν τέτοιους υποογιστές, μικρού μεγέθους, όπου με μια εγκατάσταση Linux μπορούσαν να αναλάβουν κάποιες διεργασίες χαμηλής ισχύος (δεν θα τις έλεγα καθημερινές, αλλά μπορείτε να καταλάβετε :)). Η αλήθεια είναι πως δεν υπήρξα ποτέ λάτρης του Raspberry Pi αλλά ψάχνωντας βρήκα την Hardkernel που κατασκευάζει τα ODroid, υπολογιστές μιας πλακέτας με πιο ισχυρό υλικό από αυτό του Raspberry Pi, σε αρκετά ανταγωνιστικές τιμές. Έτσι, έπεσε στα χέρια μου το Odroid U2 που μπορούσα να συνδέσω στο monitor και να παίζω παιχνίδια, ή να τρέξω το τότε XMBC και να το έχω για media server, κλπ. Τελικά κατέληξε να χειρίζεται ολόκληρο το δίκτυο φιλοξενούμενων ενός ξενοδοχείου, με απόλυτη επιτυχία.

Generally I admire single-board computers (SBCs). Their intense flourishing in the field started with the Raspberry Pi. Then followed others who created such small-sized sub-computers, where with a Linux installation they could handle some low-power processes (I wouldn't call them everyday tasks, but you get it :)). The truth is I was never a fan of the Raspberry Pi, but while searching I found Hardkernel, which manufactures the ODroid, single-board computers with more powerful hardware than the Raspberry Pi, at quite competitive prices. So, I got my hands on an Odroid U2 that I could connect to a monitor and play games, or run the then XBMC and use it as a media server, etc. It eventually ended up handling an entire hotel guest network with absolute success.

Όμως η εξέλιξη είναι έντονη και η υποστήριξη του ODroid U2 (κι ενός ODroid U3 που είχα στησει ως NAS) σταμάτησε και τα 32-bit θεωρούταν... λίγα! Τα ODroid μου κατέληξαν σε ένα συρτάρι και δεν έτρεξαν ηλεκτρόνια μέσα τους για μεγάλο χρονικό διάστημα. Με την ιδέα του Klipper στον εκτυπωτή, είπα πως θα ήταν μια καλή ευκαιριά να ξαναδούν... τα ηλεκτρόνια της ημέρας και να λειτουργήσουν στο μεγαλείο τους κάνοντας κάτι πολύ χρήσιμο. Αυτός ήταν και ο κύριος λόγος της επιλογής του ODroid U2/U3 για την αναβάθμιση του εκτυπωτή μου.

But evolution is intense and the support for the ODroid U2 (and an ODroid U3 that I had set up as a NAS) stopped, and 32-bit was considered... little! My ODroids ended up in a drawer and no electrons ran through them for a long time. With the idea of Klipper on the printer, I said it would be a good opportunity for them to see... the electrons of the day again and operate at their full glory doing something very useful. That was also the main reason for choosing the ODroid U2/U3 for upgrading my printer.

Γιατί το Odroid U3 είναι καλή επιλογή

Why the Odroid U3 is a good choice

  • Ο επεξεργαστής Exynos 4412 (4 πυρήνες Cortex-A9) και τα 2GB RAM είναι υπεραρκετά για το Klipper, επιτρέποντας υψηλές ταχύτητες επεξεργασίας, ακόμα και κάμερες. The Exynos 4412 processor (4 Cortex-A9 cores) and 2GB RAM are more than enough for Klipper, allowing high processing speeds, even cameras.
  • Μπορείς να εγκαταστήσεις ένα "καθαρό" Linux και να στήσεις τα πάντα μόνος σου, ή να χρησιμοποιήσεις έτοιμα εργαλεία. You can install a "clean" Linux and set everything up yourself, or use ready-made tools.
  • Διαθέτει δύο (ODroid-U2) ή τρεις (ODroid-U3) θύρες USB και σύνδεση σε δίκτυο LAN It has two (ODroid-U2) or three (ODroid-U3) USB ports and a LAN network connection
  • Χρησιμοποιεί μνήμη eMMC ή/και microSD ως μέσο αποθήκευσης. Η eMMC είναι μια πολύ πιο αξιόπιστη και γρήγορη μνήμη για χρήση σε λειτουργικό ενώ η microSD μπορεί να χρησιμοποιηθεί και για τη μεταφορά μοντέλων προς εκτύπωση χωρίς κανένα πρόβλημα. It uses eMMC memory and/or microSD as a storage medium. The eMMC is a much more reliable and fast memory for use as an operating system, while the microSD can also be used for transferring models for printing without any problem.

Το κύριο εμπόδιο είναι ότι το Odroid-U2/U3 είναι μια παλιά πλακέτα (armhf, 32-bit). Οι περισσότερες σύγχρονες, εύκολες λύσεις (OctoPi, MainsailOS, FluiddPi) δεν το υποστηρίζουν πλέον, καθώς βασίζονται σε 64-bit (arm64) λειτουργικά κι εδώ είναι που ξεκινάνε μερικά ευχάριστα απογεύματα, όπως λέει και ένας πολύ καλός μου φίλος!

The main obstacle is that the Odroid-U2/U3 is an old board (armhf, 32-bit). Most modern, easy solutions (OctoPi, MainsailOS, FluiddPi) no longer support it, as they are based on 64-bit (arm64) operating systems, and this is where some pleasant afternoons begin, as a very good friend of mine says!

Εγκατάσταση λειτουργικού

Operating System Installation

Το πρώτο βήμα είναι η εγκατασταση λειτουργικού. Σκοπός μας είναι να μπορέσουμε να τρέξουμε μια διανομή Linux κατάλληλη για το ODroid, αλλά όσο το δυνατόν πιο σύγχρονη. Τονίζω το "όσο το δυνατόν" γιατί η ανάπτυξη πυρήνα Linux 32 bit έχει σταματήσει εδώ κι αρκετό καιρό.

The first step is installing the operating system. Our goal is to be able to run a Linux distribution suitable for the ODroid, but as modern as possible. I emphasize "as possible" because 32-bit Linux kernel development has stopped for quite some time now.

Έπειτα από αναζήτηση στο διαδίκτυο βρήκα κάποιες πιθανές επιλογές:

After searching the internet, I found some possible options:

  • ARCH Linux: Πρόκειται για μια σοβαρή διανομή με πολύ δυνατή κοινότητα. Το μόνο κακό είναι πως δεν έχω ασχοληθεί ποτέ με το ARCH κι έτσι είπα να μην το δοκιμάσω (αν και δεν αποκλείεται να το κάνω στο μέλλον). Με μια πρώτη ματιά φαίνεται να περιέχει όλα όσα χρειάζονται για την εγκατάσταση στο ODroid. Αν έχετε γνώση επάνω στη συγκεκριμένη διανομή ίσως είναι μια πολύ καλή επιλογή. ARCH Linux: This is a serious distribution with a very strong community. The only downside is that I have never dealt with ARCH, so I decided not to try it (although I don't rule out doing so in the future). At first glance, it seems to contain everything needed for installation on the ODroid. If you have knowledge of this particular distribution, it might be a very good choice.
  • Odroid U2/U3 Ubuntu 18.04 Desktop image: Ένα image που έχει το μέγεθος των 128G! Φυσικά υπάρχει τρόπος να τη μετατρέψουμε σε 16G, αλλά σε γενικές γραμμές δεν είμαι και ο καλύτερος υποστηρικτής της διανομής Ubuntu... Επίσης είναι στημένη με τέτοιο τρόπο που λειτουργεί από τη microSD, αλλά κι αυτό διορθώνεται. Πάντως όχι η κατάσταση out of the box. Odroid U2/U3 Ubuntu 18.04 Desktop image: An image that is 128G in size! Of course, there is a way to convert it to 16G, but generally speaking, I am not the biggest supporter of the Ubuntu distribution... Also, it is set up in such a way that it works from the microSD, but that can also be fixed. Nevertheless, not an out-of-the-box situation.
  • Debian Bullseye for Exynos4 boards: Το link οδηγεί σε forum από το οποίο είδα τη συγκεκριμένη προσπάθεια. Πρόκειται για διανομή Debian Bullseye με πυρήνα 5.19.10 αλλά έχει αναβάθμιση σε πυρήμα 6.3.1! Μια επίσης ολοκληρωμένη προσπάθεια εγκατάστασης με μικρό μέγεθος και τα καλούδια της αυτόματης αύξησης του τομέα του λειτουργικού ώστε να μποέσουμε να χρησιμοποιήσουμε όλο το μέγεθος της κάρτας eMMC ή microSD στην οποία την εγκαθιστούμε. Debian Bullseye for Exynos4 boards: The link leads to a forum where I saw this particular effort. It is a Debian Bullseye distribution with kernel 5.19.10, but it has an upgrade to kernel 6.3.1! A also complete installation effort with small size and the goodies of automatic root partition expansion so that we can use the entire size of the eMMC or microSD card on which we install it.

Φυσικά, όσοι με γνωρίζουν ξέρουν πως δύο είναι οι διανομές linux τις οποίες συμπαθώ πολύ και αυτές είναι η openSUSE και η Debian. Δεν είναι δύσκολο να μαντέψουμε με ποια από τις τρεις θα ασχοληθούμε σε αυτή την ανάρτηση :)

Of course, those who know me know that there are two Linux distributions that I like very much, and these are openSUSE and Debian. It is not hard to guess which of the three we will deal with in this post :)

Εγκατάσταση Debian Bullseye

Debian Bullseye Installation

Ακολουθώντας τις οδηγείες στο Forum, κατεβάζουμε το συμπιεσμένο image στον υπολογιστή μας και το αποσυμπιέζουμε. Αυτό θα μας δώσει ένα αρχείο

Following the instructions in the Forum, we download the compressed image to our computer and decompress it. This will give us a file

Debian-Bullseye-1.0-20221017-Exynos4.img

μεγέθους 1.3G. Αυτό το αρχείο είναι που θα περάσουμε στην κάρτα eMMC. Για να το κάνουμε αυτό χρησιμοποιούμε τον αντάπτορα της eMMC σε microSD της Hardkernel. Τοποθετούμε την eMMC σε ένα microSD reader και είμαστε έτοιμοι για την εγκατάσταση.

of size 1.3G. This file is what we will write to the eMMC card. To do this, we use Hardkernel's eMMC to microSD adapter. We place the eMMC in a microSD reader and we are ready for the installation.

Το πρώτο πράγμα που κάνουμε είναι να δούμε ποια συσκευή συνδέθηκε ώστε να μπορέσουμε να γράψουμε το image στη σωστή. Αυτό είναι ένα επικίνδυνο βήμα γιατί μπορεί να φλασάουμε λάθος συσκευή και τα αποτελέσματα να είναι... χάσιμο χρήσιμων δεδομένων!!!

The first thing we do is to see which device was connected so we can write the image to the correct one. This is a dangerous step because we might flash the wrong device and the results would be... loss of useful data!!!

eliaschr@andromeda:~> dmesg
.
.
.
[11749.335131] [  T26227] scsi 0:0:0:0: Direct-Access     Generic  Mass-Storage     2.00 PQ: 0 ANSI: 2
[11749.335655] [  T26227] sd 0:0:0:0: Attached scsi generic sg0 type 0
[11749.336535] [  T30657] sd 0:0:0:0: [sda] 30777344 512-byte logical blocks: (15.8 GB/14.7 GiB)
[11749.336902] [  T30657] sd 0:0:0:0: [sda] Write Protect is off
[11749.336910] [  T30657] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
[11749.337279] [  T30657] sd 0:0:0:0: [sda] No Caching mode page found
[11749.337284] [  T30657] sd 0:0:0:0: [sda] Assuming drive cache: write through
[11749.370196] [  T30657]  sda: sda1 sda2
[11749.370419] [  T30657] sd 0:0:0:0: [sda] Attached SCSI removable disk

Εδώ φαίνεται από την έξοδο της εντολής πως η καινούργια συσκευή αναγνωρίζεται από το λειτουργικό μας ως /dev/sda αλλά στη δικιά σας περίπτωση ίσως το αναγνωριστικό να είναι διαφορετικό. Μπορούμε να προχωρήσουμε στην εγγραφή του image σε αυτή (προσοχή στο να βάλετε το σωστό αναγνωριστικό στη θέση /dev/sda):

Here it is shown from the command output that the new device is recognized by our operating system as /dev/sda, but in your case the identifier may be different. We can proceed to write the image to it (be careful to put the correct identifier in place of /dev/sda):

eliaschr@andromeda:~> sudo dd if=Debian-Bullseye-1.0-20221017-Exynos4.img of=/dev/sda bs=4M status=progress conv=notrunc,fsync
855638016 bytes (856 MB, 816 MiB) copied, 2 s, 427 MB/s1346371584 bytes (1,3 GB, 1,3 GiB) copied, 2,93373 s, 459 MB/s

321+0 records in
321+0 records out
1346371584 bytes (1,3 GB, 1,3 GiB) copied, 80,3897 s, 16,7 MB/s

Όταν η εντολή ολοκληρωθεί θα έχουμε το Debian έτοιμο να τρέξει στο ODroid μας. Βγάζουμε την κάρτα από το microSD reader και τη συνδέουμε στο ODroid. Θα πρέπει να γνωρίζουμε πως στην πρώτη εκκίνηση εκτελούνται κάποια scripts που προετοιμάζουν τη διανομή για τη λειτουργία της στο αποθηκευτικό μέσο που την εγκαταστήσαμε, όπως το να επεκτείνει το partition ώστε να καταλάβει όλο το διαθέσιμο χώρο. Μετά από αυτές τις μικροεπεμβάσεις ενδέχεται να κάνει επανεκκίνηση το σύστημα μόνο του.

When the command completes, we will have Debian ready to run on our ODroid. We remove the card from the microSD reader and connect it to the ODroid. We should know that on first boot some scripts run that prepare the distribution for operation on the storage medium where we installed it, such as expanding the partition to occupy all available space. After these small interventions, the system may reboot on its own.

Η eMMC δεν εκκινεί

eMMC Does Not Boot

Υπάρχει μια πιθανότητα να μην εκκινήσει η εγκατάστασή μας από την eMMC. Σε αυτή την περίπτωση, συνδέουμε και πάλι την eMMC στο μετατροπέα της microSD κι εκκινούμε από τη microSD στο ODroid. Αν και πάλι δεν εκκινήσει τότε κάτι δεν πήγε καλά στην εγγραφή. Αν όμως εκκινήσει, τότε χρειάζεται να γράψουμε ένα καινούργιο u-boot στην eMMC ώστε να μπορέσει να τη διαχειριστεί το ODroid ως bootable. Αν όμως λειτούργησε κανονικα η eMMC στη σωστή υποδοχή της τότε προσπεράστε αυτό το βήμα!

There is a possibility that our installation will not boot from the eMMC. In that case, we connect the eMMC back to the microSD adapter and boot from the microSD slot on the ODroid. If it still does not boot, then something went wrong during writing. But if it boots, then we need to write a new u-boot to the eMMC so that the ODroid can manage it as bootable. If the eMMC worked normally in its proper socket, then skip this step!

Το u-boot είναι ένα σύστημα που βοηθάει στην εκκίνηση των υπολογιστών αυτής της κατηγορίας. Βρίσκεται στους πρώτους sectors του μέσου αποθήκευσης, αλλά στην περίπτωση των eMMC, αυτοί είναι προστατευμένοι από εγγραφή, έτσι ώστε να μη μπορεί να αλλάξει από λάθος. Αν διαγραφεί το u-boot τότε ο υπολογιστής μας δε μπορεί να εκκινήσει.

The u-boot is a system that helps boot computers of this category. It resides in the first sectors of the storage medium, but in the case of eMMC, these are write-protected, so that it cannot be changed by mistake. If the u-boot is erased, then our computer cannot boot.

Για να μπορέσουμε να αλλάξουμε το u-boot κανονικά θα πρέπει να απενεργοποιήσουμε την προστασία εγγραφής της eMMC, να γράψουμε τους κατάλληλους sectors έτσι ώστε να μην πειράξουμε το partition table και στη συνέχεια να επαναφέρουμε την προστασία. Ευτυχώς, μιας και η διαδικασία είναι λίγο tricky το ανοικτό λογισμικό δείχνει για άλλη μια φορά τη δύναμή του. Υπάρχει έτοιμο script που γράφει το u-boot στην eMMC χωρίς να χρειαστεί τίποτα άλλο από το να το εκτελέσουμε. Θα το βρούμε στο github του Ben Howell, απ' όπου μπορούμε και να το κατεβάσουμε.

To change the u-boot properly, we need to disable the write protection of the eMMC, write the appropriate sectors so as not to touch the partition table, and then re-enable the protection. Fortunately, since the process is a bit tricky, open source shows its power once again. There is a ready-made script that writes the u-boot to the eMMC without needing anything else but to execute it. We will find it on Ben Howell's github, from where we can also download it.

Έχωντας εκκινήσει από τη microSD θύρα, απλά κάνουμε login ως root με κωδικό odroid.Aυτό μπορεί να γίνει με διάφορους τρόπους:

Having booted from the microSD port, we simply log in as root with password odroid. This can be done in various ways:

  • Ο πιο απλός είναι να έχουμε συνδέσει οθόνη και πληκτρολόγιο στο ODroid. The simplest is to have a monitor and keyboard connected to the ODroid.
  • Αν θέλουμε μπορούμε να μπούμε με ssh, αρκεί να γνωρίζουμε τη διεύθυνση ip του ODroid. If we want, we can log in via ssh, as long as we know the ODroid's IP address.
  • Ο τρίτος τρόπος είναι να κάνουμε χρήση του USB-to-serial της Hardkernel και να χρησιμοποιήσουμε ένα πρόγραμμα τερματικού, όπως το CuteCom για να κάνουμε login από τον υπολογιστή μας, απευθείας. The third way is to use Hardkernel's USB-to-serial and use a terminal program, like CuteCom, to log in directly from our computer.

Αν προσπαθήσετε να χρησιμοποιήσετε τον τρίτο τρόπο αλλά βλέπετε στο τερματικό στο τέλος ένα μήνυμα

If you try to use the third method but at the end of the terminal you see a message

[    0.000000] printk: bootconsole [exynos4210] disabled

τότε η λύση φαίνεται στην παρακάτω παράγραφο, Ενεργοποίηση του σειριακού τερματικού. Μπορείτε αν θέλετε να κάνετε τη διόρθωση πρώτα και μετά να επιστρέψετε σε αυτό το σημείο και να ολοκληρώσετε την ενεργοποίηση της eMMC με καινούργιο u-boot.

then the solution is shown in the following paragraph, Enabling the serial terminal. You can, if you want, make the correction first and then return to this point and complete the enabling of the eMMC with a new u-boot.

Σε αυτό το σημείο θα χρησιμοποιήσω τη δεύτερη περίπτωση, μιας και οι άλλες δύο είναι ίδιες με την περίπτωση που κάνουμε login και στον υπολογιστή μας. Για να βρούμε τη διεύθυνση IP αρκεί να κοιτάξουμε τη σελίδα του router μας στις εκχωρημένες διευθύνσεις και θα τη δούμε. Στη δικιά μου περίπτωση είναι η 192.168.1.238. Έτσι, δίνω την εντολή ssh:

At this point I will use the second option, since the other two are the same as logging in on our computer. To find the IP address, it is enough to look at our router's page in the assigned addresses and we will see it. In my case it is 192.168.1.238. So, I issue the ssh command:

eliaschr@andromeda:~> ssh root@192.168.1.238
The authenticity of host '192.168.1.238 (192.168.1.238)' can't be established.
ED25519 key fingerprint is: ...
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.1.238' (ED25519) to the list of known hosts.
root@192.168.1.238's password: 
Linux odroid-bullseye 5.19.10-armmp-lpae #exynos SMP PREEMPT Sun Sep 25 14:52:18 UTC 2022 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@odroid-bullseye:~# apt update
Get:1 http://deb.debian.org/debian bullseye InRelease [75.1 kB]
Get:2 http://security.debian.org bullseye-security InRelease [27.2 kB]                                            
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.0 kB]                                                       
.
.
.
root@odroid-bullseye:~#

Το πρώτο πράγμα που κάνουμε είναι να εγκαταστήσουμε το git για να μπορέσουμε να κλωνοποιήσουμε το αποθετήριο του προγράμματος εγκατάστασης του u-boot. Αυτό έχει ως προαπαιτούμενο να ενημερωθούν τα περιεχόμενα των αποθετηρίων του apt (εντολή apt update). Κάτι που θα παρατηρήσουμε είναι πως κατά τη διάρκεια του update υπάρχει σφάλμα όταν πάει το σύστημα να διαβάσει το αποθετήριο backports. Αυτό το αποθετήριο έχει καταργηθεί κι έτσι πρέπει να το απομακρύνουμε από τη λίστα των αποθετηρίων. Αυτό γίνεται πολύ εύκολα με το να απενεργοποιήσουμε την αντίστοιχη γραμμή από τη λίστα των αποθετηρίων στο αρχείο /etc/apt/sources.list προσθέτωντας απλά ένα '# στην αρχή της. Το τελικό περιεχόμενο του αρχείου φαίνεται ακολούθως:

The first thing we do is install git so that we can clone the repository of the u-boot installation program. This requires updating the contents of the apt repositories (command apt update). Something we will notice is that during the update there is an error when the system tries to read the backports repository. This repository has been discontinued, so we need to remove it from the list of repositories. This is done very easily by disabling the corresponding line from the list of repositories in the file /etc/apt/sources.list by simply adding a '#' at the beginning of it. The final content of the file is shown below:

deb http://deb.debian.org/debian bullseye main contrib non-free
deb http://security.debian.org/ bullseye-security main contrib non-free
deb http://deb.debian.org/debian bullseye-updates main contrib non-free
# deb http://deb.debian.org/debian bullseye-backports main contrib non-free

Με αυτό τον τρόπο θα σταματήσει να υπάρχει σφάλμα κατά την ενημέρωση των αποθετηρίων. Τώρα μπορούμε να εγκαταστήσουμε το git.

In this way, the error during the repository update will stop occurring. Now we can install git.

root@odroid-bullseye:~# apt-get install git
Reading package lists... Done
Building dependency tree... Done
.
.
.
Do you want to continue? [Y/n] Y
.
.
.
root@odroid-bullseye:~#

Σειρά έχει η κλωνοποίηση...

Now its time to clone the u-boot repository...

root@odroid-bullseye:~# git clone https://github.com/benhowell/odroid-U3-emmc-u-boot-debian-bullseye.git
Cloning into 'odroid-U3-emmc-u-boot-debian-bullseye'...
.
.
.
root@odroid-bullseye:~#

Για να γίνει η εγκατάσταση του u-boot αρκεί να μπούμε μέσα στον καινούργιο κατάλογο και να τρέξουμε το script. Ακολουθούμε τα βήματα:

In order to install u-boot, we must enter the newlly created directory and run its fusng script. Follow the steps:

root@odroid-bullseye:~# cd odroid-U3-emmc-u-boot-debian-bullseye/
root@odroid-bullseye:~/odroid-U3-emmc-u-boot-debian-bullseye# chmod +x sd_fusing.sh
root@odroid-bullseye:~/odroid-U3-emmc-u-boot-debian-bullseye# ll /dev/disk/by-id/
total 0
lrwxrwxrwx 1 root root 13 Aug 27 15:38 mmc-016G92_0xc84d948e -> ../../mmcblk0
lrwxrwxrwx 1 root root 15 Aug 27 15:38 mmc-016G92_0xc84d948e-part1 -> ../../mmcblk0p1
lrwxrwxrwx 1 root root 15 Aug 27 15:38 mmc-016G92_0xc84d948e-part2 -> ../../mmcblk0p2
root@odroid-bullseye:~/odroid-U3-emmc-u-boot-debian-bullseye#

Αφού μπούμε στον κατάλογο, μαρκάρουμε το sd_fusing.sh ως εκτελέσιμο, βλέπουμε την ονομασία της συσκευής αποθήκευσης (/dev/mmcblk0) και στη συνέχεια εκτελούμε το script ώστε να εγγραφεί σε αυτή τη συσκευή το καινούργιο u-boot. Η τελευταία εντολή παίρνει λίγη ώρα για να ολοκληρωθεί!

After we enter the directory, we mark sd_fusing.sh as executable, we see the name of the storage device (/dev/mmcblk0) and then we execute the script so that the new u-boot is written to this device. The last command takes a little while to complete!

root@odroid-bullseye:~/odroid-U3-emmc-u-boot-debian-bullseye# ./sd_fusing.sh /dev/mmcblk0
++ '[' -z /dev/mmcblk0 ']'
++ '[' -b /dev/mmcblk0 ']'
++ echo '/dev/mmcblk0 reader is identified.'
/dev/mmcblk0 reader is identified.
.
.
.
U-boot image is fused successfully.
++ echo 'Eject SD card and insert it again.'
Eject SD card and insert it again.
root@odroid-bullseye:~/odroid-U3-emmc-u-boot-debian-bullseye#

Απενεργοποιούμε το ODroid και στη συνέχεια βάζουμε τηνβ eMMC στην υποδοχή της. Το σύστημα πρέπει να εκκινήσει κανονικά όταν το ενεργοποιήσουμε ξανά.

We turn off the ODroid and then place the eMMC in its slot. The system should boot normally when we turn it on again.

Ενεργοποίηση του Σειριακού Τερματικού

Enabling the Serial Terminal

Αρχικά ας δούμε λίγα πράγματα για την εκκίνηση του ODroid (ισχύει και για άλλους υπολογιστές μιας πλακέτας SBCs). Το πρώτο partition μέσα στην eMMC είναι ο τομέας boot. Εκεί βρίσκονται κάποια ενδιαφέροντα αρχεία. Μπορούμε να τα δούμε όταν έχουμε κάνει login ως root μέσα στον κατάλογο /boot.

First, let's look at a few things about the ODroid boot process (this also applies to other single-board computers, SBCs). The first partition inside the eMMC is the boot partition. There are some interesting files located there. We can see them when we have logged in as root inside the /boot directory.

root@odroid-bullseye:~# cd /boot/
root@odroid-bullseye:/boot# ll
total 22828
-rw-r--r-- 1 root root  5186917 Sep 25  2022 System.map-5.19.10-armmp-lpae
-rw-r--r-- 1 root root     4221 Oct  3  2022 boot.scr
-rw-r--r-- 1 root root   183610 Sep 25  2022 config-5.19.10-armmp-lpae
-rw-r--r-- 1 root root     4844 Jul 10  2022 config.ini
lrwxrwxrwx 1 root root       49 Oct  3  2022 dtb -> dtbs/5.19.10-armmp-lpae/./exynos4412-odroidu3.dtb
lrwxrwxrwx 1 root root       49 Oct  3  2022 dtb-5.19.10-armmp-lpae -> dtbs/5.19.10-armmp-lpae/./exynos4412-odroidu3.dtb
drwxr-xr-x 3 root root     4096 Oct  3  2022 dtbs
-rw-r--r-- 1 root root  7529363 Oct  3  2022 initrd.img-5.19.10-armmp-lpae
drwx------ 2 root root    16384 Jun 17  2022 lost+found
-rwxr-xr-x 1 root root 10431864 Sep 25  2022 vmlinuz-5.19.10-armmp-lpae
root@odroid-bullseye:/boot#

Αν γνωρίζουμε λίγα πράγραματα από τον τρόπο με τον οποίο φορτώνεται το Linux στον υπολογιστή μας, θα αναγνωρίσουμε κάποια αρχεία, όπως το αρχικό ram disk image και το αρχείο του βασικού πυρήνα. Όμως αυτά τα αρχεία τα οποία έχουν ιδιαίτερη σημασία είναι το boot.scr και το config.ini. Ενώ και τα δύο αρχεία μπορούμε να τα δούμε ως απλά αρχεία κειμένου, αυτό στην πραγματικότητα ισχύει μόνο για το config.ini. Το boot.scr είναι ένα αρχείο κειμένου, αλλά τα πρώτα bytes του περιέχουν κάποιες πληροφορίες σχετικές με το αρχείο. Αν κάνουμε κάποια αλλαγή σε αυτό, τότε το u-boot θα το καταλάβει και θα παραπονεθεί πως το αρχείο δεν είναι σωστό, αρνούμενο να προχωρήσει στην εκκίνηση του συστήματος. Για να μπορέσουμε, λοιπόν, να το παραλλάξουμε δεν φτάνει μόνο ένα πρόγραμμα τύπου vi ή nano.

If we know a little about the way Linux loads on our computer, we will recognize some files, such as the initial ram disk image and the main kernel file. However, the files that are particularly important are boot.scr and config.ini. While both files can be viewed as plain text files, this actually applies only to config.ini. boot.scr is a text file, but its first bytes contain some information related to the file. If we make any change to it, then the u-boot will notice it and complain that the file is not correct, refusing to proceed with the system boot. Therefore, to be able to modify it, just a program like vi or nano is not enough.

Το πρώτο πράγμα που κάνουμε είναι να δημιουργήσουμε ένα αντίγραφο ασφαλείας του boot.scr και ένα δεύτερο που μετά να το μετατρέψουμε σε απλό κείμενο ώστε να το επεξεργαστούμε:

The first thing we do is create a backup copy of boot.scr and a second one that we then convert to plain text so that we can edit it:

root@odroid-bullseye:/boot# cp boot.scr boot.scr.bkp
root@odroid-bullseye:/boot# cp boot.scr boot.txt

Στη συνέχεια θα επεξεργαστούμε το boot.txt. Μπορείτε να το κάνετε με το αγαπημένο σας πρόγραμμα. Εγώ είμαι fun του vi, αλλά θα περιγράψω μόνο τις αλλαγές που πρέπει να κάνετε και όχι το πώς. Ανοίγετε το boot.txt και διαγράφετε την πρώτη-πρώτη γραμμή. Αυτή είναι η κεφαλίδα. Με αυτό τον τρόπο θα παραμείνουν μόνο οι εντολές του boot.scr. Στη συνέχεια εντοπίζουμε τις ακόλουθες γραμμές μέσα στο αρχείο:

Then we will edit boot.txt. You can do it with your favorite program. I am a fan of vi, but I will describe only the changes you need to make and not how. Open boot.txt and delete the very first line. This is the header. This way only the boot.scr commands will remain. Then we locate the following lines inside the file:

.
.
.
 70 # different console for AmLogic devices
 71 if test "${soc}" = "meson"; then
 72   setenv console "ttyAML0,115200n8"
 73   setenv usbcore "usbcore.autosuspend=-1"
 74 elif test "${soc}" = "exynos"; then
 75   setenv console "ttySAC2,115200n8"
 76   # set correct dtb file
 77   if test "${board_name}" = "smdk5420xu4"; then
 78     setenv fdtfile "exynos5422-odroidxu4.dtb"
.
.
.

Το σφάλμα βρίσκεται στη γραμμή 75 (στο αρχείο που έχω εγώ, στο δικό σας μπορεί να βρίσκεται σε άλλη γραμμή). Η κονσόλα που πρέπει να χρησιμοποιηθεί είναι η ttySAC1 και όχι η ttySAC2. Μπορείτε να αλλάξετε άφοβα το 2 σε 1 και αποθηκεύετε το αρχείο.

The error is on line 75 (in my file, in yours it may be on a different line). The console that must be used is ttySAC1 and not ttySAC2. You can safely change the 2 to 1 and save the file.

Τέλος μετατρέπουμε το αρχείο boot.txt σε κανονικό αρχείο τύπου scr:

Finally, we convert the boot.txt file into a proper scr file:

root@odroid-bullseye:/boot# mkimage -C none -A arm -T script -d boot.txt boot.scr
Image Name:   
Created:      Thu Aug 27 19:17:36 2026
Image Type:   ARM Linux Script (uncompressed)
Data Size:    4192 Bytes = 4.09 KiB = 0.00 MiB
Load Address: 00000000
Entry Point:  00000000
Contents:
   Image 0: 4184 Bytes = 4.09 KiB = 0.00 MiB
root@odroid-bullseye:/boot#

Αν το σύστημα δεν βρίσκει την εντολή mkimage, τότε θα πρέπει να εγκαταστήσετε το πακέτο u-boot-tools.

If the system does not find the mkimage command then you should install u-boot-toold package.

root@odroid-bullseye:/boot# apt update && apt install u-boot-tools

Έπειτα από την εκτέλεση της mkimage θα έχουμε ένα έγκυρο boot.scr στον κατάλογο. Την επόμενη φορά που θα εκκινήσουμε το ODroid θα έχουμε πρόσβαση στο σειριακό τερματικό και θα είμαστε σε θέση να χειριστούμε το σύστημά μας από εκεί!

After executing mkimage we will have a valid boot.scr in the directory. The next time we boot the ODroid we will have access to the serial terminal and we will be able to control our system from there!

Ενημέρωση του Debian Bullseye

Debian Bullseye Updating

Σε αυτό το σημείο το ODroid πρέπει να εκκινεί κανονικά και να έχουμε πρόσβαση σε αυτό, είτε με φυσική σύνδεση (τερματικό ή πληκτρολόγιο/οθόνη) είτε μέσω δικτύου. Το επόμενο βήμα είναι να κάνουμε ενημέρωση του συστήματος. Θα υπενθυμίσω πως καλό είναι να απενεργοποιηθεί η repository του backports, όπως περιγράφεται στην παράγραφο Η eMMC δεν εκκινεί

At this point the ODroid should boot normally and we should have access to it, either with physical connection (terminal or keyboard/monitor) or via network. The next step is to update the system. I will remind you that it is good to disable the backports repository, as described in the paragraph The eMMC does not boot

root@odroid-bullseye:~# apt update
.
.
.
root@odroid-bullseye:~# apt upgrade
.
.
.
Need to get 107 MB of archives.
After this operation, 130 MB of additional disk space will be used.
Do you want to continue? [Y/n] 

Σε αυτό το σημείο απαντάμε με Y και η ενημέρωση του συστήματος ξεκινάει. Όταν τελειώσει προχωράμε και στο τελευταίο βήμα ενημέρωσης και στη συνέχεια επανεκκίνηση:

Of course, our answer to this prompt is Y and the system updating starts. When its over we proceed to the last updating step and then reboot:

root@odroid-bullseye:~# apt dist-upgrade
.
.
.
root@odroid-bullseye:~# shutdown -r now

Παρότι κάναμε την επανεκκίνηση θα παρατηρήσουμε πως το σύστημα ακόμα τρέχει τον παλιό πυρήνα (5.19.10).

Though we restarted the system we can fnid out that is still runs the old kernel (5.19.10).

root@odroid-bullseye:~# uname -a
Linux odroid-bullseye 5.19.10-armmp-lpae #exynos SMP PREEMPT Sun Sep 25 14:52:18 UTC 2022 armv7l GNU/Linux
root@odroid-bullseye:~#

Μπορούμε να δούμε, όμως, πως υπάρχει ήδη καινούργιος πυρήνας 6.3.1 ο οποίος δεν ενεργοποιήθηκε αυτόματα. Για να τον χρησιμοποιήσουμε θα πρέπει να πούμε στο u-boot πως θα πρέπει να τον φορτώσει, αντί για τον παλιό. Εδώ έρχεται και η χρήση του config.ini που είχαμε βρει μέσα στον κατάλογο /boot. Εκεί θα βρούμε και διάφορα άλλα καλούδια από την άποψη της ρύθμισης της εκκίνησης του συστήματος, όπως και το ποιο video mode θα χρησιμοποιήσουμε. Σε γενικές γραμμές το αρχείο config.ini είναι ένα αρχείο που φορτώνεται πρώτο και απλά δημιουργεί κάποιες μεταβλητές συστήματος. Στη συνέχεια το boot.scr μπορεί και βλέπει αν αυτές οι μεταβλητές είναι ήδη δηλωμένες από τον χρήστη ή θα πρέπει να τις υπολογίσει μόνο του. Έτσι, αν εμείς πειράξουμε κάποια μεταβλητή το u-boot θα σεβαστεί την επιθυμία μας :). Είναι ένα απλό αρχείο κειμένου και δεν χρειάζεται κάποιο ιδιαίτερο τρόπο επεξεργασίας, όπως είναι η περίπτωση του boot.scr. Ένα απλό vi ή nano είναι αρκετό. Ας δούμε πρώτα τα νέα περιεχόμενα του /boot.

We can see, however, that there is already a new kernel 6.3.1 which was not activated automatically. To use it we need to tell u-boot that it should load it, instead of the old one. This is where the use of config.ini that we found inside the /boot directory comes in. There we will also find various other goodies regarding the boot configuration, such as which video mode to use. In general, the config.ini file is a file that loads first and simply creates some system variables. Then boot.scr can see if these variables are already declared by the user or if it has to calculate them itself. So, if we modify some variable, u-boot will respect our wish :). It is a simple text file and does not need any special editing method, unlike boot.scr. A simple vi or nano is enough. Let's first see the new contents of /boot.

root@odroid-bullseye:~# cd /boot/; ll
total 45744
-rw-r--r-- 1 root root  5186917 Sep 25  2022 System.map-5.19.10-armmp-lpae
-rw-r--r-- 1 root root  4336992 May  8  2023 System.map-6.3.1-armmp-lpae
-rw-r--r-- 1 root root     4221 Oct  3  2022 boot.scr
-rw-r--r-- 1 root root     4221 Aug 27 18:38 boot.scr.bkp
-rw-r--r-- 1 root root     4184 Aug 27 19:13 boot.txt
-rw-r--r-- 1 root root   183610 Sep 25  2022 config-5.19.10-armmp-lpae
-rw-r--r-- 1 root root   193979 May  8  2023 config-6.3.1-armmp-lpae
-rw-r--r-- 1 root root     4844 Jul 10  2022 config.ini
lrwxrwxrwx 1 root root       47 Aug 28 08:21 dtb -> dtbs/6.3.1-armmp-lpae/./exynos4412-odroidu3.dtb
lrwxrwxrwx 1 root root       49 Oct  3  2022 dtb-5.19.10-armmp-lpae -> dtbs/5.19.10-armmp-lpae/./exynos4412-odroidu3.dtb
lrwxrwxrwx 1 root root       47 Aug 28 08:21 dtb-6.3.1-armmp-lpae -> dtbs/6.3.1-armmp-lpae/./exynos4412-odroidu3.dtb
drwxr-xr-x 4 root root     4096 Aug 28 08:18 dtbs
-rw-r--r-- 1 root root  7529363 Oct  3  2022 initrd.img-5.19.10-armmp-lpae
-rw-r--r-- 1 root root  7819598 Aug 28 08:20 initrd.img-6.3.1-armmp-lpae
drwx------ 2 root root    16384 Jun 17  2022 lost+found
-rwxr-xr-x 1 root root 10431864 Sep 25  2022 vmlinuz-5.19.10-armmp-lpae
-rwxr-xr-x 1 root root 11088928 May  8  2023 vmlinuz-6.3.1-armmp-lpae
root@odroid-bullseye:/boot#

Σε πρώτη φάση ας παρατηρήσουμε πως ό,τι έχει να κάνει με τον πυρήνα 5.19.10 έχει ως αναγνωριστικό το 5.19.10-armmp-lpae, ενώ ό,τι αφορά τον πυρήνα 6.3.1 έχει αναγνωριστικό το 6.3.1-armmp-lpae. Αυτό το χρειαζόμαστε για το config.ini. Ας δούμε κάποιες αλλαγές που μπορούμε να κάνουμε μέσα στο αρχείο αυτό:

First, let's observe that everything related to kernel 5.19.10 has the identifier 5.19.10-armmp-lpae, while everything related to kernel 6.3.1 has the identifier 6.3.1-armmp-lpae. We need this for config.ini. Let's look at some changes we can make inside this file:

  • Με μια αναζήτηση στο boot.scr μπορούμε να δούμε τις γραμμές: Searching through the boot.scr file we can find the lines:
    .
    .
    .
    if test -z "${fk_kvers}"; then
      setenv fk_kvers '5.19.10-armmp-lpae'
    fi
    .
    .
    .
    Αυτό μας δείχνει πως αν εμείς αλλάξουμε το νούμερο του πυρήνα, τότε το σύστημα θα εκκινεί τον καινούργιο. Για να το κάνουμε αυτό απλά προσθέτουμε στο τέλος του config.ini τη γραμμή: This shows us that if we change the kernel number, then the system will boot the new one. To do this, we simply add to the end of config.ini the line:
    fk_kvers="6.3.1-armmp-lpae"
    τότε στην επόμενη εκκίνηση θα πρέπει να έχει φορτωθεί ο καινούργιος πυρήνας. Μετά από ένα reboot και ξανά login ας το ελέγξουμε: then on the next boot the new kernel should be loaded. After a reboot and logging in again, let's check it:
    root@odroid-bullseye:~# uname -a
    Linux odroid-bullseye 6.3.1-armmp-lpae #exynos5 SMP PREEMPT Mon May  8 15:27:00 UTC 2023 armv7l GNU/Linux
    root@odroid-bullseye:~#
  • Υπάρχει ένα τμήμα μέσα στο config.ini που ασχολείται με την ανάλυση της οθόνης. Αυτό ίσως χρειαστεί να το πειράξουμε για να θέσουμε την κατάλληλη ανάλυση και ρυθμό σάρωσης για την οθόνη που χρησιμοποιούμε. Ίσως μας χρειαστεί αν δουλέψουμε με το KlipperScreen. Ας το γνωρίσουμε: There is a section inside config.ini that deals with the screen resolution. We might need to modify it to set the appropriate resolution and refresh rate for the monitor we are using. We may need it if we work with KlipperScreen. Let's get to know it:
    ; Video Resolution
    ; You can specifiy a desired resolution
    ; Please note: this only applies to framebuffer and may be overwritten from a Desktop that you have installed
    ; https://www.kernel.org/doc/Documentation/fb/modedb.txt
    ; examples:
    ; ODROID-VU forced resolution
    ; videoconfig="video=HDMI-A-1:1280x800@60"
    ; -----------------------------------------------
    ; ODROID-VU forced EDID
    ; videoconfig="drm.edid_firmware=edid/1280x800.bin"
    ; -----------------------------------------------
    ; 1920x1080 (1080P) with monitor provided EDID information. (1080p-edid)
    ; videoconfig="video=HDMI-A-1:1920x1080@60"
    ; -----------------------------------------------
    .
    .
    .
    Τα ';' στην αρχή κάθε γραμμής δηλώνουν πως αυτές οι γραμμές είναι σχόλια, δηλαδή αγνοούνται. Αν εμείς σβήσουμε τον χαρακτήρα αυτό από κάποια γραμμή με videoconfig="..." τότε υποχρεώνουμε το ODroid να χρησιμοποιήσει αυτή την ανάλυση. Στη δικιά μου περίπτωση η ενεργοποίηση του 1080p@60-edid διόρθωσε κάποια τρεμοπαιξίματα που είχα στην εικόνα της οθόνης μου. Μόνο μια από αυτές τις γραμμές μπορεί να είναι ενεργοποιημένη. The ';' at the beginning of each line indicate that these lines are comments, meaning they are ignored. If we remove this character from a line with videoconfig="...", then we force the ODroid to use that resolution. In my case, enabling 1080p@60-edid fixed some flickering I had in my screen image. Only one of these lines can be enabled.
  • Γενικά μέσα στο config.ini υπάρχουν επιλογές όπως το όνομα που θα εμφανίζεται κατά την εκκίνηση, τη MAC Address που θέλουμε να έχει το ODroid στο δίκτυο και κάποιες άλλες επιλογές, μικρής για την ώρα αξίας. Όμως μια μικρή μελέτη του boot.scr και του config.ini μπορεί να σας οδηγήσει σε κάποιες επιλογές που ταιριάζουν στη δικιά σας περίπτωση. Generally inside config.ini there are options such as the name that will appear during boot, the MAC Address we want the ODroid to have on the network, and some other options of little value for now. However, a little study of boot.scr and config.ini can lead you to some options that suit your own case.

Τελικές Ρυθμίσεις του Λειτουργικού

Final Touches on the New Operating System

Μέσα σε αυτή τη διανομή υπάρχει ένα script που ονομάζεται setup-odroid. Αυτό φροντίζει για κάποιες λεπτομέρειες, όπως η αλλαγή του password του root, η δημιουργία νέων χρηστών, η αλλαγή του ονόματος του συστήματος στο δίκτυο, κλπ. Όταν το τρέξουμε θα μας εμφανίσει ένα μενού. Από αυτό δημιουργούμε ένα χρήστη με δυνατότητα superuser, αλλάζουμε το password του root μιας και δεν είναι καλή τακτική να έχουμε το αρχικό και αν θέλουμε αλλάζουμε και το όνομα του συστήματος, κάθε φορά ενεργοποιώντας την κατάλληλη επιλογή και ακολουθώντας τα βήματα που περιγράφονται στην οθόνη. Π.χ. εγω το όνομα που έδωσα στο δικό μου είναι 'ender5-plus' μιας και γι' αυτόν τον εκτυπωτή το προορίζω. Παρότι μας δίνεται η επιλογή, δεν εγκαθιστούμε κάποιο γραφικό περιβάλλον.

Inside this distribution there is a script called setup-odroid. It takes care of some details, such as changing the root password, creating new users, changing the system's hostname on the network, etc. When we run it, it will present us with a menu. From there we create a user with superuser privileges, change the root password since it is not good practice to keep the initial one, and if we want, change the system's hostname, each time activating the appropriate option and following the steps described on screen. For example, the name I gave mine is 'ender5-plus' since that is the printer I intend it for. Although we are given the option, we do not install a graphical environment.

Κατά την έξοδο από το script, το σύστημα μας ζητάει να κάνουμε επανεκκίνηση για να εφαρμοστούν όλες οι αλλαγες. Από την επόμενη φορά μπορούμε να κάνουμε login ως ο χρήστης που δημιουργήσαμε.

When exiting the script, the system asks us to reboot for all changes to take effect. From the next time, we can log in as the user we created.

Κάτι που παρατηρούμε εύκολα είναι πως δεν υπαρχει εγκαταστημένο το sudo, κάτι που διορθώνεται εύκολα. Κάνουμε login ως root όπως κάναμε μέχρι τώρα και δίνουμε τις εντολές:

Something we easily notice is that sudo is not installed, which is easily fixed. We log in as root as we have been doing and issue the commands:

root@ender5-plus:~# apt update
.
.
.
root@ender5-plus:~# apt-get install sudo
.
.
.
Setting up sudo (1.9.5p2-3+deb11u4) ...
invoke-rc.d: policy-rc.d denied execution of start.
Processing triggers for man-db (2.9.4-2) ...
root@ender5-plus:~#

Μετά από αυτό, ο χρήστης μας θα έχει τη δυνατότητα να χρησιμοποιεί το sudo για να κάνει δουλειές ως superuser.

After this, our user will have the ability to use sudo to do work as superuser.

Εγκατάσταση Klipper

Klipper Installation

Τώρα που το λειτουργικό μας είναι ενεργό και λειτουργεί κανονικά, ήρθε η ώρα να εγκαταστήσουμε το Klipper. Το Klipper είναι ένα ανοικτού λογισμικού λειτουργικό σύστημα για 3D εκτυπωτές. Παρέχει πολλά καλούδια και είναι αρκετά ικανό στην επέκταση αλλά και ρύθμιση παραμέτρων που έχουν να κάνουν με το φυσικό μας μηχάνημα, σε αντίθεση με το Marlin που για να αλλάξεις κάποιες παραμέτρους θα πρέπει να το ξανακάνεις compile και να το εγκαταστήσεις στον controller του εκτυπωτή. Στην περίπτωση του Marlin ο controller δεν χρειάζεται να είναι κάτι ιδιαίτερο, αλλά στην περίπτωση του Klipper πρέπει να υπάρχει ένας υπολογιστής που είναι ο εγκέφαλος του συστήματος. Στη δικιά μας περίπτωση αυτός ο εγκέφαλος είναι το ODroid. Δε θα προσπαθήσω να δείξω σε κάποιον πώς να αποφασίσει ποιο είναι καλύτερο για τη δικιά του περίπτωση. Γι' αυτό υπάρχουν άπειρες πληροφορίες μέσα στο διαδίκτυο.

Now that our operating system is active and working properly, it's time to install Klipper. Klipper is an open-source firmware for 3D printers. It provides many benefits and is quite capable of extension and configuration of parameters related to our physical machine, unlike Marlin where changing some parameters requires recompiling and reinstalling on the printer's controller. In the case of Marlin, the controller doesn't need to be anything special, but with Klipper there must be a computer that is the brain of the system. In our case, that brain is the ODroid. I won't try to show anyone how to decide which is better for their own situation—there is endless information about that on the internet.

Πίσω από το Klipper υπάρχει μια μεγάλη κοινότητα, η οποία μας κάνει τα πράγματα πιο απλά. Για την εγκατάσταση έχει δημιουργήσει το KIAUH (Klipper Installation and Updating Helper). Με τη βοήθειά του θα κάνουμε εγκατάσταση το σύστημα και κάποια πρόσθετά του, αλλά για να το χρησιμοποιήσουμε θα πρέπει να το εγκαταστήσουμε στο ODroid μας. Αφού κάνουμε login σαν απλός χρήστης κλωνοποιούμε το αποθετήριο του KIAUH.

Behind Klipper there is a large community that makes things easier for us. For installation, they have created KIAUH (Klipper Installation and Updating Helper). With its help we will install the system and some of its add-ons, but to use it we need to install it on our ODroid. After logging in as a regular user, we clone the KIAUH repository.

eliaschr@ender5-plus:~$ git clone https://github.com/dw-0/kiauh.git
Cloning into 'kiauh'...
.
.
.
Receiving objects: 100% (6247/6247), 2.61 MiB | 1.03 MiB/s, done.
Resolving deltas: 100% (4212/4212), done.
eliaschr@ender5-plus:~$
Σε αυτό το σημείο, αν προσπαθήσουμε να εκτελέσουμε το KIAUH το σύστημα θα παραπονεθεί για την έκδοση της python. Θα πρέπει να κάνουμε εγκατάσταση μιας πρόσφατης έκδοσης python3.

eliaschr@ender5-plus:~$ sudo apt install -y python3 python3-pip
.
.
.
eliaschr@ender5-plus:~$

Τώρα είμαστε σε θέση να εκτελέσουμε το KIAUH.

Now we can run KIAUH.

eliaschr@ender5-plus:~$ cd kiauh
eliaschr@ender5-plus:~/kiauh$ ./kiauh.sh
╔═══════════════════════════════════════════════════════╗
║ ~~~~~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~~~~~ ║
╟──────────────────┬────────────────────────────────────╢
║  0) [Log-Upload] │   Klipper: Not installed           ║
║                  │     Owner: -                       ║
║  1) [Install]    │      Repo: -                       ║
║  2) [Update]     ├────────────────────────────────────╢
║  3) [Remove]     │ Moonraker: Not installed           ║
║  4) [Advanced]   │     Owner: -                       ║
║  5) [Backup]     │      Repo: -                       ║
║                  ├────────────────────────────────────╢
║  S) [Settings]   │        Mainsail: Not installed     ║
║                  │          Fluidd: Not installed     ║
║ Community:       │   Client-Config: -                 ║
║  E) [Extensions] │                                    ║
║                  │   KlipperScreen: Not installed     ║
║                  │       Crowsnest: Not installed     ║
╟──────────────────┼────────────────────────────────────╢
║      v6.3.2      │  Changelog: https://git.io/JnmlX   ║
╟──────────────────┴────────────────────────────────────╢
║                        Q) Quit                        ║
╚═══════════════════════════════════════════════════════╝
###### Perform action: 1

Για να εγκαταστήσουμε το Klipper επιλέγουμε το 1) [Install], στη συνέχεια επιλέγουμε το 1) [Klipper], επιλέγουμε μόνο 1 instance και αν θέλουμε να μας δημιουργήσει ένα παράδειγμα printer.cfg. Εγώ επιλέγω το Y, παρότι όταν ρυθμίζουμε τον εκτυπωτή μας μπορούμε να χρησιμοποιήσουμε άλλο έτοιμο. Όταν προχωρήσει η εγκατάσταση θα μας ρωτήσει αν θέλουμε να βάλει το χρήστη μας στο group dialout. Η απάντηση θα είναι θετική, 'Y'. Αυτό ήταν. Το βασικό Klipper εγκαταστάθηκε!

To install Klipper we select 1) [Install], then we select 1) [Klipper], choose only 1 instance and if we want it to create an example printer.cfg. I choose Y, even though when configuring our printer we can use another ready-made one. When the installation proceeds it will ask if we want to add our user to the dialout group. The answer will be positive, 'Y'. That's it. The basic Klipper is installed!

Εγκατάσταση Moonraker

Moonraker Installation

Το moonraker είναι ένα σύστημα που δίνει πρόσβαση στο API του Klipper μεσω web. Δεν είναι το Web Interface αλλά ο ενδιάμεσος κρίκος από ένα web interface με το ίδιο το Klipper. Η εγκατάστασή του σε ένα 32-bit σύστημα έχει τα προβλήματά της, κυρίως λόγω μιας βιβλιοθήκης της python που δεν υποστηρίζει τέτοια παλιά συστήματα.

The moonraker is a system that provides access to the Klipper API via web. It is not the Web Interface but the intermediary link from a web interface to Klipper itself. Its installation on a 32-bit system has its problems, mainly due to a python library that does not support such old systems.

Ας προσπαθήσουμε να την κάνουμε εγκατάσταση από το KIAUH. Αρχικά στο κεντρικό μενού του KIAUH επιλέγουμε το 1) [Install] και στη συνέχεια το 2) [Moonraker]. Το σύστημα μας ρωτάει αν θέλουμε να κατασκευάσει ένα αρχείο moonraker.conf. Εδώ και πάλι η απάντησή μου είναι θετική, έτσι ώστε να έχω ένα αρχικό ξεκίνημα. Μετά από αυτό ξεκινάει η διαδικασία της εγκατάστασης.

Let's try to install it from KIAUH. First, in the main menu of KIAUH we select 1) [Install] and then 2) [Moonraker]. The system asks if we want it to create a moonraker.conf file. Here again my answer is positive, so that I have a starting point. After that, the installation process begins.

Κι ενώ όλα πάνε υπέροχα, ξαφνικά η εγκατάσταση σταματάει με σφάλμα κατά την εγκατάσταση του markupsafe. Προσπαθεί να εγκαταστήσει την έκδοση 3.0.3 η οποία δεν υποστηρίζει τα 32 bit συστήματα. Θα πρέπει να εγκαταστήσουμε την έκδοση 2.1.5 που υποστηρίζει τα συστήματα σαν το ODroid μας. Για να γίνει αυτό πρέπει να βγούμε από το περιβάλλον του KIAUH και να κάνουμε το υπόλοιπο της εγκατάστασης χειροκίνητα.

And while everything goes wonderfully, suddenly the installation stops with an error during the installation of markupsafe. It tries to install version 3.0.3 which does not support 32-bit systems. We need to install version 2.1.5 which supports systems like our ODroid. To do this, we need to exit the KIAUH environment and do the rest of the installation manually.

Μέχρι τώρα η εγκατάσταση που είχε ξεκινήσει, έχει φέρει τον κώδικα του moonraker από το αποθετήριο στον κατάλογο του χρήστη και έχει φτιάξει ένα εικονικό περιβάλλον της python γι' αυτό. Εμείς θα πρέπει να ενεργοποιήσουμε το περιβάλλον του moonraker, να εγκαταστήσουμε το κατάλληλο markupsafe και να συνεχίσουμε την εγκατάσταση. Στη συνέχεια θα ξαναμπούμε στο KIAUH για να του πούμε να ολοκληρωσει την εγκατάσταση μόνο του, αλλά με τα ήδη υπάρχοντα. Ας δούμε τη διαδικασία βήμα προς βήμα:

Up to now, the installation that had started has fetched the moonraker code from the repository to the user's directory and has created a python virtual environment for it. We will need to activate the moonraker environment, install the appropriate markupsafe, and continue the installation. Then we will re-enter KIAUH to tell it to complete the installation on its own, but with the already existing components. Let's see the process step by step:

Πρώτα πρέπει να ενεργοποιήσουμε το εικονικό περιβάλλον της python για το moonraker.

First we need to activate the python virtual environment for moonraker.

eliaschr@ender5-plus:~/kiauh$ cd ..
eliaschr@ender5-plus:~$ source moonraker-env/bin/activate
(moonraker-env) eliaschr@ender5-plus:~$ pip install markupsafe==2.1.5
.
.
.

Η τελευταία εντολή εγκαθιστά το markupsafe στη σωστή έκδοση που ταιριάζει στα 32 bit συστήματα. Στη συνέχεια θα πρέπει να συνεχίσουμε την εγκατάσταση, αλλά αυτό θα γίνει με το χέρι.

The last command installs markupsafe in the correct version that fits 32-bit systems. Next we need to continue the installation, but this will be done manually.

(moonraker-env) eliaschr@ender5-plus:~$ cd moonraker
(moonraker-env) eliaschr@ender5-plus:~/moonraker$ pip install -r scripts/moonraker-requirements.txt
Looking in links: /home/eliaschr/moonraker/scripts/python_wheels
Collecting tornado<=6.5.8,>=6.2.0
  Using cached tornado-6.5.8.tar.gz (520 kB)
.
.
.

Η εγκατάσταση ουσιαστικά έχει ολοκληρωθεί. Για τυχόν κομμάτια που θα έκανε το KIAUH καλό είναι να εκτελέσουμε άλλη μια φορά την εγκατάσταση από εκεί, αλλά πάμε να δούμε πως... Φυσικά, πριν την εκτέλεση του KIAUH θα πρέπει να βγούμε από το εικονικό περιβάλλον python του moonraker.

The installation has essentially been completed. For any parts that KIAUH would do, it is good to run the installation from there once more, but let's see how... Of course, before running KIAUH we need to exit the moonraker python virtual environment.

(moonraker-env) eliaschr@ender5-plus:~/moonraker$ deactivate
eliaschr@ender5-plus:~/moonraker$ cd ~/kiauh
eliaschr@ender5-plus:~/kiauh$ ./kiauh.sh

Επιλέγουμε το 1) [Install] και στη συνέχεια το 2) [Moonraker]. Ακολουθεί ένα στιγμιότυπο από τα μηνύματα του συστήματος και τις απαντήσεις που δίνουμε:

We select 1) [Install] and then 2) [Moonraker]. A screenshot of the system messages and the answers we give follows:

###### Create example moonraker.conf? (Y/n): Y

###### Cloning repository from 'https://github.com/Arksine/moonraker'
###### '/home/eliaschr/moonraker' already exists. Overwrite? (y/N): N
[INFO] Skip cloning of repository ...

###### Parsing Moonraker system dependencies  ...
[INFO] Parsing system dependencies from system-dependencies.json ...

###### Set up Python virtual environment ...
###### Virtualenv already exists. Re-create? (y/N): N
[INFO] Skipping re-creation of virtualenv ...

###### Installing Moonraker policykit rules ...
[sudo] password for eliaschr: 
[INFO] Moonraker policykit rules are already installed.

###### Creating new Moonraker Instance ...
[OK] Service file created: /etc/systemd/system/moonraker.service
[OK] Env file created: /home/eliaschr/printer_data/systemd/moonraker.env

###### Enable moonraker.service ...
[OK] OK!

###### Creating example moonraker.conf in '/home/eliaschr/printer_data/config'
[INFO] '/home/eliaschr/printer_data/config/moonraker.conf' already exists.

###### Start moonraker.service ...
[OK] OK!
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃         [ Moonraker successfully installed! ]         ┃
┠───────────────────────────────────────────────────────┨
┃ You can access Moonraker via the following URL:       ┃
┃ ● moonraker: http://192.168.1.5:7125                  ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

Και επίσημα, πλέον, η εγκατάσταση του Moonraker έχει ολοκληρωθεί! Αν θέλετε να τεστάρετε τη λειτουργία του, μπορείτε να επισκευτείτε με ένα browser τη σελίδα του, όπως φαίνεται και στην ακόλουθη εικόνα:

And now, officially, the installation of Moonraker has been completed! If you want to test its functionality, you can visit its page with a browser, as shown in the following image:

Εγκατάσταση Fluidd

Fluidd Installation

Επόμενο βήμα στη διεργασία μας είναι να εγκαταστήσουμε ένα Web περιβάλλον. Εδώ έχουμε τη δυνατότητα να εγκαταστήσουμε είτε το Mainsail είτε το Fluidd. Εγώ θα προχωρήσω με το Fluidd, αλλά δε νομίζω να υπάρχει κάποιο πρόβλημα στην εγκατάσταση του Mainsail. Είναι καθαράστη δικιά σας επιλογή.

Next step in our process is to install a Web environment. Here we have the ability to install either Mainsail or Fluidd. I will proceed with Fluidd, but I don't think there is any problem with installing Mainsail. It is entirely your own choice.

Όπως πάντα, αν είμαστε στην κεντρική οθόνη του KIAUH, επιλέγουμε το 1) [Install] Ενώ στην επόμενη οθόνη επιλέγουμε το περιβάλλον Web που θέλουμε. Εδώ εγώ θα επιλέξω το 4) [Fluidd]. Η συνέχεια της εγκατάστασης δεν περιλαμβάνει εκπλήξεις όπως πριν.

As always, if we are on the main screen of KIAUH, we select 1) [Install]. And on the next screen we select the Web environment we want. Here I will select 4) [Fluidd]. The rest of the installation does not include surprises like before.

###### Perform action: 4
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                       [ INFO ]                        ┃
┠───────────────────────────────────────────────────────┨
┃ It is recommended to use special macros in order to   ┃
┃ have Fluidd fully functional and working.             ┃
┃                                                       ┃
┃ The recommended macros for Fluidd can be seen here:   ┃
┃ https://github.com/fluidd-core/fluidd-config          ┃
┃                                                       ┃
┃ If you already use these macros skip this step.       ┃
┃ Otherwise you should consider to answer with 'Y' to   ┃
┃ download the recommended macros.                      ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
###### Download the recommended Fluidd-Config? (Y/n): Y
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Please select the port, Fluidd should be served on.   ┃
┃ If your are unsure what to select, hit Enter to apply ┃
┃ the suggested value of: 80                            ┃
┃                                                       ┃
┃ In case you need Fluidd to be served on a specific    ┃
┃ port, you can set it now. Make sure that the port is  ┃
┃ not already used by another application on your       ┃
┃ system!                                               ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
###### Configure Fluidd for port (default=80): 

###### Installing dependencies ...
.
.
.
###### Restart nginx ...
[OK] OK!
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃           [ Fluidd installation complete! ]           ┃
┠───────────────────────────────────────────────────────┨
┃        Open Fluidd now on: http://192.168.1.5         ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

Αν θέλουμε να ελέγξουμε την εγκατάσταση τότε απλά επισκεπτόμαστε την ιστοσελίδα του ODroid με ένα browser και βλέπουμε το ακόλουθο:

If we want to check the installation then we simply visit the ODroid's website with a browser and see the following:

Φυσικά, το σφάλμα που δίνει το Klippy είναι λογικό, μιας και δεν υπάρχει συνδεδεμένος άλλος controller εκτυπωτή στο ODroid. Μπορείτε να το αγνοήσετε, αυτό θα φτιαχτεί όταν ρυθμίσετε το ODroid σας να λειτουργήσει με τον υπόλοιπο 3D εκτυπωτή σας.

Of course, the error given by Klippy is logical, since there is no other printer controller connected to the ODroid. You can ignore it; it will be fixed when you configure your ODroid to work with the rest of your 3D printer.

Εγκατάσταση KlipperScreen

KlipperScreen Installation

Το KlipperScreen είναι ένα module που μας δίνει τη δυνατότητα να χρησιμοποιήσουμε μια οθόνη HDMI και κάποιο συμβατό touchscreen για να κάνουμε χειρισμό του εκτυπωτή μας τοπικά και όχι μέσω δικτύου. Μπορεί να λειτουργήσει είτε ως ένα περιβάλλον X11 ή Wayland, ή ακόμα και σαν απλή εφαρμογή που τρέχει μέσα σε ένα ήδη υπάρχον γραφικό περιβάλλον. Στην περίπτωση του ODroid θα λειτουργήσει ως περιβάλλον X11.

KlipperScreen is a module that gives us the ability to use an HDMI display and a compatible touchscreen to control our printer locally rather than over the network. It can run either as an X11 or Wayland environment, or even as a simple application inside an existing graphical environment. In the case of the ODroid, it will run as an X11 environment.

Για την εγκατάστασή του θα χρησιμοποιήσουμε πάλι το KIAUH, αλλά κι εδώ θα αντιμετωπίσουμε πρόβλημα, όπως έγινε και με το Moonraker. Θα το διαχειριστούμε, όμως, με άλλη προσέγγιση μιας και το KlipperScreen μηδενίζει το εικονικό του περιβάλλον κι έτσι η προσέγγιση που χρησιμοποιήσαμε στο moonraker δεν είναι η σωστή.

For its installation we will again use KIAUH, but here too we will face a problem, as happened with Moonraker. We will manage it, however, with a different approach since KlipperScreen resets its virtual environment, so the approach we used for moonraker is not the right one.

Ας ξεκινήσουμε την εγκατάσταση του KlipperScreen. Αρχικά τρέχουμε το KIAUH (αν δεν είμαστε ήδη εκεί) και επιλέγουμε το 1) [Install]. Στην επόμενη οθόνη επιλέγουμε το 7) [KlipperScreen]. Το σύστημα ξεκινάει με το κατέβασμα του KlipperScreen από το αποθετήριο. Στη συνέχεια μας ρωτάει για το αν θέλουμε να είναι γραφικό περιβάλλον από μόνο του ή να τρέχει ως εφαρμογή. Επιλέγουμε τη standalone προσέγγιση με 'Y'. Στη συνέχεια μας ρωτάει αν θέλουμε να λειτουργήσει με X11 ή με Wayland. Εδώ προτείνω το X11, οπότε απαντάμε με 'X'. Μας ρωτάει και το password του χρήστη μας για να μπορέσει να κάνει την εγκατάσταση των πακέτων του συστήματος. Και μετά από αυτό παρακολουθούμε την εγκατάσταση μέχρι να ολοκληρωθεί. Όμως η αγκατάσταση θα παρουσιάσει κάοπιο σφάλμα και παρότι θα συνεχίσει δε θα είναι λειτουργική.

Let's start the installation of KlipperScreen. First we run KIAUH (if we are not already there) and select 1) [Install]. On the next screen we select 7) [KlipperScreen]. The system begins by downloading KlipperScreen from the repository. Then it asks whether we want it to be a standalone graphical environment or to run as an application. We choose the standalone approach with 'Y'. Then it asks whether we want it to run with X11 or Wayland. Here I recommend X11, so we answer with 'X'. It also asks for our user password to be able to install system packages. After that, we watch the installation until it completes. However, the installation will show some error and although it will continue, it will not be functional.

###### Perform action: 7
###### Installing KlipperScreen ...

###### Cloning repository from 'https://github.com/KlipperScreen/KlipperScreen.git'
.
.
.
Checking Python version > 3,8
Python 3.9.2
Install standalone?
It will create a service, enable boot to console and install the graphical dependencies.

Say no to install as a regular desktop app that will not start automatically

Press enter for default (Yes)
[Y/n]Υ

Choose graphical backend

Wayland requires working KMS/DRM drivers

Press enter to install X11/Xserver
Backend X11 or Wayland (cage)? [X/w]X
Installing Xserver
[sudo] password for eliaschr: 
.
.
.

Για να μπορέσουμε να διορθώσουμε το πρόβλημα θα πρέπει να μπούμε στον κατάλογο του KlipperScreen και να δηλώσουμε στα requirements πως θέλουμε το markupsafe 2.1.5. Έτσι, αφού βγούμε από το KIAUH εκτελούμε τις εντολές:

To fix the problem, we need to enter the KlipperScreen directory and specify in the requirements that we want markupsafe 2.1.5. So, after exiting KIAUH, we run the commands:

eliaschr@ender5-plus:~/kiauh$ cd ~/KlipperScreen/scripts/
eliaschr@ender5-plus:~/KlipperScreen/scripts$ vi KlipperScreen-requirements.txt

Φυσικά αντί για το vi μπορείτε να χρησιμοποιήσετε το nano ή όποιο άλλο πρόγραμμα επιθυμείτε για να προσθέσετε στο τέλος του αρχείου KlipperScreen-requirements.txt τη γραμμή:

Of course, instead of vi you can use nano or any other program you prefer to add to the end of the KlipperScreen-requirements.txt file the line:

markupsafe==2.1.5

Αποθηκεύετε το αρχείο, σβήνετε το εικονικό περιβάλλον της python για το KlipperScreen και ξεκινάτε και πάλι το KIAUH.

Save the file, deactivate the virtual python environment of KlipperScreen and execute KIAUH again.

eliaschr@ender5-plus:~/KlipperScreen/scripts$ cd
eliaschr@ender5-plus:~$ rm -rf .KlipperScreen-env/
eliaschr@ender5-plus:~$ cd kiauh
eliaschr@ender5-plus:~/kiauh$ ./kiauh.sh

Εκεί θα ξεκινήσετε για άλλη μια φορά την εγκατάσταση του KlipperScreen, όπως και πριν. Εδώ θα υπάρξει μια μικρή αλλαγή. Το σύστημα θα μας ρωτήσει αν θέλουμε να ξανακατεβάσει το KlipperScreen από το αποθετήριό του. Εμείς εδώ θα το αρνηθούμε για να μην αλλάξει το requirement που έχουμε θέσει:

There you will start the KlipperScreen installation once again, as before. There will be a small change here. The system will ask us if we want to re-download KlipperScreen from its repository. We will refuse here, so that the requirement we have set does not change:

###### Perform action: 7

###### Installing KlipperScreen ...

###### Cloning repository from 'https://github.com/KlipperScreen/KlipperScreen.git'
###### '/home/eliaschr/KlipperScreen' already exists. Overwrite? (y/N): N
[INFO] Skip cloning of repository ...
Checking Python version > 3,8
.
.
.

Τώρα το KlipperScreen θα εγκατασταθεί κανονικά. Αυτό που θα παρατηρήσετε είναι πως η υπηρεσία δεν εκκινεί σωστά και αν ψάξουμε λίγο το λόγο θα δούμε πως δε βρίσκει ένα εκτελέσιμο αρχείο, το chvt. Αυτό είναι ένα εκτελέσιμο που βοηθάει στην αλλαγή τερματικού (change virtual terminal). Βρίσκεται στο πακέτο kbd, το οποίο δεν έχει εγκατασταθεί στο σύστημά μας. Ώρα να το προσθέσουμε κι αυτό (θα μπορούσαμε, βέβαια, να το κάναμε νωρίτερα, πριν ξεκινήσουμε την εγκατάσταση του KlipperScreen).

Now KlipperScreen will be installed normally. What you will notice is that the service does not start correctly and if we look a little into the reason we will see that it cannot find an executable file, chvt. This is an executable that helps with changing virtual terminal (change virtual terminal). It is found in the kbd package, which has not been installed on our system. Time to add it as well (we could, of course, have done it earlier, before starting the installation of KlipperScreen).

eliaschr@ender5-plus:~/kiauh$ sudo apt update
.
.
.
eliaschr@ender5-plus:~/kiauh$ sudo apt install kbd
.
.
.
eliaschr@ender5-plus:~/kiauh$

Μόλις ολοκληρωθεί η εγκατάσταση θα δούμε στην οθόνη που είναι συνδεδεμένη στο HDMI του ODroid να εμφανίζεται η κλασική οθόνη του Klipper. Η εγκατάσταση του KlipperScreen ολοκληρώθηκε!.

As soon as the installation is completed, we will see the classic Klipper screen appear on the display connected to the ODroid's HDMI. The installation of KlipperScreen is completed!

Εγκατάσταση Crowsnest

Crowsnest Installation

Το τελευταίο κομμάτι που θα εγκαταστήσουμε είναι το Crowsnest. Αυτό είναι ένα module που μας χρειάζεται αν εγκαταστήσουμε κάμερα στον εκτυπωτή μας. Η εγκατάστασή του δεν επιφυλάσσει εκπλήξεις και γίνεται χωρίς κανένα πρόβλημα.

The last part we will install is Crowsnest. This is a module we need if we install a camera on our printer. Its installation holds no surprises and is done without any problem.

Από την κεντρική οθόνη του KIAUH επιλέγουμε το 1) [Install] και στη συνέχεια το 8) [Crowsnest]. Η εγκατάσταση ξεκινάει κανονικά. Σε κάποιο σημείο μας ρωτάει το password του χρήστη μας και το αν θέλουμε να προσθέσει τον update manager στο moonraker.conf. Στο τέλος μας ζητάει να κάνει επανεκκίνηση το σύστημα. Η εγκατάσταση ολοκληρώθηκε χωρίς κανένα πρόβλημα.

From the main screen of KIAUH we select 1) [Install] and then 8) [Crowsnest]. The installation starts normally. At some point it asks for our user password and whether we want it to add the update manager to moonraker.conf. At the end it asks the system to reboot. The installation was completed without any problem.

###### Perform action: 8

###### Cloning repository from 'https://github.com/mainsail-crew/crowsnest.git'
Cloning into '/home/eliaschr/crowsnest'...
remote: Enumerating objects: 1302, done.
.
.
.
###### Launching crowsnest installer ...
[INFO] Installer will prompt you for sudo password!
[sudo] password for eliaschr: 
crowsnest - A webcam daemon for multiple cams and stream services.
.
.
.
Do you want to add 'update manager' entry to your moonraker.conf? [Y/n]: Y
Trying to add 'update manager' entry to moonraker.conf ...
.
.
.
Installation successful.

        Reboot your machine for the changes to take effect!

Reboot NOW? [y/N]: Y

Συμπεράσματα

Conslusion

Το ODroid U2 είναι ένας πολύ παλιός υπολογιστής μιας πλακέτας των 32 bit. Στα νιάτα του υπήρξε ένα αξιοπρόσεκτο μηχάνημα, αλλά σήμερα που η ισχύς των 64 bit είναι υπαρκτή και στα σημερινά μηχανήματα θα έλεγε κάποιος πως μπαίνει στο συρτάρι των αναμνήσεων για πάντα. Η 3D εκτύπωση FDM είναι κάτι που στην πραγματικότητα δεν έχει ανάγκη την ισχύ των 64 bit επεξεργασιάς. Συνεπώς, είναι μια καλή ευκαιρία να επαναφέρουμε στη ζωή ένα τέτοιο μηχάνημα. Είναι κρίμα, αλλά από την άλλη λογικό, που έχει σταματήσει η ανάπτυξη κώδικα για αυτή την κατηγορία υπολογιστών, αλλά οι κοινότητες πάντα βρίσκουν τρόπο να τα επαναφέρουν.

The ODroid U2 is a very old 32-bit single-board computer. In its youth it was a remarkable machine, but today, when 64-bit power is present in modern machines, one might say it goes into the drawer of memories forever. FDM 3D printing is something that does not really need 64-bit processing power. Therefore, it is a good opportunity to bring such a machine back to life. It is a pity, but on the other hand logical, that code development for this category of computers has stopped, but communities always find a way to bring them back.

Το Klipper είναι μια πολύ καλή ιδέα για να ζωντανέψει ένα παλιό 32 bit μηχάνημα. Η προσπάθεια που έχει γίνει σε αυτό το άρθρο πετυχαίνει ακριβώς αυτό! Το klipper ανασταίνει το ODroid με όλα τα καλούδια του, όπως γραφική οθόνη, touchscreen, απομακρυσμένο έλεγχο μέσω δικτύου και πληθώρα από extensions που υπάρχουν. Και, φυσικά, μην ξεχνάμε όλη τη διαχείριση της 3D εκτυπωσης που γίνεται με το μοναδικό του τρόπο!

Klipper is a very good idea to revive an old 32-bit machine. The effort made in this article achieves exactly that! Klipper resurrects the ODroid with all its goodies, such as graphical display, touchscreen, remote control via network, and a plethora of extensions. And, of course, let's not forget all the 3D printing management that is done in its unique way!

Αυτή η ανάρτηση ελπίζω να δώσει πνοή, όχι μόνο σε παλιούς υπολογιστές μιας πλακέτας, αλλά και σε projects που, σε κάποια περίπτωση θα μας ήταν ακριβά να ολοκληρώσουμε με σημερινά συστήματα 64 bit. Εξάλλου, το να δημιουργούνται ηλεκτρονικά σκουπίδια δεν είναι και ό,τι καλύτερο, ειδικά τη στιγμή που θα μπορούσαν να φανούν χρήσιμα.

This post I hope gives breath not only to old single-board computers, but also to projects that, in some cases, would be expensive to complete with today's 64-bit systems. After all, creating electronic waste is not the best thing, especially when they could be useful.


Ηλίας Χρυσοχέρης

Elias Chrysocheris

Κυριακή 23 Ιουνίου 2013

NoIP στο Raspberry Pi και μείωση του Internet TrafficNoIP in Raspberry Pi and Internet Traffic Reduction

Εισαγωγή

Introduction

Πολλές φορές χρειαζόμαστε να στήσουμε κάποιου είδους server έτσι ώστε να μπορούμε να έχουμε πρόσβαση σε αυτόν από τον "έξω κόσμο", δηλαδή από παντού, όπου υπάρχει πρόσβαση στο διαδίκτυο. Το πρόβλημα σε αυτό είναι πως οι περισσότεροι πάροχοι Internet (Internet Service Providers, εν συντομία ISPs) δε δίνουν σταθερή διεύθυνση IP στα router που έχουμε σπίτι μας (εκτός, φυσικά, αν το ζητήσουμε με κάποια παραπάνω χρέωση). Έτσι, θα πρέπει κάθε φορά να γνωρίζουμε την IP διεύθυνση του router μας για να μπορέσουμε να έχουμε πρόσβαση στον server που κάθεται πίσω από αυτό. Αυτόν ακριβώς το σκοπό έχει και το παρόν άρθρο. Τι θα λέγατε όμως, αν το σύστημα που θα μας βοηθούσε είναι ένα Raspberry Pi; Όχι πως αυτά που περιγράφονται εδώ δε μπορούν να εφαρμοστούν και σε άλλο σύστημα υπολογιστή... Αντιθέτως, ένα δυνατό σημείο του ανοικτού λογισμικού, είναι πως η διαχείρισή του γίνεται με τον ίδιο ακριβώς τρόπο, είτε αυτό τρέχει σε ένα μηχάνημα με 64 επεξεργαστές, είτε τρέχει σε μια... τοστιέρα (βλ. NetBSD!).

There are sometimes that we need to setup a small server in a way to have access to it from the "outer world", meaning everywhere, wherever there is internet access. The problem is that most of the Internet Service Providers (abbreviated as ISPs) do not give static IP address to our home routers (unless of course, we ask for it, in extra charge). So, we have to know the IP address of our router in order to gain access to our server behind it. This is the goal of this article. But, what if the helper system for our purpose is a Raspberry Pi? Not that what is described in here cannot be applied to some other computer system... Contrariwise, this is a very powerful part of opensource; the administration and setup of a system is a similar way, whether it runs on a 64 core system, or even a... toaster (see NetBSD site!).

Τι θα δούμε

What is in this article

Παρότι το άρθρο προορίζεται σε ανθρώπους που ξέρουν να ρυθμίζουν routers, να στήνουν servers, να διαχειρίζονται υπηρεσίες σε λειτουργικά όπως το Linux και να έχουν τη δυνατότητα, ίσως, να ασχοληθούν με ένα gadget του τύπου Raspberry Pi, εν τούτης θα δοθούν πληροφορίες ακόμα και σε πιο "αρχικά" πράγματα. Μέσα σε όλους τους σκοπούς του άρθρου είναι να μπορέσει ακόμα και κάποιος αρχάριος να βρει κάποιες εναρκτήριες πληροφορίες, εισαγωγικές περισσότερο σε όλα αυτά με τα οποία σχετίζεται η πρόσβαση ενός υπολογιστή σε ένα άλλο, μέσω του διαδικτύου. Ακόμα και για την πληρότητα του άρθρου, δε θα μπορούσαν να λείπουν αυτές οι πληροφορίες. Αν είστε κάπως πιο προχωρημένος χρήστης/γνώστης και κάποια παράγραφος σας είναι απλή ή δεν προσφέρει κάποιες παραπάνω γνώσεις σε αυτές που ήδη έχετε, μπορείτε ασφαλώς να την προσπεράσετε και να μπείτε στο "ψητό" της ιστορίας.

Though this article is for people who know how to setup a router, servers, administrate services in operating systems such as Linux and have the ability, perhaps, to deal with a gadget of Raspberry Pi's type, yet, the information in here will be in a novice level. Between the article's goals is for a not so advanced user to find some basic steps in all these stuff that communication between two computers through the internet, involves. Even for clarity, some of these information could not be omitted. If you are more advanced user and you find that some paragraphs do not contribute to your knowledge, feel free to skip it and proceed to the "hot point" of the story.

Μια μικρή περίληψη όσων θα δούμε μέσα στο παρόν άρθρο:

A brief of what we will find is:

DNS, Ευρετήριο διευθύνσεων διαδικτύου

DNS, Domain names index of the internet

Κάθε υπολογιστής ή άλλη συσκευή που συνδέεται στο διαδίκτυο με σκοπό να ανταλλάξει πληροφορίες διαμέσου αυτού, παίρνει μια μοναδική διεύθυνση στον κόσμο. Αυτή είναι και η βασική ιδέα. Αυτή την ονομάζουμε διεύθυνση IP. Φυσικά και υπάρχουν διευθύνσεις που θα τις δούμε να υπάρχουν ταυτόχρονα σε πολλούς υπολογιστές (π.χ. μια διεύθυνση της μορφής 192.168.1.1), αλλά ας μείνουμε στη βασική ιδέα του συστήματος του διαδικτύου και ας μην επεκταθούμε σε τέτοιες λεπτομέρειες. Το router που έχουμε στο σπίτι μας ή στο γραφείο μας (ή οπουδήποτε, τέλος πάντων) είναι και αυτό μια συσκευή επικοινωνίας που συνδέεται με το διαδίκτυο. Κατά συνέπεια και αυτό έχει μια διεύθυνση IP. Γιατί γίνεται αυτό; Αυτή η διεύθυνση είναι ένα κομμάτι της "ταυτοποίησης" του αντικειμένου. Όταν γίνεται μια επικοινωνία = μεταφορά δεδομένων από ένα σύστημα σε ένα άλλο, τότε απλά οι διευθύνσεις είναι αυτές που καθορίζουν τον αποστολέα και τον παραλήπτη. Όπως ακριβώς και η μεταφορά αλληλογραφίας με το κανονικό ταχυδρομείο που χρειάζεται να φέρει ο φάκελος τις διευθύνσεις αποστολέα και παραλήπτη.

Every computer or other network device that is connected to the internet with the purpose of exchanging data through it, must have a unique address all over the world. That's the basic idea. This is the address we call "IP Address". Of course we will find IP addresses that exist in more than one computer at the same time (ie. an address of type 192.168.1.1), but lets stick on the basic idea of the internet's system and not expand to such details for now. The routing device (called router) we have at home or office (or wherever) is a communication device that is connected to the internet. So, it also has an IP address. Why that happens? This address is used for some kind of identification of this device. When a communication takes place = data transfer from one system to another, the addresses identify who is the sender and to who is the target, in all over the network; similar to the way mail transfer takes place at the ordinary post office; the envelope has both the sender's and the recipient's address.

Οι διευθύνσεις που δίνονται σε όλα αυτά τα συστήματα επικοινωνίας, είτε είναι υπολογιστές είτε είναι ένας δικτυακός εκτυπωτής κ.λ.π, έχουν τη μορφή 4 αριθμών χωρισμένων από τελείες (.). Ο κάθε αριθμός μπορεί να πάρει τιμές από 0 μέχρι και 255. Υπάρχει και ένας πιο σύγχρονος τρόπος διευθυνσιοδότησης, όπου η κάθε διεύθυνση αποτελείται από 8 τετραψήφιους δεκαεξαδικούς αριθμούς χωρισμένους από άνω-κάτω τελείες (:).

The given addresses to all these communication and networking devices, whether they are computers or network printers etc., they consist of 4 numbers separated by dots (.). Each number cat take a value from 0 to 255. There is also a newer way of addressing where the address is formed by 8 four-digit hexadecimal numbers separated by colons (:).

Και γιατί τα αναφέρουμε όλα αυτά; Βλέπετε πουθενά λέξεις, όπως google.com, blogspot.gr ή my_really_really_fancy_site.biz; Όχι, γιατί ΔΕΝ ΥΠΑΡΧΟΥΝ. Αυτό σημαίνει πως για να μπορέσουμε να επισκεφθούμε τη μηχανή αναζήτησης της Google, το site που φιλοξενεί τα περισσότερα blogs ή μια άλλη τοποθεσία με το πιο σημαντικό υλικό που μας ενδιαφέρει (λέμε τώρα!) θα έπρεπε να θυμόμαστε ένα σωρό νούμερα που να δώσουν στον browser μας να καταλάβει ποια τοποθεσία θέλουμε να δούμε. Λίγο δύσκολο ε;... Ναι. Και για να μπορέσουμε να βρούμε τοποθεσίες στο internet θα έπρεπε να έχουμε ένα τεράστιο κατάλογο με αντιστοιχία διευθύνσεων σε ονόματα των site που αντιστοιχούν, ή ιδιότητες των site κ.λ.π. Και κάθε φορά που θα θέλαμε να επισκεφθούμε μια τοποθεσία θα έπρεπε να κατεβάζουμε τον αντίστοιχο τόμο από τη βιβλιοθήκη μας και να τον ψάχνουμε, μέχρι να βρούμε αυτή την τοποθεσία που ψάχνουμε... Ακόμα χειρότερα, κάθε φορά που ένα καινούργιο site θα δημιουργόταν στο διαδίκτυο, θα έπρεπε να ανανεώσουμε το ράφι με αυτούς τους καταλόγους!

And why do we point all of these? Do you see words like google.com, blogspot.gr or my_really_really_fancy_site.biz anywhere? No, because THEY DO NOT EXIST. In order to visit Google's search engine, the site that contains many blogs or another web site we are interested in, we have to remember a lot of numbers that will give our browser the information of which site we want to visit. Kind of hard, isn't it?... Yeap!. And in order to be able to find out some websites later we should own a really huge index that should have a one to one correlation between addresses and site names or site properties etc. And every time we would like to visit a site we should take the corresponding volume from our library and search through it untili we find tyhe desired site... There's even worse, every time a new site appeared in the total network, we should update the index!

"Χμμμ... Μα εγώ δε θυμάμαι να δίνω τέτοια νούμερα που αναφέρεις στον browser μου...". Επειδή ακριβώς το να θυμόμαστε νούμερα είναι πολύ δυσκολότερο από το να θυμόμαστε λέξεις, για να μη μπαίνουμε στον κόπο να ψάχνουμε τις διευθύνσεις που πρέπει να δώσουμε για να μπορέσουμε να προσπελάσουμε τον κάθε ιστότοπο που επιθυμούμε, έχουν δημιουργηθεί κάποιοι servers οι οποίοι κάνουν ακριβώς αυτό· αντικαθιστούν το τεράστιο ράφι της βιβλιοθήκης μας, που λέγαμε πριν... Τους δίνουμε ένα όνομα ιστότοπου και αν αυτό υπάρχει μας επιστρέφουν διεύθυνση IP στην οποία βρίσκεται ο εν λόγω ιστότοπος. Αλλά μπορούν να κάνουν και το αντίθετο, δηλαδή να μας πουν το όνομα του ιστότοπου στον οποίο οδηγεί μια διεύθυνση.

"Hmmm... But I don't remember specifying such numbers in my browser...". Due to the difficulty in remembering numbers compared to remembering words, in order not to try to search through IP addresses every time we need to access a site, there are some servers they perform this action for us: They replace the huge library shelf we were talking about... We can send them the site name we want to access and they return the IP address the web site in question lies. But they can also perform the reverse function; they can tell the name of the website an IP address points to.

Διαδικασία ονοματοδοσίας

Naming

Και το ερώτημα είναι πώς γίνεται μια ονοματοδοσία στον τεράστιο χώρο του internet; Όταν κάποιος θελήσει να στήσει ένα server στο διαδίκτυο, τότε θα πρέπει να κατοχυρώσει ένα όνομα, το οποίο όλοι οι υπόλοιποι θα χρησιμοποιούν για να έχουν πρόσβαση σε αυτή την υπηρεσία που προσφέρει ο εν λόγω εξυπηρετητής. Αυτό το όνομα είναι μοναδικό. Αφού κατοχυρωθεί το όνομα, σε κάποιο server του διαδικτύου, μπορεί να φιλοξενηθεί η ιστοσελίδα ή η υπηρεσία που μας ενδιαφέρει. Ο server αυτός έχει κάποια συγκεκριμένη διεύθυνση IP. Μπορεί να ανήκει σε κάποια εταιρία φιλοξενίας (hosting) ιστοσελίδων, ή ακόμα και στον υπολογιστή που έχουμε στο σπίτι μας! Το τελευταίο βήμα, είναι να "παντρέψουμε" το όνομα που κατοχυρώσαμε με τη διεύθυνση στην οποία βρίσκεται η εν λόγω ιστοσελίδα/υπηρεσία· αυτή, συνήθως, τη φτιάχνουμε εμείς.

And the question now is how the naming of the sites happen throughout the huge internet space? If someone wants to set a server in the internet, he must first register a name, the one that all the others will use to be served by the server in question. This name must be unique. After the registration of the name, another server must host the web page or the needed service to be offered. That server must have a specific IP address. It can be owned by a web hosting company, or can be even the computer we have at our place! The final step is to tie together the name and the IP address in question. The web page or the service is the one that we create.

Πού βρίσκεται το πρόβλημα; Όταν το μόνο που μας ενδιαφέρει είναι να έχουμε ένα ωραιότατο server για δική μας δουλειά, θα πρέπει να κατοχυρώσουμε ένα όνομα στο διαδίκτυο (=κόστος), να πληρώσουμε σε κάποια εταιρία hosting χώρο που να τον διαμορφώσουμε κατάλληλα ώστε να φιλοξενήσει την υπηρεσία που μας ενδιαφέρει (=κόστος) και τέλος να δηλώσουμε σε κάποιο DNS ότι το όνομα που κατοχυρώσαμε "δείχνει" στον server της εταιρίας hosting (=κόστος) η οποία φιλοξενεί την υπηρεσία μας... Εναλλακτικά, μπορούμε να πληρώσουμε τον ISP μας για να μας δώσει σταθερή IP διεύθυνση, οπότε τη φιλοξενία της υπηρεσίας μας την κάνουμε στον υπολογιστή στο σπίτι μας. Όλα αυτά μας επιβαρύνουν οικονομικά.

Where the problem is? If the only thing that matters is to have a nice personal server, for our personal usage only, we should buy an internet domain name (=added cost), pay a hosting service company to give us space in their servers, configure that space to host our service (=added cost) and finally submit the new domain name in a DNS pointing the IP address of the host server (=added cost, again) that serves our service... Also an alternative is to pay our ISP to give us a static IP address, so we can use our own computer to serve whatever we want from our home. But all these cost us money.

Το ερώτημα είναι: «Αφού δεν κάνω επαγγελματική ιστοσελίδα, αλλά με ενδιαφέρει να έχω πρόσβαση στο δίκτυό μου για τη δική μου διευκόλυνση και μόνο. Δε μπορώ να το κάνω χωρίς κόστος;» Αυτό που χρειαζόμαστε είναι μια υπηρεσία που να μπορεί να μας αντιστοιχεί μια δυναμική διεύθυνση σε ένα σταθερό όνομα.

The question is: "Since I don't service a professional web page, but I just want to have access to my own home network for my convenience and only, does it have to cost me that much?". In that case what we really need is a web service that can bound a static domain name to a dynamic IP address, just as a normal DNS server does.

Δυναμικός DNS για δυναμικές IP

Dynamic DNS for Dynamic IP addresses

Αυτή είναι μια υπηρεσία που πλέον βρίσκεται αρκετά στο διαδίκτυο. Η εγγραφή σε μια υπηρεσία δυναμικού DNS είναι μια απλή λύση στο πρόβλημά μας. Οι περισσότερες δυναμικές DNS υπηρεσίες που προσφέρονται από κάποια sites, θέλουν να έχει κάποιος ένα κατοχυρωμένο όνομα. Άλλες πάλι, αφήνουν τον χρήστη να επιλέξει από μια σειρά ονόματα που έχει διαθέσιμα. Ένα χαρακτηριστικό παράδειγμα είναι το DynDNS.

This is a service that can be found nowadays on the internet. The registration in a Dynamic DNS service is a simple solution to our problem. Most of the Dynamic DNS services available through some sites, just need someone to have a registered domain name. Some other, let the user select one from the available to that site domain names. An example is DynDNS.

Το DynDNS είναι ένα site που προσφέρει υπηρεσίες δυναμικού DNS. Ο χρήστης έχει τη δυνατότητα να χρησιμοποιήσει ένα όνομα της αρεσκείας του, αρκεί αυτό να ανήκει σε domains που ανήκουν στην ίδια τη DynDNS. Παράδειγμα, ένας χρήστης θα μπορούσε να χρησιμοποιεί το όνομα eliasfiles.dyndns-at-home.org γιατί ανήκει στο domain της DynDNS (dyndns-at-home.org). Το καλό που έχει το DynDNS είναι πως τα περισσότερα, πλέον, routers έχουν ενσωματωμένη την υποστήριξη για τη συγκεκριμένη υπηρεσία. Όμως, τον τελευταίο καιρό το site άρχισε να προσφέρεις τις υπηρεσίες του με πληρωμή. Πιο συγκεκριμένα, ένας καινούργιος χρήστης είναι υποχρεωμένος να δοκιμάσει την υπηρεσία DynDNSPro ελεύθερα για 14 ημέρες και αν δεν τη διακόψει νωρίτερα τότε χρεώνεται για τη χρήση της. Αυτό του δίνει το δικαίωμα να έχει την υπηρεσία για ένα χρόνο. Αν τη διακόψει πριν τη 14η ημέρα, τότε δε μπορεί να έχει καθόλου υπηρεσίες DynDNS. Για κάποιον ο οποίος θέλει να έχει πρόσβαση σε κάποια αρχεία του, κάποια βάση δεδομένων με δικές του πληροφορίες κ.λ.π. δεν είναι ότι καλύτερο να πρέπει να πληρώσει για κάτι το οποίο δεν του αποφέρει καθόλου κέρδος.

DynDNS is a site that offers Dynamic DNS services. The user has the ability to use a domain name he/she likes, provided that this name belongs to domains that really belong to DynDNS itself. For example, a user could use eliasfiles.dyndns-at-home.org because it belongs to a registered DynDNS domain. The good part is that most of the routers available for home usage can be configured to use this service. But, lately the site started to offer their services with a cost. More specifically, a new user is forced to test the DynDNSPro service free of charge for 14 days only. If he/she does not stop using it then, after the 14th day a small fee is charged for one more year usage. If he/she stops using the service then there will be no more DynDNS services. For someone who wants to have access to his files, a personal database having his own data etc, it is not the best idea to pay for something that does not offer him some income.

NoIP: Υπηρεσία δυναμικού DNS για όλους

NoIP: Dynamic DNS Services for all

Αρκετό ψάξιμο στο internet μου εμφάνισε σελίδες που προσέφεραν υπηρεσίες δυναμικού DNS, αλλά σε όλες έπρεπε να έχει κάποιος κατοχυρωμένο domain name. Τελικά, μια από όλες μου τράβηξε περισσότερη την προσοχή, η NoIP. Αυτή η σελίδα προσφέρει υπηρεσίες δυναμικού DNS, αλλά και ελεύθερης κατοχύρωσης ονόματος που θα ανήκει στο domain no-ip.biz (και άλλα). Κάτι παρόμοιο, δηλαδή, με το παλιό καλό DynDNS.

After a log search through the internet there were many web sites offering Dynamoc DNS services, but they needed the user to have a domain name already registered. Finally, one of them just paid my attention, NoIP. That web page offers Dynamic DNS, but also gives the ability to use a NoIP registered domain name that belongs to no-ip.biz (and many more). It is something similar to DynDNS.

Τι άλλο προσφέρει η NoIP:

What else does NoIP offer:

  • Ελεύθερο (χωρίς χρέωση) Domain Name που ανήκει στο no-ip.biz (ή κάποιο άλλο από τα προκαθορισμένα του)
  • Free of charge (no cost at all) Domain Name that belongs to no-ip.biz (or another that belongs to NoIP list)
  • Έναν client που αναλαμβάνει την ενημέρωση της λίστας του DNS με την καινούργια IP. Αυτόν τον ονομάζει DUC - Dynamic Update Client (περισσότερα ακολούθως)
  • A client program that updates the DNS database with the new IP when there is an IP address change from our ISP. They call it DUC - Dynamic Update Client (more on this later)
  • Ο DUC είναι ανοιχτού κώδικα
  • DUC is open sourced!
  • Οδηγείες για τη δημιουργία δικού μας client αν δε μας αρέσει ο δικός της
  • There are also information on how to create our own update client if for some reason we don't like theirs

Ο NoIP Client είναι ένα πρόγραμμα που τρέχει στον υπολογιστή μας και ανά τακτά διαστήματα ανιχνεύει τη διεύθυνση που έχουμε από τον ISP και αν δει ότι διαφέρει από την προηγούμενη, ενημερώνει τον DNS Server της NoIP για την καινούργια διεύθυνση. Έτσι, το όνομα το οποίο έχουμε κατοχυρώσει δείχνει στην καινούργια μας διεύθυνση. Το ίδιο ακριβώς σύστημα έχει και το DynDNS με ένα πρόγραμμα client που ονομαζόταν ddclient.

NoIP Client is a small program that runs in our computer and at regular intervals it checks for our IP address the ISP has set and if it is different from the one we had earlier, then it updates NoIP DNS server. So, the domain name we have registered points to our new IP address. DynDNS laso uses the same updating system, using a client called ddclient.

Πλεονεκτήματα της χρήσης ενός client προγράμματος είναι ότι αυτός τρέχει σε έναν υπολογιστή και ενημερώνει τη NoIP για τις αλλαγές της IP διεύθυνσης χωρίς να χρειάζεται να κάνει κάτι ο χρήστης.

The advantage of using an update client program is that it runs in a computer at the background and informs NoIP whenever there is an IP address change, without user's intervention.

Μειονεκτήματα της χρήσης ενός client είναι πως ο client λειτουργεί μόνο όση ώρα είναι σε λειτουργία ο υπολογιστής που τον τρέχει. Συνεπώς, υπάρχει η περίπτωση να πρέπει να έχουμε ένα υπολογιστή ενεργοποιημένο 24 ώρες το 24ωρο. Ο client ελέγχει για αλλαγή διεύθυνσης ανά τακτά διαστήματα. Τέτοια αλλαγή μπορεί να γίνει οποιαδήποτε ώρα και στιγμή από τον provider. Αυτό οδηγεί στο δεύτερο μειονέκτημά, πως από τον χρόνο που θα εκτελέσει ο ISP μια αλλαγή στη διεύθυνσή μας μέχρι τη στιγμή που ο client θα ελέγξει για μια τέτοια κατάσταση, ο DNS θα έχει την παλιά μας διεύθυνση και έτσι δε θα μπορούμε να έχουμε πρόσβαση στον server μας γι' αυτό το χρονικό διάστημα. Τέλος, ο client για να ανιχνεύσει την αλλαγή της διεύθυνσης, στέλνει ένα request στο server της NoIP. Αυτό σημαίνει διακίνηση δεδομένων στο διαδίκτυο, κατά συνέπεια δε μπορούμε να ρυθμίσουμε τον client να κάνει τον έλεγχο σε πολύ τακτά χρονικά διαστήματα (π.χ. 5 δευτερολέπτων). Χρήση τακτικών ελέγχων βοηθάει στο να μειώσουμε το χρόνο της ασυμφωνίας της διεύθυνσης που έχει ο DNS με την πραγματική μας, μετά από αλλαγή από τον ISP. Ταυτόχρονα, όμως, αυξάνει και τη διακίνηση πληροφορίας προς τον NoIP server. Αποτέλεσμα είναι να κινδυνεύουμε να μας κάνει τελικά ban ο server και να μη δέχεται τις πληροφορίες μας, διότι θεωρεί ότι του κάνουμε ηλεκτρονική επίθεση.

The drawback of using such a client is that it works only when the computer that runs it is powered on. Thus, we may have to keep our computer running 24 hours a day. The client checks for an address change at regular intervals. An IP address can be performed by the internet provider any time. This leads to a second drawback. From the time the ISP changes our IP address till the time the update client does its job, the DNS servers over the internet will have our old IP address, so we will not be able to access our server during that time. Finally, the client tracks the address change by sending a request to NoIP server. This, in turn, means internet traffic, so we cannot configure the client to use a small update interval (such as 5 seconds). The small updating interval helps having a small lag during IP address change and DNS tables updating. But, at the same time increases the traffic to NoIP server. This could make NoIP server to ban us and ignoring information send by our update client, because it could thing we perform an electronic attack.

Γιατί το Raspberry Pi;

Why Raspberry Pi?

Το Raspberry Pi είναι ένας μικρός υπολογιστής μεγέθους πιστωτικής κάρτας (όχι δε μπορείτε να κάνετε πληρωμές σε καταστήματα με αυτό! :)) βασισμένος σε αρχιτεκτονική επεξεργαστή ARM. Καταναλώνει ελάχιστα και τρέχει οποιαδήποτε διανομή Linux (ή ακόμα και FreeBSD) είναι μεταγλωττισμένη γι' αυτή την αρχιτεκτονική. Είναι πολύ βολικό για τέτοιες καταστάσεις.

Raspberry Pi is a small computer at the size of a credit card (well, no, you cannot perform in shop payments using it! :)) based on ARM architecture. It consumes little power and can run any Linux distribution (or even FreeBSD) that is compiled for that architecture. It is very convenient for cases like ours.

Επίσης, δεν υπάρχει λόγος γιατί να πρέπει να λειτουργεί 24/7 ένας υπολογιστής (εκτός και αν είναι απαραίτητο για άλλους σκοπούς). Το Raspberry Pi λόγω της μικρής του κατανάλωσης, αλλά και του μικρού του μεγέθους, μπορεί να λειτουργεί συνεχώς, χωρίς πρόβλημα, ενώ δεν πιάνει χώρο επάνω σε ένα γραφείο, όπως τα PC. Μπορεί να μπει δίπλα από το router μας (κάποια από αυτά διαθέτουν και μια USB θύρα και μπορούν να το τροφοδοτήσουν), ενώ υπάρχουν αρκετά όμορφα κουτάκια τα οποία το κάνουν να δείχνει σοβαρό σε οποιοδήποτε χώρο (μη φωνάζει η γυναίκα πως δεν ταιριάζει με τις κουρτίνες :Ρ).

There is no reason why a PC computer should be on 24/7 (unless it must be on for specific services). Because Raspberry Pi consumes so little power and because of its small size, it can be powered on without problems, and at the same time it has small footprint on our desktop, unlike PCs. It can live side by side with our router (some of them having USB connectors can also power it). There are also some very good looking boxes for it, making suitable for the space it lives in our house (not to let your wife comlain that it does not suit with the curtains of the room :Ρ).

Όσα περιγράφονται στο παρόν άρθρο έχουν γίνει επάνω στο λειτουργικό Raspbian που είναι βασισμένο στο Debian. Επειδή, όμως, οι διανομές Linux έχουν πάρα πολλά κοινά μεταξύ τους, δεν υπάρχει λόγος γιατί, με έστω λίγες αλλαγές, να μη μπορούν να τρέξουν και σε οποιαδήποτε άλλη διανομή για οποιαδήποτε αρχιτεκτονική.

What is described in this article is done in Raspbian operating system which is based on Debian. But, since Linux distributions share a lot in common, there is no particular reason why, even with small changes, they cannot be done in other distribution or architecture.

Ο Dynamic Update Client της NoIP

NoIP Dynamic Update Client

Η NoIP δίνει έναν client για το update της διεύθυνσης IP στον DNS τους, ο οποίος είναι γραμμένος σε γλώσσα C. Για απλή χρήση είναι αυτό που χρειάζεται κάποιος. Μπορείτε να τον κατεβάσετε και να τον κάνετε compile κανονικά, όπως και κάθε άλλο πρόγραμμα. Στο Raspberry Pi γίνεται κανονικά compile, ενώ τρέχει χωρίς κανένα πρόβλημα.

NoIP provides an update client for updating their DNS server with our new IP address. It is written in C language. For a simple use it is what anybody needs. You can download and compile it normally, as any other program that can be installed from its source code. In Raspberry Pi its compilation and execution runs flawlessly without any problems.

Η εγκατάσταση είναι απλή. Αρχικά κατεβάζετε τον πηγαίο κώδικα, μιας και είναι opensource, από το site της NoIP. Στη συνέχεια αποσυμπιέζετε το αρχείο:

The installation is very simple. First you download the program's source code, since it is opensource, from NoIP site. The decompression follows:

pi@raspberrypi:~ > tar -xvzf noip-duc-linux.tar.gz
...
pi@raspberrypi:~ > 

Αυτό θα δημιουργήσει ένα κατάλογο με όνομα noip-version. Μέσα σε αυτόν βρίσκεται όλος ο πηγαίος κώδικας, scripts για διάφορες διανομές ώστε να λειτουργέι σαν υπηρεσία κ.λ.π. Μπορείτε ελεύθερα να περιηγηθείτε μέσα στα περιεχόμενα του καταλόγου. Όταν τελικά αποφασίσετε να το εγκαταστήσετε κάνετε τα ακόλουθα: (η έκδοση που βρίσκεται ο DUC τη στιγμή που γράφεται το άρθρο είναι η 2.1.9-1)

A directory named noip-version will be created. In there you can find the source code, service scripts for some distributions, etc. You can freely browse through the contents of the directory. When you finally decide to install it just do the following: (The version of DUC the time this article is edited is 2.1.9-1)

pi@raspberrypi:~ > cd ~/noip-2.1.9-1
pi@raspberrypi:~ > make
...
pi@raspberrypi:~ > sudo make install
...
pi@raspberrypi:~ > 

Αυτές οι εντολές θα εγκαταστήσουν το noip2 στον κατάλογο /usr/local/bin. Οι πληροφορίες που δίνονται στα διάφορα αρχεία README.FIRST είναι αρκετές για να το χρησιμοποιήσετε.

These commands will install noip2 in /usr/local/bin directory. The provided information by various files like README.FIRST are enough to make you use it.

Μιας και τα μειονεκτήματα του DUC τα είδαμε πριν, ας προχωρήσουμε σε μια διαφορετική υλοποίηση από αυτή του NoIP DUC που βελτιώνει κάποια χαρακτηριστικά.

Since we presented the drawbacks of DUC earlier, lets proceed to a different implementation than that of NoIP's DUC, that improves it.

Μείωση του Internet Traffic

Internet Traffic Reduction

Η μεγαλύτερη διακίνηση πληροφορίας που γίνεται στο Internet από τον client είναι για την εύρεση της IP διεύθυνσης που μας έχει δώσει ο provider μας. Κάθε φορά που ο DUC θέλει να μάθει την IP μας, υποβάλει ένα ερώτημα στον server της NoIP. Αυτός βλέπει από ποια IP γίνεται το ερώτημα και την επιστρέφει στον DUC. Αν διαπιστωθεί αλλαγή της, τότε ο DUC στέλνει άλλο ένα request που αναφέρει πως θα πρέπει να γίνει η αλλαγή της διεύθυνσης και στον κατάλογο του DNS. (αυτή είναι η γενική ιδέα)

The most exchanged data by the client program through the internet is the question of the current IP address our ISP provided to us. Every time DUC wants to find our IP, it sends a request to NoIP's server. The server checks which is the source IP of the request and returns it to DUC. If DUC finds a different IP than the one of the previous request, it sends another request for the DNS table updating (That is the general idea)

Επειδή η αλλαγή της διεύθυνσης συμβαίνει σε αραιά χρονικά διαστήματα (ανά μερικές ημέρες), η περισσότερη επικοινωνία που συμβαίνει (το ερώτημα της τρέχουσας IP διεύθυνσης) είναι άσκοπη. Ταυτόχρονα, σκοπός μας είναι να μπορέσουμε να υποβάλουμε ερώτημα για τη διεύθυνση IP τόσο συχνά ώστε να μην υπάρχει μεγάλο χρονικό διάστημα όπου ο DNS περιέχει παλαιά διεύθυνση (να είναι ασυγχρόνιστος).

Since an IP change happens in very big intervals (several days), the most communication traffic happens (the query of tha current IP address) is pointless. At the same time, our goal is to send an IP address query as often as possible, for the time the DNS contains our old address (not be synchronized) be as small as it can be.

Ο πιο απλός τρόπος είναι να μην υποβάλλεται το ερώτημα στον server της NoIP, αλλά στο router μας. Πολλά router έχουν ενεργοποιημένο telnet server, έτσι ώστε να μπορούμε να συνδεθούμε με αυτό το πρωτόκολλο και να εκτελούμε εντολές. Μια άλλη εναλλακτική υπάρχει αν το router που διαθέτουμε τρέχει ssh server, οπότε μπαίνουμε με ssh στο router και πάλι μπορούμε να εκτελέσουμε εντολές. Κάποια, βέβαια, routers δεν έχουν τίποτα από τα δυο (π.χ. κάτι oxygen)... Εκεί θα πρέπει να κάνουμε ερώτημα μέσω https (συνήθως).

The simplest way is to send the IP address query, not to NoIP's server but to our router. Many routers provide a telnet server, thus, we can connect to it using that protocol and execute commands. Another alternative exists is our router runs a ssh server, so we connect to it using ssh and again we can execute commands. Well, there is also the possibility for some routers not to provide any of the above (ie. some oxygen routers)... We can send them queries using https protocol (usually).

Επειδή δεν είναι σταθερός ο τρόπος με τον οποίο υποβάλλουμε ερώτημα για την IP στο router, σε αυτό το άρθρο θα παρουσιαστεί ένα script που είναι για χρήση σε πρωτόκολλο telnet που είναι και το πιο συχνά εμφανιζόμενο. Συγκεκριμένα έχει δοκιμαστεί σε τρία διαφορετικά routers. Ένα ZTE (που δίνει ο ΟΤΕ), ένα TP-Link και ένα AirTies. Φυσικά, με διαφορετικό configuration. Τα δύο από τα τρία εκτελούν κανονικές εντολές Linux, ενώ το TP-Link έχει δικές του εντολές.

Since the way we question our router for our IP address is not by default the same to all routers, in this article we present a script that uses telnet protocol, which is the most applicable. We have tested it in three different routers, a ZTE (the Greek Telecomunications Company provides), a TP-Link and an AirTies. Of course, we used different configuration. Two of these execute normal Linux commands, while the TP-Link has its own.

Αρχικά, ας δημιουργήσουμε τις συνθήκες για να κάτσουν τα script. Πρώτο βήμα είναι να φτιαχτεί ο κατάλογος που θα φιλοξενήσει τα scripts:

First, lets create the space our scripts will sit in. The first step is to create a directory that will host the scripts:

pi@raspberrypi:~ > sudo mkdir /usr/scripts
pi@raspberrypi:~ > cd /usr/scripts
pi@raspberrypi:/usr/scripts > 

Ας δούμε το script που υποβάλλει ερώτημα στο router για την IP. Το script είναι γραμμένο σε python. Μιας και δεν είμαι γνώστης της python, δεν περιμένω ότι το script αυτό είναι το τελειότερο του κόσμου (λέμε τώρα!). Είναι το πρώτο script που γράφω στη συγκεκριμένη γλώσσα προγραμματισμού οπότε κάποιος έμπειρος python προγραμματιστής πολύ πιθανό να βρει κάποιες ατέλειες. Επίσης, είναι μια πρώτη έκδοση. Σκοπεύω στο μέλλον (κοντινό) να του μπαλώσω μια "τρύπα" που έχει. Αλλά για την ώρα κάνει τη δουλειά του. Μπορείτε να το κάνετε Copy/Paste στον αγαπημένο σας editor από εδώ:

Lets see the script that questions the router for our current IP address. This script is written in python. Since I'm not a python programmer, I don't expect this script to be the most perfect one all over the world (well... matter of speaking!). It is my first python script so any experiences python programmer will find some defects. Also, this is a first version. In the future (near future) I intend to patch a "whole" in there. But for now it does what it promises. You can Copy/Paste it in your favourite editor from here:

#!/usr/bin/python
# THE SOFTWARE IS LICENSED UNDER GPL2 GENERAL PUBLIC LICENSE v2.
# IN ORDER TO OBTAIN A COPY OF THIS LICENSE PLEASE VISIT THE FOLLOWING
# ADDRESS:
# http://www.gnu.org/licenses/gpl-2.0.html

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#First import the necessary python libraries
import sys
import os
import telnetlib

#Setup the default values, before using the configuration file
ConfFile = "/etc/GetInetIP.conf"
RouterIP = "192.168.1.1"
UserName = "admin"
Password = "admin"
NetComm = "ifconfig ppp0"
AddrPrefix = "inet "
ExpTime = 0.0001

#If the user has entered a CLI argument, use it as the configuration file to be used
InArgs = len(sys.argv)
if InArgs > 2:
        sys.stderr.write("ERROR: Only one input argument expexted!\n")
        sys.stderr.write("Usage: GetInetIP [configuration_filename]\n");
        exit(1)
elif InArgs == 2:
        ConfFile = sys.argv[1]
        #Need to check if the user specified filename exists. If not => Error
        if not(os.path.exists(ConfFile)):
                sys.stderr.write("ERROR: Configuration file" + ConfFile + "not found\n")
                exit(2)

#Check for the existance of the configuration file

#Time to import the configuration file's values. If the user specified a configuration file
# then it really exists. But if not, we must try to load the configuration file from
# the default path. If this file doesnot exist, then we ave to use our hardcoded values
#NOTE:The execfile command should be changed for security reasons... A more secure approach
# is to parse the configuration file, and not execute it... (no time to fixit right now)
if os.path.exists(ConfFile):
        execfile(ConfFile)

#Connect to the specified router using telnet protocol
Conn = ""
try:
        Conn = telnetlib.Telnet(RouterIP)
except:
        sys.stderr.write("ERROR: Cannot communicate with" + RouterIP +"\n")
        exit(3)

#Send the login credentials
RespStr = "First"
FailCount = 3
while (RespStr != "") and (FailCount > 0):
        RespStr = Conn.read_until("\n",ExpTime)
        LoginFlag = RespStr.find("login:")
        if LoginFlag >= 0:
                Conn.write(UserName + "\n")
                RespStr = Conn.read_until("\n",ExpTime)
        PassFlag = RespStr.find("Password:")
        if PassFlag >= 0:
                Conn.write(Password + "\n")
                RespStr = Conn.read_until("\n",ExpTime)
                FailCount -= 1

if FailCount == 0:
        sys.stderr.write("ERROR: Credentials failed 3 times\n")
        exit(4)

#Now the telnet awaits commands! Issue the command that announces the IP needed
Conn.write(NetComm +"\n")
RespStr = Conn.read_until("\n",ExpTime)
InetFlag = False
while (RespStr != "") and not(InetFlag):
        InetStrt = RespStr.find(AddrPrefix)
        if InetStrt >= 0:
                InetFlag = True
                InetStrt += len(AddrPrefix)
                InetEnd = RespStr.find(" ",InetStrt)
        else:
                RespStr = Conn.read_until("\n",ExpTime)
Conn.write("exit\n")
DummyStr = Conn.read_all()
Conn.close()
if not(InetFlag):
        sys.stderr.write("ERROR: IP Address not found\n")
        exit(5)
OutStr = RespStr[InetStrt:InetEnd]
print(OutStr.strip())
exit(0)

Αυτό το script το σώζουμε με το όνομα GetInetIP.py μέσα στον κατάλογο που φτιάξαμε. Για να λειτουργήσει χρειάζεται και ένα configuration αρχείο μέσα στον κατάλογο /etc. Προσοχή χρειάζεται στο ότι στο configuration αρχείο βρίσκονται στοιχεία που δεν πρέπει να φτάσουν στα μάτια τρίτων! Κοινώς, το password του router... Το αρχείο θα πρέπει να ονομάζεται GetInetIP.conf:

We save it with the name GetInetIP.py under the directory we created earlier. For the script to function properly it needs a configuration file in /etc directory. Caution is needed as in this configuration file some strings are for your eyes only! More specifically, your router's password... The file must be named GetInetIP.conf:

Configuration για router TP-Link

Configuration for TP-Link router

RouterIP = "192.168.1.1"
Password = "MyCrazyPassword"
NetComm = "show wan status"
AddrPrefix = "Ip = "
ExpTime = 0.07

Ας δούμε λίγο τα περιεχόμενα του configuration αρχείου:

Lets see the bones of this configuration file:

  • RouterIP: Δηλώνει τη διεύθυνση IP που έχει το router μαςSpecifies the router's IP address
  • UserName: Το όνομα χρήστη για το router. Αν δεν δηλώνεται εδώ χρησιμοποιείται η default τιμή που είναι το admin. Κάποια από τα routers δε ζητάνε το username. Σε αυτή την περίπτωση το script το καταλαβαίνει και δεν το στέλνει.The username of the router's administrator. If it not specified it takes the default value which is "admin". Some routers do not ask for a username. In that case the script is smart enough to understand it and it does not send a username at all.
  • Password: Το password που χρειαζόμαστε για να κάνουμε login στο routerThe password we need to login to router
  • NetComm: Η εντολή που εκτελούμε, όταν κάνουμε telnet στο router που μας δείχνει τη διεύθυνση IP που έχει στο WAN. Για το TP-Link είναι show wan status, ενώ για ένα router που τρέχει busybox ή γενικά εκτελεί εντολές Linux είναι κάτι του στυλ ifconfig ppp0The command we need to execute, using telnet, that announces the IP address of the WAN. For TP-Link it is show wan status, while for a router that runs busybox or executes Linux commands it is something like ifconfig ppp0
  • AddrPrefix: Όποια και αν είναι η εντολή που μας δίνει την επιθυμητή πληροφορία, δεν δίνει απλά ένα ξερό νούμερο, αλλά ολόκληρο κείμενο. Εδώ περιγράφεται τι περιμένει το script για να βρει ακριβώς πριν τη διεύθυνση IP που μας ενδιαφέρει. Αμέσως μετά από αυτό το κείμενο αναφέρεται η πληροφορία μας.Whichever the command is to get our IP address, it does not return only this number, but a whole text containing the desired information. This value describes what the script expects just before the IP address we need to filter. Just after that text placed in this variable the IP address appears.
  • ExpTime: Είναι ο χρόνος μέσα στον οποίο αν το router δεν στείλει κάποιο χαρακτήρα, θεωρείται πώς δεν έχει κάτι άλλο να στείλει. Προσοχή, σε άλλα router είναι μικρότερος και σε άλλα μεγαλύτερος. Γενικά, ο μεγάλος χρόνος κάνει για όλα τα router, αλλά καθυστερεί την εξέλιξη του script.This is the time that the script expects the router to sent a character. If there is no character during this time interval, the script assumes there is nothing more coming from the router as an answer. Be careful, at some routers this time is small while at others it is larger. In general, a bigger value is suitable for all routers but it slows down the performance of the script.

Αν μπούμε χειροκίνητα σε ένα TP-Link router και δώσουμε την εντολή show wan status τότε θα δούμε τα ακόλουθα:

If we manually connect to a TP-Link router and execute the command show wan status then it will return the following:

eliaschr@orion:~> telnet router
Trying 192.168.1.1...
Connected to router.
Escape character is '^]'.

Password: *********************
Copyright (c) 2001 - 2011 TP-LINK TECHNOLOGIES CO., LTD.
TP-LINK> show wan status
PVC-0 
        Status = Up
PVC-1 
        Status = Up
PVC-2 
        Status = Up
PVC-3 
        Status = Up
PVC-4 
        Status = Up
        Ip = 94.71.120.43
PVC-5 
        Status = Up
PVC-6 
        Status = Up
PVC-7 
        Status = Down
TP-LINK> 

Βλέπουμε ότι ακριβώς πριν την IP που μας ενδιαφέρει βρίσκεται το Ip = . Αυτό είναι που βάζουμε στο AddrPrefix.

We can see that just before the IP address we need to read is Ip = . This is what we set AddrPrefix to.

Στην περίπτωση του ZTE και του AirTies ένα configuration αρχείο σαν αυτό που ακολουθεί κάνει τη δουλειά:

In case of a ZTE or an AirTies a configuration file like the following does the necessary job:

Configuration για router ZTE - AirTies - Linux style commands

Configuration for ZTE - AirTies routers - Linux style commands

RouterIP = "192.168.1.1"
Password = "MyCrazyPassword"
NetComm = "ifconfig ppp0"
AddrPrefix = "inet addr:"
ExpTime = 0.05

Φυσικά, όποιο και να είναι το configuration που θα επιλέξετε, το μόνο σίγουρο είναι πως δεν πρέπει να το διαβάζει κανένας, παρά μόνο ο root!:

Of course, whichever is the configuration you choose, it is mandatory to be accessible by no one, except root!:

pi@raspberrypi:/usr/scripts > chown root:root /etc/GetInetIP.conf
pi@raspberrypi:/usr/scripts > chmod 0600 /etc/GetInetIP.conf
pi@raspberrypi:/usr/scripts > 

Dynamic Updater Client script

Ωραία! Αφού φτιάξαμε το script που μας διαβάζει την IP από το router μας, μένει να φτιάξουμε και το script που θα κάνει τη δουλειά του NoIP DUC. Δημιουργήστε το αρχείο IP-Updater.sh στον κατάλογο /usr/scripts που φτιάξαμε πριν. Το αρχείο αυτό θα πρέπει να το κάνετε Copy/Paste από εδώ:

Great! After we created the script that reads our router's WAN IP address, we have to create a new script that will simulate NoIP DUC. Just create the file named IP-Updater.sh under the directory /usr/scripts as earlier. You can Copy/Paste the source of the script in question from here:

#!/bin/bash
# THE SOFTWARE IS LICENSED UNDER GPL2 GENERAL PUBLIC LICENSE v2.
# IN ORDER TO OBTAIN A COPY OF THIS LICENSE PLEASE VISIT THE FOLLOWING
# ADDRESS:
# http://www.gnu.org/licenses/gpl-2.0.html

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# The script uses a configuration file that is called /etc/IP-Updater.conf
# Valid lines in the script are:
# NoIPUser=the_username_of_NoIP_login_account
# NoIPPass=the_password_of_the_account
# NoIPHost=the_host_to_which_the_IP_is_going_to_be_updated
# FindIPComm=/path/to/the_command_line_to_be_executed_to_get_the_IP
# FailIPDelay=Delay in seconds before retrying to find out the new
#       IP address, after a failure
# RepeatDelay=Delay in seconds before trying to refresh the IP after a
#       successful update
# FailDelay=Delay in seconds if there is a fatal error in NoIP. (Only if PreventExit=true)
# WGetDelay=Delay in seconds if there is a failure in wget to NoIP
# WGetLongFailDelay=Delay in seconds after Maximum number of failures reached
# WGetMaxFails=Maximum wget sequensial failures that make the daemon exit (unless
#       PreventExit=true
# MaxFailIPCnt=Maximum number of retries to fetch IP address from router
#       while it seems to have connection to the internet
# PreventExit={true/false} If true, then upon fatal error the script never ends
# SuccessCmd=Command to execute after a successful update to No-IP
# FailCmd=Command to execute after a failed NoIP update
# ExitCmd=Command to execute if the program must exit because of Fatal Error

# In ExitCmd, FailCmd and SuccessCmd you can use the following values as input:
#       $NoIPResp: if you want to include the responce from NoIP after the 
#               request of IP Address updating
#       $NewIP: the new IP that found and sent to NoIP
#       $CurrIP: the old IP that the system had before the update
#       $CurDate: the time that the execution of the IP update happened

PIDFILE=/var/run/IP-Updater.pid
PID=$BASHPID
LOGME="logger -ist 'NoIP-Updater'"
TEMPFILE="/tmp/CurrentIP"
TEMPWGET="/tmp/CurrentIP.wget"
CONFFILE="/etc/IP-Updater.conf"
USERAGENT="WGet from Raspberry Pi Linux/1.0 eliaschr@gmail.com"
NoIPUser=""
NoIPPass=""
NoIPHost=""
FindIPComm="echo 'ERROR: No router IP fetch program specified' >&2; exit 4;"
PreventExit=true
FailDelay=1800
MaxFailIPCnt=3
FailIPDelay=15
RepeatDelay=60
WGetDelay=5
WGetLongFailDelay=60
WGetMaxFails=10
SuccessCmd=""
FailCmd=""
ExitCmd=""
WGetErrMess[1]="Generic error code"
WGetErrMess[2]="Parse error"
WGetErrMess[3]="File I/O error"
WGetErrMess[4]="Network failure"
WGetErrMess[5]="SSL verification failure"
WGetErrMess[6]="Username/password authentication failure"
WGetErrMess[7]="Protocol errors"
WGetErrMess[8]="Server issued an error response"

CurrIP="x"

test -r $CONFFILE || ( echo "Failed to load the configuration file $CONFFILE..." >&2;
        exit 1 )

source $CONFFILE

touch $TEMPFILE
echo "" > $TEMPFILE

touch $PIDFILE
echo $PID > $PIDFILE

while true
do
        source $TEMPFILE
        FailCounter=$MaxFailIPCnt
        NextDelay=$RepeatDelay
        NewIP=`$FindIPComm`
        Status=$?

        while (( $Status != 0 ))
        do
                CurDate=`date +%T`
                $LOGME "$CurDate WARNING: Could not read the IP address"
                if (( $FailCounter == 0 ))
                then
                        $LOGME "Too many failures... Abording"
                        rm $PIDFILE
                        exit 2
                fi
                sleep $FailIPDelay
                PingStat=`ping -c1 www.no-ip.com > /dev/null; echo $?`
                if [[ "$PingStat" == "0" ]]
                then
                        NewIP=`$FindIPComm`
                        Status=$?
                        FailCounter=$((FailCounter -1))
                fi
        done

        if [[ "$CurrIP" != "$NewIP" ]]
        then
                CurDate=`date +%T`
                WGetStatus=`wget -qO $TEMPWGET -U "$USERAGENT" --user=$NoIPUser --password=$NoIPPass "http://dynupdate.no-ip.com/nic/update?hostname=${NoIPHost}&myip=$NewIP"; echo $?`
                NoIPResp=`cat $TEMPWGET`
                if (( $WGetStatus == 0 ))
                then
                        WGetFails=$WGetMaxFails
                        case ${NoIPResp/ */} in
                                "good")
                                        FailIPResult=0
                                        echo "CurrIP=$NewIP" > $TEMPFILE
                                        $LOGME "IP Address successfuly updated"
                                        ;;
                                "nochg")
                                        FailIPResult=1
                                        HostIPResp=`host $NoIPHost`
                                        if (( $? == 0 ))
                                        then
                                                HostIP=${HostIPResp/* /}
                                                if [[ "$HostIP" == "$NewIP" ]]
                                                then
                                                        FailIPResult=0
                                                        Comment="successfuly"
                                                        echo "CurrIP=$HostIP" > $TEMPFILE
                                                else
                                                        Comment="but it seems different than expected..."
                                                        NextDelay=$FailIPDelay
                                                fi
                                        else
                                                Comment="but could not resolve $NoIPHost"
                                                NextDelay=$FailIPDelay
                                        fi
                                        $LOGME "$CurDate WARNING: The IP in NoIP was updated by another process $Comment"
                                        ;;
                                "nohost")
                                        FailIPResult=1
                                        $LOGME "$CurDate ERROR: Hostname supplied does not exist under specified account"
                                        ;;
                                "badauth")
                                        FailIPResult=1
                                        $LOGME "$CurDate ERROR: Invalid username password combination"
                                        ;;
                                "badagent")
                                        FailIPResult=2
                                        $LOGME "$CurDate ERROR: Client disabled. Client should exit and not perform any more updates without user intervention"
                                        ;;
                                "\!donator")
                                        $LOGME "$CurDate ERROR: An update request was sent including a feature that is not available to that particular user"
                                        FailIPResult=1
                                        ;;
                                "abuse")
                                        $LOGME "$CurDate ERROR: Username is blocked due to abuse. Either for not following our update specifications or disabled due to violation of the No-IP terms of service"
                                        FailIPResult=1
                                        ;;
                                "911")
                                        $LOGME "$CurDate FATAL ERROR: NoIP.com error such as a database outage. Retry the update no sooner 30 minutes"
                                        FailIPResult=1
                                        NextDelay=1800
                                        ;;
                                *)
                                        $LOGME "$CurDate ERROR: Unknown responce from NoIP.com - $NoIPResp"
                                        FailIPResult=1
                                        ;;
                        esac

                        case $FailIPResult in
                                0)
                                        eval $SuccessCmd
                                        ;;
                                1)
                                        eval $FailCmd
                                        ;;
                                *)
                                        if $PreventExit
                                        then
                                                NextDelay=$FailDelay
                                                eval $FailCmd
                                        else
                                                eval $ExitCmd
                                                rm $PIDFILE
                                                exit 3
                                        fi
                                        ;;
                        esac
                else
                        $LOGME "$CurDate ERROR: Wget exited with error status $WGetStatus: ${WGetErrMess[$WGetStatus]}"
                        WGetFails=$((WGetFails -1))
                        if (( $WGetFails == 0 ))
                        then
                                WGetFails=1
                                NextDelay=$WGetLongFailDelay
                        else
                                NextDelay=$WGetDelay
                        fi
                fi
        fi

        sleep $NextDelay
done

Αυτό το script είναι γραμμένο σε bash shell. Και αυτό για να λειτουργήσει χρειάζεται το configuration αρχείο του, /etc/IP-Updater.conf. Ένα δείγμα του εν λόγω αρχείου φαίνεται ακολούθως:

The is a bash shell script. It also needs its configuration file, /etc/IP-Updater.conf. A sample of this file follows:

NoIPUser=noipusermail@myisp.gr
NoIPPass="MyUltraFancyPassword!"
NoIPHost=myhostname.no-ip.biz
FindIPComm="/usr/scripts/GetInetIP.py"
FailIPDelay=15
RepeatDelay=60
FailDelay=1800
MaxFailIPCnt=3
PreventExit=true
SuccessCmd="/usr/bin/ttytter -keyf=/etc/ttytter/Servertty -silent -status=\"\`date\` IP Updated successfully. NoIP Response is: \$NoIPResp\""
FailCmd="/usr/bin/ttytter  -keyf=/etc/ttytter/Servertty -silent -status=\"\`date\` IP Update failed. NoIP Response is: \$NoIPResp\""
ExitCmd="/usr/bin/ttytter  -keyf=/etc/ttytter/Servertty -silent -status=\"\`date\` Fatal Error during IP Update. NoIP response is: \$NoIPResp. Exiting...\""

Ας δουμε μια λίστα με πιθανές παραμέτρους του αρχείου:

Lets see a list of the possible parameters that can be specified in this file:

  • NoIPUser: Δηλώνει τη διεύθυνση mail του λογαριασμού του χρήστη που έχουμε φτιάξει στο NoIPSpecifies the e-mail address of the NoIP user's account we have created
  • NoIPPass: Το password που έχουμε στο NoIP λογαριασμόThe password for this account
  • NoIPHost: Το όνομα του domain που έχουμε καταχωρήσειThe domain name we own (or the one from the default that NoIP provides).
  • FindIPComm: Δηλώνεται το script που όταν τρέξει μας δίνει τη διεύθυνση IP του router. Κοινώς, το script που φτιάξαμε πριν σε pythonThe script name (command) that returns the IP address from our router. It is the script in python, we created earlier
  • FailIPDelay: Όταν δεν καταφέρει να διαβάσει την IP από το router, όπως σε περίπτωση που το router δεν έχει πάρει ακόμα IP μετά από διακοπή ρεύματος, ή το router είναι σβηστό, το script περιμένει όσα δευτερόλεπτα ορίζονται σε αυτή την παράμετρο, πριν ξαναπροσπαθήσειWhen the script fails to read the WAN IP from the router, as in case the router still waits for the ISP to send its IP after a power failure, or even if the router is powered off, the script sleeps for as many seconds as specified in this parameter before retrying
  • RepeatDelay: Όταν διαβάσει σωστά μια IP διεύθυνση, δηλώνει σε πόσο χρόνο θα ξαναπροσπαθήσει να δει αν υπάρχει αλλαγή τηςWhen the script fetches the IP address correctly, this parameter defines how much time it will wait until it checks again for an IP change
  • FailDelay: Όταν υπάρξει πρόβλημα στην ενημέρωση της καινούργιας IP, όπως σε περίπτωση που το NoIP επιστρέψει "911", το script περιμένει όσο χρόνο δηλώνεται εδώ σε δευτερόλεπτα πριν ξαναπροσπαθήσει την ενημέρωση του NoIP DNSWhen there is a failure during NoIP address update request, as in case NoIP server answers with "911", the script waits for such time as described in here, in seconds before retrying
  • MaxFailIPCnt: Ο μέγιστος αριθμός προσπαθειών στις οποίες δε θα μπορέσει να διαβάσει την IP διεύθυνση από το router, ενώ πιστοποιείται πως υπάρχει σύνδεση με το internet. Αυτή η κατάσταση κανονικά δεν πρέπει να υπάρξει ποτέ.The maximum number of retries that will fail to read the IP address from the router, while there is certified internet connection. Normally, this state will never be reached.
  • PreventExit:true ήor false. Αν είναι true τότε το script δε σταματάει ποτέ, ούτε σε περίπτωση λάθους όπως π.χ. username/password στο NoIPIf it is true the script never ends, not even in case of a failure like ie. wrong NoIP username/password
  • SuccessCmd: Εντολή που θα εκτελείται όταν έχουμε μια σωστή απάντηση από το NoIP όσον αφορά την ανανέωση της IP μας. Στο παράδειγμα φαίνεται να τρέχει το ttytter με τέτοιο τρόπο ώστε να μπορεί να στέλνει tweet την κατάστασή του. Δώστε βάση στον τρόπο με τον οποίο δηλώνονται μεταβλητές και εσωτερικές εκτελέσεις εντολών, όπως η dateCommand to be executed when there is a correct answer from NoIP for our IP address updating to DNS tables. In this example ttytter is executed in a way to tweet us the DNS status. Pay attention to the way the variables are specified in this command and interna command execution, like date
  • FailCmd: Το ίδιο, αλλά για την περίπτωση όπου υπάρξει απάντηση σφάλματος από το NoIPSame thing for the case of a NoIP answer for failure
  • ExitCmd: Ομοίως για την περίπτωση όπου υπάρξει τέτοιο σφάλμα όπου θα πρέπει το script να τερματιστείAnd again same thing in case the failure is severe and the script must be terminated
  • WGetDelay: Το script χρησιμοποιεί τη wget για να στείλει το request στο NoIP server. Σε περίπτωση που υπάρξει σφάλμα περιμένει όσο χρόνο του ορίζει αυτή η μεταβλητήThis script uses wget to send a request to NoIP server. In case of request failure it wait for as long as this parameter specifies
  • WGetMaxFails: Όταν υπάρξουν τόσα σφάλματα στη σειρά από τη wget όσα ορίζονται σε αυτή την παράμετρο, τότε ο χρόνος αναμονής μέχρι το επόμενο wget που θα επιχειρηθεί ορίζεται από την WGetLongFailDelayWhen there are as many wget failures as this parameter specifies, then the delay until any further wget request will be as WGetLongFailDelay specifies.
  • WGetLongFailDelay: Μετά από WGetMaxFails αποτυχίες της wget ο χρόνος που περιμένει πριν ξαναδοκιμάσει να στείλει request ορίζεται από αυτή την παράμετροAfter WGetMaxFails wget failures, the delay interval till next retry is specified by this parameter

Το script μας δίνει τη δυνατότητα να εκτελέσουμε κάποιες εντολές, ανάλογα με το αν ήταν επιτυχής η αλλαγή της IP, αν υπήρξε κάποιο σφάλμα, ή αν υπήρξε μια ανεπίτρεπτη κατάσταση που οδηγεί το script σε τερματισμό. Οι εντολές αυτές ορίζονται στις παραμέτρους SuccessCmd, FailCmd και ExitCmd. Σε αυτές τις εντολές, μπορεί να θέλουμε να χρησιμοποιήσουμε κάποιες πληροφορίες από το script. Οι δυνατές περιπτώσεις είναι οι:

The script provides us the ability to execute some commands depending on the case of success or failure of the IP update request, or even if there was a severe error that forced the script to terminate. The commands in question are specified in SuccessCmd, FailCmd and ExitCmd parameters. In these commands we may need to use some information coming from the script. The possible script variables are:

  • $NoIPResp: Περιέχει την απάντηση από τον server της NoIPContains the answer of the NoIP server
  • $NewIP: Περιέχει την καινούργια IP διεύθυνσηContains the new IP address
  • $CurrIP: Περιέχει την παλιά IP διεύθυνσηContains the old IP address
  • $CurDate: Περιέχει την ώρα που ανιχνεύτηκε η αλλαγή της IPContains the time value the IP change was detected

Και φυσικά, μιας και σε αυτό το αρχείο περιέχονται ευαίσθητες πληροφορίες, θα πρέπει να μπορεί να το διαβάσει μόνο ο root:

Well, of course in this file there are also sensitive information that only root should be able to read:

pi@raspberrypi:/usr/scripts > chown root:root /etc/IP-Updater.conf
pi@raspberrypi:/usr/scripts > chmod 0600 /etc/IP-Updater.conf
pi@raspberrypi:/usr/scripts > 

Τέλος, μιας και αυτά τα δύο scripts είναι βασικά για τη λειτουργία του συστήματός μας, καλό είναι και αυτά να τα κάνουμε μη προσβάσιμα από τους χρήστες (εκτός του root):

Finally, since both scripts are mandatory for the functionality of our system, it is a good practice not to let any user access them (unless, of course root):

pi@raspberrypi:/usr/scripts > sudo chown -R root:root /usr/scripts
pi@raspberrypi:/usr/scripts > sudo chmod -R 0700 /usr/scripts
pi@raspberrypi:/usr/scripts > 

Μετατροπή του καινούργιου client σε υπηρεσία

Conversion of the new client to a system service

Το τελικό στάδιο είναι να εκτελείται το script που φτιάξαμε ως υπηρεσία του συστήματος. Κάποιος θα μπορούσε πολύ απλά να το τρέξει μέσα από τον cron. Αυτό όμως δεν θεωρείται και τόσο καλή ιδέα. Είναι σαφώς καλύτερα να λειτουργεί όπως όλες οι υπηρεσίες του συστήματος, να ενεργοποιείται και να απενεργοποιείται ανάλογα με το runlevel κ.λ.π. Για να το πετύχουμε αυτό θα πρέπει να φτιάξουμε ένα ακόμα script. Μια παρόμοια εργασία κάναμε και σε προηγούμενο άρθρο. Θα ακολουθήσουμε, λοιπόν, την ίδια τακτική.

The final stage is to let the script we created run as a system service. Somebody would let it start through cron. But this is not considered a good practice. It is far better to let it act as any other system service, start or stop depending on the runlevel of the system, etc. To reach our goal we must create another one script. A similar process we followed in an earlier article. We will follow the same tactics.

Κάντε Copy/Paste τον ακόλουθο κώδικα στον αγαπημένο σας editor:

Again, you can Copy/Paste the following source code in your favourite editor:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          IP-Updater
# Required-Start:    $local_fs $syslog $network
# Required-Stop:     $local_fs $syslog $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: IP Updater for NoIP Dynamic DNS service
# Description:       Start IP Updater to check the IP that the ISP has given to router.
#       When the IP is changed, the updater informs NoIP and updates the chosen domain name
#       to point to the new IP.
### END INIT INFO

# Author: Elias Chrysocheris 
#

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="IP Updating client service for NoIP (http://www.noip.com/)"
NAME=IP-Updater
DAEMON=/usr/scripts/IP-Updater.sh
SCRIPTNAME=/etc/init.d/$NAME
PIDFILE=/var/run/IP-Updater.pid

# Exit if the package is not installed
[ -e "$DAEMON" ] || { echo "Cannot find IP-Updater executable in $DAEMON. Perhaps it is not installed...";
        if [ "$1" = "stop" ]; then exit 0;
        else exit 5; fi; }

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
        # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started
        start-stop-daemon --test --start --quiet --pidfile $PIDFILE --exec $DAEMON > /dev/null \
                || return 1
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON &
        RETVAL="$?"
        [ "$RETVAL" > 2 ] && return 2
        # Add code here, if necessary, that waits for the process to be ready
        # to handle requests from services started subsequently which depend
        # on this one.  As a last resort, sleep for some time.
}

#
# Function that stops the daemon/service
#
do_stop()
{
        # Return
        #   0 if daemon has been stopped
        #   1 if daemon was already stopped
        #   2 if daemon could not be stopped
        #   other if a failure occurred
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
        RETVAL="$?"
        [ "$RETVAL" = 2 ] && return 2
        # Wait for children to finish too if this is a daemon that forks
        # and if the daemon is only ever run from this initscript.
        # If the above conditions are not satisfied then add some other code
        # that waits for the process to drop all resources that could be
        # needed by services started subsequently.  A last resort is to
        # sleep for some time.
        start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --pidfile $PIDFILE
        [ "$?" = 2 ] && return 2
        rm $PIDFILE
        return "$RETVAL"
}

#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
        #
        # If the daemon can reload its configuration without
        # restarting (for example, when it is sent a SIGHUP),
        # then implement that here.
        #
        start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
        return 0
}

case "$1" in
  start)
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
        do_start
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  stop)
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
        do_stop
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  status)
        status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
        ;;
  #reload|force-reload)
        #
        # If do_reload() is not implemented then leave this commented out
        # and leave 'force-reload' as an alias for 'restart'.
        #
        #log_daemon_msg "Reloading $DESC" "$NAME"
        #do_reload
        #log_end_msg $?
        #;;
  restart|force-reload)
        #
        # If the "reload" option is implemented then remove the
        # 'force-reload' alias
        #
        log_daemon_msg "Restarting $DESC" "$NAME"
        do_stop
        case "$?" in
          0|1)
                do_start
                case "$?" in
                        0) log_end_msg 0 ;;
                        1) log_end_msg 1 ;; # Old process is still running
                        *) log_end_msg 1 ;; # Failed to start
                esac
                ;;
          *)
                # Failed to stop
                log_end_msg 1
                ;;
        esac
        ;;
  *)
        #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
        echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
        exit 3
        ;;
esac

Το script βασίστηκε για άλλη μια φορά στο κλασικό skeleton που υπάρχει στον κατάλογο /etc/init.d/. Εκεί θα το σώσουμε σαν root με το όνομα IP-Updater. Αν δεν έχουμε τη δυνατότητα να το κάνουμε απ' ευθείας, μπορούμε σαν χρήστες να το σώσουμε στον κατάλογό μας και στη συνέχεια να το αντιγράψουμε ως root στην κατάλληλη θέση. Στη συνέχεια αλλάζουμε τα δικαιώματα και το κάνουμε εκτελέσιμο και ενημερώνουμε το σύστημα για την καινούργια υπηρεσία:

This script is based once more in the clasical skeleton that lives under /etc/init.d/. There we eill save it as root user under the name IP-Updater. If you cannot do it straight forward, you can save it under your home directory and then you can copy it as root to the correct place. Then you can change its access rights making it executable and inform the system for the new service:

pi@raspberrypi:/usr/scripts > cd /etc/init.d/
pi@raspberrypi:/etc/init.d > sudo cp /home/pi/IP-Updater .
pi@raspberrypi:/etc/init.d > sudo chmod 0755 IP-Updater
pi@raspberrypi:/etc/init.d > sudo update-rc.d IP-Updater defaults
pi@raspberrypi:/etc/init.d > 

Μετά από αυτό μπορούμε να εκκινήσουμε την υπηρεσία μας. Όμως, για να δοκιμάσουμε ότι όλα βαίνουν καλώς, καλό είναι να δούμε αν ενεργοποιείται αυτόματα με μια επανεκκίνηση:

After that we can start the new service. But first we have to make sure everything is fine and the service starts automatically after a reboot:

pi@raspberrypi:/usr/scripts > sudo shutdown -r now
pi@raspberrypi:/etc/init.d > 

Αποτελέσματα

Conclusions

Εαν όλα έχουν πάει καλά, τότε μπορείτε να παρακολουθήσετε τα μηνύματα στο /var/log/messages και να δείτε τη λειτουργία του script. Αν προσέξατε, στο configuration αρχείο του IP-Updater, χρησιμοποιείται το ttytter που είναι ένας client για το twitter. Μέσω αυτού βλέπουμε on-line τη λειτουργία της αλλαγής διεύθυνσης

If everything is done correctly then you could see the information in /var/log/messages and watch the service in action. You must have noticed, in the IP-Updater configuration file, ttytter is used which is a command line twitter client. Using that we can observe on-line the function of IP updating

Αυτό φυσικά προϋποθέτει να έχετε στήσει το ttytter και να το έχετε ρυθμίσει.

For this you are supposed to have ttytter installed and configured.

Έπειτα από αρκετό καιρό που λειτουργεί η υπηρεσία του NoIP στο Raspberry Pi δεν έχω πετύχει κατάσταση που να μη μπορώ να έχω πρόσβαση μέσω του δικτύου, απομακρυσμένα. Η απόκριση του συστήματος είναι παραπάνω από ικανοποιητική.

Using NoIP service system in Raspberry Pi for enough time now, I never had that awkward moment of not having access to my system through the internet. The system's response is more than satisfactory.


Ηλίας Χρυσοχέρης

Elias Chrysocheris