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.

pátek 29. listopadu 2013

Ansys 5.7 license manager (windows based) on Linux

Our professional version of Ansys 5.7 has been bound to a license manager running on a windows NT server. Once mighty server rests in peace already, but our professional Ansys is worth to use. At least time to time.

Our license is based on serial number of hard disc, from which is the flexlm started. OK, wine emulator allows to specify the label and serial of its (virtual) disks.

Wine installation on CentOS 6.4 x86_64

Remark: use just zypper in wine on (open)SUSE. However, Ansys on CentOS is said to be "oficially supported". It does not apply to this case, I guess.
Wine is not part of the official repository tree. As a first step configure EPEL repository (thanks to this link ).
yum install wget
wget https://fedoraproject.org/static/0608B895.txt --no-check-certificate
mv 0608B895.txt /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
rpm -ivh http://mirror.slu.cz/epel/6/i386/epel-release-6-8.noarch.rpm

check success:
[root@localhost ~]# yum repolist
repo id     repo name                                         status
base        CentOS-6 - Base                                   6,381
epel        Extra Packages for Enterprise Linux 6 - x86_64    10,031
extras      CentOS-6 - Extras                                 13
updates     CentOS-6 - Updates                                1,555

install Wine:
[root@localhost ~]# yum install wine
Yum finds and installs a huge number of 32bit dependencies. 

License manager configuration

Run winecfg and specify Windows NT compatibility. In the Drives panel press Advanced options and specify the serial number of the disk C: (or use ~/.wine/drive_c/.windows-serial file containing the serial number)

copy flexlm directory to C: (.wine/drive_c)

┌┌<─ ~/.wine/drive_c/flexlm ───────────────────────────.[^]>┐
││'n               Name                │ Size  │Modify time │
││/..                                  │UP--DIR│Nov 29 01:19│
││/Intel                               │   4096│Apr 26  2004│
││ ansyslmd                            │      0│Nov 29 01:45│
││ ansyslmd.ini                        │     33│Apr 26  2004│
││ license.dat                         │    224│Nov 29 01:38│
││ license.log                         │   1351│Nov 29 01:45│
││ lmgrd.8                             │    144│Nov 29 01:45│
││ startup.log                         │    227│Nov 29 01:45│
││                                     │       │            │



startup.sh :
#!/bin/bash
cd ~/.wine/drive_c/flexlm
date >>startup.log
LOGF=license.log
mv -f $LOGF license.log-`date +"%F+%T"`
nohup wine Intel/lmgrd.exe -z >> $LOGF 2>>startup.log  &

Check the status (it takes some time to start up the server)
[root@plchova3 flexlm]# wine Intel/lmutil.exe lmdiag -c license.dat
lmutil - Copyright (C) 1989-2001 Globetrotter Software, Inc.
FLEXlm diagnostics on Fri 11/29/2013 11:06

-----------------------------------------------------
License file: license.dat
-----------------------------------------------------
"ansys" v2001.0630, vendor: ansyslmd
  License server: hostname
  floating license no expiration date


This license can be checked out
-----------------------------------------------------
or:
[root@plchova3 flexlm]# wine Intel/lmutil.exe lmstat -a -c license.dat

For shutdown:

[root@plchova3 flexlm]# wine Intel/lmutil.exe lmdown -c license.dat
lmutil - Copyright (C) 1989-2001 Globetrotter Software, Inc.
[Detecting lmgrd processes...]

   Port@Host            Vendors
1) 1057@hostname        ansyslmd 

Are you sure (y/n)?  y
    1 FLEXlm License Server shut down

