Showing posts with label debian. Show all posts
Showing posts with label debian. Show all posts

Tuesday, January 3, 2012

How To Set up a repository cache with apt-cacher


By Pallavi Shastry

When running multiple machine with the same distribution, it is sensible to set up a repository cache on your network so that once a package is downloaded from an official repository, all other machines will download it from your local area network.
Having different machines running the same linux distribution, it becomes interesting to set up a repository cache in your local network. This way, you won't download common packages more than 1 time from official repositories.
Here is the situation, we have one machine called repository-cache, this machine is going to act as the repository cache, basically, any other machines in your network is going to use it as a repository.



1. Getting started : Server configuration

As usual, you need to install the required packages in the first place. So type in a terminal:

$sudo apt-get install apt-cacher apache2

To start the service of the apache web server. 
 $sudo /etc/init.d/apache2 start
 
Then test by going to http://repository-cache:3142/apt-cacher to verify that it's running. 
repository-cache in the URL above is the host name or IP of the cache server in the LAN. 

Once this is done, it is time to get into the configuration files in /etc/apt-cacher/apt-cacher.conf

$sudo gedit /etc/apt-cacher/apt-cacher.conf

The default port apt-cacher is running on is port 3142.

Allowed_hosts: by default, all host are allowed to use the repository cache. You can change this value if you want to only allow certain host.

Generate_reports: This directive makes apt-cacher create a report on how efficient your cache was on a daily basis. Default is 1, if you want to disable this, set it to 0.apt-cacher will generate report on the usage of the cache every day.

Clean cache: This directive makes apt-cacher clean the cache every 24 hours . So reset it , clean cache =0


2. Activating apt-cacher to start

In order to start, apt-cacher needs to be activated from /etc/default/apt-cacher. So open /etc/default/apt-cacher and set AUTOSTART to 1:
AUTOSTART=1
Now restart apt-cacher:
$sudo /etc/init.d/apt-cacher restart
Now that apt-cacher runs, it is time to update all our clients /etc/apt/sources.list files so every host on the network will use our repository-cache machine.


3. Importing existing package from /var/cache/apt/archives/ to apt-cacher repository

It might happen that your server already has got a whole lot of packages cached in its local repository: /var/cache/apt/archives/.  
apt-cacher offers a tool to import those files to apt-cacher repository logically without in fact replicating copies of these packages.
There are whole lot of cool and useful scripts that can be found in /usr/share/apt-cacher/
The one we are interested in here is apt-cacher-import.pl which is handy to import deb files from /var/cache/apt/archives to apt-cacher repository run:

$sudo /usr/share/apt-cacher/apt-cacher-import.pl -s /var/cache/apt/archives


5. Setting up the Clients sources.list

Now it is time to set up the client hosts apt source list files: /etc/apt/sources.list
It make sense to use the repository cache on the server too, as that way, any updates made by the server will fill up the cache.

In each line , ie every instance of the sources.list file, if for example there is an entry

deb http://archive.ubuntu.com/ubuntu/ main restricted

becomes

deb http://repository-server:3142/apt-cacher/archive.ubuntu.com/ubuntu/ main restricted

Cool, now, every host should be able to retrieve the .deb packages from our repository cache once has been ran on every host.

$ sudo apt-get update

Then test report by going to http://repository-cache:3142/reports to verify that it's running. The report is generated once a day, but if you need it at a certain time, you can force it by running:

$sudo /usr/share/apt-cacher/apt-cacher-report.pl


6. Conclusion

apt-cacher is an easy and efficient package which will save you both time and bandwidth when using multiple machines with the same distribution like it could happen in a home network or at a company.

Sunday, October 23, 2011

Adding custom menu entries in Debian/Ubuntu

Some of the applications which we install from third party sources are not indexed in the Applications tab in the GNOME shell.

The problem in such a case is the high chances of forgetting what the application name is! And this happens so often with me, that I am forced to create these entries in the Applications menu.

Here's a simple procedure to do this. Although there's System->Preferences->Main Menu to do this, this one is better for some obvious reasons (you can give your custom icons)

  • The Applications Menu entries reside in the directory /usr/share/applications , and to create a new entry create a .desktop file in this directory
cd /usr/share/applications
sudo nano myapp.desktop

  • The .desktop files have just the information needed to put up an entry in the Applications tab, and to run your app; Here is the sample content of the Qtoctave entry from the file qtoctave.desktop
