Puppet On ArchLinux

Installation

Install via;

sudo pacman -S puppet

Configurate this machine into server mode.

Install new Virtual Machine

Install a new ubuntu14.04 using qemu, and install puppet in it.
Generate the configuration file for mirror.list of Ubuntu.

Finally use the vdi file in the Ubuntu.

Install puppet in Ubuntu14.04:
http://linuxconfig.org/puppet-installation-on-linux-ubuntu-14-04-trusty-tahr

Make Ubuntu use a fixed IP.

$ cat  /etc/network/interface
# s file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
	iface eth0 inet static
	address 10.0.0.88
	netmask 255.255.255.0
	gateway 10.0.0.1

And Copy the virtual disk, and change the UUID of the disk:

$ VBoxManage internalcommands sethduuid ./Ubuntu.vdi 
UUID changed to: d1xxxxxxxxxxxxxxxxxxxxxxxxxx

Be sure to change the ip address to 10.0.0.89.

Now we have 2 machines.

No password enter for ssh login:

$ cat ~/.ssh/id_rsa.pub| ssh Trusty@10.0.0.88 'cat>>~/.ssh/authorized_keys'
$ cat ~/.ssh/id_rsa.pub| ssh Trusty@10.0.0.89 'cat>>~/.ssh/authorized_keys'

Server and Client

Install Server side in 10.0.0.88:

sudo apt-get install puppetmaster

In 10.0.0.88, edit /etc/hosts:

10.0.0.89	client

While in 10.0.0.89, edit /etc/hosts:

10.0.0.88	puppet

In client(10.0.0.89), start the service of puppet:

$ sudo service puppet start
 * Starting puppet agent                                                                                
puppet not configured to start, please edit /etc/default/puppet to enable
                                                                                                 [ OK ]

In server(10.0.0.88), start the service of puppet master:
Add following lines in to /etc/puppet/puppet.conf:

dns_alt_names = puppet, master.local, puppet.terokarvinen.com

Then remove all of the generated ssl :

rm -rf /var/lib/puppet/ssl

Now restart the puppetmaster via:

# service puppetmaster restart 

Change the hostname of 10.0.0.88 to Ubuntu88, 10.0.0.89 to Ubuntu89, and then restart the computer.
Now change the Ubuntu88’s configuration Add following lines in 10.0.0.88(Server): In /etc/puppet/puppet.conf, [master] heading:

dns_alt_names = puppet, master.local, puppet.terokarvinen.com

On 10.0.0.89(Client), change the following line in /etc/default/puppet:

START=yes

Then in /etc/puppet/puppet.conf, add following:

[agent]
server = puppet

Restart the puppet service.

Now on server, use following command to list the cert and add signed cert.

Trusty@Ubuntu88:~$ sudo puppet cert --list
sudo: unable to resolve host Ubuntu88
Warning: Setting templatedir is deprecated. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/lib/ruby/vendor_ruby/puppet/settings.rb:1095:in `block in issue_deprecations')
  "ubuntu89" (SHA256) xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Trusty@Ubuntu88:~$ sudo puppet cert --sign ubuntu89
sudo: unable to resolve host Ubuntu88
Warning: Setting templatedir is deprecated. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/lib/ruby/vendor_ruby/puppet/settings.rb:1095:in `block in issue_deprecations')
Notice: Signed certificate request for ubuntu89
Notice: Removing file Puppet::SSL::CertificateRequest ubuntu89 at '/var/lib/puppet/ssl/ca/requests/ubuntu89.pem'

Create the Site Manifest and a Module

Go to /etc/puppet, run following command:

Trusty@Ubuntu88:/etc/puppet$ sudo mkdir -p manifests/ modules/helloworld/manifests

Edit following file:

Trusty@Ubuntu88:/etc/puppet$ cat manifests/site.pp 
include helloworld

Create the file:

Trusty@Ubuntu88:/etc/puppet$ sudo cat modules/helloworld/manifests/init.pp
class helloworld {
        file { '/tmp/helloFromMaster':
                content => "See you at http://terokarvinen.com/tag/puppet\n"
        }
}

And Now in client, restart the puppet service:

Trusty@Ubuntu89:~$ sudo service puppet restart
sudo: unable to resolve host Ubuntu89
[sudo] password for Trusty: 
no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory
 * Restarting puppet agent                                               [ OK ] 
