pátek 4. dubna 2014

Centos autofs - automatic mount of samba share

A very useful feature.

yum install autofs

vim /etc/auto.master
the only active (uncommented line) should be:
/mnt/auto /etc/auto.samba --timeout=600 --ghost

create new file:
vim /etc/auto.samba
ID -fstype=cifs,username=USR,password=PSW,uid=NAME,gid=users ://server.xy/share

target mount will be:
/mnt/auto/ID

non-standard SSL port for apache (on CentOs) and owncloud

The procedure is not limited to owncloud installation, of course.

Install SElinux tools:

# yum install setools-gui setroubleshoot checkpolicy

check available (i.e. already allowed) http port

# semanage port -l | grep http

http_port_t          tcp   80, 81, 443, 488, 8008, 8009, 8443, 9000

For custom ports, see RedHat docs. In short, the  correct command for port 12345 is

# semanage port -a -t http_port_t -p tcp 12345

then change port in conf.d/ssl.conf, or add a "virtual host: for owncoud:

vim /etc/httpd/conf.d/owncloud.conf:
 <Directory /var/www/html/owncloud>
  AllowOverride All
</Directory>

Listen 12345
and include the Virtual host part from the ssl.conf
<VirtualHost *:12345>
DocumentRoot "/var/www/html/owncloud"

ErrorLog logs/ssl_oc_error_log
TransferLog logs/ssl_oc_access_log
LogLevel warn

SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
SSLCertificateFile /etc/pki/tls/certs/ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
CustomLog logs/ssl_oc_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>              

pátek 21. února 2014

migrace "spisovky" mezi pocitaci

1. dostatecne vybaveny server:  php moduly...
Oficialni pozadavky:


2. kopie adresare na druhy stroj
[root@novy ~]# cd /srv/www/htdocs/
rsync -avP -e ssh stary:/srv/www/htdocs/spisovka33 .
chown -R apache. spisovka33/client spisovka33/log # writable adresare
ln -s spisovka33 spisovka

3a. kopie databaze - komplet
stroj1:
root@stary:/home/user/spisovka> mysqldump -p --all-databases > db_backup.sql

stroj2:
[root@novy ~]# scp -C user@stary:spisovka/db_backup.sql .
[root@novy ~]# mysql <db_backup.sql 
[root@novy ~]# mysql
mysql> use spisovka33 ;
mysql> flush privileges;
mysql> GRANT ALL PRIVILEGES ON spisovka33.* TO 'spisovka'@'localhost' ;
mysql>\q

3b. kopie pouze databaze spisovky
stroj1:
root@stary:/home/user/spisovka> mysqldump -u spisovka -p spisovka33 > db_backup.sql

stroj2:
[root@novy ~]# scp -C user@stary:spisovka/db_backup.sql .
[root@novy ~]# mysql
mysql> create database spisovka33 ;
mysql> use spisovka33 ;
mysql> flush privileges;
mysql> CREATE USER 'spisovka'@'localhost' IDENTIFIED BY 'XXXXXXX';
mysql> GRANT ALL PRIVILEGES ON spisovka33.* TO 'spisovka'@'localhost' ;
mysql>\q
[root@novy ~]# mysql -u spisovka -p spisovka33 <db_backup.sql  

sobota 8. února 2014

ssh tunnel over NAT or firewall (chained ssh)

Your target server is running e.g. vncserver on port 5904. Your gateway has a free port 6111. Your client has a free port 333

client:~> ssh -A -t  user1@gateway -L 3333:localhost:6111 \
ssh -A user2@target -L 6111:localhost:5904


Then:

client:~> vncviewer ::3333

pondělí 3. února 2014

Reset image orientation and other EXIF tricks

Different image viewers/editors use different EXIF tags to set image rotation, so the best way is to avoid use any of them. IMHO physical rotation (preferably lossless) is the best solution. So, how to get rid of any rotation for all x-thousand holiday photos?

I have found two suspicious exif tags: Orientation and Rotation. Wipe them off from my pictures

exiftool  -Orientation=  -Rotation= -overwrite_original_in_place .

(the final dot stands for the current directory)
Or:

for i in *JPG ; do
   exiftool  -Orientation=  -Rotation= -overwrite_original_in_place "$i"
done

---------------
To delete the relatively large preview image (created by the Lumix camera for its own display) try:
exiftool -P -overwrite_original -PreviewImage=  -trailer:all= *jpg

---------------
Copy all tags from other files (original files)

for i in * ; do 
    exiftool -tagsfromfile src/$i -iptc:all -codedcharacterset=utf8 \
             -overwrite_original $i ; 
done



středa 29. ledna 2014

CentOS based ownCloud

ownCloud seems to be a promising piece of sw, it allows to run your own cloud-like repository. 

Installation:
1. apache web server and some additional modules
yum install php-pear


2. ssl for apache - see the official guide. Remember to specify the  "Common Name" in the self-signed certificate.  Enter your official domain name here or, if you don't have one yet, your site's IP address. Incorrectly set up SSL certificate makes big troubles.

3. install the ownCloud server using repository and yum (using "packages"). It installs all dependencies, in opposite to the web install and tar install.
It is necessary to have the epel repository availabe and active.

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6-8.noarch.rpm

cd /etc/yum.repos.d/
wget http://download.opensuse.org/repositories/isv:ownCloud:community/CentOS_CentOS-6/isv:ownCloud:community.repo
yum install owncloud

4. correct the paths in /etc/httpd/conf.d/owncloud.conf a /etc/httpd/conf.d/ssl.conf

Client: linux client requires https: connection and correct SSL certificate

Update:

Create database:
create database owncloud;
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
grant all privileges on owncloud.* to 'user'@'localhost' ;
FLUSH PRIVILEGES;


Update:

Move owncloud installation from the default place:
mount /dev/BIGdevice /srv
service httpd stop
cp -a --preserve=context owncloud /srv
chcon -Rv --type=httpd_sys_content_t /srv/owncloud



edit configs:
change DocumentRoot in /etc/httpd/conf.d/owncloud.conf
DocumentRoot "/srv/owncloud"

change 'datadirectory' in /srv/owncloud/config/config.php
'datadirectory' = '/srv/owncloud/data'

service httpd start

From the README.SELinux:
# semanage fcontext -a -t httpd_sys_rw_content_t '/srv/owncloud/data'
# restorecon '/srv/owncloud/data'
# semanage fcontext -a -t httpd_sys_rw_content_t '/srv/owncloud/config'
# restorecon '/srv/owncloud/config'



Update 2014-10-01:
If you see error: Your data directory and your files are probably accessible from the internet. The .htaccess file is not working. We strongly suggest that you configure your webserver in a way that the data directory is no longer accessible or you move the data directory outside the webserver document root. , add following to the httpd.conf
 
<Directory "/var/www/html/owncloud/">
      AllowOverride all
</Directory>

pondělí 9. prosince 2013

Převod TeX do Wordu

Použij PANDOC
pandoc -f latex -s tmp1.tex -o word.docx

Z rovnic texového souboru je potřeba odstranit definovaná makra a některé méně standardní klíčova slova (aligned a pod). Pokud se některá rovnice nepřelozí, je v ní něco, co překladač nezná. Nebo syntaktická chyba.
Nejlépe odstranit celou preambuli a formátování pak ve Wordu udělat nanovo.

Obráceně to nefunguje.