Category Archives: (K) Ubuntu

Ubuntu and Kubuntu

Ubuntu: Create own repository

mkdir -p /opt/repository/ubuntu/
mkdir -p /opt/repository/ubuntu/{conf,dists,incoming,indices,logs,pool,project,tmp}
cd /opt/repository/ubuntu/
vim conf/distributions

1
2
3
4
5
6
7
Origin: packages.localdomain                                                                                                                                      
Label: My Own Repository                                                                                                                                          
Codename: precise                                                                                                                                            
Architectures: amd64                                                                                                                                          
Components: main
Description: Allods Team repository
Version: 12.04

Codename should contain name of OS branch.

First initializing of repository:
Continue reading Ubuntu: Create own repository

Ubuntu: Create own deb package

I'll show you how to create own deb package using modified nginx
1) we download nginx sources
2) we download some external nginx modules
3) we run

1
2
3
4
5
6
7
./configure --with-cc-opt="-static -static-libgcc" --with-ld-opt="-Bstatic" --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid \
    --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
    --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx \
    --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed' \
    --add-module=./modules/naxsi/naxsi_src \
    --add-module=./modules/nginx-goodies-nginx-sticky-module-ng-bd312d586752 \
    --add-module=./modules/headers-more-nginx-module-0.25

4) make
after make we have out/nginx file so we could create own package using it

$ mkdir -p /opt/nginx/deb/nginx-ng
$ cd /opt/nginx/deb/nginx-ng
$ ls -1

1
2
3
4
DEBIAN
etc
usr
var

I downloaded original nginx deb and unpack it, after that I took DEBIAN, usr, var and etc folders from it
Continue reading Ubuntu: Create own deb package

Setup Ansible latest version

Download ansible from git:

1
2
3
cd /opt/
git clone https://github.com/ansible/ansible.git
cd ansible

Download all necessary modules:

1
2
3
4
git submodule update --init lib/ansible/modules/core
git submodule update --init lib/ansible/modules/extras
git submodule update --init v1/ansible/modules/core
git submodule update --init v1/ansible/modules/extras

add ansible's path to PATH (I use it from root):

1
2
echo 'export PATH=/opt/ansible/bin:$PATH' >> ~/.bashrc
echo 'export PYTHONPATH=/opt/ansible/lib' >> ~/.bashrc

reload .bashrc and after check ansible version command:

1
ansible --version

if you see that there is no some modules:

1
pip install <module name>

output should looks similar to:

1
2
3
4
5
6
7
ansible --version
ansible 2.0.0 (devel 2c9d1257ba) last updated 2015/07/06 12:42:09 (GMT +300)
  lib/ansible/modules/core: (detached HEAD ff69ce7912) last updated 2015/07/06 12:53:13 (GMT +300)
  lib/ansible/modules/extras: (detached HEAD 4e48ef9eca) last updated 2015/07/06 12:53:21 (GMT +300)
  v1/ansible/modules/core: (detached HEAD f8d8af17cd) last updated 2015/07/06 12:53:27 (GMT +300)
  v1/ansible/modules/extras: (detached HEAD 495ad450e5) last updated 2015/07/06 12:53:33 (GMT +300)
  configured module search path = /usr/share/ansible

restore admins permissions in windows 8.1

1) download latest ubuntu from ubuntu.com
2) dd if=ubuntu_image.iso of=/dev/usb_device bs=8M
3) boot from usb with ubuntu
4) open terminal
5) ntfsfix /dev/drive_with_windows
6) mount -t ntfs-3g -o remove_hiberfile /dev/drive_with_windows /mnt/hdd
7) cd /mnt/hdd/Windows/System32
8) cp sethc.exe sethc.exe.orig
9) cp cmd.exe sethc.exe
10) reboot to windows
11) in the login screen click «shift» button 5 times
12) in appeared console type «mmc»
13) add user
14) add user to administration group

You're welcome!

Nginx: sticky sessions

If you have several backends and your clients should get access to only one of them during their session, you need in sticky sessions.
In case of nginx you have 2 ways:
1) Buy nginx plus
2) Build nginx from source with sticky sessions module

In this article we'll how to for 2nd variant.

Download latest stable sources from http://nginx.org/ru/download.html
Download module from https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/overview
Unpack all.
Setup necessary packages for building from sources

1
apt-get install libpcre3-dev build-essential libssl-dev gcc

cd to folder with nginx sources:

1
./configure --with-http_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_gunzip_module --with-http_gzip_static_module --add-module=../nginx-goodies-nginx-sticky-module-ng-f2adff04b8e3

where .../nginx-goodies-nginx-sticky-module-ng-f2adff04b8e3 path to module

1
2
3
make -j6
sudo checkinstal
sudo dpkg -i /home/alter/nginx/nginx-1.6.2/nginx_1.6.2-1_amd64.deb

where /home/alter/nginx/nginx-1.6.2/nginx_1.6.2-1_amd64.deb — path to deb file checkinstall generated for you.
Nginx will be installed in /usr/local/nginx/
If you have configs from previous nginx in /etc/nginx, you could make symlink for configs:

1
rm /usr/local/nginx/config/nginx.conf && ln -sf /etc/nginx/nginx.conf /usr/local/nginx/config/nginx.conf

Your upstream section should looks like:

1
2
3
4
5
6
upstream backends {
    sticky; # this is necessary option.

    server web1.domain.net:80 fail_timeout=60 max_fails=10;
    server web2.domain.net:80 fail_timeout=60 max_fails=10;
}