Kogaion Wall

Update Notification Script in Kogaion

This post is also available in: Romanian

For a while I entered in amateur linux administration. I can not say I’m a professional because I have not yet charged anyone for administration so just because I manage my servers all by my self, to me it means that I’m at amateur level.
I learned from experience that it is helpful to know that your server needs updates, that packages updates needs to be installed, that your server has a service that stopped, such as MySQL and you have to make somehow the server to detect this and then try to restart the service and notify you that this has happened.
Many things related to a server are those that can be monitored and there are some great utilities in this regard but often I prefer to create and run my own scripts monitoring and reporting.
That is why I have developed several scripts that runs with the help of CRON and this would be my monitor in what happens to a server.
If I declare myself an amateur, I can declare specialist-amateur in servers running Debian and Ubuntu then CentOS and at investigating level other operating sistems, but recently I started, as I mentioned here, to button the Kogaion OS – testing, verification, implementation etc. ..
Personally I installed Kogaion and then people around me who liked the idea realised that they wanted Kogaion on their personal computers.
Problems arise when they want something, an application that do something additional activities or when they just want help with anything and … there is no one to intervene. It appears instinctive need to call the one who knows (in this case … the undersigned) and call to solve the problem.
Let’s say 10 such situations occur in a certain time, and probably can not even reach 2 of them and on 4 I was in my way them and on the other four we took the opportunity to drink a beer. Also difficulty grade occurs, and why not related to the degree of personal comfort of my mood at the time.
I wanted to solve some situations of this kind, REMOTE – connected from home or from anywhere else, and so I asked people to let me connect to their remote computers or to make some of them to run automatically.
So it is that … I started working.
The first situation that I dealt with was

the one related updates.
I know it well and I recommend everyone to have system updates daily, so I left this to take place automatically.
A small CRON script runs when I want and it reports what happened using an email address.

However, we do not have in Kogaion a mail server and to run the script I needed one and, as I learned things with Postfix I installed it on Kogaion.
Postfix is ​​not part of Kogaion packages so I had to resort to “Vasile” (kvasile) to search for packages that are not part of Kogaion.

kvasile --devmode
emerge postfix
kvasile --usermode

Postfix will run behind the system so you should know in advance if you are willing to give up some resources to it. In my case, the computer is powerful enough and I said I can.

The script itself is this:
tmpfile=$( /bin/mktemp -t )
/bin/echo return-path: $myname >> $tmpfile
/bin/echo for: $myname >> $tmpfile
/bin/echo from: $myname >> $tmpfile
/bin/echo to: $myname >> $tmpfile
/bin/echo subject: Kogaion Linux Update Status >> $tmpfile
/bin/echo Hello there ROOT... this is an informational message: >> $tmpfile
/bin/echo >> $tmpfile
/bin/echo EPKG Update was run: $( /bin/date +%c ) >> $tmpfile
/bin/echo >> $tmpfile
/bin/echo -n "Result: " >> $tmpfile
/usr/bin/epkg update > /dev/null
/usr/bin/epkg upgrade | genlop -l --date 1 day ago >> $tmpfile
/bin/echo OS DETAILS : $( /bin/uname -a ) >> $tmpfile
/bin/echo >> $tmpfile
/bin/echo Yours truly, "KOGAION Linux Computer of Vasile's" >> $tmpfile
/bin/echo >> $tmpfile
/bin/cat $tmpfile | sendmail -t
/bin/rm $tmpfile
exit 0

As seen the script does not do much but for me it means a lot … 🙂
Save the script, say update_kogaion.sh and set the flag to run chmod +x update_kogaion.sh.

Attention to your internet connection. Postfix uses the default settings and configuration is rudimentary. If email messages do not arrive on set, that user@mail.com, then you may need additional settings for postfix or ask to unblock port 25 to the Internet provider.

The script can be run in the console:
and then if everything is ok the script can be added to CRON or to start-up … etc …

Maybe in the future I will return with the remote connection method;)

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA * Time limit is exhausted. Please reload CAPTCHA.