Deploy Vagrant

Installation

Couldn’t install the vagrant via rubygems, so we directly download packages in vagrantup.com, rpm for OpenSuse.
https://www.vagrantup.com/downloads.html
https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2_x86_64.rpm
Install it via rpm -ivh xxxx.rpm.

Install GitLab And Gogs

For sharing the git managed codes, we need setup the online repositories, we got two options, one is for gitlab, the other is for gogs.

Gitlab

The reference URL is listed as in:
https://www.digitalocean.com/community/tutorials/how-to-set-up-gitlab-as-your-very-own-private-github-clone
But following the tutorial you will met the problem, following records the solution:

$ sudo -u git -H bundle install --deployment --without development test postgres
   Could not find modernizr-2.6.2 in any of the sources
$ cd /home/git/gitlab
$ wget http://rubygems.org/downloads/modernizr-2.6.2.gem
$ sudo gem install modernizr
$ vim Gemfile
gem "modernizr"    "2.6.2"   ===> gem "modernizr-rails",        "2.7.1"
$ vim Gemfile.lock
modernizr  (2.6.2)   ===>     modernizr-rails (2.7.1)
modernizr  (2.6.2)   ===>     modernizr-rails (= 2.7.1)
$ sudo -u git -H bundle install --deployment --without development test postgres 

Gogs

We use docker for installing Gogs, the command listed as following:

# sh -c "wget -qO- https://get.docker.io/gpg | apt-key add -"
# sh -c "echo deb http://get.docker.io/ubuntu docker main\
> /etc/apt/sources.list.d/docker.list"
# apt-get update
# apt-get install lxc-docker
# proxychains4 docker pull codeskyblue/docker-gogs

This pull back the docker-gogs image, later you could run the gogs server via:

$ mkdir /var/gogs
$ docker run -d -p 2223:22 -p 3000:3000 -v /var/gogs:/data codeskyblue/docker-gogs

Then visit http://1xx.xx.xx.xxx:3000 you will got the installation webpage, simply install it.
Everytime you run into error case, you could remove the /var/gogs directory and let everything happen from zero.

Using Gogs

Create Repository, then git clone, then add your own files, git add ., git commit -m, git push origin master, the same as you did in github.

Some problems happens…. We changed to OpenSuse for installing.
Remove all of the .git directory in sub-directories via following command, then problem won’t happen.