Trusty@Ubuntu89:~$ cat /tmp/helloFromMaster 
See you at http://terokarvinen.com/tag/puppet

Now the basic configuration is OK.

7 Weeks 7 Databases Reading Digest

This chapter will introduct postgresql.

Installation in ArchLinux

Install it via:

# pacman -S postgresql

Then configure the initial configuration:

# su - postgres
[postgres]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'
# systemctl enable postgresql

Create the user:

[root@Arch_Container ~]# su - postgres
[postgres@Arch_Container ~]$ createuser --interactive
Enter name of role to add: root
Shall the new role be a superuser? (y/n) y
[postgres@Arch_Container ~]$ exit
logout

Now using a test command for verifying your postgresql runs OK:

# createdb myDatabaseName

Create the Database

Create a database named book:

# createdb book

Installing plugins cube into the database book.

[root@Arch_Container postgresql]# psql -d book
psql (9.3.5)
Type "help" for help.

book=# CREATE EXTENSION cube;  
CREATE EXTENSION
book=# \q
[root@Arch_Container postgresql]# psql book -c "SELECT '1'::cube;"
 cube 
------
 (1)
(1 row)

LXC ArchLinux Tutorial

Installation

Install lxc, bridge-utils, netctl from the official repository.

$ sudo pacman -S lxc bridge-utils netctl

For creating ArchLinux Container, install arch-install-scripts:

$ sudo pacman -S arch-install-scripts

Check Configurations:

$ lxc-checkconfig

Network Configuration

Since I use systemd for bridged network, so this step remains blank, the official Arch Wiki use netctl.

Creating Container Using Template

List all of the available templates:

$ ls /usr/share/lxc/templates 
lxc-alpine     lxc-centos    lxc-fedora        lxc-oracle  lxc-ubuntu-cloud
lxc-altlinux   lxc-cirros    lxc-gentoo        lxc-plamo
lxc-archlinux  lxc-debian    lxc-openmandriva  lxc-sshd
lxc-busybox    lxc-download  lxc-opensuse      lxc-ubuntu

Now using the template for creating the Linux Container:

$ sudo lxc-create -n Arch_Container -t /usr/share/lxc/templates/lxc-archlinux

If the container is created successfully, it will indicates that you could use it from now.

Start the Container

List the installed Containers:

$ sudo lxc-ls
Arch_Container  

Start the installed Container:

$ sudo lxc-start -n Arch_Container

The default username is root, and you will got a terminal window, now check the network configuration:

[root@Arch_Container ~]# ip link show dev eth0
5: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff

Simply use dhcpcd we could get the ip address currently, and surely we can see this network configuration is OK now.
Enable the automatically dhcpcd at startup

$ dhcpcd
$ systemctl enable dhcpcd.service

Now reboot you will notice the ip address has been configurated automatically.

Create Other Distributions

First you should install yum and debootstrap from AUR repository.

$ yaourt -S yum
$ yaourt -S debootstrap

Fedora

Install Fedora or CentOS will failed, I don’t know why.

Debian

Install rxync first via:

pacman -S rsync

Some packages failed to download, so won’t install.

After installed rsync, install debian container via:

sudo lxc-create -n Debian_Container -t /usr/share/lxc/templates/lxc-debian

Start the container via:

 sudo lxc-start -n Debian_Container

The default username/password are root, In Debian network is not configured.

Configure Network in rc.local

Following is the configuration of the vlan and whole network:
In rc.local, RHEL.

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

echo VLAN=yes > /etc/sysconfig/network 

/sbin/vconfig add eth1 10
/sbin/vconfig add eth1 11
/sbin/vconfig add eth1 12
/sbin/vconfig add eth1 13
/sbin/vconfig add eth1 30
/sbin/vconfig add eth1 40

/sbin/vconfig add eth1 100
/sbin/vconfig add eth1 110
/sbin/vconfig add eth1 120
/sbin/vconfig add eth1 130
/sbin/vconfig add eth1 200

