Monday 26 January 2015

Install Subversion server with web access on Ubuntu 14.04

http://www.krizna.com/ubuntu/setup-svn-server-on-ubuntu-14-04/

1. Create a VMBox based on ubuntu14.04 image trusty64 on the real server
$ vagrant init trusty64  
$ nano VagrantFile   // enable a public_network and change memory 1024
$ vagrant up
$ vagrant ssh   // change the hostname, change to static ip and nameserver
$ sudo nano /etc/network/interface
auto eth1
inet iface eth1 static
address x.x.x.70
netmask 255.255.255.0
network x.x.x.0
gateway x.x.x.1
$ sudo nano /etc/resolvconf/resolve.conf/tail
nameserver x.x.0.252

2. update and install necessary packages
$ sudo apt-get update

// install SVN and apache webserver (To access SVN through http ) 
$ sudo apt-get install subversion apache2 libapache2-svn apache2-utils

3. setup the svn configuration

// create a directory and create a new repository in that directory
$ sudo mkdir -p /svn/repos/
$ sudo svnadmin create /svn/repos/testrepo

// change ownership for the repository.
$ sudo chown -R www-data:www-data /svn/repos/testrepo

// Create a file testrepo.conf in /etc/apache2/sites-available/
// and add the below lines for creating apache virtual host.
$ sudo nano /etc/apache2/site-available/testrepo.conf

  DAV svn
  SVNParentPath /svn/repos/
  AuthType Basic
  AuthName "Test Repo"
  AuthUserFile /etc/svnpasswd
  Require valid-user


// enable the site and restart or reload apache service.
$ sudo a2ensite testrepo
$ sudo service apache2 reload

// create user for accessing repository and add the user details to /etc/svnpasswd file.
$ sudo htpasswd -cm /etc/svnpasswd user1

enter password for the user

// for other users
$ sudo htpasswd -cm /etc/svnpasswd user2

// access svn server through:
http://x.x.x.70/svn/testrepo

4. create sub-directoryon the repository
$ svn mkdir -m "Making a new dir." http://x.x.x.70/svn/testrepo/newdir

Sunday 25 January 2015

Install Gitlab server on Ubuntu

From
http://www.turnkeylinux.org/gitlab
http://fortysomethinggeek.blogspot.sg/2012/10/install-git-server-in-5-10-minutes.html

From
https://bitnami.com/stack/gitlab

1. First approach: Download the virtualBox image:

https://bitnami.com/redirect/to/48167/bitnami-gitlab-7.6.2-0-ubuntu-14.04.zip

Default application login information (Please change to avoid unauthorized access.)

The default login information for GitLab cloud images is:

Username
    user@example.com
Password
    bitnami1

System account:

Username
    bitnami


2. Second approach:install bitnami gitlab

2.1 download installer file here:
https://bitnami.com/stack/gitlab/installer

2.2 add the executed properties and run
$ chmod + x bitnami-gitlab-7.13 ... .run
$ sudo ./bitnami-gitlab-7.13 ... .run

Note: not using SMTP and email sending

2.3 disable add new user with email notification
$ sudo nano /opt/gitlabxxx/apps/gitlab/htdocs/config/gitlab.yaml

uncomment and set:

email_enabled: false

2.4 restart
$sudo /opt/gitlabxxx/ctlscript.sh restart

For auto start when computer boots:

$ sudo nano /etc/rc.local
$ add the command line above before ending line: "exit 0"

2.5 disable sign up new user

- go to login with registered admin user during installation
- go to [admin area]
- go to [setting]

disable [signup_enabled]

2.6 add new user

- from admin account, add new user without password
- go to [admin area] -> [users], select the user and add password

2.7 change password

- user login through web page
- go to [profile] --> password --> update new password


3. Uninstall

$ cd /opt/gitlab-xxxx
$ sudo ./uninstall

An uninstall window will appear.

Using Box.com in Ubuntu 14.04

The following instructions are taken from:
https://www.liberiangeek.net/2012/03/automatically-mount-box-cloud-storage-in-ubuntu-12-04-11-10/

TODO:

$ sudo apt-get install davfs2 

run the command below to reconfigure davfs2 so that regular users can mount storages

$ sudo dpkg-reconfigure davfs2 

run the command below to copy davfs2 folder to your home directory

$ sudo cp -r /etc/davfs2/ /home/elendh/.davfs2   

Then run the commands below to change the permissions so that you’re the owner

$ sudo chown -R elendh /home/elendh/.davfs2/ 
nano ~/.davfs2/secrets 

