понедельник, 5 ноября 2012 г.

vzlist

vzlist -o laverage,hostname,ctid


vztop.sh

#! /bin/bash
# Usage: ovzps <CTID> [ps flags ...]

ctid=${1:-0}
shift

ps $* -p $(grep -l "^envID:[[:space:]]*$ctid\$" /proc/[0-9]*/status |
    sed -e 's=/proc/\([0-9]*\)/.*=\1=')

воскресенье, 21 октября 2012 г.

Error SSH: Read from socket failed: Connection reset by peer

 Проблема в новом клиенте SSH (OpenSSH_5.8p1 Debian-7ubuntu1, OpenSSL 1.0.0e 6 Sep 2011)
при коннекте получаю:

Read from socket failed: Connection reset by peer


Ошибка чиниться добавлением параметра при подключении

ssh root@host -c aes256-ctr

или в /etc/ssh/ssh_config



Host *
   Ciphers 3des-cbc





или же

   Ciphers aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc

Источник: https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/708493

пятница, 11 мая 2012 г.

mysqlcheck

http://www.informit.com/articles/article.aspx?p=174365&seqNum=5

понедельник, 9 апреля 2012 г.

php disable_functions

disable_functions = "apache_child_terminate, apache_setenv, define_syslog_variables, escapeshellarg, escapeshellcmd, eval, exec, fp, fput, ftp_connect, ftp_exec, ftp_get, ftp_login, ftp_nb_fput, ftp_put, ftp_raw, ftp_rawlist, highlight_file, ini_alter, ini_get_all, ini_restore, inject_code, openlog, passthru, php_uname, phpAds_remoteInfo, phpAds_XmlRpc, phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, posix_setuid, posix_uname, proc_close, proc_get_status, proc_nice, proc_open, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode,mail"
or

disable_functions= "exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source "
for VirtualMin
#!/bin/bash
cd /home

for i in `ls`; do
   dir=/home/$i/etc/php5
   if [ -d $dir ]; then

        cd  $dir
        lsattr php.ini
        chattr -i php.ini
        sed -i.bak -e "s@\W*open_basedir\s*=.*@open_basedir = /home/$i@" \
        -e 's@\W*disable_functions\s*=.*@disable_functions = "apache_child_terminate, apache_setenv, define_syslog_variables, escapeshellarg, escapeshellcmd, eval, exec, fp, fput, ftp_connect, ftp_exec, ftp_get, ftp_login, ftp_nb_fput, ftp_put, ftp_raw, ftp_rawlist, highlight_file, ini_alter, ini_get_all, ini_restore, inject_code, openlog, passthru, php_uname, phpAds_remoteInfo, phpAds_XmlRpc, phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, posix_setuid, posix_uname, proc_close, proc_get_status, proc_nice, proc_open, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode,mail"@' php.ini
        chattr +i php.ini
   else
        echo $i empty           
   fi;
done

суббота, 31 марта 2012 г.

openmeetings over proxy

Relevant section of openmeetings virtual host:

 <VirtualHost *:80>
        ServerAdmin developer@xxxxxxxxxxxx
        ServerName openmeetings.mydomain.com

        ProxyPass / http://openmeetings.mydomain.com:5080/
        ProxyPassReverse / http://openmeetings.mydomain.com:5080/
 ...
 </VirtualHost>

 Relevant section of openmeetings-rtmpt virtual host:

 <VirtualHost *:80>
        ServerAdmin developer@xxxxxxxxxxxx
        ServerName rtmpt.mydomain.com

        ProxyPass /openmeetings http://openmeetings.mydomain.com:5080/openmeetings
        ProxyPassReverse /openmeetings http://openmeetings.mydomain.com:5080/openmeetings

        ProxyPass / http://openmeetings.mydomain.com:8088/
        ProxyPassReverse / http://openmeetings.mydomain.com:8088/
 ...
 </VirtualHost>

 OpenMeetings config:

 red5/webapps/openmeetings/config.xml:

 <rtmphostlocal>rtmpt.mydomain.com</rtmphostlocal>

 <rtmpTunnelport>80</rtmpTunnelport>

 <red5httpport>80</red5httpport>

 --