/sbin/ifconfig eth1.10 172.10.1.55 netmask 255.255.0.0 up
/sbin/ifconfig eth1.10:11 172.10.11.55 netmask 255.255.0.0 up
/sbin/ifconfig eth1.11 172.11.1.55 netmask 255.255.0.0 up
/sbin/ifconfig eth1.12 172.12.1.55 netmask 255.255.0.0 up
/sbin/ifconfig eth1.13 172.13.1.55 netmask 255.255.0.0 up
/sbin/ifconfig eth1.30 172.30.1.55 netmask 255.255.0.0 up
/sbin/ifconfig eth1.30:11 172.30.11.55 netmask 255.255.0.0 up
/sbin/ifconfig eth1.40 172.40.1.55 netmask 255.255.0.0 up

/sbin/ifconfig eth1.100 20.100.1.55 netmask 255.255.0.0 up
/sbin/ifconfig eth1.110 20.110.1.55 netmask 255.255.0.0 up
/sbin/ifconfig eth1.120 20.120.1.55 netmask 255.255.0.0 up
/sbin/ifconfig eth1.130 20.130.1.55 netmask 255.255.0.0 up

/sbin/ifconfig eth1.10 inet6 add fd00::410:172:10:1:88/64
/sbin/ifconfig eth1.10 inet6 add fd00::410:172:10:11:88/64
/sbin/ifconfig eth1.11 inet6 add fd00::411:172:11:1:88/64
/sbin/ifconfig eth1.12 inet6 add fd00::412:172:12:1:88/64
/sbin/ifconfig eth1.13 inet6 add fd00::413:172:13:1:88/64
/sbin/ifconfig eth1.30 inet6 add fd00::430:172:30:1:88/64
/sbin/ifconfig eth1.30 inet6 add fd00::430:172:30:11:88/64
/sbin/ifconfig eth1.40 inet6 add fd00::440:172:40:1:88/64

route add -net 224.0.0.0 netmask 224.0.0.0 dev eth1.40
/sbin/route add default gw 10.9.134.1 dev eth1

echo 1 > /proc/sys/net/ipv4/ip_forward

echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
echo 1 > /proc/sys/net/ipv6/conf/all/mc_forwarding

modprobe sctp

#/etc/init.d/xinetd restart
#/usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid
#echo "nameserver 10.9.133.243" >> /etc/resolv.conf
# Activate eth0 again. 
/sbin/ifconfig eth0 1xx.xx.xxx.xxx netmask 255.255.255.0 up
/sbin/route add default gw 1xx.xx.xxx.1 dev eth0

For eth0 will lose configuration, so we add the eth0 again.

Moving System on 1T Harddisk(2)

Tips

Here are some tips for customize the existing system.
1. Add octopress directory to heroku repository.
Install heroku client tools:

$ yaourt -S heroku-client
$ heroku keys:add
Found existing public key: /home/Trusty/.ssh/id_rsa.pub
Uploading SSH public key /home/Trusty/.ssh/id_rsa.pub... done

Now in the copied octopress directory we could use git push command for pushing our website onto herokuapp.

2. MTP Device

sudo pacman -S libmtp


3. libvirt

sudo pacman -S libvirt

4. virtualbox-ext-oracle
By installing this you can use USB2.0.

yaourt -S virtualbox-ext-oracle

Download Virtualbox Guest ISO.
Set Proxy in virtualbox global.

add user “Trusty” to “vboxusers”:

$ gpasswd -a Trusty vboxusers
$ usermod -a -G vboxusers Trusty

Now the virtualbox could use usb. And be sure to run following at suitable place:

$ modprobe vboxdrv vboxnetflt vboxnetadp
$ modprobe vboxnetflt
$ modprobe vboxnetadp

4. Lumia On ArchLinux
I don’t have good options, but connect it into virtualbox and use it.
Install the corresponding driver. and browser your phone content in Windows 7.

5. lampp adjustment
Since the public directory is not available in my system, so I have to change the default directory from the octopress public to /opt/public.
Then, in Rakefile, add this line:

#######################
# Working with Jekyll #
#######################

desc "Generate jekyll site"
task :generate do
  raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
  puts "## Generating Site with Jekyll"
  system "compass compile --css-dir #{source_dir}/stylesheets"
  system "jekyll"
  # Copy the content to the public directory
  system "sudo cp -r /home/Trusty/code/octo/heroku/Tomcat/public /opt"
end

6. gedit

sudo pacman -S gedit 

7. Remmina
I use remmina for connecting to my own Surface pro, because it will automatically “shrink” my Desktop for the right resolution. Install it via:

sudo pacman -S remmina