[Desktop Entry]
Version=1.0
Name=QtOctave
Comment=Graphical Qt frontend for GNU Octave
TryExec=qtoctave
Exec=qtoctave
Icon=qtoctave
Type=Application
Categories=Development;Math;Science;Education;Electronics
  • Make these entries into the myapp.desktop file with relevant modifications like your executable file name in the exec field.
  • After modification of the .desktop file, save and close it. Now, the entry should appear in the categories which you mention.
  • To add your application an icon, crop a 32x32 png image and add it into the default icons directory /usr/share/app-install/icons/,
sudo cp myicon.png /usr/share/app-install/icons/ 

In the Icon field of the .desktop file, provide the file name if the icon resides in the aforementioned default directory, or give the full path of the icon

And there you go, your own custom application entry with a custom icon!

Wednesday, August 17, 2011

Right Click, Refresh Desktop in Debian/Ubuntu

Windoze users when switching to Debian/Ubuntu or any other flavours of GNU/Linux seem to have a hangover of some futile actions, that one would get used to while being desperate on the Windoze environments :D

And if you seriously are missing the "refresh desktop" options on the GNU/Linux environments, just to demonstrate the power of Free and Open Source Software, and the freedom they provide the users with, here's a small tweak which gives the "Refresh Desktop" option.

By the way, F5 on Debian/Ubuntu still perform the Refresh blink. This tweak is to add the Right Click -> Refresh Desktop option.

1.Open terminal (ctrl+alt+t)
2. Install the the nautilus (default file browser) menu configuration tool and the lineakd is the daemon that runs in the background of an X session and listens to incoming events from multimedia buttons

sudo apt-get install nautilus-actions lineakd

3. Create a directory to dump this and anymore future tweaks you might be performing to nautilus

mkdir nautilus-scripts

4. Enter the new directory,

cd nautilus-scripts

5. Create the script file,

gedit refresh-desktop

6. Copy these contents in the file (this will perform toggling of F5, and hence the refresh !)

#!/bin/bash
xsendkeycode 71 1
xsendkeycode 71 0

Save and close.

7. Make the script executable using chmod.

sudo chmod u+x refresh-desktop

8. Now, the script is ready, we need to link it to the action. And to add the right-click -> Refresh Desktop short cut, go to System -> Preferences -> Nautilus Actions configuration,

9. Create a new action


10. Change the context label to "Refresh Desktop", or "Mimic Windoze", or anything that pleases you :P

11. Check all the "Display Item options"

12. In the command tab, click on the browse option of Path, and link the refresh-desktop file in the directory "nautilus-scripts" created in step 5
13. In the conditions tab, select "Both"
14. Record all changes, or Save
15. Logout and login
16. And there you go! No more missing a futile action :P

Friday, August 12, 2011

GRUB and Reinstalling GRUB : Debian/Ubuntu

GNU GRUB is a Multiboot boot loader. It was derived from GRUB, the GRand Unified Bootloader, which was originally designed and implemented by Erich Stefan Boleyn. 

And playing around with GRUB to get multiple Operating Systems indexed and to make them available for booting is as awesome as it could get. 
The sheer scalability GRUB has to offer in terms of the number of OS'es it can index is superb. I have gone up to six different operating systems at one point of time, and currently am running five. And that doesn't still represent the number of OS'es that can be multi-booted via GRUB. It is only constrained by the space on your hard drive!

My current Grub entry
While trying the tricks of installing multiple operating systems, if care is not taken the latest OS will overwrite the GRUB and if it ain't a GRUB based bootloader (as would be the case when the last OS is M$ Windoze, or sometimes even Redhat!) the entries of other OS will be lost. 

GRUB on the top of Ubuntu/Debian are the best to retrieve and index all the installed OS. 

Here are the steps for reinstalling GRUB at the MBR for an Ubuntu/Debian distro. 

  • Get hold of a Live CD/Live USB stick with either Debian or Ubuntu
  • After entering the Live user environment, spot the ext4 partition of the Ubuntu/Debian
  • To get to know the partition where the hidden Ubuntu/Debian is installed, usually   
sudo fdisk -l
would suffice. Or gparted is another tool which could be of help
  •  Once you've got to know the ext4 partition, then mount it in the Live environment 