понедельник, 27 февраля 2012 г.

программы и скрипты для мониторинга здоровья системы

top
htop
atop
iotop
sysstat: sar iostat
vmstat
ps .....
netstat .....
lsof
fuser
smem
pmap
ps -e -O rss,user | awk '/php[^[]/{sum+=$2}END{print sum}'

Prestashop multishop

1) make soft link of image folder from main shop to new shop
ln -fs main_shop/img new_shop/img
2)Rename new_shop_db and main_shop_db to your names in sql procedure and run sql script
DELIMITER $$
DROP PROCEDURE if exists make_linked_tables $$

CREATE PROCEDURE make_linked_tables() 
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE str VARCHAR(250);
DECLARE cur CURSOR FOR 
 SELECT table_name FROM information_schema.tables WHERE 
table_schema = 'new_shop_db' AND (table_name LIKE 'ps_product%'
OR  table_name LIKE 'ps_category%') 
UNION
SELECT 'ps_image'
UNION
SELECT 'ps_image_lang'
;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN cur;
REPEAT
 FETCH cur INTO str;
 SET @s = CONCAT("RENAME TABLE ", str," TO ");
 SET @s = CONCAT(@s,str,"_orig");
 PREPARE sth FROM @s;
 EXECUTE sth;
 DEALLOCATE PREPARE sth;

 SET @s = CONCAT("CREATE VIEW ",str," as SELECT * FROM main_shop_db.",str);
 PREPARE sth2 FROM @s;
 EXECUTE sth2;
 DEALLOCATE PREPARE sth2;

UNTIL done END REPEAT;
CLOSE cur;
END$$
DELIMITER ;
3)Run procedure
CALL make_linked_tables();
DROP PROCEDURE if exists make_linked_tables; 
Manually customize categories list of new shop:
drop table if exists ps_category;
create OR replace view ps_category AS
SELECT * FROM MAIN_SHOP_DB.`ps_category` WHERE 
id_category in ( 1,17,28,35) OR id_parent in (17,28,35);

drop table if exists ps_category_group;
create OR replace view ps_category_group AS
SELECT * FROM MAIN_SHOP_DB.`ps_category_group` WHERE 
id_category in ( SELECT id_category FROM `ps_category` ) ;

drop table if exists ps_category_lang;
create OR replace view ps_category_lang AS
SELECT * FROM MAIN_SHOP_DB.`ps_category_lang` WHERE 
id_category in ( SELECT id_category FROM `ps_category`);

drop table if exists ps_category_product;
create OR replace view ps_category_product AS
SELECT * FROM MAIN_SHOP_DB.`ps_category_product` WHERE 
id_category in ( SELECT id_category FROM `ps_category`) ;

There are  id_category = 1 - main category(required), 17(subcategory optional)  .... 

среда, 25 января 2012 г.

custom php.ini для fastcgi

php5.fcgi  :

#!/bin/bash
PHPRC=$PWD/../etc/php5
#PHPINIDir=$PWD/../etc/php5
#PHP_INI_SCAN_DIR=$PWD/../etc/php5/conf.d
#export PHPINIDir
#export PHP_INI_SCAN_DIR

export PHPINIDIR=$PWD/../etc/php5
export PHP_INI_PATH=$PWD/../etc/php5

export PHPRC
umask 022
export PHP_FCGI_CHILDREN
SCRIPT_FILENAME=$PATH_TRANSLATED
export SCRIPT_FILENAME
exec /usr/bin/php5-cgi
или же в php.ini раскоментировать строчку
; Name for user-defined php.ini (.htaccess) files. Default is ".user.ini"
user_ini.filename = ".user.ini"
и в корневой вебдиректории можно создать файл .user.ini и писать в него конфигурацию php

bash Test

http://www.ibm.com/developerworks/library/l-bash-test/index.html

установка Gimp 2.7 на Ubuntu