For Surface pro, because it has resolution as 1920x1080,so use toggle mode could get better effects.

8. aurget
This is a simple client for aur repository packages, install via yaourt

yaourt -S aurget

9. acpi
Using acpi for viewing the battery status:

sudo pacman -S acpi

10. Recordmydesktop
For recording specified screen and output to ogv or other format:

sudo pacman -S gtk-recordmydesktop recordmydesktop

11. Rss Reader
I installed liferea for view RSS.

sudo pacman -S liferea

12. Rstudio
RStudio is used for generate pdf from md(markdown) file.

sudo yaourt -S rstudio

13. pdflatex
Need it for compiling pdf out:

yaourt -S pdflatex.sh

14. you-get-git
For downloading videos from youtube/CNTV, etc..

yaourt you-get-git

15. git under proxy
The detailed configuration steps should be changed via:

git config --global core.gitproxy /usr/bin/myproxy

16. pandoc
Install pandoc via yaourt:

yaourt pandoc

17. wkhtmltopdf
Install wkhtmltopdf via pacman:

sudo pacman -S wkhtmltopdf
wkhtmltopdf -s A4  -B 10 -T 10 ./Output/CV_Chinese.html ./Output/CV_Chinese.pdf

-B Bottom Margin, -T Top Margin.

18. expect
For automatically login and doing processing.

sudo pacman -S expect

19. Minicom
Minicom is a serial port terminal tool for minitoring serial ports.

sudo pacman -S minicom

20. Multilib Support
Uncomment following 2 lines in /etc/pacman.conf:

[multilib]
Include = /etc/pacman.d/mirrorlist

30. lib32-glibc
For using 32-bit applications:

sudo pacman -S lib32-glibc

31. ghex
For viewing the binary file under Linux:

sudo pacman -S ghex

32. lib32-gtk2
Install this for compatable for CodeSourcery’s toolchain installation:

sudo pacman -S lib32-gtk2

33. lib32 others:
Install following packages for CodeSourcery:

sudo pacman -S xulrunner lib32-xcb-util lib32-gtk-engines lib32-ncurses

34. fbreader:
fbreader is for opening the epub files:

sudo pacman -S fbreader

35. Auto update the dkms:
For building the virtualbox modules:

 sudo systemctl enable dkms.service

36. Fakeroot
For building some embedded systems.

sudo pacman -S fakeroot

37. dosfstools
Install it for obtains mkfs.vfat:

sudo pacman -S dosfstools

38. tsocks
For acrossing the company firewall:

sudo pacman -S tsocks

Then edit the configuration file:

$ cat /etc/tsocks.conf 
server = 127.0.0.1
server_type = 5
server_port = 1394

You can run tsocks gnome-terminal for getting a totally free terminal.

39. For building Android
Install required packages:

$ sudo pacman -S gcc-multilib lib32-zlib lib32-ncurses lib32-readline

Notice this will remove the gcc and gcc-libs, for gcc-libs-multilib and gcc-multilib will be conficted with the origin installed gcc and gcc-lib version.

Use Sun/Oracle JDK for compiling:

$ set2383
$ yaourt jdk6-compat
$ export JAVA_HOMNE=/opt/java6

For using virtualenv2 you have to install:

$ sudo pacman -S python2-virtualenv
$ virtualenv2 venv
New python executable in venv/bin/python2
Also creating executable in venv/bin/python
Installing setuptools, pip...done.
$ ln -s /usr/lib/python2.7/* /media/y/embedded/Android/ubuntu/venv/python2.7/
$ repo sync
$ /bin/bash
$ source venv/bin/activate

Install make 3.81 for building:

$ sudo yaourt make 3.81
$ make-3.81 -j4

Lacking flex, install it via:

$ sudo pacman -S flex

Lacking gperf, install it via:

$ sudo pacman -S gperf

Install perl related(first configure as automatic, then install switch):

$ cpan App::cpanminus
$ cpanm Switch

Then install gcc44 from yaourt:

$ yaourt -S gcc44

Build with gcc44:

$ make-3.81 CC=gcc-4.4 CXX=g++-4.4 -j4

Met build error:

  error: aggregate ‘setrlimitsFromArray(ArrayObject*)::rlimit rlim’ has incomplete type and cannot be defined struct rlimit rlim; ^ 

Solution is simply to add #include <sys/resource.h> to dalvik/vm/native/dalvik_system_Zygote.cpp. When you met compatible, install gcc44-multilib:

yaourt -S gcc44-multilib 

39. pavucontrol
pavucontrol is A GTK volume control for PulseAudio, install it for redirecting the sound into the bluetooth device.

$ sudo pacman -S pavucontrol

40. nfs
For embedded Linux development, we have to use nfs(Network FileSystem) so we install it via:

sudo pacman -S nfs-utils

To be configured, because the parameters is complicated.

41. xclip
For using clipboard under X, we have to install this tool.

sudo pacman -S xclip

42. avidemux
For modify the videos under Linux:

sudo pacman -S avidemux avidemux-gtk

It couldn’t handle ogv format.

43. pitivi
Editor for audio/video projects using the GStreamer framework, we also add some plugins.

$ sudo pacman -S pitivi
$ sudo pacman -S gst-libav gst-plugins-bad gst-plugins-ugly frei0r-plugins

But pitivi won’t run on archlinux, for lacking the pycanberra, so I try the openshot.

44. openshot

$ sudo pacman -S openshot

45. Mencoder:
For converting video format:

$ sudo pacman -S mencoder
$ mencoder output.flv -o video_final.flv -ovc copy -oac copy -audiofile xxx.mp3
$ ffmpeg -i
50项护理技术_27胃肠减压技术_土豆_高清视频在线观看_112507230.h264_1.f4v -codec
copy weichangjianya.mp4

46. ffmpeg:
For converting video format:

$ sudo pacman -S ffmpeg
$ ffmpeg -i out.ogv -vcodec libx264 -strict -2  output.mp4 

47. p7zip
p7zip is the linux version 7zip:

$ sudo pacman -S p7zip

48. Acrobat Reader
Sometimes evince will crash when viewing some embedded picture pdf, we use Acrobat Reader for viewing such pdfs:

$ sudo pacman -S acroread

Notice, acroread package only includes in archlinuxfr, so firstly you should add archlinuxfr in your pacman.conf.

49. Konsole
Since the gnome-terminal will be not see input line when you enable the new tabs, I install konsole and use it as default terminal:

$ sudo pacman -S kdebase-konsole

Change the default run command to zsh -l, this will enable the “run as login shell”, then change the default shortcuts, also you should change the default fonts just like we used set in xfce4-terminal/gnome-terminal.
Default font changes:

$ cat ~/.kde4/share/apps/konsole/Shell.profile
[Appearance]
ColorScheme=DarkPastels
Font=YaHei Consolas Hybrid,13,-1,5,50,0,0,0,0,0

Now re-login your desktop environment(mine is awesome), you will found the font has been changed in the konsole terminal.
Alter the startup window of konsole, and don’t let it recovers to the last altered size:
/images/konsolesize.jpg

50. pip-shadowsocks First you should install pip via:

$ sudo pacman -S python-pip
$ sudo pacman -S python2-pip

Since shadownsocks only support python2, install python2 is the right way.

$ sudo pip2 install shadowsocks

51. DNSutils
For querying the dns.

sudo pacman -S dnsutils

Then you could use host/dig/nslookup, etc.

52. gdisk
For format into gpt format’s fdisk:

sudo pacman -S gdisk

53. pandoc-static
For generating beautiful pdf and other formats of documentations.

# yaourt -S pandoc-static --noconfirm

54. ShadowSocks
For crossing the GFW:

sudo pacman -S shadowsocks

55. mtools
For using mcopy, etc:

sudo pacman -S mtools

56. lzop
File compressor using lzo lib, for compiling some images:

$ sudo pacman -S lzop

57. vnstat
For monitoring the network traffic:

$ sudo pacman -S vnstat
$ sudo systemctl start vnstat.service
$ sudo systemctl enable vnstat.service
$ sudo vnstat -u -i enp0s25

Use following commands for querying the traffic statistics:

$ vnstat -q

58. htop
For viewing the system performance, comparing to top, its display will be more clearly.

$ sudo pacman -S htop

59. virtualbox-ext-oracle
For enable usb or other attached devices:

yaourt -S virtualbox-ext-oracle

60. lighthttpd
For replacing the heavy xampp, use it for serving the static website:

sudo pacman -S lighttpd

61. Synergy
For sharing the mouse and keyboard between different systems.

sudo pacman -S synergy qsynergy