find ./* -name ".git" | xargs rm -rf

Now git push all of the changes to the remote repository and you got everything works well.
Add the running command into /etc/rc.local thus the docker runs together with the system startup.

Prison-Break For Something

I’ve worked two days on prison-break something, this will greatly improve my working efficiency. There are so many steps for recording, so I will detailed described them in following parts.

Single MOde

In Single Mode you could get an terminal with root then you could do anything you want, simply pass init=/bin/bash in Grub then you could do anything.
Question: why Unix-like system enable this command?
Answer: In Unix-like systems, init is the first process to be run, and the ultimate ancestor of all processes ever run. It’s responsible for running all the init scripts.
We could add sudo users, with sudo users, you could get more priviledges.

privoxy

This fantanstic software could let you setup your own proxy server, simply compile it and let it run under user root, after it starts up, a proxy which listens on 8118 will be available for using.

System Upgrade

!!!Notice!!!: Always keep at least 2 root loginned terminal alive, thus if any problem happens you could do debugging.
Since you have the privoxy for using proxy, you could do anything you want, you could upgrade system from default 11.3 to the latest 13.2. The reference URLs are listed as following:
Upgrade from 11.3 to 12.3:
https://zh.opensuse.org/SDB:%E7%B3%BB%E7%BB%9F%E5%8D%87%E7%BA%A7
Main tips:

$ sudo zypper addrepo --check --name 'openSUSE-11.3-Update' http://download.opensuse.org/update/11.3/repo-update
$ sudo zypper ref && zypper update
$ sudo reboot
.....
$ sudo zypper mr -da
$ sudo zypper ar -f http://download.openSUSE.org/distribution/12.3/repo/oss/ openSUSE:12.3:OSS
$ sudo zypper ar -f http://download.openSUSE.org/distribution/12.3/repo/non-oss/ openSUSE:12.3:NON-OSS
$ sudo zypper addlock liblzma0
$ sudo zypper dup --download "in-advance"
$ sudo shutdown -hP now                                                                                                                       

Upgrade from 11.3 to 12.3 won’t cause any problems, and on my machine the new system become available for using immediately.
Upgrade from 12.3 to 13.2:
https://en.opensuse.org/SDB:System_upgrade
Main tips:

$ sudo zypper addrepo --check --name 'openSUSE-12.3-Update' http://download.opensuse.org/update/12.3/repo-update
$ sudo zypper ref && zypper update
$ sudo reboot
.....
$ sudo zypper mr -da
$ sudo zypper ar -f http://download.openSUSE.org/distribution/13.2/repo/oss/ openSUSE:13.2:OSS
$ sudo zypper ar -f http://download.openSUSE.org/distribution/13.2/repo/non-oss/ openSUSE:13.2:NON-OSS
$ sudo zypper addlock liblzma0
$ sudo zypper dup --download "in-advance"
$ sudo shutdown -hP now

Trouble shooting:
1. When upgrading the system, zypper will halt(hang) at following packages:
zypper dup locks up Bug #802525. Workaround: make sure to keep a root shell open while zypper dup is running. Run “killall dbus-send” when zypper dup hangs at rtkit.
https://en.opensuse.org/openSUSE:Most_annoying_bugs_13.1_dev
2. tuned installation got stuck:

$ ps -ef | grep tuned
$ kill tunned
$ ps -ef | grep rpm 
$ kill greped_rpm_install

Route

References:
http://w.gdu.me/wiki/Linux/iptables_forward_internetshare.html
First in the middleware machine, add following rules in iptables:

# iptables -P FORWARD ALLOW
# iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
# iptables -t nat -A POSTROUTING -s 10.1.1.0/24 -j SNAT --to 60.1.1.1
# iptables -A FORWARD -s 10.1.1.9 -j ACCEPT

Now you could use this middle machine for acrossing something.
But, in your own machine, should use the following command for deleting the routes and add new routes:

# route del default gw xxx.xxx.xxx.xxx
# route add default gw xxx.xxx.xxx.xxx

There are also some complicated commands for holding the routes, but we could also edit the following files:

# pwd
/etc/sysconfig/network
linux:/etc/sysconfig/network # cat routes 
default xxx.xx.xxx.xxx - - 
any net xxx.xx.0.0 netmask 255.255.0.0 gw xxx.xxx.xxx.200

Now even if you reboot the machine, the default route and the exchange route will be also added into the system.

More Safer

Change the opensshd listenning port.
More and more.

Try OpenContrail In Ubuntu

To be write

Speed-Up the WP website in TianChao

Since our Great Fire Wall forbidden the google, thus all of the google related service becomes available in china, this leads to access to wordpress based website which uses google online fonts pretty slow. Following is how to speedup your website without too many changes:
First go to your website’s folder, find the files which calls fonts.googleapis.com:

$ grep -i "fonts.googleapis.com" ./ -r
./wp-content/themes/twentytwelve/functions.php:		$font_url = add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" );
./wp-content/themes/twentyfifteen/functions.php:		), '//fonts.googleapis.com/css' );
./wp-content/themes/twentyfourteen/functions.php:		$font_url = add_query_arg( 'family', urlencode( 'Lato:300,400,700,900,300italic,400italic,700italic' ), "//fonts.googleapis.com/css" );
./wp-content/themes/tdpersona/functions.php:	wp_enqueue_style( 'tdpersona-googlefonts', '//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700' );
./wp-content/themes/twentythirteen/functions.php:		$fonts_url = add_query_arg( $query_args, "//fonts.googleapis.com/css" );
./wp-includes/script-loader.php:		$open_sans_font_url = "//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets";
./wp-includes/js/tinymce/plugins/compat3x/css/dialog.css:@import url(//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=latin-ext,latin);


Replace all of the fonts.googleapis.com with fonts.useso.com, this could be done via scripts.
After modification, your website will be much more faster than before.