sabato 9 marzo 2013
Pxe with Dnsmasq
For a much too long period of my life I have always manually changed the "pxelinux" entry in the "dnsmasq.d/domain.conf" file, to achieve the boot with this and with that image depending to the needed install distro
I just have finally found a way to serve each pxe images in one shot and even with a confortable menu list
That is accomplished adding something like:
Needless to say that you could even make point each pxe entry to a different tftp servers
sabato 17 novembre 2012
Python-stdeb
So, in your directory you list:
Create the stdeb configuration file stdeb.cfg
This file will write parameters in the soon generated DEBIAN/control file. A complete list of the parameters translation is here: http://pypi.python.org/pypi/stdeb#stdeb-cfg-configuration-file
Given that, build your package with:
NOTE: It will compile the package with mypylib-"version"; the version is the one written in setup.py (version="")
enjoy your deb_dist directory.
martedì 21 agosto 2012
Shorewall and Pptp VPN on Ubuntu
~# apt-get install shorewall linux-pptp
PPP
Let's create a ppp peer file:
~# vim /etc/ppp/peers/zmo
I ve successfully tried these options
# Zmo PPTP VPN configuration
remotename zmo
linkname zmo
ipparam zmo
pty "pptp 149.79.X.X --nolaunchpppd" (remote VPN endpoint)
name username
require-mppe-128
refuse-eap
noauth
lock
noauth
refuse-pap
refuse-eap
refuse-chap
refuse-mschap
nobsdcomp
nodeflate
persist
mtu 1400
mru 1400
Compile the chap-secret file
# Secrets for authentication using CHAP
# client server secret IP addresses
username zmo 2023n5t-w0re *
Network Interface
Fill the /etc/network/interfaces file. You can use the "unit x" parameter. This blessy option allows you to enumerate your ppp device (like ppp0, ppp1, ppp5 ..).
# Zmo Pptp VPN
auto ppp5
iface ppp5 inet ppp
provider zmo
unit 5
Try to get up the link, just giving
~# ifup ppp5
I raccomand to use this file (/etc/network/interfaces) even in the case you wanna add some route/net rules to your VPN device. Use the "post-up" options here.
# Zmo Pptp VPN
auto ppp5
iface ppp5 inet ppp
provider zmo
unit 5
post-up /sbin/route add 149.88.X.X gw 149.19.X.X
post-up /sbin/route add -net 150.84.X.X netmask 255.255.255.0 gw 150.84.X.X
Shorewall
Define a zone for the vpn on shorewall. I will define "zmo"
~# vim /etc/shorewall/interfaces
It should be looks like:
# For information about entries in this file, type "man shorewall-interfaces"
###############################################################################
#ZONE INTERFACE BROADCAST OPTIONS
wan eth0 detect tcpflags,nosmurfs,routefilter,logmartians,dhcp
dmz eth1 detect tcpflags,nosmurfs,routefilter,logmartians,dhcp
lan eth2 detect tcpflags,nosmurfs,routefilter,logmartians,dhcp
# VPN pptp
zmo ppp5 detect tcpflags,nosmurfs,routefilter,logmartians
Allow the vpn to be reached just by the lan
~# vim /etc/shorewall/policy
...
# Zmo Pptp VPN
lan zmo ACCEPT
all zmo REJECT
...
Masquerade the VPN traffic from that interface:
~# vim /etc/shorewall/masq
# For information about entries in this file, type "man shorewall-masq"
##############################################################################
#INTERFACE SOURCE ADDRESS PROTO PORT(S) IPSEC MARK
ppp5 - -
NOTE: an IP wont be needed here; shorewall will be masquerade the traffic with the interface IP address. Then we just can put a "-" in SOURCE/ADDRESS fields. The IP address would be needed if you would masquerade the traffic with a different IP address.
In the end, compile the "tunnels" shorewall file. You can retrieve a tunnels template file from the doc
~# cp /usr/share/doc/shorewall/default-config/tunnels /etc/shorewall
It should be looks like:
###############################################################################
#TYPE ZONE GATEWAY GATEWAY
# ZONE
pptpclient zmo 0.0.0.0/0
lunedì 25 giugno 2012
Convert HG to Git repository
On Ubuntu:
~# ls
repository.hg
~# apt-get install hg-fast-export
~# git init new_repository.git
~# ls
repository.hg new_repository.git
~# cd new_repository.git
~/new_repository.git# hg-fast-export -r ../repository.hg
You will recieve a summary text in the end, like
git-fast-import statistics:
---------------------------------------------------------------------
Alloc'd objects: 5000
Total objects: 478 ( 14 duplicates )
blobs : 133 ( 14 duplicates 54 deltas of 133 attempts)
trees : 216 ( 0 duplicates 194 deltas of 196 attempts)
commits: 129 ( 0 duplicates 0 deltas of 0 attempts)
tags : 0 ( 0 duplicates 0 deltas of 0 attempts)
Total branches: 4 ( 1 loads )
marks: 1024 ( 129 unique )
atoms: 16
Memory total: 2344 KiB
pools: 2110 KiB
objects: 234 KiB
---------------------------------------------------------------------
pack_report: getpagesize() = 4096
pack_report: core.packedGitWindowSize = 1073741824
pack_report: core.packedGitLimit = 8589934592
pack_report: pack_used_ctr = 901
pack_report: pack_mmap_calls = 215
pack_report: pack_open_windows = 1 / 1
pack_report: pack_mapped = 331971 / 331971
---------------------------------------------------------------------
In the end do:
~/new_repository.git# git checkout HEAD
Test your repo with git log.
giovedì 14 giugno 2012
Migrate PhpBB3 on Ubuntu server
Backend: Mysql
Mode: Fcgi
Dump the database
ubuntu~# mysqldump -u root -p phpbb3 > /tmp/phpbb3.sql
On the new machine
new~# apt-get update && apt-get install phpbb3
During the installation, choose to configure mysql/phpbb3 via debconf and answer about passwords in this order
* Mysql root password
* Phpbb3 database password
* Phpbb3 admin interface password
Afterwords, setup the web server. You have a configuration example in /etc/phpbb3/apache2.conf; you can directly copy this file in your /etc/apache2/sites-available directory and run
new:/etc/phpbb3# cp apache2.conf /etc/apache2/sites-available/phpbb3
new:/etc/phpbb3# cd /etc/apache2/sites-available/
new:/etc/apache2/sites-available# a2ensite phpbb3 && service apache2 reload
Try to login and surf the admin interface (APC). If you had a custom theme in the previous server, do the follow:
ubuntu~# scp -r /srv/phpbb3/theme/ (or wherever it is) new:/usr/share/phpbb3/styles
Important , make a sym link in /etc/phpbb3/styles directory to make phpbb see the custom theme
new~# cd /etc/phpbb3/styles
new:/etc/phpbb3/styles# ln -s /usr/share/phpbb3/styles/theme theme
Once the link is ok, configure the new theme in the APC (administrative panel)
If everything seems to be fine, move on and restore the database
new~# mysql -u root -p phpbb3 < phpbb3.sql
Configure FCGI
new~# apt-get install php5-cgi
new~# cd /etc/apache2/
new:/etc/apache2/# a2dismod php5
new:/etc/apache2/# service apache2 restart
Setup fcgi environment
new~# cd /srv (or wherever you'll locate it)
new:/srv# mkdir php-fcgi
new:/srv# cd (alt+.)
new:/srv/php-fcgi# ls
phpbb.fcgi
phpbbrc -> /etc/php5/cgi/
phpbb.fcgi
#!/bin/sh
PHP_FCGI_MAX_REQUESTS=10000
PHP_FCGI_CHILDREN=0
export PHPRC=/srv/php-fcgi/php53rc
export PHP_FCGI_MAX_REQUESTS PHP_FCGI_CHILDREN
# Replace with the path to your FastCGI-enabled PHP executable
exec /usr/bin/php-cgi
NOTE: phpbbrc is a link to /etc/php5/cgi/ directory
The virtualhost section should be something like
<VirtualHost *:80>
ServerName forum.example.org
DocumentRoot /usr/share/phpbb3/www
ErrorLog /var/log/apache2/forum_error.log
CustomLog /var/log/apache2/forum_access.log combined
Alias / /usr/share/phpbb3/www/
<Directory>
Order allow,deny
Allow from all
Options +ExecCGI
AddHandler fcgid-script .php
FcgidWrapper /srv/php-fcgi/phpbb.fcgi .php
</Directory>
</VirtualHost>
Try to load a forum page and check with
new~# ps ax | grep cg[i]
2248 ? S 0:00 /usr/bin/php-cgi
that php-cgi is running ..