Ура! в GIMP 2.7 появилась наконец-то опция всё в одном окне.
Устанавливаю по инструкции
http://www.gimpusers.com/tutorials/compiling-gimp-for-ubuntu

манипуляция строками в bash

a="aaa/bbbb.t"
# удалить с начала строки макс. вхождений
echo "${a##*/}"
# удалить с начала строки мин. вхождений
echo "${a#*/}"
# удалить с конца строки мин. вхождений
echo "${a%/}"
# удалить с конца строки макс. вхождений
echo "${a%%/}"
# замена первой найденой подстроки
echo "${a/a/_}"
# замена всех найденых подстрок
echo "${a//a/_}"


источник: http://tldp.org/LDP/abs/html/string-manipulation.html

Git INFO Common Commands

Configure Git client options:
# show config options
git config --list # show all
git config --global --list # show only global
git config --local --list # show only local

# --global option impacts options at a global level
# --local option impacts options at a local level (.git/config)

# set username/email associated with client
git config --global user.email "joe@example.com"
git config --global user.name "Joe Jaz"

# add color syntax highlighting
git config --global color.status auto
git config --global color.branch auto

# set default pager and editor
git config --global core.editor vim # or set the GIT_EDITOR environment variable
git config --global core.pager less # or set the GIT_PAGER environment variable

# display an option value
git config group.value
git config user.name

Start a new repository and import:
# In the root folder to add to version control:
git init
git init --bare  # creates a new repository (with no working copy)
git add . # add everything in directory to repo
git commit -m 'initial commit'

Making commits:
# commit specific files
git commit file1 file2 -m 'comment'

# commit all 'added' files
git commit -a -m 'comment'

# change a commit message
git commit --amend -m 'New Message'

Create new repository by cloning existing one:
git clone --bare . path_or_url_to_git_dir.git

Setting the remote repository (to push and pull from):
git remote add short_name path_or_url_to_git_dir.git
git remote add origin git://github.com/imagescape/iscape-authlog.git

Show remote branches:
git ls-remote orig
git remote show orig




Show remote repositories available:
git remote
git remote -v # show the url
git remote show origin  # show detail information about origin

Remove a remote repository: 
git remove repo_name

Rename a remote repository: 
git rename old_repo_name new_repo_name

Push and Pull from remote repository:
git push origin # push recent commits to remote repository called "origin"
git pull origin # pull updates from origin

Revert changes in working copy:
git clean -n
git clean --dry-run

Show file differences:
git diff   # show differences between working copy and any files staged for commit
git diff --staged   # compares staged changes with last commit
git diff --cached  # same as above for git older than 1.6.1

Show File/s History:
git log filename # Show single file versions

# Show number of lines changed in file/s
git log -stat filename # single file
git log -stat # multiple files

# show log summaries on one line
git log --pretty=oneline # Pre-defined format
git log --pretty=format:"%h - %cD (%an) %s" # custom format (see below)
git log --pretty=format:"%h %s" --graph

    Pre-Defined Pretty formats:
    oneline
    short
    medium
    full
    fuller
    email
    raw
    format:string # where string is
        Format Strings
        %H: commit hash
        %h: abbreviated commit hash
        %T: tree hash
        %t: abbreviated tree hash
        %P: parent hashes
        %p: abbreviated parent hashes
        %an: author name
        %aN: author name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
        %ae: author email
        %aE: author email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
        %ad: author date (format respects --date= option)
        %aD: author date, RFC2822 style
        %ar: author date, relative
        %at: author date, UNIX timestamp
        %ai: author date, ISO 8601 format
        %cn: committer name
        %cN: committer name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
        %ce: committer email
        %cE: committer email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
        %cd: committer date
        %cD: committer date, RFC2822 style
        %cr: committer date, relative
        %ct: committer date, UNIX timestamp
        %ci: committer date, ISO 8601 format
        %d: ref names, like the --decorate option of git-log(1)
        %e: encoding
        %s: subject
        %f: sanitized subject line, suitable for a filename
        %b: body
        %B: raw body (unwrapped subject and body)
        %N: commit notes
        %gD: reflog selector, e.g., refs/stash@{1}
        %gd: shortened reflog selector, e.g., stash@{1}
        %gs: reflog subject
        %Cred: switch color to red
        %Cgreen: switch color to green
        %Cblue: switch color to blue
        %Creset: reset color
        %C(…): color specification, as described in color.branch.* config option
        %m: left, right or boundary mark
        %n: newline
        %%: a raw %
        %x00: print a byte from a hex code
        %w([[,[,]]]): switch line wrapping, like the -w option of git-shortlog(1).