When the file opens, add the line shown below at the end and save.

https://www.box.com/dav

$ sudo nano /etc/fstab  

Then add the line shown below at the end and save the file.

https://www.box.com/dav/ /home/elendh/box davfs _netdev,rw,user 0 0


$ sudo adduser elendh davfs2 
$ mkdir ~/box 

Remember to replace all with your box account username, and with your box account password.
Restart and test

Saturday 24 January 2015

Run matlab on web browser by IPython notebook (on ubuntu 14.04)

To run Matlab commands in Ipython Notebook, we need install Python-matlab-bridge (see http://arokem.github.io/python-matlab-bridge/)

1. Install libzmq from zeromq (http://zeromq.org/intro:get-the-software)
- read : to build on Unix-like system
- download source code (zeromq-4.1.0-rc1.tar.gz)

$ sudo apt-get install libtool pkg-config build-essential autoconf automake
$ sudo apt-get install uuid-dev
$ tar xvfz zeromq-4.1.0-rc1.tar.gz ; cd zeromq-4.1.0-rc1
$ ./configure ; make
$ sudo make install
$ sudo ldconfig

check whether if libzmq.so.4 exists in /usr/local/lib . If found, then update the path in .bashrc

$ nano ~/.bashrc
add:  export LD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/lib

2. Install pyzmq

$ pip install pyzmq

It seems that this package had already been installed inside Anaconda

3. Install pymatbridge
- download arokem-python-matlab-bridge-0.3-67-g11751dd.tar.gz
from http://arokem.github.io/python-matlab-bridge/

$ tar xvfz arokem-python-matlab-bridge....tar.gz
$ cd arokem-python-matlab-bridge....
$ python setup.py install

4. Run demo as following: http://arokem.org/code/pymatbridge.html

Basically, from web browser (ipython notebook): https://ipaddress:8888
In [1]: import pymatbridge as pymat
In [2]: ip = get_ipython()
           pymat.load_ipython_extension(ip)

Install ipython notebook in Ubuntu 14.04

Notes:

1. Install python packages through Anaconda

1.1 Download Anaconda for Linux from the official website:
- http://continuum.io/downloads
- current version is: Anaconda-2.1.0-Linux-x86.sh

1.2 Go to the downloading location:
- $ chmod +x Anaconda-2.1.0-Linux-x86.sh
- $ ./Anaconda-2.1.0-Linux-x86.sh

After installing Anaconda, we have:
- core python (2.7), ipython, ipython notebook interactive IDE, spyder for programming IDE, numpy, scipy, matpolib, ...
- The path to Ananconda has been added to the bash environment .bashrc

2. Set up ipython notebook that it can run remotely

Following instructions are found in website:
http://nbviewer.ipython.org/github/melund/ipython/blob/master/examples/Notebook/Running%20the%20Notebook%20Server.ipynb

2.1 Before running everything, need to update openssl for anaconda
- $ conda update openssl

2.2 Create password for web server from ipython ide
- $ ipython
- In [1] from IPython.lib import passwd
- In [2] passwd() then enter password twice and save the hashed password (ex:
sha1:6c2164fc2b22:ed55ecf07fc0f985ab46561483c0e888e8964ae6' )

2.3 Create default profile ipython_notebook_config.py (which is not exist in ~/.ipython/profile_default/) 
- $ ipython create profile

It will create some default configuration files in the default folder

2.4 Create certificated key and file for accessing to secured ipython web server
- $ cd ~/.ipython/profile_default/
- $ openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.key -out mycert.crt


2.5 Update the configuration file 
- $ nano ipython_notebook_config.py

find and update the following places:


# The full path to an SSL/TLS certificate file.
c.NotebookApp.certfile = u'/home/elendh/.ipython/profile_default/mycert.crt'

# The full path to a private key file for usage with SSL/TLS.
c.NotebookApp.keyfile = u'/home/elendh/.ipython/profile_default/mycert.key'
 
c.NotebookApp.password = 
u'sha1:6c2164fc2b22:ed55ecf07fc0f985ab46561483c0e888e8964ae6' 
 

 
 Press Ctrl+O to write the update to file then Ctrl+X to exit

2.5 Run $ ipython notebook and check on the web browser by 

https://[ip_address_or_localhost]:8888

To auto start this service

$ which ipython

copy the path to ipython

$ sudo nano /etc/rc.local

 add the following line before "exit 0"

su -c "path_to_ipython notebook &"