sudo mount /dev/sda5 /mnt (assuming that the ext4 partition of the hidden Ubuntu/Debian install is on sda5)

  • Now, reinstall GRUB :)
sudo grub-install --root-directory=/mnt /dev/sda
(GRUB will be installed on the MBR of sda)

And you're done!

  • Now, boot into your Ubuntu/Debian distro which was running on sda5 (in the example) and run  
sudo update-grub

This will generate a new grub.cfg file as shown in the image above.

Saturday, April 30, 2011

Natty Narhwal Release


Ubuntu 11.04, the thirteenth edition of Ubuntu, aka Natty Narhwal is out. I call Natty a mix bag, with lot of improvements and major digressions from its previous versions.

  • Unity: It is the new GUI for Ubuntu, replacing the long standing GNOME-Ubuntu rapport. After a somewhat regressive debacle in the community, Ubuntu vs GNOME, the two have parted and that GNOME will not be officially supported by Ubuntu, and will be available only via a PPA. Canonical is obviously pushing Unity, and although GNOME isn't dependent on Canonical or Ubuntu, it will certainly be a setback for GNOME. I personally am missing GNOME on Natty. On the positive side of Unity is the four point touch support. That is something to look forward to in the releases to come.

  • Open Office to Libre Office: With the Oracle takeover of Sun Microsystems, projects such as Virtual Box, Open Office, Mysql, etc.. which were mentored by Sun have been under the threat of losing their traits (although Oracle argues otherwise). With Ubuntu switching from Open Office to Libre office, this apprehension about Oracle effect is reduced, nevertheless Open Office will be missed. (BTW, Open Office and Libre Office are almost the same)

  • Banshee replaces Rhythmbox: The default music player for Natty is Banshee, and I don't mind, for I haven't got used to Rhythmbox as yet. VLC still is what I'll be going for. 

  • It's still Mozilla: Firefox4 ships as the default browser, and no prizes for guessing as to why. 
 
  • Proprietary codecs and Software more easily accessible. In order to attract new users, Ubuntu is more than happy to prompt the users to go for proprietary codecs, which has been under a lot of debate since the release of Maverick.  
  • Installation in Telugu and (broken) Kannada are on in Natty.
While the Debian community insists (rightly) to call Debian, a GNU/Linux Operating system as Free (free as in Freedom),

Canonical has been consciously pushing Ubuntu as an Open Source Linux based OS as Free ( as in no price).


Yesterday in Bangalore, the Ubuntu Loco team had called for the Natty Release party, and it was nice to see a bunch of Free and Open Source Software enthusiasts join in and have a small Party for Natty.



PS: Ubuntu is getting no better with every release :(
They're now only "Open", "free" is only a matter of price to Canonical.
But, Ubuntu is like my first love. It drew me into the Free Software Movement, and I am still not ready to part with it.
Nonetheless, if they keep digressing the way they are now, soon I shall have to part with it :)

Saturday, October 30, 2010

Installing and configuring Cacti

Cacti is a comprehensive monitoring tool for network
equipment resource utilization. We can view utilization graphs of incoming and outgoing traffic on the ports of any networking equipment which supports SNMP ( any of the three versions).

In this post, I shall mention the steps involved in installing and getting Cacti run on a Debian based machine.


1. Prerequisite packages : Apache, Mysql, PHP, Basically if the LAMP package is installed it would suffice. Installing LAMP is very straightforward using tasksel. Run the command and select the LAMP server option as shown


root@fossphosis:~# tasksel 





2. Package dependecies to install Cacti: cacti, cacti-cacid, spine, rrdtool
The dependecies are taken care of by APT. So, just type in apt command as shown.

3. While the packages are being installed, certain essential configurations have to be performed.
 i) Configuring the MYSQL database entry for Cacti. This can be performed using dbconfig. To do this select the option as shown

 ii) Enter the adminsitrative password for MYSQL and also for the user 'cacti'


 iii)Select the webserver for running Cacti. Choose Apache2

4. If things have gone fine, without any errors,  check the following URL to reach the Cacti Screen

http://localhost/cacti
Congrats :)

5. Now, that we have installed Cacti, some simple basic configurations have to be performed




Finally, click on graphs to see if Cacti is working fine. 
After about 30 minutes the resource utilization of the local host can be observed