Show git branches available:
git branch

Show all branches including remote branches:
git branch -a

Create new branch:
git branch new_branch

Change branches:
git checkout new_branch

Delete branch:
git branch -D new_branch

Merge branch into current copy:
git merge branch_to_merge_in

Resolve a Merge:
1) Edit file to resolve
2) git add conflict_file
3) git commit

Undo a Merge:  # restores state to pre-merge
git reset --heard HEAD

~/.gitignore
[color]
 diff = auto
 status = auto
 branch = auto
[user]
 name = Joe Jaz
 email = joe@example.com
[alias]
 st = status
 stu = status -uno
 ci = commit
 co = checkout
 br = branch -v
 tree = log --graph --pretty=oneline --abbrev-commit --decorate
[core]
 editor = vim
 pager = less

воскресенье, 22 января 2012 г.

redmine эмайл увидомления с приложениями

Патч добавляющий в тело эмайла ссылки на приложения к задачи
http://pastebin.com/p0Esq3iP
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index ff434d8..0a7e69a 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -116,6 +116,11 @@ class Attachment < ActiveRecord::Base
   def deletable?(user=User.current)
     container.attachments_deletable?(user)
   end
+  
+  # my fix for email attachment
+  def to_s
+        self.filename
+  end
 
   def image?
     self.filename =~ /\.(jpe?g|gif|png)$/i
diff --git a/app/views/mailer/_issue_text_html.rhtml b/app/views/mailer/_issue_text_html.rhtml
index 3d851d4..06f0aec 100644
--- a/app/views/mailer/_issue_text_html.rhtml
+++ b/app/views/mailer/_issue_text_html.rhtml
@@ -7,6 +7,16 @@
 <li><%=l(:field_assigned_to)%>: <%=h issue.assigned_to %></li>
 <li><%=l(:field_category)%>: <%=h issue.category %></li>
 <li><%=l(:field_fixed_version)%>: <%=h issue.fixed_version %></li>
+<% if issue.attachments.size > 0 %>
+    <li>
+        <ul>
+           <%=l(:label_attachment)%>: 
+           <% issue.attachments.each do | c | %>
+               <li> <%= link_to(c.to_s(), "http://redmine.tnt.it-solutions.cz/attachments/"+ c.id.to_s() + "/" + c.to_s() ) %> </li>
+        <% end %>
+        </ul>
+    </li>
+<% end %>
 <% issue.custom_field_values.each do |c| %>
   <li><%=h c.custom_field.name %>: <%=h show_value(c) %></li>
 <% end %>
diff --git a/app/views/mailer/_issue_text_plain.rhtml b/app/views/mailer/_issue_text_plain.rhtml
index bea2a58..5e49b99 100644
--- a/app/views/mailer/_issue_text_plain.rhtml
+++ b/app/views/mailer/_issue_text_plain.rhtml
@@ -7,6 +7,7 @@
 <%=l(:field_assigned_to)%>: <%= issue.assigned_to %>
 <%=l(:field_category)%>: <%= issue.category %>
 <%=l(:field_fixed_version)%>: <%= issue.fixed_version %>
+<% if issue.attachments.size > 0 %><%=l(:label_attachment)%>: <%= issue.attachments.join(", ") %><% end %>
 <% issue.custom_field_values.each do |c| %><%= c.custom_field.name %>: <%= show_value(c) %>
 <% end %>

пятница, 20 января 2012 г.

perl oneliner

perl -n -e 'm/(?:[^\d.])((?:\d*)(?:(\.\d{0,2})?))(?:\s\&euro)/ && {print "$1\n"}'