Troubleshooting

  • check the drive serial number
    [root@localhost flexlm]# wine cmd
    
    CMD Version 1.4.1
    
    C:\flexlm>dir
    Volume in drive C has no label.
    Volume Serial Number is 70fa-1234
    
    Directory of C:\flexlm
    
    11/29/2013   1:45 AM  <dir>         .
    11/29/2013   1:19 AM  <dir>         ..
    11/29/2013   1:45 AM             0  ansyslmd
     4/26/2004   8:34 PM            33  ansyslmd.ini
     4/26/2004   8:23 PM  <dir>         Intel
    11/29/2013   1:38 AM           224  license.dat
    11/29/2013   2:05 AM         1,452  license.plchova.log
    11/29/2013   2:15 AM           144  lmgrd.8
    11/29/2013   1:45 AM           227  startup.log
           6 files                    2,080 bytes
           3 directories      7,727,013,888 bytes free
    

  • check the if hostname in the license.dat match the hostname, specify the same hostname in /etc/hosts
  • check the firewall settings. The two ports specified in the license file have to be opened fog incoming traffic
    SERVER hostname DISK_SERIAL_NUM=70fa1234 1057
    VENDOR ansyslmd PORT=1058
    
    INCREMENT ansys ansyslmd 2001.0630 permanent 1 3A8F12345678 \
     VENDOR_STRING=customer:00000001 SUPERSEDE ISSUED=24-May-2001 \
     START=03-Apr-2001
    
    
    The two ports are 1057 and 1058 in our case:
    iptables -A INPUT -m state -s $LAN --state NEW -m tcp -p tcp --dport 1057 -j ACCEPT
    iptables -A INPUT -m state -s $LAN --state NEW -m tcp -p tcp --dport 1058 -j ACCEPT
    
    or specify the corresponding rules in /etc/sysconfig/iptables (in CentOS).

pondělí 25. listopadu 2013

Ansys 5.7 on a recent linux workstation (openSUSE 12.3 x86_64 or CentOS6.5)

Some 15 years ago we have bought the professional version of ANSYS 5.7, from time to time somebody still uses it. Installation of such ancient sw is always challenging.


Prior the installation it is necessary to have uncompress installed; for openSUSE it is in gzip package, for CentOS use
yum install ncompress tcsh
The target environment is 64-bit openSUSE server. Installation script works in text mode (great!!) and works as expected. The license manager is running elsewhere, so  "Product only" installation has been performed. The license manager machine has to be included into the /ansys_inc/shared_files/licensing/ansyslmd.ini
SERVER=1057@flexlmserver.site
It seems, that the newer versions of ANSYS (v12.5, v14.0, v14.5) which are already installed in the tree /ansys_inc/ are untouched a working.

Let's try to start:
/ansys_inc/ansys57/bin/xansys57
Executing /ansys_inc/ansys57/bin/linuxia32/xans.e57
/ansys_inc/ansys57/bin/linuxia32/xans.e57: error while loading shared libraries: libXp.so.6: 
cannot open shared object file: No such file or directory


There is a few missing 32bit libraries, which have to be installed separately:
zypper in libXp6-32bit libXi6-32bit libGLU1-32bit 
yum -y install libXp.i686 lesstif.i686 libXi.i686 mesa-libGLU.i686

For openSUSE: The rare libXm.so.2 is included in the ANSYS installation:
rpm -ivh /ansys_inc/ansys57/syslib/OPENMOTIF/openmotif-2.1.30-2_ICS.i386.rpm
ln -sf /usr/X11R6/lib/libXm.so.2.1 /usr/lib/libXm.so.2

For CentOS: libXm.so.2 is included in lesstif
[root@hrabos ansys-5.7]# yum whatprovides  libXm.so.2
Loaded plugins: refresh-packagekit, replace
lesstif-0.95.2-1.el6.i686 : OSF/Motif library clone
Repo        : epel
Matched from:
Other       : libXm.so.2    .....

Now, /ansys_inc/ansys57/bin/xansys57 works well in a VNC environment.

Update, 2016-12-13
For CentOS 7:
lesstiff.rpm is available only in the 64 bit variant. Use corresponding package from the Fedora19 repository
rpm -ivh -force ftp://ftp.pbone.net/mirror/archive.fedoraproject.org/fedora/linux/releases/19/Fedora/i386/os/Packages/l/lesstif-0.95.2-5.fc19.i686.rpm