Tiny Core Linux – Part 2 – Cron and Back-Up

As mentioned in previous post, changes are only backed up manually by running the filetool.sh -b command. Which is fine for scheduled shut-downs but what about power cuts and such?

The most straight forward option is to run the filetool.sh -b command on a schedule, which is where cron comes in. You need to enable to cron daemon at start-up (see more options at http://www.tinycorelinux.net/faq.html#bootcodes). As per http://ostatic.com/blog/thinking-small-with-tiny-core-linux, you need to edit  /mnt/sdb/boot/syslinux/syslinux.cfg to add cron to the boot parameters list under APPEND. At the next reboot, the cron daemon will be running.

Then you need to edit the crontab (sudo crontab -e, see here for vi basics – http://www.washington.edu/computing/unix/vi.html).

*/15 * * * * filetool.sh -b > /home/tc/cron.log

This will run the filetool.sh -b command every 15 minutes and log it in /home/tc/cron.log so I can actually confirm it is running.

You then need to add/var/spool/cron to /opt/.filetool.lst file in order for your cron job to be backed up.

Tiny Core Linux – Personal Web Server off a USB key

The logic: Keeping a computer the whole time to self-host my stuff has a cost so I wanted to explore some alternatives.I have an HP Thin Client (with Windows XP Embedded) that doesn’t have a hard drive (runs off Flash Memory) but can boot from USB.

After looking at SMS (Superb Mini Server – boot SMS is not the default option in the start up screen), Freenas/Nas4free (not really geared to run a web server), Puppy Linux (could have been a decent alternative), I settled on Tiny Core Linux – http://distro.ibiblio.org/tinycorelinux/

Very nifty piece of kit! I installed it on a USB using http://sourceforge.net/projects/core2usb/ and booted my Thin Client from the USB.

Some references to get started:

– Install SSH so I can remote from my laptop- http://myblog-kenton.blogspot.ie/2012/03/install-openssh-server-on-tiny-core.html 

– Install of packages via terminal – http://wiki.tinycorelinux.net/wiki:package_management_cheat_sheet

– For more, see http://wiki.tinycorelinux.net/wiki:start

I installed apache2, apache2-mod-php5 and mysql. PHP is enabled by default. In order to install web apps (WordPress, MyTinyToDo, Tiny Tiny RSS), the empty databases need to created before you can run the web installer so I had to dig out the manual for the mysql terminal commands (http://dev.mysql.com/doc/refman/5.0/en/mysql-command-options.html). It boils down to:

– Create an admin (first time run): mysqladmin -u root password “newpassword”

– Log in: mysql -u root -p

Enter Password

– CREATE DATABASE wordpress;

– exit

Let’s stick with the WordPress example, download the installer from the WordPress site, expand it under /usr/local/apache2/htdocs, start apache (sudo /usr/local/apache2/bin/apachectl start, edit first /usr/local/apache2/conf/httpd.conf if you want to use another port than default port 80 and add index.php to the DirectoryIndex directive) and access http://your.ip/wordpress/ to kick off the web installer.

Note, if you use xampp (available as a self-contained package .scm for Tiny Core Linux) instead of apache2/mysql native packages .tcz, the mysql.sock file isn’t created in the default /tmp/ directory but the one under the /opt/lampp directory structure, you need to create a symlink from that directory so the WordPress installer can find /tmp/mysql.sock (see http://stackoverflow.com/questions/4219970/warning-mysql-connect-2002-no-such-file-or-directory-trying-to-connect-vi).

OK, so you have it working. Now, you need to set up the persistence. Yes, Tiny Core Linux runs from RAM so if you shut down now, you will have lost all your changes.

So, 3 things to look at:

– Edit /opt/.filetool.lst to add the new locations to be backed up (/usr/local/apache2/ and /usr/local/mysql/data)

– Edit /opt/bootlocal.sh to add the daemons to start automatically at start-up (/usr/local/apache2/bin/apachectl and /etc/init.d/services/mysql start)

– And back up by running filetool.sh -b!

I need to figure out if there is a better way to ensure things are backed up before any type of shutdown than running the filetool.sh -b script.

I have everything in place so I’ll leave everything run for a few days and I’ll update this with the outcome, viable or just a nice to play with.

 

Debian and Parental Control

The premise: Old Samsung laptop (40GB HDD, 700Mg RAM) is being repurposed for use by a 9-year old with very little experience of using the internet.

Better safe than sorry, I went all out. Debian runs very decently on the decrepit machine and I used tinyproxy to block everything apart from wikipedia.org – details below. Short of that, I just removed the Chat software and the Epiphany browser (I set up Iceweasel to go through tinyproxy) and it looks safe enough!

Reference links for tinyproxy: 

Excerpts of /etc/tinyproxy.conf:

LogLevel   Critical

Filter   “/etc/tinyproxy/filter”

FilterURLs   On

FilterDefaultDeny    Yes

Content of /etc/tinyproxy/filter:

.wikipedia.org

.wikimedia.org