Thursday, December 30, 2010

Mantis Part 2

I can't leave well alone... Having another go at Mantis. Have followed the instructions here and installed phpmyadmin:
    sudo apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server
    sudo apt-get install phpmyadmin
During the install of phpmyadmin, it will do some config work. Select apache as the web server and answer yes when it offers to setup the database. I supplied 'root' and 'password' when prompted for credentials :-o. Also, I had to set the permissions on the mantis directory otherwise the browser returned a 403 message:
    sudo chmod 755 /var/www/mantis/

I could then navigate to http://localhost/mantis/admin/install.php and fill in the form and click the button. The resulting page requested that I add:

    $g_hostname = 'localhost';
    $g_db_type = 'mysql';
    $g_database_name = 'bugtracker';
    $g_db_username = 'root';
    $g_db_password = 'password';

to /var/www/mantis/config_inc.php as it could not do it itself, for some reason. Ahh - there was no such file as mantis ships with config_inc.php.sample. I added the code and renamed it and the install script was happy.


Clicking continue led me to the mantis login page. Using 'administrator' and 'password' as the credentials I was able to log in. So, up to this point I think I haven't actually needed phpmyadmin at all...


However, if I wanted to create a new user, a password is sent to the user's email address which they use to log in for the first time. As I don't know how to set up emailing, a shortcut would be to look at the mantis database via phpmyadmin and retrieve the password from the sent email. Sneaky eh?


I think I'm gonna call it a day on this little mantis project of mine. Kept me quiet for a bit...

Beware of tasksel!

One of the things I messed about with yesterday when doing the Mantis project was to use tasksel to install all necessary packages for a LAMP server:
    sudo tasksel install lamp-server

When eventually I gave up on the project (at about 2:30am this morning!) I reverted with:
    sudo tasksel remove lamp-server

I noticed something strange - the remove process took quite a long time and I noticed unexpected package names whizzing by on the tasksel dialogue. Anyway, when I came to boot up this morning I got a message about not being able to configure my display hardware or something. It looks like tasksel remove removed some things it shouldn't have alright.

I only had a low graphics console environment available, and could not connect to my wireless network. In short, I've spent the last couple of hours reinstalling Mint :-(

Setting up apache/mySql/PHP/Mantis

Fancied having a go at setting up the Mantis bug tracker on Mint. Here's what I did:


    sudo apt-get install apache2
    sudo apt-get install mysql
    sudo apt-get install libdbd-mysql (stopped browser d'loading php files instead of executing them)


Download Mantis
Download PHP
Unzip PHP
Run ./ configure --with-mysqli=mysqlnd in the php directory
- Had to install libxml2-dev due to error
make
make tests
sudo make install
...
...
...
...
I gave up :-( Too much hassle trying to get PHP and mySQL working together. Maybe another time...

Wednesday, December 29, 2010

Backup script using 7Zip, cron and NSLU2

Have written a script to zip and archive important folders on the NSLU2:
    sudo 7za u /media/nslu2/backup/backup /media/Pictures /media/Documents -mx9 -mmt -mhe -ppassword

This backs up my Pictures and Documents drives to a 7zip archive called backup in the backup folder on the NSLU2. The command 'u' means update the archive, which will check for what has updated rather than just archiving everything each time. The options are:
    -mx9 - maximum compression
    -mht - use multi-threading where there's more than one CPU. I think this is on by default anyway
    -mhe - encrypt the file headers. I think this relies on the next option:
    -ppassword - supplies the password 'password'. Not sure whether it does any encryption with this or it's just to restrict access

I've put this in my crontab:
    0 3 * * 7 sudo 7za u /media/nslu2/backup/backup /media/Pictures /media/Documents -mx9 -mmt -mhe -ppassword
It'll run at 3am every Sunday.

Sunday, December 19, 2010

Setting up the NSLU2 on Linux Mint

Create a mount point:
    mkdir /media/nslu2

Mount the share you set up on the NSLU2 (assumes the default NSLU2 IP address):
    sudo mount -t smbfs "//192.168.1.77/DISK 1/music" /media/nslu2 -o "workgroup=Home,username=barry"

Copy your files over, using -r to copy folders:
    sudo cp -r "/home/barry/Desktop/Abba greatest hits"/ .
;-)

I'll put the mount line in fstab and it should mount at boot up. - Update - this is a bit trickier than I'd hoped. I've had to escape the space in the share name (which I can't get rid of as far as I can see - dictated by NSLU2) with \040:
    //192.168.1.77/DISK\0401/music/ /media/nslu2 smbfs "workgroup=Home,username=admin,password=password,auto,user" 0 0

This means I could lose the "", which were also causing a problem.

After testing - by jove it works! Was a bit worried as of course my wireless connection on the laptop is not fully set up when fstab is processed during boot up, but as soon as I was connected up popped my samba share as a drive on the desktop.

Saturday, December 18, 2010

Tip for removing distributed directories in Linux

I needed to strip out the .svn folders from a project which was no longer version controlled. These appear in each folder of an svn hierarchy, so could be a lengthy job!

This did it in a second:
    find . -name .svn -exec rm -rf {} \;

Sunday, December 5, 2010

Developing with Android Devices on Linux, the complete solution!

To summarise some previous posts regarding the process for getting Android adb to see your device in Linux (Mint/Ubuntu) and tie the whole lot up in a nice convenient script:

1 - create /etc/udev/rules.d/51-android.rules and add
  SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
    This assumes you're using an HTC phone. For more vendor IDs, see here

2 - execute
  sudo udevadm control --reload-rules
     to load the new android rule

3 - create restart_adb.sh and add the following:
  #!/bin/bash
  # android_device_reset script
  sudo /usr/bin/android/android-sdk-linux_86/tools/adb kill-server
  sudo service udev stop
  sudo /usr/bin/android/android-sdk-linux_86/tools/adb start-server
  sudo /usr/bin/android/android-sdk-linux_86/tools/adb devices
  eclipse

    Change your SDK path accordingly. 'eclipse' starts eclipse(!) so is of course optional.

4 - make your script executable:
  chmod 744 restart_adb.sh

5 - Bob's your uncle. Double-click your script to start eclipse and run your app/tests on a device rather than the emulator

An extra step for 64bit environments is:
  apt-get install ia32-libs


Thanks to Marc Cooper (@auxbuss) for help with the script

Saturday, December 4, 2010

Auto mounting of drives in Linux

Here's a nice GUI tool for managing the mounting of drives in Linux:
    sudo apt-get install pysdm

Saves faffing about in /etc/fstab

Sudo PATH problem

I was having problems getting sudo to see my Android adb tool. My own path was set correctly but sudo reported command not found. Putting the following in my /bashrc solved it:
    alias sudo env PATH=$PATH

Thanks to http://stackoverflow.com/questions/257616/sudo-changes-path-why/257666#257666

Additionally, if you want to go full blown superuser, execute
    su -p
The '-p' preserves your PATH for use as superuser