Utilitats i trucs

Index

MS Windows 2000/NT i Linux

  1. A la instal·lació de Linux: posar el Lilo a la partició principal de Linux (NO al Master Boot Record). Si teniu problemes perquè la vostra partició comença en un cilindre més gran que 1024, proveu a afegir l'opció lba32 (una línia sola, cap al principi) al fitxer /etc/llilo.conf.
  2. Des de Linux: si la partició principal és, per exemple /dev/hda7 :
    dd if=/dev/hda7 of=/root/bootsec.lin bs=512 count=1
  3. Des de Linux: moure el fitxer creat a la partició MSWindows:
    cp /root/bootsec.lin /mnt/<partició de MSWindows>
    Si no podem muntar el disc de MSWindows (perquè sigui NTFS i no VFAT, per exemple), podem gravar el fitxer en un disquet (cp /root/bootsec.lin /mnt/floppy) i copiar-lo a c:\bootsec.lin des de MSWindows.
  4. Des de Windows 2000: afegir al fitxer c:\boot.ini la línia
    c:\bootsec.lin = "Linux"
  5. Si tot ha anat bé, quan arrenquem l'ordinador, el loader de W2000 ens demanarà si volem arrencar des de Linux o des de W2000.

Resin

  • La variable d'entorn JAVA_HOME ha de contenir l'adreça de la distribució del JDK:
    • csh: en el fitxer .cshrc
      setenv JAVA_HOME /usr/local/jdk1.2.2/
    • bash: en el fitxer .bashrc
      JAVA_HOME=/usr/local/jdk1.2.2/
      export JAVA_HOME

Resin i Apache

Per a fer servir el Resin amb l'Apache (assegureu-vos que teniu l'apache-devel) heu de posar aquestes opcions quan compileu el Resin (tot en una línia):
  • ./configure --with-apache-libexec=/usr/lib/apache --with-apache-include=/usr/include/apache --with-apache-conf=/etc/httpd/conf/httpd.conf

Resin i MS Internet Information Server

En el fitxer resin.conf una configuració d'aquest tipus no funciona:
  • <http-server>
    <http-port>8888<http-port/>
    <app-dir>doc<app-dir/>
    <http-server/>
Ha de ser tot en una sola línia:
  • <http-server port='8888' app-dir='doc'/>

Apache

  • Installation
  • Versions
  • Config files, service start/stop

    config
    modules config
    vhost config
    start/stop
    file
    default docs
    (DocumentRoot ...)
    default cgi-bin
    (ScriptAlias /cgi-bin/ ...)
    file
    file
    Mageia
    /etc/httpd/conf/http.conf
    /var/www/html/index.html
    /var/www/cgi-bin/

    /etc/httpd/conf/vhosts.d/*.conf
    # service httpd start
    CentOS
    /etc/httpd/conf/http.conf /var/www/html/index.html
    /etc/httpd/conf.d/*.conf

    • sudo systemctl start httpd.service
    • service httpd start
    • apachectl start
    Debian /Ubuntu
    /etc/apache2/apache2.conf
    /var/www/index.html (Apache 2.2)
    /var/www/html/index.html (Apache 2.4)
    /usr/lib/cgi-bin/
    /etc/apache2/mods-available/*.conf /etc/apache2/sites-available/* $ sudo service apache2 start
    Cygwin
    /etc/apache2/http.conf
    /srv/www/htdocs/



    $ /usr/sbin/apachectl2 -k start
    XAMPP
    c:\xampp\apache\conf\http.conf
    c:\xampp\htdocs\



  • Estructura de directoris de configuració / Configuration directory structure

    Apache 2.2
    Apache 2.4

    Mageia 1, 2
    Debian / Ubuntu
    Mageia 3, 4
    CentOS
    Debian / Ubuntu
    general
    /etc/httpd/ conf/
    • httpd.conf
    • magic
    • mime.types
    /etc/apache2/
    • apache2.conf
    • magic
    • ports.conf
    • envvars
    /etc/httpd/
    conf/
    • httpd.conf
      • # Include sites configuration
        Include conf/sites.d/*.conf
    • magic
    /etc/httpd/
    • conf/
      • httpd.conf
      • magic
    /etc/apache2/
    • apache2.conf
    • magic
    • ports.conf
    • envvars
    virtual hosts
    • vhosts.d/
      • 00_default_vhosts.conf
      • 00_default_ssl_vhost.conf
    • sites-available/
      • default
      • default-ssl
    • sites-enabled/
      • 000-default -> ../sites-available/default
    • vhosts.d -> sites.d
    • webapps.d -> sites.d
    • sites.d/
      • 00_default_vhosts.conf
      • 00_default_ssl_vhost.conf
      • ...
      • bugzilla.conf
      • mediawiki.conf

    a2ensite / a2dissite
    • sites-available/
      • default
      • default-ssl
    • sites-enabled/
      • 000-default -> ../sites-available/default
    webapps
    • webapps.d/
      • bugzilla.conf
      • mediawiki.conf
      • phpmyadmin.conf
      • timetracker.conf
      • your_app.conf
      • ...

    • conf.d/
      • mediawiki.conf
      • mediawiki.conf -> /etc/mediawiki/apache.conf
      • phpmyadmin.conf -> ../../phpmyadmin/apache.conf
      • your_app.conf
      • ...
      • charset
      • localized-error-pages
      • other-vhosts-access-log
      • security

    • conf-available/
      • mediawiki.conf
      • mediawiki.conf -> /etc/mediawiki/apache.conf
      • phpmyadmin.conf -> ../../phpmyadmin/apache.conf
      • your_app.conf
      • ...
      • charset
      • localized-error-pages
      • other-vhosts-access-log
      • security
    • conf-enabled/
      • ... -> ../conf-available/...

    • conf.d/
    • conf.d/
      • autoindex.conf
      • info.conf
      • languages.conf
      • mpm.conf
      • multilang-errordoc.conf
      • security.conf
      • ssl.conf
    • conf.d/
      • autoindex.conf
      • ssl.conf
      • userdir.conf
      • welcome.conf
    modules
    • modules.d/
      • 40_mod_ssl.conf
      • 70_mod_php.conf
      • 75_mod_perl.conf
    • mods-available/
      • actions.conf
      • actions.load
      • ...
    • mods-enabled/
      • ...
    • modules.d/
      • 00_base.conf
      • 00_mod_lua.conf
      • 00_mod_ssl.conf
      • 00_mod_systemd.conf
      • 00_mpm.conf
      • 00_mod_cgi.conf
    • conf.modules.d/
      • 00-base.conf
      • 00-dav.conf
      • 00-lua.conf
      • 00-mpm.conf
      • 00-proxy.conf
      • 00-ssl.conf
      • 00-systemd.conf
      • 01-cgi.conf
    a2enmod / a2dismod
    • mods-available/
      • actions.conf
      • actions.load
      • ...
    • mods-enabled/
      • ...

    • extramodules -> ../../usr/lib/apache-extramodules/
    • lib -> ../../usr/lib/
    • logs -> ../../var/log/httpd/
    • modules -> ../../usr/lib/apache/
      • mod_*.so


    • logs -> ../../var/log/httpd/
    • modules -> ../../usr/lib64/httpd/modules/
      • mod_*.so
    • run -> ../../run/httpd/
    • logs -> ../../var/log/httpd
    • modules -> ../../usr/lib64/httpd/modules/
      • mod_*.so
    • run -> /run/httpd


  • Utils
    • a2query
      • get the Apache version
        • a2query -v
    • a2ensite
    • a2dissite
    • a2enmod
    • a2...
  • Configuració / Configuration
    • Virtual hosts (vhosts.d, sites-available)
    • /etc/httpd/conf/httpd.conf or /etc/apache2/apache2.conf
      • ServerName your_ip_address
      • Logs
      • Variables d'entorn / Environment variables
        • SetEnv VARIABLE toto_value
        • test CGI to print them all
      • MPM
        • mpm_prefork_module
          • number of childs: StartServers, MinSpareServers, MaxSpareServers, MaxClients
            • number of requests per child: MaxRequestsPerChild
  • Rewriting
  • Scripts d'instal·lació / Installation scripts
    • Script d'instal·lació per a Django / Django installation script
    • estructura / structure:
      • webapp_name
        • apache_config
          • install_apache.sh
          • webapp_name.conf
        • index.html
        • js/
        • css/
        • ...
      • install_apache.sh
        • #!/bin/bash
          EXPECTED_ARGS=1
          if [ $# -ne $EXPECTED_ARGS ]
          then
              cat <<EOF
          Usage: `basename $0` webapp_name

          Example: `basename $0` hbbtv

          Actions:
          - copy webapp_name.conf to apache configuration directory (e.g. /etc/httpd/conf/webapps.d/)
          - recursively copy .. (parent directory, except apache_config) to apache directory (e.g. /var/www/webapp_name/)
          - change the owner and group of the files and directories to the right ones

          The following typical OS are automatically detected:
          - Red Hat, CentOS, Mageia, ...
          - Debian, Ubuntu, ...
          - MAC OSX (MAMP)
          EOF
              exit 1
          fi

          webapp_name=$1

          webapp_dir=/var/www/${webapp_name}

          # Red Hat, CentOS, Mageia, ...
          if [ -f /etc/httpd/conf/httpd.conf ]
          then
              httpd_config=/etc/httpd/conf/httpd.conf
              webapp_conf_dir=/etc/httpd/conf/webapps.d/
             
              grup_httpd=`grep "^Group" $httpd_config | awk '{print $2}'`
              usuari_httpd=`grep "^User" $httpd_config | awk '{print $2}'`
          fi

          # MAC OSX
          if [ -f /Applications/MAMP/conf/apache/httpd.conf ]
          then
              httpd_config=/Applications/MAMP/conf/apache/httpd.conf
              webapp_conf_dir=/Applications/MAMP/conf/apache/extra
              webapp_dir=~/sites/${webapp_name}
          fi

          # Debian, Ubuntu, ...
          if [ -f /etc/apache2/apache2.conf ]
          then
              httpd_config=/etc/apache2/apache2.conf
              webapp_conf_dir=/etc/apache2/conf.d/
             
              usuari_httpd=`awk -F= '/APACHE_RUN_USER/ {print $2}' /etc/apache2/envvars`
              grup_httpd=`awk -F= '/APACHE_RUN_GROUP/ {print $2}' /etc/apache2/envvars`
          fi

          # còpia recursiva de la webapp
          echo "copying application $webapp_name to $webapp_dir"
          mkdir -p $webapp_dir
          rsync -a --exclude='.git' --exclude='apache_config' .. $webapp_dir
          chown ${usuari_httpd}.${grup_httpd} -R $webapp_dir

          # webapp config
          echo "copying config file ${webapp_name}.conf to ${webapp_conf_dir}"
          cp ${webapp_name}.conf ${webapp_conf_dir}
  • Start server
    • Serveis / Service
    • apachectl / httpd
      • compiled in modules
        • apachectl -l
        • httpd -l
      • check syntax:
        • apachectl -t
        • httpd -t
      • loaded modules
        • apachectl -M
        • httpd -M
    • Logs
      • Apache Module mod_log_config
      • detailed log in error_log (or name specified by ErrorLog) file:
        • LogLevel debug
      • httpd.conf / apache2.conf
        • errors
          • ErrorLog "logs/error_log"
          • LogLevel debug
        • access
          • TransferLog  "logs/access_log"
          • # CustomLog with format nickname
            LogFormat "%h %l %u %t \"%r\" %>s %b" common
            CustomLog "logs/access_log" common
          • # CustomLog with explicit format string
            LogFormat "logs/access_log" "%h %l %u %t \"%r\" %>s %b"
          • # real remote ip when using AWS ELB load balancer (%a, %h give ELB ip address) LogFormat"%v %A %{X-FORWARDED-FOR}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" elb-ncsa
            CustomLog "logs/access_log" elb-ncsa
      • /etc/apache2/conf.d/other-vhosts-access-log
        • CustomLog ${APACHE_LOG_DIR}/other_vhosts_access.log vhost_combined
      • cat /etc/httpd/logs/error_log
      • grep httpd /var/log/messages
      • systemctl status httpd.service
      • httpd -e debug -E /tmp/toto.log
    • Problemes / Problems
      • /var/log/apache2/error.log
        • "Client denied by server configuration" / 403 Forbidden
          • Apareix al navegador com a: «Forbidden You don't have permission to access / on this server.»
          • Si feu servir Apache 2.4, comproveu que feu servir la directiva "Require all granted" i no "Order deny,allow", "Allow from all"
          • Comproveu que el directori dins de la directiva <Directory ...> és el correcte
          • Comproveu els permisos Unix amb / Check Unix permissions with:
            • namei -m /ful/path/to/index.html
        • ValueError: Unable to configure handler 'logfile': [Errno 13] Permission denied: .../logfile
          • Passa amb el log de Django. settings.py:
            • LOGGING = {
              ...
                  'handlers': {
                      'logfile': {
                          'filename': PROJECT_PATH + "/logfile",
          • Solució / Solution:
            • ...
      • CentOS / RHLE
        • "http dead but subsys locked" / /usr/sbin/httpd: Symbol lookup error: /usr/lib64/libaprutil-1.so.0: Undefined symbol: apr_os_uuid_get
  • Change listen ports
    • Debian
      • ports.conf
    • Mageia
      • /etc/httpd/conf/httpd.conf
        • Listen 8000 # can be specified in sites.d/toto.conf instead
      • /etc/httpd/conf/sites.d/00_default_vhosts.conf
        • Listen 8000
          <VirtualHost _default_:8000>
      • open firewall
    • RedHat / CentOS
      • SELinux: semanage (to avoid error "could not bind to address 127.0.0.1:12345 no listening sockets available, shutting down")
        • semanage port -l | grep -w http_port_t
        • semanage port -a -t http_port_t -p tcp 12345
      • Firewall / tallafoc
      • http.conf
        • Listen 12345
  • Directory index (per exemple: per a fer que serveixi index.html i no index.php, per omissió)
    • DirectoryIndex index.html
  • Accés des d'una subxarxa especificada / Access from a specified subnet
    • Allow from 192.168.1
      ErrorDocument 403 "Access denied per /etc/httpd/conf/webapps.d/my_webapp.conf"
  • CGI
    • mod_cgi
    • configuració / configuration
      • ScriptLog logs/cgi_log
      • ScripAlias /toto /var/www/cgi-bin/toto.cgi
    • /var/www/cgi-bin/
      • test_variables.cgi
        • #!/usr/bin/perl
          print "Content-type: text/html\n\n";
          foreach $key (keys %ENV) {
          print "$key --> $ENV{$key}<br>";
          }
    • http://localhost/cgi-bin/test.cgi
  • Directori addicional / Additional directory (/home/user1/other_dir to be accessed as http://server/new_dir/)
    • Option 1: in system directory
      • (cal? només usuari? només grup?) Check user and group permissions, according to directives in httpd.conf
        • # Mageia, CentOS, ... httpd_config=/etc/httpd/conf/httpd.conf
          usuari_httpd=`grep "^Group" $httpd_config | awk '{print $2}'`
          grup_httpd=`grep "^User" $httpd_config | awk '{print $2}'`
          chmod ${usuari_httpd}.${grup_httpd} -R ...
        • # Ubuntu
          usuari_httpd=`awk -F= '/APACHE_RUN_USER/ {print $2}' /etc/apache2/envvars`
          grup_httpd=`awk -F= '/APACHE_RUN_GROUP/ {print $2}' /etc/apache2/envvars`
          chmod ${usuari_httpd}.${grup_httpd} -R ...
    • Option 2: in user directory
      • Solution 1: symbolic link (no funciona / it does not work) (caldria FollowSymLinks?)
        • cd /var/www/html
        • ln -s /home/user1/parent_dir/other_dir new_dir
      • Solution 2: http.conf
        • Alias /new_dir /home/user1/parent_dir/other_dir <Directory "/home/user1/parent_dir/other_dir">
              Options -Indexes +FollowSymLinks +MultiViews
              AllowOverride None
              # Apache 2.2:
              #Order allow,deny
              #Allow from all
              # Apache 2.4:
              Require all granted
          </Directory>
      • Note: check the user permissions and owners of /home/user1/parent_dir/other_dir IMPORTANT: els passos següents no són necessaris si feu servir Apache 2.4 / next steps are not required when using Apache 2.4; check only that user running Apache has Unix permissions to read index.html
        IMPORTANT: parent directory must have execution permissions for group apache (or whatever group defined in Group directive in httpd.conf, or in APACHE_RUN_USER variable)
        • # usermod -a -G apache user1
        • # chgrp apache -R /home/user1/parent_dir/
        • # chmod g+x /home/user1/parent_dir/
        • # chmod g+rX -R /home/user1/parent_dir/other_dir
    • Option 3: in some other directory (e.g. a mounted external disk), owned by a user:
      • ...
  • Web Apps (webapps.d, sites.d, conf.d)
  • Cache
    • Controlar cache con Apache
    • <FilesMatch "\.(mpd|m4s)$">
        Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
      </FilesMatch>
  • CORS
    • httpd.conf or available-sites/default, ...:
      • #CORS
        Header set Access-Control-Allow-Origin "*"
        Header set Access-Control-Allow-Credentials "true"
        Header set Access-Control-Allow-Methods "POST,PUT,DELETE,GET, OPTIONS"
        Header set Access-Control-Allow-Headers "Content-Type"
        Header set Access-Control-Expose-Headers "Location"
  • HTTPS (see also: Seguretat en WWW / WWW security)
    • Apache modules installation:
      • urpmi apache-mod_ssl
    • Autenticació de servidor amb certificat autosignat / Server authentication with self-signed certificate
      • Mageia:
        • [cd /etc/httpd/conf/vhosts.d; cp 01_default_ssl_vhost.conf 02_hostname_ssl_vhost.conf]
        • canvi de port 443 -> 8443:
          • httpd.conf (diu quins ports obre per a escoltar)
            • Listen 8443
          • 01_default_ssl_vhost.conf (diu a quin dels ports on està escoltant fa referència)
            • <VirtualHost _default_:8443>
      • Ubuntu:
        • cd /etc/apache2/sites-enabled; sudo ln -s ../sites-available/default-ssl 001-default-ssl
        • cd /etc/apache2/mods-enabled; sudo ln -s ../mods-available/ssl.conf .; sudo ln -s ../mods-available/ssl.load .
        • canvi de port 443 -> 8443:
          • ports.conf (diu quins ports obre per a escoltar)
            • Listen 8443
          • default-ssl (diu a quin dels ports on està escoltant fa referència)
            • <VirtualHost _default_:8443>
        • sudo service apache2 restart
    • Autenticació de servidor / Server authentication:
      • Info
      • Passos / Steps:
        1. Creeu una CA amb OpenSSL / Create a CA with OpenSSL
        2. Creeu un certificat de servidor amb OpenSSL i / Create a server certificate with OpenSSL and:
          • mv /etc/pki/tls/newcert.pem /etc/pki/tls/certs/hostname_server.crt
          • mv /etc/pki/tls/newkey.pem /etc/pki/tls/private/tva_server.key
        3. Configuració del servidor Apache / Apache server configuration:
          • /etc/hosts
            • your_ip_address hostname
          • /etc/httpd/conf/httpd.conf
            • LoadModule ssl_module modules/mod_ssl.so
          • cp /etc/httpd/conf/vhosts.d/01_default_ssl_vhost.conf /etc/httpd/conf/vhosts.d/02_hostname_ssl_vhost.conf
          • /etc/httpd/conf/vhosts.d/02_hostname_ssl_vhost.conf
          • to avoid entering the passphrase every boot, create an unsecure version of your key file:
            • cd /etc/pki/tls/private; cp hostname.key hostname.key.orig; openssl rsa -in hostname.key.orig -out hostname.key; chmod 700 hostname.key
        4. Configuració del client / Client configuration
          • import CA
          • connect to server:
            • https://...
          • Si la resposta és sec_error_inadequate_key_usage:
            • comproveu que al certificat del servidor, a keyUsage hi ha keyEncipherment
          • Si sec_error_reused_issuer_and_serial:
            • Netegeu la memòria cau del navegador / Clean the cache on the browser
          • Si sec_error_unknown_issuer:
            • Descarregueu el certificat de la CA i doneu-li permís per a identificar servidors www: "Confia en aquesta CA per identificar llocs web"
          • ssl_error_rx_record_too_long
            • check /var/log/httpd/ssl_error_log
        5. Accés des de client / Access from client:
      • ...
        • mv newcert.pem hostnameCert.prm; cp /etc/pki/tls/hostnameCert.prm /etc/pki/tls/certs/hostname_server.crt
        • mv newkey.pem hostnameKey.pem; cp /etc/pki/tls/hostnameKey.pem /etc/pki/tls/private/hostname_server.key
    • Autenticació de client amb certificat / Client authentication with certificate
      • Info:
      • Passos / Steps:
        1. Creeu un certificat de client amb OpenSSL / Create a client certificate with OpenSSL (client.crt)
        2. Encapsuleu el certificat de client en un fitxer PKCS12 / Encapsulate client certificate into a PKCS12 file (client.p12)
        3. Configuració del servidor Apache / Apache server configuration:
          • import CA certificate
            • creat per nosaltres / created by us
              • cp ...
            • altres / others (e.g. for DNIe)
              • cd /etc/pki/tls/certs/
              • wget http://www.dnielectronico.es/ZIP/ACRAIZ-SHA1.zip
              • unzip ACRAIZ-SHA1.zip
              • conversion from DER to PEM:
                • openssl x509 -in ACRAIZ-SHA1.crt -inform DER -out ACRAIZ-SHA1.crt -outform PEM
          • Host based:
            • /etc/httpd/conf/vhosts.d/01_default_ssl_vhost.conf
              • SSLEngine on
                #CA certificate (PEM encoded) whose client certificates the server is prepared to accept
                SSLCACertificateFile
                /etc/pki/tls/certs/ACRAIZ-SHA1.crt
                SSLVerifyClient require
                SSLVerifyDepth  10
            • el navegador presentarà una llista dels certificats de client disponibles, però només aquells que hagin estat emesos per la CA especificada a SSLCACertificateFile (TLS: RFC 4336 7.4.4 "Certificate request")
          • Directory-based: Authentication with a certificate:
        4. Configuració de client / Client configuration:
          • Si el client es connecta amb un navegador / If the clients connects from a web browser:
          • Si el client es connecta per línia de comanda / If the client connects from command line:
            • la CA li ha de passar el certificat de client (client_pem.crt), la clau de client (client_pem.key) i el certifcat de la CA (root_ca_pem.crt)
            • el client es connecta de forma segura:
              • wget --certificate=client_pem.crt --private-key=client_pem.key --ca-certificate=root_ca_pem.crt https://...
          • Perquè el navegador oblidi el certificat de client amb què s'ha connectat:
            • Eines -> Neteja l'historial recent -> Sessions actives
          • Si quan el client es connecta apareix un error del tipus ssl_error_handshake_failure_alert, pot ser que:
            • el client no tingui instal·lat cap certificat de client (per exemple, el DNIe)
            • (el servidor no tingui el SSLCACertificate adequat)
          • Si ssl_error_unknown_ca_alert
            • el servidor no té el SSLCACertificate adequat
    • Autenticació de client sense certificat / Client authentication without certificate (basic authentication)
      • Info:
      • Passos / Steps:
        1. Configuració del servidor Apache / Apache server configuration:
          • Install mod_auth_basic, mod_auth_digest (mod_auth_cert?)
            • urpmi ...
          • mkdir /var/www/passwd
          • htpasswd -c /var/www/passwd/passwords user_name
          • /etc/httpd/conf/httpd.conf
            • <Directory "/var/www/html/protegit">
                AuthType Basic
                AuthName "Zona protegida"
                # (Following line optional)
                AuthBasicProvider file
                AuthUserFile /var/www/passwd/passwords
                Require valid-user
              </Directory>
          • http://server/protegit/
    • Certificate Revocation List (CRL)
  • WebDAV
    • urpmi apache-mod_dav
    • httpd.conf:
      • Listen 8080 (optional)
      • LoadModule dav_module modules/mod_dav.so
      • LoadModule dav_fs_module modules/mod_dav_fs.so
      • LoadModule dav_lock_module modules/mod_dav_lock.so
      • DAVLockDB /var/lock/apache2/DAVLock
        Alias /toto /var/www/toto
        <Location /toto>
          Dav on
        </Location>
        <Directory "/var/www/toto">
            Options -Indexes MultiViews
            AllowOverride None
            Order allow,deny
            Allow from all
        </Directory>
    • client
  • Llengües / Languages
  • Balanceig de càrrega / Load balancing

OpenSSL

Nginx

  • Installation from packages
    • CentOS
      • nginx -V
        • nginx version: nginx/1.10.1
          built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
          built with OpenSSL 1.0.1e-fips 11 Feb 2013
          TLS SNI support enabled
          configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'
  • Installation from source
    • Add user nginx
      • CentOS, Mageia
        • sudo adduser --system --no-create-home --user-group -s /sbin/nologin nginx
      • Ubuntu
        • sudo adduser --system --no-create-home --disabled-login --disabled-password --group nginx
    • Dependències / Dependencies
      • module
        Mageia
        CentOS
        --with-http_xslt_module lib64xslt-devel
        libxslt-devel
        --with-http_ssl_module

    • Modules
    • Compilació / Compilation (Building nginx from Sources) ():
      1. nginx_version=1.16.1
      2. wget http://nginx.org/download/nginx-${nginx_version}.tar.gz
      3. tar xvzf nginx-${nginx_version}.tar.gz
      4. cd nginx-${nginx_version}
      5. additional modules
        • arut
          • git clone git://github.com/arut/nginx-rtmp-module.git
          • cd nginx-rtmp-module
          • nginx_rtmp_module_version=v1.2.1
          • git checkout ${nginx_rtmp_module_version}
          • cd ..
        • bbc (solves problem with Wirecast)
          • git clone git://github.com/bbc/nginx-rtmp-module.git
          • sed -i.bak '/#define NGINX_RTMP_VERSION/ c\#define NGINX_RTMP_VERSION  "1.2.1.bbc"' nginx-rtmp-module/ngx_rtmp_version.h
        • nginx-upload-module
          • wget -O nginx-upload-module-2.2.tar.gz https://github.com/vkholodkov/nginx-upload-module/archive/2.2.tar.gz
          • tar xvzf nginx-upload-module-2.2.tar.gz
      6. ./configure [--with-debug] --prefix=/usr/share/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=/run/nginx.pid --user=nginx [--with-http_ssl_module] [--with-http_xslt_module] [--add-module=./nginx-rtmp-module] [--add-module=./nginx-upload-module-2.2] --with-cc-opt="-Wimplicit-fallthrough=0"
      7. make
      8. su; make install
    • Problemes / Problems
    • Nginx init scripts
      • CentOS
        • Systemd
          • save it to:
            • /usr/lib/systemd/system/nginx.service
      • Ubuntu
    • Starting, Stopping, and Restarting Nginx
      • /usr/local/nginx/sbin/nginx
      • Open port 1935 (?)
      • Start
        • /usr/local/nginx/sbin/nginx
      • Stop
        • /usr/local/nginx/sbin/nginx -s stop
      • Reload config
        • /usr/local/nginx/sbin/nginx -s reload
    • Test
      • cd nginx-1.9.2/nginx-rtmp-module/test/
      • edit nginx.conf
        • /path/to/
      • cp nginx.conf /usr/local/nginx/conf/
      • /usr/local/nginx/sbin/nginx
      • publish:
        • ./ffstream.sh
        • with ffmpeg
          • ffmpeg -loglevel verbose -re -i sintel-1024-stereo.mp4 -c copy -f flv rtmp://localhost/myapp/mystream
      • play:
        • ./play.sh
        • ffplay -loglevel verbose "rtmp://localhost/myapp/mystream"
      • statistics:
    • Config
      • Django wsgi
      • /usr/local/nginx/conf/
        • nginx.conf
          • ...
          •         location /stat.xsl {
                        # you can move stat.xsl to a different location
                        #root /usr/build/nginx-rtmp-module;
                        root /home/cesc/src/nginx-1.7.0/nginx-rtmp-module;
                    }
    • Debug and logs
    • Publish to server
      • ffmpeg -re -i sintel-1024-stereo.mp4 -c copy -f flv rtmp://localhost/myapp/mystream
    • Play from server:
      • ffplay rtmp://localhost/myapp/mystream
    • Status

Memcached

  • Instal·lació / Installation
  • Configuració / Setup
    • /etc/sysconfig/memcached
      • tcp port
        • PORT="11211"
          USER="memcached"
          MAXCONN="1024"
          CACHESIZE="64"
          OPTIONS=""
      • unix socket
        • ...
          OPTIONS="-s '/var/run/memcached/memcached.sock' -a 0766"
  • Ús / Usage
    • Django
    • Stats
      • memcached-tool 127.0.0.1:11211
      • memcached-tool 127.0.0.1:11211 stats
      • echo stats | nc localhost 11211

XAMPP

  • XAMPP
  • To be accessible from outside (and on port 8080) http://192.168.1.15:8080
    • <install_dir>\xampp\apache\conf\httpd.conf
      • Listen 8080
      • ServerName 192.168.1.15
    • <install_dir>\xampp\apache\conf\extra\httpd-xampp.conf
      • # Close XAMPP security section here
        <LocationMatch "^/(?i:(?:security))">
            Order deny,allow
            #Deny from all
            #Allow from ::1 127.0.0.0/8
            ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var
        </LocationMatch>

        # Close XAMPP sites here
        <LocationMatch "^/(?i:(?:xampp|licenses|phpmyadmin|webalizer|server-status|server-info))">
            Order deny,allow
            #Deny from all
            #Allow from ::1 127.0.0.0/8
            ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var
        </LocationMatch>
  • ...

Tomcat

  • Per a instal·lar-lo en MS Windows, falta el fitxer:
  • Axis2: name of the host behind a NAT (wdsl file) (*)
    • WEB-INF/conf/axis2.xml
      • <axisconfig name="AxisJava2.0">
              ...
            <!-- Following parameter will set the host name for the epr-->
            <parameter name="hostname" locked="true">myhost.com</parameter>

Django

Squid (HTTP Proxy)

  • Info
  • Server
    • Install
      • Mageia
        • urpmi squid
    • Setup
      • /etc/squid/squid.conf
        • acl localnet src <client_ip>/32
          http_access allow localnet
    • Start
      • sudo systemctl start squid.service
  • Client (<client_ip>)
    • export http_proxy='http://<server_ip>:3128'
      export https_proxy='http://<server_ip>:3128'
      export ftp_proxy='http://<server_ip>:3128'

DOS-UNIX

  • Per a canviar el tipus de fitxer de DOS (amb retorns de carro ^M) a UNIX (retorns de carro senzills): dos2unix
  • Noms de fitxer de majúscula a minúscula:
    • #! /bin/csh
      foreach f ( * )
      mv $f `echo $f | tr '[A-Z]' '[a-z]'`
      end
    • #! /bin/bash
      for f in *;
      do mv $f `echo $f | tr '[A-Z]' '[a-z]'`;
      done

Canvi de nom 

  • #! /usr/bin/bash
    comptador=1;
    while test $comptador -le $1
    do
    mv Imatge${comptador}.hist Imatge${comptador}_rgb_256d.hist
    let comptador=$comptador+1
    done

Conversió de MS-Word a PDF

  • Des d'OpenOffice:
    1. Obriu el fitxer .doc i feu "Exporta com a PDF".
    2. Per a generar vistes prèvies i hiperenllaços: extendedPDF
  • Des de MS Word:
    1. Assegureu-vos que a Windows teniu configurada una impressora PostScript. Si no, aneu a Inici/Configuració/Impressores i afegiu-ne una altra, del tipus PostScript (p.ex. qualsevol HP LaserJet, o bé una genèrica).
    2. Obriu el fitxer amb MS Word.
    3. Imprimir / A fitxer: toto (assegureu-vos que a les opcions d'impressora hi ha Opcions de Postscript / Màxima portabilitat; si està activa l'opció de màxima velocitat podeu tenir problemes de numeració de les pàgines en el fitxer PS generat). La impressora seleccionada ha de ser la de tipus PostScript.
    4. Des de l'explorador de Windows (o similar) canvieu el nom de fitxer de toto.prn a toto.ps
    5. Feu la conversió de Postscript a PDF.
  • Des de MS Word:

Conversió de Postscript a PDF

  • UNIX
    1. ps2pdf toto.ps toto.pdf
  • MS Windows
    1. Obriu toto.ps amb el GSView (assegureu-vos que utilitzi Ghostscript >=6.01; si no, algunes lletres poden quedar amb quadrets [format bitmap en lloc del desitjat vectorial])
    2. Imprimiu-lo a fitxer amb el dispositiu pdfwrite: toto.pdf

Múltiple pàgina en PostScript

  • psnup -2 toto.ps toto.2.ps

PDF

  • Manipulació
    • pdftk
      • Manipulación de ficheros PDF (CRySoL)
      • separa en pàgines individuals / split into single pages:
        • pdftk toto.pdf burst
      • uneix documents / join documents:
        • pdftk 1.pdf 2.pdf cat output 12.pdf
      • afegeix un peu de pàgina / add a footer:
        • pdftk input.pdf multistamp footer.pdf output input_with_footer.pdf
      • compilation (Mandriva)
        • urpmi fastjar gcc-java
        • modify Makefile.Base:
          • ... -I$(JAVALIBPATH) -I/usr/include/libgcj-4.4.3 ...
        • make -f Makefile.RedHat
    • PDF-Xchange viewer
  • Edició
    • Inkscape

X-face

  • giftoppm face.gif | ppmtopgm |pgmnorm |pnmscale -xy 48 48 |pgmtopbm > face.pbm
  • pbmmake -white 48 48 |pnmpaste face.pbm 0 0 |pbmtoicon |tail +3 |compface > face.xface

Registre MS Windows

  • Auto login: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\
    • AutoAdminLogon REG_SZ 1
    • DefaultUsername REG_SZ usuari
    • DefaultPassword REG_SZ contrasenya
    • DefaultDomainName REG_SZ
  • Auto login gràfic: control userpasswords2
  • Execució a l'inici: HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

Xerces

  • Xerces C++ samples
  • MS Visual / MFC:
    • To avoid errors of type "error LNK2001: unresolved external symbol" about a function containing wchar:
      • Project Poperties (All Configurations) / Configuration Properties / C/C++ / Language / Treat wchar_t as Built-in type: No
  • Ambiguous DOMDocument
    • XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument
    • XERCES_CPP_NAMESPACE_QUALIFIER DOMDocumentFragment
    • #define WIN32_LEAN_AND_MEAN // to vaoid using MSxml.h
  • DOMWriter
    • delete of object LocalFileFormatTarget to close and release the file
  • Active-X: to avoid failed registration, copy all xerces .lib and .dll files into the same directory of .ocx file to be registered.
  • Memory leaks
    • cal alliberar sempre el resultat d'un transcode (or better: use std:string instead of char*):
      • char *pStringValorNode;
      • pStringvalorNode = XMLString::transcode( nodeAtribut->getNodeValue() );
      • XMLString::release(&pStringValorNode);
  • Avoid loading (downloading) external DTD:
  • Read from memory (parse a string):
    • string cadena;
    • const char*  gXMLInMemBuf = cadena.c_str();
    • static const char*  gMemBufId = "prodInfo";
    • MemBufInputSource* memBufIS = new MemBufInputSource(
              (const XMLByte*)gXMLInMemBuf,
              strlen(gXMLInMemBuf),
              gMemBufId,
              false );
    • XercesDOMParser *parser = new XercesDOMParser;
    • parser->parse(*memBufIS);
    • XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc = parser->getDocument();
  • Copy of a node:
    • same document:
      • nodeA2 = nodeA1->cloneNode( true );
      • nodeRootA->appendChild( nodeA2 );
    • different documents (docA -> docB):
      • nodeB1 = docB->importNode( nodeA1, true );
      • nodeRootB->appendChild( nodeB1 );
  • Moving nodes from one document (docA, containing nodeA1) to another (docB, containing elB1), using fragments:
    • nodeA1_bis = nodeA1->cloneNode(true); (true: recursive; false: non recursive)
    • fragA1 = docA->createDocumentFragment();
    • nodeAi = fragA1->appendChild(nodeA1_bis);
    • elB2 = docB->createElement("tag");
    • nodeB3 = docB->importNode( fragA1, true );
    • elB2->appendChild(nodeB3);

VMWare / QEmu

  • Install RPM:
  • urpmi kernel-desktop-devel
  • Launch config:
    • /usr/bin/vmware-config.pl
  • Resize virtual disk size
    1. vmplayer
    2. select virtual machine -> Settings -> Utilities -> Expand disk
    3. start guest OS (eg Mandriva) in safe mode
    4. #drakdisk -> resize partition
    5. reboot
  • Resize virtual disk file (6GB -> 8GB) (NOTA: les noves versions de vmplayer ja permet el redimensionament dels discos):
    1. Install needed software
      1. urpmi qemu
      2. urpmi dkms-kqemu (plf) (needed to activate -kernel-kqemu option)
    2. resize disk from several parts (option 1, recommended):
      1. qemu-img convert WindowsXP-s001.vmdk -O raw WindowsXP-s001.raw
      2. qemu-img convert WindowsXP-s002.vmdk -O raw WindowsXP-s002.raw
      3. qemu-img convert WindowsXP-s003.vmdk -O raw WindowsXP-s003.raw
      4. qemu-img convert WindowsXP-s004.vmdk -O raw WindowsXP-s004.raw
      5. cat WindowsXP-s001.raw WindowsXP-s002.raw WindowsXP-s003.raw WindowsXP-s004.raw > WindowsXP_8G.raw
      6. dd bs=1 if=/dev/zero of=WindowsXP_8G.raw seek=8G count=0
      7. qemu-img convert WindowsXP_8G.raw -O vmdk WindowsXP_8G.vmdk
    3. resize disk from several parts (option 2):
      1. qemu-img convert WindowsXP-s004.vmdk -O raw WindowsXP-s004.raw
      2. dd bs=1 if=/dev/zero of=WindowsXP-s004.raw seek=2G count=0
      3. qemu-img convert WindowsXP-s004.raw -O vmdk WindowsXP-s004.vmdk
      4. edit WindowsXP-s004.vmdk:
        • RW 6144 SPARSE "WindowsXP-s004.vmdk" -> RW 4192256 SPARSE "WindowsXP-s004.vmdk"
    4. resize disk from one part
      1. qemu-img convert WindowsXP_6GB.vmdk -O raw WindowsXP_8GB.raw
      2. dd bs=1 if=/dev/zero of=WindowsXP_8GB.raw seek=8G count=0
      3. qemu-img convert WindowsXP_8GB.raw -O vmdk WindowsXP_8GB.vmdk
    5. resize partition with Gparted-LiveCD (select "force Vesa"):
      1. (modprobe kqemu)
      2. qemu -kernel-kqemu [-no-kvm] -m 512 -k es -cdrom gparted-livecd-xxx.iso -boot d -hda WindowsXP_8G.vmdk
    6. cp WindowsXP.vmx WindowsXP_8G.vmx and edit it:
      1. ide0:0.fileName = "WindowsXP_8G.vmdk"
    7. vmplayer WindowsXP_8G.vmx
  • serial device on file.vmx:
    • serial0.present = "TRUE"
    • serial0.fileName = "Auto Detect"
    • serial0.autodetect = "TRUE"
    • serial0.hardwareFlowControl = "TRUE"
  • Xarxa / Network

NFS/Samba

  • server SMBFS
    • urpmi samba-server
    • add user
  • server NFS (configure with MCC or use the folowing:)
    • install service
      • CentOS
        • Chapter 18. Network File System (NFS)
        • Sharing files with NFSv4 on Fedora (Server & Client configuration)
        • Setting Up NFS Server And Client On CentOS 7
        • yum install nfs-utils nfs-utils-lib
        • firewalld
          • systemctl start firewalld.service
          • NFSv4
            • firewall-cmd --permanent --add-service=nfs
            • firewall-cmd --permanent --add-service=rpc-bind
            • firewall-cmd --permanent --add-service=mountd
          • firewall-cmd --reload
        • SELinux (in server or in client?)
          • option 1: booleans
            • getsebool -a | grep -i nfs
            • setsebool -P <someboolean>=1 <someotherbool>=1 ...
          • option 2: policy
            • grep rpc.statd /var/log/audit/audit.log | audit2allow -M mypol
            • semodule -i mypol.pp
        • NFSv4
          • systemctl enable rpcbind.service nfs-idmapd.service nfs-server.service
          • systemctl start rpcbind.service nfs-idmapd.service nfs-server.service
          • Problemes / Problems
            • # systemctl enable nfs-idmap.service
              Failed to execute operation: No such file or directory
              • Solució / Solution
                • /usr/lib/systemd/system/nfs-idmapd.service
                  • [Install]
                    WantedBy=multi-user.target
                • systemctl enable nfs-idmapd.service
        • NFSv3
          • systemctl start rpc-statd.service
          • systemctl start rpcbind nfs-lock nfs-idmap
      • Mageia
        • urpmi nfs-utils
        • service nfs-server start
        • firewall (shorewall) (Réseau Linux avec NFS - Mandriva) (Configuring NFS under Linux for Firewall control)
          • /etc/sysconfig/nfs-common:
            • STATD_OPTIONS="--port 4000"
          • service nfs-common restart
          • /etc/sysconfig/nfs-server:
            • RPCMOUNTD_OPTIONS="--port 4002"
          • service nfs-server restart
          • /etc/modprobe.conf:
            • options lockd nlm_udpport=4001 nlm_tcpport=4001
          • reboot computer
          • open ports: 111/tcp 111/udp 2049/tcp 2049/udp 4000:4002/tcp 4000:4002/udp
          • check port attibution:
            • rpcinfo -p
    • configure idmap
      • /etc/idmapd.conf
        • [General]
          Domain = domain.tld

          [Mapping]
          Nobody-User = nfsnobody
          Nobody-Group = nfsnobody
    • configure permissions
      • /etc/hosts.allow
        • rpcbind: 172.16.11.0/255.255.255.0
    • configure export points
      • /etc/exports
        • /tmp 172.16.11.0/24(no_all_squash,async,secure,no_subtree_check,ro)
        • # NFSv4 (in client: mount -t nfs4 server_address:/var/toto)
          /var/toto 172.16.11.0/24(rw,sync)
        • # NFSv4(in client: mount -t nfs4 server_address:/)
          /var/toto 172.16.11.0/24(rw,sync,fsid=0)
        • # NFSv4 (in client: mount -t nfs4 server_address:/)
          # exported dir /mnt/vol1 is itself a mounted drive
          /mnt/vol1 172.31.0.0/16(rw,async,mountpoint=/mnt/vol1,fsid=0,no_root_squash)
      • Options
        • 21.6 NFS Server Configuration
        • 21.7 The /etc/exports Configuration File
        • Optimizing performance: Network File Systems (MythTV)



        • optimized
          (suggested by MythTV)
          general options ro, rw
          read only, read and write

          insecure
          allow connections from port 1024 and higher

          insecure_locks
          allow insecure file locking

          no_subtree_check
          disable subtree checking

          sync / async
          sync write operations on request
          async
          no_wdelay
          force sync of write operations immediately

          nohide
          do not hide filesystems beneath

          mountpoint[=/mnt/xxx]
          export only if mounted

          fsid=X
          set explicit filesystem ID

          tcp / udp

          udp
          user access
          no_root_squash
          remove map of root in client to anonymous in server (use carefully)

          all_squash
          map all users in client to anonymous in server

          anonuid
          specify uid of the anonymous user in server

          anongid
          specify gid of the anonymous group in server
    • manage export points
      • exportfs man page
      • list of export points
        • exportfs
      • reload (-r) all (-a) exports points
        • exportfs -rav
      • unexport (-u) all (-a) export points
        • exportfs -uav
  • client SAMBA from Unix (*):
    • urpmi mount-cifs [samba_client]
    • mount -t [cifs,smbfs] //server/dir /mnt/toto -o username=usuari_remot,password=contrasenya_remota
    • mount -t [cifs,smbfs] //server/dir /mnt/toto -o credentials=/home/usuari_local/.smbpasswd
    • /home/usuari_local/.smbpasswd
      • username=usuari_remot
      • password=contrasenya_remota
    • server client
      mount /etc/fstab
      CIFS no UNIX ext mount -t cifs //server/dir /mnt/toto -o credentials=/home/usuari_local/.smbpasswd,
      uid=usuari_local,gid=grup_local
      //server/dir /mnt/toto cifs credentials=/home/usuari_local/.smbpasswd, uid=usuari_local,gid=grup_local 0 0
      UNIX ext mount -t cifs //server/dir /mnt/toto -o credentials=/home/usuari_local/.smbpasswd //server/dir /mnt/toto cifs credentials=/home/usuari_local/.smbpasswd 0 0
      Samba mount -t smbfs //server/dir /mnt/toto -o credentials=/home/usuari_local/.smbpasswd,
      uid=usuari_local,gid=grup_local,nounix
      //server/dir /mnt/toto smbfs credentials=/home/usuari_local/.smbpasswd, uid=usuari_local,gid=grup_local,nounix 0 0
    • cli
    • GUI
      • konqueror/dolphin: smb://usuari_remot@server/dir
    • if local computer is using UTF8:
      • ... iocharset=utf8,credentials=...
    • Explora / Browse
      • findsmb
        • Instal·lació / Installation
          • urpmi samba
      • nmblookup domain_name
        • nmblookup WORKGROUP
      • smbclient -L192.168.1.100
        • without password:
          • smbclient -L192.168.1.100 -N
          • smbclient -L192.168.1.100 -U ' % '
    • Exemples / Examples
      • 4geek
      • ZTE F680 (ONT)
        • /root/.smbpasswd
          • username=
            password=
        • sudo mkdir /mnt/ont
        • sudo mount -v -t cifs //192.168.1.1/samba /mnt/ont/ -o credentials=/root/.smbpasswd -o vers=1.0
    • Problemes / Problems
      • check dmesg
      • Server requested LANMAN password (share-level security) but 'client lanman auth = no' or 'client ntlmv2 auth = yes'
        tree connect failed: NT_STATUS_ACCESS_DENIED
        • Solució / Solution
          • a l'ordinador que fa de client:
            • /etc/samba/smb.conf
              • [global]
                client lanman auth = yes
                client ntlmv2 auth = no
      • only first character of filenames or directories is shown
        • No subject (Re: smbmount from Linux to an AS/400)
        • wireshark
          • a byte 00 is following any single character:
            • u 00 s 00 b 00 2 00 _ 00 1 00 _ 00 1 00/7
      • ??????????  ? ?       ?   ?                ? directory
        • Solution: umount -l /mnt/directory
    • Grups secundaris / Supplementary groups
      • feu servir CIFS / UNIX ext
      • a l'ordinador local heu de tenir el mateix user_id que al servidor
      • a l'ordinador local heu de pertànyer als mateixos grups secundaris que al servidor. Si pertanyeu a un grup secundari de forma local, però no al servidor, això no us donarà permisos addicionals al servidor! A la màquina local heu de fer:
        1. creeu els grups amb el mateix GID que al servidor:
          • # groupadd -g 8001 grup_secundari_1
          • # groupadd -g 8002 grup_secundari_2
          • ...
        2. assigneu a l'usuari aquests grups secundaris:
          • # usermod -a -G grup_secundari_1 grup_secundari_2 nom_usuari
        3. (opcional) si l'usuari no vol esperar a sortir i tornar a entrar, pot forçar l'actualització dels grups:
          • $ newgrp grup_secundari_1 grup_secundari_2
  • client NFS from Unix:
    • Mageia
      • urpmi nfs-utils-clients
      • needed?
        • service rpcbind start
        • service nfs-common start
      • Browse:
        • Dolphin: network NFS
    • CentOS
      • sudo yum install nfs-utils
    • Configure idmap
      • /etc/idmapd.conf
        • [General]
          Domain = domain.tld

          [Mapping]
          Nobody-User = nfsnobody
          Nobody-Group = nfsnobody
    • mkdir /mnt/toto
    • Mount temporarily:
      • mount -t nfs server:/var/toto /mnt/toto
      • mount -t nfs4 server:/var/toto /mnt/toto
    • Mount permanently:
      • /etc/fstab (see examples of present mounts at: /etc/mtab)
        • <ip-address-to-server>:/var/toto /mnt/toto nfs4 rsize=8192,wsize=8192,timeo=14,soft 0 0
        • Example (generated by manual mount in CentOS 7: mount -t nfs4 192.168.1.218:/ /mnt/nfs) in /etc/mtab
          • 192.168.1.218:/ /mnt/nfs nfs4 rw,relatime,vers=4.0,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.236,local_lock=none,addr=192.168.1.218 0 0
      • Common NFS mount options



        • optimized
          general options
          hard / soft
          soft: not recommended when using a very busy server

          timeo=value_seconds
          default: 600

          actimeo=value_seconds

          actimeo=0
          sync / async

          async
          intr
          Makes I/O to a NFS mounted filesystem interuptable if the server is down intr
          nfsvers={2,3}


          vers=4.0


          nolock


          noexec


          namlen=255


          port=num


          rsize=num,wsize=num
          default for v2,v3: 8192; default for v4: 32768 (CentOS: 262144)
          rsize=32768,wsize=32768
          sec={sys,krb5,krb5i,krb5p}


          tcp / udp


          proto=tcp


          retrans=2


          relatime


          noatime


          user access
          nosuid

          noacl

      • Check real values:
        • cat /proc/mounts
    • User permissions
      • create a dir owned by a user with login:
        • su my_user -c "mkdir /mnt/nfs/my_dir"
        • the following variant cannot be called from userdata in aws cloudformation because you cannot use sudo in it (you will have the error "sudo: sorry, you must have a tty to run sudo"):
          • sudo su - my_user -c "mkdir /mnt/nfs/my_dir"
      • create a dir owned by a user without login:
        • su nginx -s /bin/bash -c "mkdir /mnt/nfs/my_dir; chmod 777 /mnt/nfs/my_dir; chmod g+s /mnt/nfs/my_dir"
    • Utils
      • List exported dirs in a remote server:
        • showmount -e <remote_server_ip_address>

Compartició de carpetes en MS Windows / MS Windows sharing folders

  1. Comparteix la carpeta / Share the folder
  2. Dóna permisos a l'usuari
    • Properties / Security / Add / Advanced options / Search now
    • if Security tab is not present:
      • Tools / Folder options / View / (don't use) Simple file sharing

Open Office / Libre Office

  • Configuració / Settings
    • ~/.config/libreoffice/
  • Línia d'ordres / Command line
  • Tipus de lletres generals / General fonts
    • Eines -> Opcions -> OpenOffice.org Writer -> Tipus de lletra bàsic
  • Plantilles / Templates (.ot*)
  • Writer
    • Estils i formatació / Styles and formatting
      • Estils -> Gestiona els estils (F11)
      • quan us situeu sobre un lloc del document se us ressaltarà el seu estil a la finestra del estils
      • des de qualsevol lloc, si aneu a Estils -> Edita l'estil..., editareu l'estil que hi ha aplicat en aquell punt, i totes les modificacions s'aplicaran automàticament a tots els altres elements que fan servir aquell estil
      • per a recuperar els valors originals d'un estil, editeu-lo i cliqueu sobre «Reinicialitza els valors heretats»
      • formatació directa
        • si voleu modificar puntualment l'estil d'una part (p.ex. una paraula) podeu fer servir alguna d'aquestes opcions:
          • Format -> ...
          • el tipus de lletra o mida des de la barra d'eines de formatació (apareix amb: Visualitza -> Barra d'eines -> Formatació)
        • per a tornar a l'estil que li tocaria:
          • (botó dret) Neteja la formatació directa
        • si voleu que l'estil passi a tenir les característiques puntuals:
          • Estils -> Actualitza l'estil seleccionat
      • Copying and moving styles
      • Aplicar estils d'una pàgina mestra (ooimpress)
        • A partir d'una pàgina mestra:
          • Plafó lateral dret: Pàgines mestres -> Disponibles per a ser utilitzades (les de ~/.ooo3/user/template/)
          • Si heu modificat la pàgina mestra d'una plantilla disponible, haureu de tancar i tornar a obrir l'OpenOffice perquè els canvis es recarreguin.
        • Per a tenir més pàgines mestres disponibles, a partir de plantilles (Load additional slide masters):
          • Format -> Disseny de la diapositiva -> Carrega -> Les meves plantilles (potser les que ja surten no són les de ~/.ooo3/user/template/)
        • Si es vol importar la pàgina mestra des d'una altra presentació, primer s'haurà de desar aquesta altra presentació com a plantilla, i després aplicar el procediment descrit en el punt anterior.
    • Portada
      • situeu-vos a la primera pàgina
      • Format -> Portada... -> Converteix les pàgines existents a portades
    • Numeració dels capítols (seccions i subseccions)
      • Eines -> Numeració de capítols
      • A la taula de continguts, per a afegir un espai entre el nombre i el títol
    • Taula de continguts / Table of content
      • Insereix -> Índexs i taules -> Taula de continguts, índex o bibliografia
      • Espai entre la numeració i el títol de secció
        • Insereix -> Índexs i taules -> Índexs i taules -> Entrades
          • A la casella en blanc que hi ha entre «E#» i «E» poseu-hi un espai (amb el teclat)
      • Make Table of Contents hyperlink?
        • (menú contextual) Edita l'índex o la taula -> Entrades
        • a la posició desitjada (casella en blanc), amb el botó Enllaç, incloure principi d'enllaç (LS); a la posició final, tornar a prémer el botó Enllaç per a posar un final d'enllaç (LE). El text així delimitat serà clicable.
    • Removing line breaks
      • Tools / AutoCorrect/AutoFormat
      • Options: Combine single line paragraphs if length is greater than 50%
      • Select text
      • Apply Style: Default
      • Format / AutoFormat / Apply
    • Peus / capçaleres
      • Per a distingir entre capçalera i peu per a la primera pàgina i la resta, assegureu-vos que el format de pàgina és el que correspon:
        • Visualitza -> Barra d'eines -> Formatació
        • Estils de pàgina -> Primera pàgina / Per defecte
      • Activeu capçalera/peu:
        • (Estil de pàgina -> Primera pàgina / Per defecte): menú -> Modifica -> Capçalera/Peu de pàgina -> Activa
      • Editeu-los normalment
      • Per a posar text a l'extrem dret i a l'esquerre, separeu-lo amb tabuladors.
    • Una sola pàgina horitzontal / One single horizontal page
      • Re: [libreoffice-users] How do I change page orientation for only ONE page in Writer?
      • On ha de començar la pàgina horitzontal:
        • Insereix -> Salt de pàgina
          • (click dret sobre el salt de pàgina) Edita el salt de pàgina
            •  Flux de text: Salts -> Insereix -> Amb estil de pàgina: Horitzontal
      • On han de començar una altra vegada les pàgines verticals:
        • Insereix -> Salt de pàgina
          • (click dret sobre el salt de pàgina) Edita el salt de pàgina
            • Flux de text: Salts -> Insereix -> Amb estil de pàgina: Estil de pàgina per defecte
    • Per a definir la llengua del text:
      • (impress) Format -> Caràcter -> Llengua
      • Per a tot el text:
        • Eines -> Opcions -> Language settings -> Languages -> Default languages for documents -> Només per al document actual
    • Per a activar la correcció ortogràfica automàtica:
      • Eines -> Opcions -> Configuració de la llengua -> Opcions: Revisa l'ortografia a mida que es teclegi
    • Per a activar/desactivar la substitució automàtica de paraules [suposadament] mal escrites:
    • Activeu el control de canvis: Edita -> Canvis -> Registra
    • L'estructura lògica s'ha de veure reflectida en la visió de l'estructura del document:
      • Edita -> Navegador
    • El cos de text ha de tenir l'estil "Cos de text".
    • Autofit text (Impress for Linux) equivalent:
      • Format -> Text -> Fit to frame
    • Per a incloure figures (dibuix fet amb Draw):
      • [creeu un marc]
      • Obriu la vostra figura amb el Draw, seleccioneu-la i copieu-la
      • Posicioneu-vos al lloc on la voleu enganxar (dins del marc si n'heu creat un)
      • Enganxeu la figura
      • Per a posar un peu:
        • [seleccioneu el marc]
        • menú contextual: Llegenda...
      • Posicionament del marc (marc = imatge+llegenda):
        • Alineació -> Centrada
        • Àncora -> Al paràgraf
        • Ajusta -> Sense ajustament (Cap)
      • Nota: si la lletra us surt massa grossa, l'haureu de canviar prèviament al Draw.
    • Per a incloure figures (imatge):
      • Insereix -> Imatge...
      • Si encara no té llegenda, afegiu-la amb el menú contextual: Insereix una llegenda...
      • Per a properes ocasions, si voleu que cada vegada que s'insereixi una imatge es posi automàticament una llegenda:
        • Eines -> Opcions -> OpenOffice.org writer -> Llegenda automàtica -> Imatge de l'OpenOffice Writer -> Categoria: Figura
      • Posicionament del marc (marc = imatge+llegenda) (NO de la imatge) amb el menú contextual:
        • Alinea els objectes -> Centrat
        • Àncora -> Al paràgraf
        • Ajusta -> Cap
      • Referència a una figura:
        • Insereix -> Referència creuada
          • Tipus: Figura
          • Consulteu utilitzant: Categoria i número
    • Inclusió de fitxers PDF:
      • si teniu un fitxer EPS, el podeu convertir a PDF amb: eps2pdf
      • Insereix -> Objecte -> Objecte OLE -> Crea'n un a partir de fitxer
      • es veurà bé a la pantalla i s'imprimirà en alta qualitat
    • Inclusió de fitxers EPS:
      • el fitxer EPS a inserir ha d'haver estat normalitzat amb eps2eps.
      • des de l'OpenOffice: Insereix -> Imatge -> Des d'un fitxer
      • es veurà bé a la pantalla i s'imprimirà en alta qualitat
    • Taules
      • Tipus de numeració:
        • ...
      • Peu automàtic de taules:
        • Eines -> Opcions -> OpenOffice.org writer -> Llegenda automàtica -> Taula de l'OpenOffice Writer -> Categoria: Taula
    • Per a eliminar les modificacions locals de format respecte el format de l'estil:
      • Format -> Formatació per defecte
    • Bibliografia
      • Base de dades
        • Eines -> Base de dades bibliogràfica
      • Referència des d'un paràgraf:
        • Insereix -> Índexs i taules -> Entrada bibliogràfica
      • Llista de les referències citades des del document
        • Insereix -> Índex i taules -> Taula de continguts, índex o bibliografia -> Tipus: Bibliografia
      • Perquè la secció Bibliografia aparegui a l'índex de continuguts:
        • Bibliografia (botó dret) Edita l'índex -> Estils
          • seleccioneu a l'esquerra: Títol [Encapçalament de la bibliografia]
          • seleccioneu a la dreta: Encapçalament 1
          • cliqueu sobre el botó <
            • a l'esquerra ara tindreu: Títol [Encapçalament 1]
    • Clipart (png, svg)
      • urpmi clipart-openclipart
      • Eines -> Galeria
    • Enllaços / Hyperlinks
      • Using hyperlinks
      • Edita / Edit:
        • Select hyperlink
        • Edit -> Hyperlink
      • Exportació a PDF
    • Conversió a PDF
      • Enllaços / Hyperlinks
      • Problemes
        • Si s'han importat fletxes grosses bidireccionals des d'un MSPowerPoint, l'OpenOffice petarà quan s'intenti fer una exportació a PDF.
        • Okular
          • no apareixen els enllaços
            • assegureu-vos que esteu en mode «Visualització» (i no en «Selecció de text»)
    • Signatura digital / Digital signature
      • Eines -> Opcions -> LibreOffice -> Seguretat -> Camí del certificat
        • assegureu-vos que és el mateix directori que fa servir Firefox
          • p.ex: firefox:default (~/.mozilla/firefox/xxxxxxxx.default/)
      • Comproveu que heu afegit els certificats arrel i hi confieu
        • ...
      • Per a signar un document open document (odt, ...)
        • Fitxer > Signatures digitals > Signatures digitals...
          • Signa el document...
            • us hauria de sortir una llista dels certificats disponibles; si us surt una llista buida, verifiqueu el «Camí del certificat»
            • seleccioneu-ne un
            • assegureu-vos que és vàlid fent «Mostra el certificat...»
              • si a la pestanya «General» us diu «No s'ha pogut validar el certificat»:
                • ...
            • «Signa»
              • si el cerificat no s'havia pogut validar, us apareixerà un avís: «Com a mínim una signatura té problemes: no se n'ha pogut validar el certificat»
      • Per a signar un document PDF generat a partir d'un open document:
        • Fitxer > Exporta com a PDF...
          • pestanya: Signatures digitals
            • Selecciona...
      • Per a signar un document PDF qualsevol (p.ex. okular)
      • Signing ODF and PDF documents with LibreOffice (Linux Kamarada)
        • Signing an ODF document
        • Checking the digital signature of an ODF document
        • Modifying a signed ODF document
        • Exporting a document as a signed PDF
        • Checking the digital signature of a PDF document
        • Checking the digital signature of a PDF document
        • Setting up LibreOffice to use Chromium certificates
      • ...
  • Impress
    • Pàgines mestres / Master pages
      • Visualitza -> Mestra -> Elements mestres...: data/hora, peu, número de diapositiva (cal tancar la mestra per a actualitzar)
      • Es poden afegir tantes pàgines mestres com calgui (com si fos una presentació normal): títol, contingut,...
    • Número de pàgina
      • A la diapositiva mestre cal que hi aparegui (Elements mestres)
      • i, a més, cal activar Visualitza -> Capçalera i peu
      • Es poden desactivar també amb si trieu Format - Disseny de la diapositiva i desactiveu la casella de selecció Objectes al fons.
    • Esquema / Outline
    • Numeració de les capçaleres / Heading numbering
      • Eines -> Numeració d'esquemes...
    • Nom de la diapositiva / Slide name
    • Text al voltant d'una imatge (adapta el text a un polígon) / Wrap text around an image (adapt text to a polygon)
      • creeu el rectangle principal
      • creeu el rectangle on posareu la imatge (es menjarà una part del rectangle principal)
      • seleccioneu: el rectangle principal, maj + rectangle secundari
      • Formes -> Resta
      • feu doble clic al polígon principal
      • escriviu el text
      • seleccioneu tot el text
      • menú amb el botó dret: Text...
        • Ajusta a la vora
      • per a modificar la forma del polígon:
        • seleccioneu-lo
        • menú botó dret: activeu Punts
  • Draw
    • Text alineat amb els connectors / Text aligned to the connectors:
      • Adjusting text to suit the connecting line
      • Configuració:
        • Visualitza -> Barres d'eines -> Formatació de text
          • (clic dret sobre la barra d'eines de formatació de text) Personalitza la barra d'eines... -> Categoria: Formata -> Fontwork -> (fletxa cap a la dreta)
        • Eines -> Personalitza -> Barres d'eines -> Barra d'eines: Dibuix -> Afegeix -> Formata -> Fontwork
      • Ús / Usage:
        • Seleccioneu el connector i cliqueu sobre la icona que acabeu d'afegir (Fontwork)
  • Calc
    • Congelació de files i columnes en un full de càlcul / Freeze rows and columns in a spreadsheet (*):
      • Seleccioneu la primera fila o columna o cel·la que volgueu que es pugui moure
      • Finestra -> Congela / Window -> Freeze
    • Entrada automàtica / Auto completion
    • Amaga i mostra files i columnes
      • Format -> {Fila,Columna,Full} -> {Amaga. Mostra}
    • Ordenació alfabètica / Alphabetic sort
      • Dades -> Ordena
    • Text a columnes / Text to column
    • Ordinals
      • Eines -> Opcions de correcció automàtica... -> Opcions de llengua -> Formata els sufixos dels nombres ordinals (1r -> 1^r)
    • Funcions del full de càlcul
      • CONSULTAV / VLOOKUP
        • poseu el 4t paràmetre a 0 per a trobar el valor exacte (no el primer que se li assembli)
    • Base de dades
    • Histograma / Histogram
    • Impressió / Print
      • límit de la pàgina
        • Visualitza > Salt de pàgina
  • Problemes amb Mandriva i KDE/Qt:
  • Bugs
    • Impress 2.1.7
    • un cop desada una plantilla, la llista de la diapositiva mestra no s'actualitza (aquesta mestra inactualitzable seguirà així en els documents creats a partir d'aquesta plantilla). Però l'estil, que és el que compta, es modificarà bé i serà el que s'aplica als documents creats a partir d'aquesta plantilla.
    • per a tornar a aplicar la mateixa plantilla un cop modificada, cal aplicar una altra plantilla, desar el document, tancar i obrir l'OpenOffice, i aplicar de nou la plantilla que hem modificat.

Google Docs

Flameproject

  • urpmi libgnome2_0-devel

Biblioteques compartides / Shared libraries

Llengua / Language


Servei / Service

  • UbuntuBootupHowto
  • /etc/init.d/toto:
    • #!/bin/sh
      #
      # Startup script for the toto daemon
      #
      # chkconfig: 2345 26 59
      #
      # description: toto daemon
      #
      ### BEGIN INIT INFO
      # Provides: toto
      # Should-Start: xxxx
      # Required-Start: xxx
      # Required-Stop: xxx
      # Default-Start: 2 3 4 5
      # Short-Description: Toto daemon
      # Description: Toto daemon
      ### END INIT INFO

      . /etc/init.d/functions

      case "$1" in
        start)
              gprintf "Starting toto daemon: "
              daemon "/usr/bin/toto -i 172.16.11.5" -d
              RETVAL=$?
              echo
              [ $RETVAL -eq 0 ] && touch /var/lock/subsys/toto
              ;;
        stop)
              gprintf "Shutting down toto daemon: "
              killproc toto
              RETVAL=$?
              echo
              [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/toto
              ;;
        status)
              status toto
              RETVAL=$?
              ;;
        restart|reload)
              $0 stop
              $0 start
              ;;
        condrestart)
              [ -f /var/lock/subsys/toto ] && restart || :
              ;;
        *)
              gprintf "Usage: %s {start|stop|status|restart}\n" "$0"
              RETVAL=1
              ;;
      esac

      exit $RETVAL
  • ln -s /etc/init.d/toto /etc/rc5.d/S99toto
  • service toto start
  • Configuració / Setup
    • chkconfig
      • chkconfig -list
    • install a service:
      • update-rc.d to make all the links from /etc/rc?.d/ to /etc/init.d/toto (start: 90, kill: 10)
        • sudo update-rc.d toto defaults 90 10
    • uninstall a service:
      • sudo rm /etc/rc*/*toto

Logitech Harmony

  • concordance
    • Harmony 700
      • concordance >= 0.22
    • Codi font / Source code
    • old cvs instructions
      • [cvs -d:pserver:anonymous@concordance.cvs.sourceforge.net:/cvsroot/concordance login]
      • [cvs -z3 -d:pserver:anonymous@concordance.cvs.sourceforge.net:/cvsroot/concordance co -P concordance]
      • urpmi autoconf automake make gcc-c++ libtool-base libusb-compat0.1-devel
      • cd concordance/libconcord
        • autoreconf --install
        • ./configure
        • make
        • make install
      • cd concordance/libconcord/bindings/python
        • urpmi libpython2.6-devel
        • python setup.py install
      • cd concordance/concordance
        • autoreconf --install
        • ./configure
        • make
        • make install
      • Add /usr/local/lib to the library path
  • congruity (GUI)
    • Instal·lació / Installation
      • Mageia
        • sudo urpmi congruity
  • http://members.harmonyremote.com/ (it will call Congruity)

SVG

  • Include scalable SVG into HTML (Inkscape ViewBox bug, Bug #168261) (feedicons examples):
    • .svg
      • <svg ...
        width="..."
        height="..."
        ViewBox="0 0 200 100">
        ...
    • .html (figure scaled to 40x20 pixels)
      • <object type="image/svg+xml" data="figure.svg" width="40" height="20">
        You cannot display SVG files.
        </object>

QR

Dropbox

  • Dropbox
  • The Unofficial Dropbox wiki
  • Linux installation (Dropbox: Painless and Free Backup)
    • from package
      • Mageia
        • urpmi nautilus-dropbox (will also install dropbox package)
    • from code:
      • Mageia
        • urpmi gcc make lib64nautilus-devel python-docutils
      • wget https://linux.dropbox.com/packages/nautilus-dropbox-1.6.1.tar.bz2
      • tar xjf nautilus-dropbox-1.6.1.tar.bz2
      • cd nautilus-dropbox-1.6.1
      • ./configure; make;
      • su; make install
    • (as user): dropbox start -i
    • nautilus will open /home/user/Dropbox/ folder
    • rm -f ~/.dropbox-dist/libz.so.1
      dropbox start
    • (run dropbox again and follow the displayed URL to sync your Dropbox account to your PC)
  • Problems:
    • Plasma / KDE5 (e.g. Mageia 6)
      • "isn't running"
      • Solució provisional / Workaround
        • CTRL + ALT F2 to open a text console
          • $ dropbox start
        • or use Gnome instead of Plasma
    • Dropbox Not Syncing On Ubuntu Linux
      • Solution:
        • kill the dropbox process
        • dropbox start
  • Website host

Google Drive

  • Grive
    • Installation [Grive]
      • Dependències / Dependencies
        • urpmi cmake lib64json-devel
      • yajl
        1. git clone git://github.com/lloyd/yajl yajl
        2. cd yajl
        3. ./configure
        4. cmake .
        5. make
        6. su; make install
      • grive
        1. git clone https://github.com/Grive/grive.git
        2. cd grive
        3. cmake .
        4. make
        5. su; make install
    • Usage
      • ...

Media Tomb (UPnP server)

  • urpmi mediatomb
  • /etc/mediatomb.conf
    • MT_INTERFACE="eth0"
  • service mediatomb start
  • /etc/mediatomb/
    • config.xml
      • <name>Servidor MediaTomb</name>
  • add supoort for mts (MPEG-2 TS) files:
    • config.xml
      • <map from="mts" to="video/mpeg"/>
        <map from="ts" to="video/mpeg"/>
        <map from="m2ts" to="video/mpeg"/>
  • Administració / Administration

DirectFB

Emacs 

  • Paquets / Packages
  • Meta key (M-)
    • ESC (and release)
    • Alt (and keep)
  • xemacs indent tutorial
  • c-set-style java
  • Modes
  • Instal·lació d'un mode / Mode installation
    • (consider MELPA)
    • set ~/.emacs.d as part of load-path
      • ~/.emacs
        • (add-to-list 'load-path "~/.emacs.d")
    • put your file in:
      • ~/.emacs.d/toto.el
    • load it from ~/.emacs
      • ~/.emacs
        • (require 'toto)
  • carregar un fitxer .el / load a .el file
    • M-x load-file
    • .emacs:
      • (load "~/nxml-mode-200YMMDD/rng-auto.el")
  • carregar un mode / load a mode
    • M-x [sh-mode c-mode xml-mode...]
    • .emacs:
      • (setq auto-mode-alist
                (cons '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)
                      auto-mode-alist))
  • informació sobre un mode / information about a mode
    • M-x describe-mode
  • newline in replace:
    • C-q C-j
  • Inverted colours (reverse video):
    • emacs -rv
  • printf colors
    • Ansi Color (built-in)
      • M-x load-library ansi-color
        M-: (ansi-color-apply-on-region (point-min) (point-max))
  • columnes / columns
    • M-x column-number-mode
    • .emacs
      • (setq column-number-mode t)
  • parèntesis
  • cerca
    • tornar al lloc després de la cerca:
      • C-x C-x
  • Índex a partir d'una cerca:
    • M-occurs
  • HTML tags
    • cerca el tag de tancament a partir del tag d'obertura / search corresponding ending tag
      • C-c C-f
    • cerca el tag d'obertura a partir del tag de tancament / search corresponding opening tag
      • C-c C-b
    • elimina el tag / remove tag
      • C-c Backspace
  • .emacs:
    • disable bell
      • (setq visible-bell t)
    • font
      • (set-default-font "6x13")
  • auto-fill (automatic introduction of newlines for long lines):
    • mouse-3 button over (Text) at bottom to activate or deactivate it
  • posar bé un paràgraf / fill paragraph:
    • M-q
  • eliminar els retorns de carro / join line:
    • aneu a la darrera línia del paràgraf i aneu fent una de les següents opcions:
      • M-^ (cal fer un espai, perquè ^ és una tecla morta)
      • M-x join-line
  • conflictes / conflicts (text diff)
  • envoltar un text seleccionat
    • wrap-region.el
      • dependencies
        • M-x package-install
      • cd ~/.emacs.d/
      • wget https://raw.githubusercontent.com/rejeep/wrap-region.el/master/wrap-region.el
      • i18n in Smarty
        • (wrap-region-add-wrapper "{t}" "{/t}" "/")     ; hit / then region -> {t}region{/t}
      • .emacs
        • (add-to-list 'load-path "~/.emacs.d/wrap-region.el")
      • usage
        • M-x html-mode
        • M-x wrap-region-mode
        • select text
        • type '/'
  • Indentation
  • Macros
  • tabs
    • Show white space
      • WhiteSpace
        • install
          • ~/.emacs
            • (require 'whitespace)
        • activate
          • C-u 1 M-x whitespace-mode RET
        • deactivate
          • C-u 0 M-x whitespace-mode RET
    • usage


      only for this session permanently, in ~/.emacs
      display

      M-x set-variable RET tab-witdth RET 4 (setq tab-width 4);
      insert
      CCMode
      c-basic-offset


      perl
      cperl-indent-level





    • inserting
      • (setq tab-stop-list 4);
    • (setq default-tab-width 4);
    • (setq-default indent-tabs-mode t);
    • tabs -> spaces
      • M-x untabify
    • spaces -> tabs
      • M-x tabify

Fitxers de text / Text files

  • Codificació de text / Text encoding
    • Per a saber en quina codificació està un fitxer .tex (*):
    • Per a canviar la codificació del fitxer (d'iso-8859-1 a UTF-8):
      • iconv -f iso-8859-1 -t utf8 toto.tex > toto2.tex
      • recode UTF-8 toto.tex
      • convert_html_encoding.sh
        • #!/bin/bash

          # defaults
          output_encoding=utf-8

          EXPECTED_ARGS=1
          if (( $# != $EXPECTED_ARGS ))
          then
              cat <<EOF
          Usage: `basename $0` html_filename

          Converts html_filename to ${output_encoding}, by modifying the file text encoding and setting:
            <meta content="text/html; charset=${output_encoding}" http-equiv="Content-Type">
          EOF
              exit 1
          fi

          # parameters
          input_path=$1

          input_basename=$(basename ${input_path})
          input_name=${input_basename%.*}
          input_extension=${input_basename##*.}
          input_dirname=$(dirname ${input_path})

          output_basename=${input_name}.${output_encoding}.${input_extension}
          output_path=${input_dirname}/${output_basename}

          # get present mime-type
          mime=$(file -bi ${input_path})
          echo "file mime: ${mime}"

          # get present text encoding charset
          charset=${mime##*=}
          echo "file charset: ${charset}"

          if [[ $charset != $output_encoding ]]
          then
              echo "converting file to $output_encoding"
             
              # convert file encoding
              iconv -f ${charset} -t ${output_encoding} ${input_path} >${output_path}
             
              # convert html charset
              sed -i "/<meta.*charset/ c\  <meta content=\"text/html; charset=${output_encoding}\" http-equiv=\"Content-Type\">" ${output_path}
             
              # rename output file
              rm -f ${input_path}
              mv ${output_path} ${input_path}
          else
              echo "file already in $output_encoding"
          fi

          exit 0
  • Per a canviar la codificació del nom del fitxer:
    • convmv -f ascii -t utf8 --notest [filename] > [newfilename]
  • Diferències / Differences

eyeOS

  1. urpmi php-curl php-mbstring php-mcrypt php-mysqli php-sqlite3 php-pdo_mysql php-pdo_sqlite openoffice.org-pyuno
  2. Download the latest version
  3. untar it
  4. /etc/httpd/conf/vhosts.d/eyeos.conf:
    • Alias /eyeOS /var/www/eyeOS
      <Directory "/var/www/eyeOS">
          Options -Indexes FollowSymLinks MultiViews
          AllowOverride None
          Order allow,deny
          Allow from all
      </Directory>
  5. Open http://localhost/eyeOS/install

LDAP (Lightweight Directory Access Protocol)

  • Info
  • Servidor / Server
    • OpenLDAP
      • slapd (server)
      • modes
      • install
        • urpmi openldap-servers
      • config:
      • afegir entrades / add entries
        • ldapadd
          • -x: simple authentication
          • -W: prompt for password
          • -D: bind dn
        • general:
          • edit general.ldif:
            • dn: dc=example,dc=com
              dc: example
              objectClass: top
              objectClass: domain

              dn: ou=usuaris,dc=example,dc=com
              ou: usuaris
              objectClass: top
              objectClass: organizationalUnit

              dn: ou=grups,dc=example,dc=com
              ou: grups
              objectClass: top
              objectClass: organizationalUnit
          • ldapadd -x -W -D "cn=Manager,dc=example,dc=com" -f general.ldif
        • grups / groups:
          • grups.ldif (or generated by a script)
            • dn: cn=example,ou=grups,dc=example,dc=com
              objectClass: posixGroup
              cn: grup1
              gidNumber: 10000
          • ldapadd -x -W -D "cn=Manager,dc=example,dc=com" -f grups.ldif
        • persones / people:
          • usuaris.ldif (or generated by a script)
            • ...
              objectClass: posixAccount
              ...
          • ldapadd -x -W -D "cn=Manager,dc=example,dc=com" -f usuaris.ldif
    • Apache DS
  • Clients
    • command line
      • openldap client
        • urpmi openldap-clients
        • usage:
          • ldapsearch -x -b 'dc=example,dc=com' '(objectclass=*)'
          • ldapsearch [-h ldap_server] -xLLL -b 'dc=example,dc=com' '(objectclass=posixGroup)' cn gidNumber
      • shelldap
        • urpmi shelldap
      • smbldap-tools
        • urpmi smbldap-tools
        • /etc/smbldap-tools/smbldap.conf
          • ...
        • usage:
          • smbldap-...
          • smbldap-passwd
          • ...
    • GUI tools (Samba & LDAP)
    • Apache Directory Studio
      • Bind DN or user:
        • cn=Manager,dc=example,dc=com
    • LUMA browser
    • Mandriva Directory Server - MDS
  • Integration with:
    • Bugzilla
    • DHCP
    • MMC (Pulse2)
    • OpenSSH
      • /etc/ssh/sshd_config
        • PAMAuthenticationViaKbdInt yes
    • PAM (Pluggable Authentication Module) in Unix
      • Mageia
        • drakauth (urpmi drakxtools-curses) (MCC: Sistema -> Autenticació)
        • [urpmi nss_ldap pam_ldap autofs nss_updatedb pam_ccreds]
    • Samba
    • Subversion

MMC Mandriva Management Console

  • Mandriva Management Console
  • Packages

    • MMC
      (3.0.4)
      Pulse2
      (1.3.1)
      Mandriva Directory Server (2.4.2.2)
      core
      plugins

      source
      mmc-core-3.0.3.2.tar.gz
      mmc-core-3.0.3.2.tar.gz
      pulse2-1.3.1.1.tar.gz mds-2.4.2.2.tar.gz
      server
      MMC web interface

      • mmc-web-base
      • mmc-web-ppolicy
      • mmc-web-pulse2
      • mmc-web-dyngroup
      • mmc-web-glpi
      • mmc-web-imaging
      • mmc-web-inventory
      • mmc-web-msc
      • mmc-web-pkgs
      • mmc-web-bulkimport
      • mmc-web-mail
      • mmc-web-network
      • mmc-web-proxy
      • mmc-web-samba
      • mmc-web-sshlpk
      • mmc-web-userquota
      MMC agent
      • mmc-agent
      • python-mmc-core
      • python-mmc-base
      • python-mmc-ppolicy

      • python-mmc-pulse2
      • python-mmc-dyngroup
      • python-mmc-glpi
      • python-mmc-imaging
      • python-mmc-inventory
      • python-mmc-msc
      • python-mmc-pkgs
      /usr/share/doc/python-pulse2-common/ contrib/<PLUGIN>/sql/install.sh
      /etc/mmc/plugins/
      • python-mmc-bulkimport
      • python-mmc-mail
      • python-mmc-network
      • python-mmc-proxy
      • python-mmc-samba
      • python-mmc-sshlpk
      • python-mmc-userquota
      servers


      • pulse2-common
      • pulse2-imaging-server
      • pulse2-inventory-server
      • pulse2-launcher
      • pulse2-package-server
      • pulse2-scheduler
      /etc/mmc/pulse2

      client


      • pulse2-imaging-client

  • Pre-install
    • Get MMC source
      • wget http://mds.mandriva.org/pub/mmc-core/sources/3.0.2.1/mmc-core-3.0.2.1.tar.gz
      • tar xvzf mmc-core-3.0.2.1.tar.gz
    • Get MMC / Pulse2 packages
      • Debian Squeeze
        • /etc/apt/sources.list
          • deb http://pulse2.mandriva.org/pub/pulse2/server/debian squeeze 1.3.1.1
          • [deb http://mds.mandriva.org/pub/mds/debian squeeze main]
        • sudo apt-get update
        • dpkg-reconfigure debconf
          • medium
        • sudo apt-get install slapd mysql-server
        • sudo apt-get install mmc-agent python-mmc-dyngroup python-mmc-imaging python-mmc-inventory python-mmc-msc python-mmc-pkgs python-mmc-pulse2 mmc-web-base mmc-web-dyngroup mmc-web-imaging mmc-web-inventory mmc-web-msc mmc-web-pkgs mmc-web-pulse2
      • Mandriva / Mageia
        • urpmi php-xmlrpc php-gd python-sqlalchemy python-mysql python-OpenSSL python-ldap
  • Install from source (README, INSTALL)
    • cd mmc-core-3.0.2.1
    • ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
    • make
    • make install
      • ### MMC LDAP schema must be added to your LDAP directory in order for
        ### mmc-agent to run.
        ### If using dynamic backend (from OpenLDAP 2.3), schema must be converted
        ### in LDIF format.
        ### You can use "mmc-add-schema" to convert and add the schema.
        ### Schema file is available in: /usr/share/doc/python-mmc-base/contrib/ldap
  • Install from package
    • Debian:
      • LDAP and MySQL root password will be configured after package installation
  • Post-install
    • LDAP ("slapd using LDAP based configuration") (INSTALL)
      • Debian
        • dpkg-reconfigure slapd
          • DN: example.com (must match baseDN in /etc/mmc/plugins/base.ini)
        • [slappasswd -s secret]
        • [sudo debconf-show slapd]
        • sudo apt-get install ldap-utils
        • mmc-add-schema /usr/share/doc/python-mmc-base/contrib/ldap/ /etc/ldap/schema/
        • sudo /etc/init.d/slapd restart
      • Mageia
        • mmc-add-schema /usr/share/doc/python-mmc-base/contrib/ldap/ /usr/share/openldap/schema/
        • service slapd restart
    • MMC agent
      • /etc/mmc/plugins/base.ini
        • baseDN = dc=example, dc=com
        • password = secret
        • [computers]
          method = inventory
      • mkdir /home/archives
      • /etc/default/mmc-agent
        • ENABLE=yes
      • /etc/init.d/mmc-agent start
      • If you get a "failed", try with debugging:
        • mmc-agent -d
    • Apache
      • Debian
        • ln -s /etc/mmc/apache/mmc.conf /etc/apache2/conf.d/
        • sudo /etc/init.d/apache2 restart
      • Mandriva / Mageia
        • ln -s /etc/mmc/apache/mmc.conf /etc/httpd/conf.d/
        • service httpd restart
  • MMC usage

Pulse2




  • latest (1.3.1) 1.3.0
    download
    http://pulse2.mandriva.org/pub/pulse2/
    Pulse2 Downloads Pulse2 Downloads (Previous releases)
    documentation
    install
    from source

    from packages
    Pulse2-Install-Debian-Lenny.pdf
    user

    User manuals
    development



  • Architecture
    • Services
      • Inventory
      • Launcher
      • Package
      • Scheduler
    • MMC (Mandriva Management Console) plugins
      • Dyngroup
      • Inventory
        • Fusion Inventory agent for Android
          • "FusionInventory agent for other platforms (Linux, Windows, ...) can also be used as a drop-in in replacement of OCSInventory agent for inventory part."
      • GLPI (when Inventory is not used)
      • MSC
      • Pkgs
  • General
  • Pulse2 Documentation (Previous documentation)
  • Documentation
  • Prerequisites
    • MMC
    • urpmi python-sqlalchemy python-mysql
  • Installation from package
  • Installation from source (README, INSTALL)
    • Info
      • /usr/share/doc/pulse2/
    • Compilation and installation
      1. wget pulse2-1.3.1.1.tar.gz
      2. tar xvzf pulse2-1.3.1.1.tar.gz; cd pulse2-1.3.1.1
      3. ./configure --disable-nsis --prefix=/usr --sysconfdir=/etc --localstatedir=/var
      4. make
      5. make install
    • Post-install (choose one of the following)
      • pulse2-setup
      • manual MySQL config:
        • setup
          • mysql -u root -p
          • create database pulse2;
          • create database msc;
          • create database imaging;
          • create database inventory;
          • create database dyngroup;
          • create user 'mmc'@'localhost' identified by 'mmc';
          • grant all on pulse2.* to 'mmc'@'localhost';
          • grant all on msc.* to 'mmc'@'localhost';
          • grant all on imaging.* to 'mmc'@'localhost';
          • grant all on inventory.* to 'mmc'@'localhost';
          • grant all on dyngroup.* to 'mmc'@'localhost';
          • flush privileges;
        • installation
          • cd /usr/share/doc/pulse2-common/contrib/
          • ./pulse2/sql/install.sh
          • ./msc/sql/install.sh
          • ./imaging/sql/install.sh
          • ./inventory/sql/install.sh
          • ./dyngroup/sql/install.sh
    • usage

FLUTE

DSM-CC

  • redbutton
    • Installation
      • urpmi redbutton-download redbutton-browser
    • Compilation
      • Compiling and using MHEG Engine Redbutton
      • rb-download
        • urpmi zlib1-devel
        • get it (one of the following):
          • svn checkout https://redbutton.svn.sourceforge.net/svnroot/redbutton/redbutton-download/trunk/ redbutton-download
          • wget http://sourceforge.net/projects/redbutton/files/current/redbutton-download-20090727.tar.gz
        • make
        • usage:
          • you need a channels.conf file correctly generated. The last field in each line corresponds to the service_id
          • dvbtune -f 658000 -qam 64 -gi 4 -cr AUTO -bw 8 -tm 8 && rb-download -vv
          • dvbtune -f 818000 -qam 64 -gi 4 -cr AUTO -bw 8 -tm 8 && rb-download -vv -c 35490 (TVE La1)
          • dvbtune -f 650000 -qam 64 -gi 32 -cr AUTO -bw 8 -tm 8 && rb-download -vv [-c carousel_id] service_id
          • ...
      • rb-browser
        • urpmi libexpat1-devel libfreetype6-devel libffmpeg-devel libxrender1-devel libxft-devel libpng-devel
        • get it:
          • svn checkout https://redbutton.svn.sourceforge.net/svnroot/redbutton/redbutton-browser/trunk/ redbutton-browser
        • make

dvbsnoop

  • Compilació / Compilation
    • Get the source:
      • ...
    • Get and apply patches
    • Compile

Diccionaris per a Netscape

  • Aquests són alguns diccionaris:
  • Linux: poseu-los a /usr/lib/netscape/spell
  • MS Windows: poseu-los a ...\Netscape\Communicator\Program\SpellChk\

Diccionaris per a ispell

  1. Obteniu els diccionaris (de català: ispell-ca, Softcatalà)
  2. Modifiqueu [/usr/share/emacs/20.7/lisp/]ispell.el per a afegir el català i compilar-lo (menú Emacs-Lisp/Byte-compile this file) Amb això ens funcionarà ispell-change-disctionary (accessible també des del menú Edit/Spell/Change dictionary)
  3. Modifiqueu [/usr/share/emacs/20.7/lisp/]loaddefs.el per a afegir el català i compilar-lo (menú Emacs-Lisp/Byte-compile this file) Amb això funcionarà el menú Edit/Spell/Select Catala.

Internacionalització de Netscape

Per a tenir el Netscape internacionalitzat des de UNIX us heu d'instal·lar:
  1. netscape-communicator
  2. (algun netscape-llengua)
Després establiu la variable d'entorn LANG al valor desitjat:
  • ca -> català
  • es -> castellà
I el netscape se us engegarà en aquella llengua.

Diccionari català per a MS Word

Descarregueu-vos aquest fitxer i seguiu les instruccions del fitxer HTML:

Defunció del ratolí en Linux

Si el ratolí se us ha mort mentre utilitzàveu Linux, proveu el següent:
  1. CTRL+ALT+F1 per anar a una sessió de text.
  2. Mogueu el ratolí i veureu el cursor (quadrat blanc) que belluga.
  3. CTRL+ALT+F7 per a tornar allà on éreu. El ratolí hauria d'anar bé.

Ratolí estrany en MSWindows 2000 sota VMWare

  • Dins de MSWindows: mireu si teniu dues petites icones a baix a la dreta que siguin "VMWare tools". Elimineu la que té el martellet i deixeu la del logotip de VMWare.
  • Més informació a vmware.for-linux.configuration: Jumpy mouse

CVS

  • server (computer_name)
    • urpmi cvs xinetd
    • cvs -d /usr/local/cvsroot/repository_name init
    • chown cvs.cvs /usr/local/cvsroot
    • sticky group (els nous fitxers i directoris es crearan amb el grup cvs / new files and directories are created as group cvs): 
      • chmod 2775 /usr/local/cvsroot
    • edit/etc/cvs/cvs.conf:
      • CVS_REPOS="/usr/local/cvsroot/repository_name"
    • start cvspserver (as root): 
      • (urpmi xinetd)
      • chkconfig cvs on
      • service xinetd restart
    • tallafoc / firewall:
      • mcc:
        • 2401/tcp
    • client: cvs -d :pserver:usuari@computer_name:/usr/local/cvsroot/repository_name login
  • Per a fer servir el WinCVS:
    • La primera vegada
      • CVSROOT -> :pserver:username@dev.isoco.com:/usr/local/cvs-repository
      • Identification: password on CVS server
      • Admin / Login
      • Create / Checkout del projecte que ens interessa:
        • Local directory: BackOfficeCVS (o un altre qualsevol)
        • CVS directory: BackOfficeRepository
      • Globals / read-only deshabilitada
    • Les altres vegades
      • per a pujar un fitxer que hem modificat: commit
      • per a baixar-nos l'última versió que hi ha al CVS: update
  • Si els fitxers es pugen per primera vegada al CVS en mode binary es baixaran com a tals quan es faci checkout o update.
  • L'inconvenient de fer-ho en binari és que si es modifica localment una versió més antiga que la que hi havia al CVS, no es fa el merge automàticament quan es puja.
  • Les combinacions text/binary són:
    PC local (commit) CVS (update) PC local fitxer final
    paraula^M -(bin)-> paraula^M -(-kb)-> paraula^M PC



    -(-ko)-> paraula^M^M Netscape
    paraula^M -(text)-> paraula -(-kb)-> paraula UNIX



    -(-ko)-> paraula^M PC
  • Per a eliminar "-kb" d'un fitxer (*):
    • cvs admin -kkv toto.txt
    • cvs update -A toto.txt (des de lincvs: "Treure opcions locals (-kx")
  • Per a eliminar "-kb" de tots els fitxers d'un directori (*):
    • find . -type f -maxdepth 1 -print | xargs -n1 cvs admin -kkv
    • find. -type f -maxdepth 1 -print | xargs -n1 cvs update -A
  • Els finals de línia es fan de les formes següents, depenent del sistema operatiu (aquesta nomenclatura és la que fa servir TextPad):
    PC ^M \r \n CR LF
    UNIX      \n    LF
    Mac ^M \r CR
    Netscape ^M^M \r \r \n CR CR LF
    CR: 0D, LF: 0A
  • Vigileu que el rellotge del vostre ordinador estigui ben configurat (GMT+1) i a l'hora. Si no, pot ser que no es detectin diferències entre els fitxers locals i els corresponents al CVS.
  • Canvi de log en un commit:
    • crear nou_log.txt amb els nous comentaris per a la versió 1.35 de fitxer.cpp (que conté uns comenatris erronis)
    • Linux:
      • cvs admin -m 1.35:"`cat nou_log.txt`" fitxer.cpp
    • Cygwin:
      • /cygdrive/c/Archivos\ de\ programa\LinCVS\cvs admin -m 1.35:"`cat nou_log.txt`" fitxer.cpp
    • MS Windows (amb text de comentari simple):
      • "c:\Archivos de programa\LinCVS\cvs.exe" admin -m 1:35:"canvis de l'actual versió" fitxer.cpp

WinCVS -> LinCVS

  • CVS/Root:
    • :pserver;username=usuari;hostname=maquina:/cvsroot -> :pserver:usuari@maquina:/cvsroot

Subversion

  • servidor (maquina)
  • Sincronització / Synchronisation
  • GUI client
    • Eclipse
    • esvn
      • File / Options / Other / Authentication / User and Password
      • ~/.qt/esvnrc
    • TortoiseSVN
  • Client
    • List of modules:
      • svn list svn://maquina/repo1 --verbose --non-interactive
      • ~/.subversion
    • Creació de directoris / Creation of directories
      • svn mkdir svn://usuari@maquina/repo1/module_name_remote/ -m "added module_name"
      • svn mkdir svn://usuari@maquina/repo1/module_name_remote/trunk/ -m "added module_name trunk"
      • svn mkdir svn://usuari@maquina/repo1/module_name_remote/tags/ -m "added module_name tags"
      • svn mkdir svn://usuari@maquina/repo1/module_name_remote/branches/ -m "added module_name branches"
      • svn mkdir svn://usuari@maquina/repo1/module_name_remote/trunk/dir1/ -m "added dir1"
    • Pujada de codi per primera vegada / First time upload
      • cd module_name_local_dir_no_svn
      • svn import . svn://host/repo1/module_name_remote/trunk/
    • Baixada de codi per primera vegada / First time download:
      • svn co svn://host/repo1/module_name_remote/trunk/ /local/dir/module_name_local
    • Estat local / Local status
      • svn status
    • Estat remot / Remote status
      • svn status -uv
    • Actualització / Update
      • svn update
    • Afegir / Add
      • svn add file1 file2 ...
      • svn delete --keep-local file1 file2 ...
      • un directori, però sense el seu contingut / a directory without its contents
        • svn add --depth=empty name_dir
    • Pujada / Commit
      • svn commit [fitxer_local] -m "comentari"
    • Diferències locals / Local differences
      • svn diff
      • svn diff | kompare -on -
      • meld .
    • Diferències remotes / Remote differences
      • svn diff -r HEAD
    • Dóna un conflicte per resolt / Mark a conflict as resolved
      • svn resolved toto.txt
    • Etiquetes / Tags
      • svn copy http://svn.example.com/repos/calc/trunk http://svn.example.com/repos/calc/tags/release-1.0 -m "Tagging the 1.0 release of the 'calc' project."
    • Propietats / Properties
      • Estableix les propietats / Set properties (*)
        • directament / directly:
          • svn propset svn:ignore dirname .
        • editant-les / editing:
          • svn propedit svn:ignore . --editor-cmd emacs
        • des de fitxer / from file:
          • svn propset svn:ignore -F file.txt .
          • on / where file.txt
            • dir1
              dir2
      • Unset
        • svn pdel svn:ignore .
      • Get properties
        • svn proplist
        • svn propget svn:ignore
      • List of properties
        • svn:ignore
        • svn:external
      • Eclipse
    • Remote dump:
      • svnrdump (v>=1.7)
        • urpmi subversion-tools
      • rsvndump
      • Creació del dump:
        • svnrdump dump http://server_name/repository_name/ > repository_name.dump
      • Recuperació del dump:
        • svnrdump load http://new_server_name/new_repository_name/ < repository_name.dump
        • Problemes / Problems:
          • svnrdump: E165006: Repository has not been enabled to accept revision propchanges;
          • Solució / Solution (*):
            • al servidor / on server (new_server_name):
              • cd /var/lib/svn/repositories
              • echo '#!/bin/sh' > new_repository_name/hooks/pre-revprop-change
              • chmod 755 new_repository_name/hooks/pre-revprop-change
    • Canvi de servidor:
      • svn sw --relocate old_url new_url
    • svn+ssh
      • NOTE: if you don't generate the pair of keys, you can use svn+ssh schema with login/password, but you need to specify the absolute path.
      • ssh-keygen -t rsa -C remoteserver_name -f ~/.ssh/id_rsa_remoteserver
      • edit file ~/.ssh/config
        • Host hostname
              HostName hostname
              User username
              IdentityFile ~/.ssh/id_rsa_remoteserver
      • chmod 600 ~/.ssh/config
      • send ~/.ssh/id_rsa_hostname.pub to hostname and put it under ~username/.ssh/authorized_keys. All this is done by simply:
        • ssh-copy-id -i .ssh/id_rsa_remoteserver.pub username@remoteserver
      • svn list svn+ssh://username@hostname/absolute_path/to/repo1
      • if you want to avoid the specification of the absolute path, edit the file on the server:
        • ~username/.ssh/authorized_keys
          • command="/path/to/svnserve -t -r /virtual/root" ssh-rsa KEY COMMENT (where /virtual/root could be, e.g. /var/lib/svn/repositories/)
        • then you can access the repository with:
          • svn list svn+ssh://username@hostname/repo1
  • cvs2svn
    • urpmi cvs2svn
    • Documentation
    • without options file
      • cvs2svn -s /var/lib/svn/repositories/repo2 --encoding latin_1 /usr/local/cvsroot/repository_name/module_name (/usr/local/cvsroot/repository_name/CVSROOT exists)
      • cvs2svn --dumpfile DUMPFILE CVSREPOS
    • with options file
        • (cd /home/cvs)
        • wget http://cvs2svn.tigris.org/source/browse/*checkout*/cvs2svn/tags/2.3.0/cvs2svn-example.options
        • cp cvs2svn-example.options your_file.options
      • your_file.options:
        • ctx.cvs_author_decoder = CVSTextDecoder(['latin1',],)
          ctx.cvs_log_decoder = CVSTextDecoder(['latin1',],)
          ctx.cvs_filename_decoder = CVSTextDecoder(['latin1',],)
        • ctx.output_option = DumpfileOutputOption(
              dumpfile_path=r'toto.dump', # Name of dumpfile to create
              )
        • run_options.add_project(
          'my/cvsrepo/project_a',
          trunk_path='project_a/trunk',
          branches_path='project_a/branches',
          tags_path='project_a/tags',
          symbol_transforms=[
          #...whatever...
          ],
          symbol_strategy_rules=[
          #...whatever...
          ] + global_symbol_strategy_rules,
          )
        • run_options.add_project(
          'my/cvsrepo/project_b',
          trunk_path='project_a/trunk/dir_b',
          branches_path='project_a/branches/dir_b',
          tags_path='project_a/tags/dir_b',
          symbol_transforms=[
          #...whatever...
          ],
          symbol_strategy_rules=[
          #...whatever...
          ] + global_symbol_strategy_rules,
          )
      • cvs2svn --options=your_file.options
    • Importar el fitxer dump.

Git

  • Problemes / Problems
    • fatal: unable to access 'https://github.com/...': Peer reports incompatible or unsupported protocol version.
      • Check if the problem is the same with curl:
        • bad response:
          • $ curl -v -I -X GET https://github.com/meetecho/janus-gateway/
            * About to connect() to github.com port 443 (#0)
            *   Trying 192.30.253.112...
            * Connected to github.com (192.30.253.112) port 443 (#0)
            * Initializing NSS with certpath: sql:/etc/pki/nssdb
            *   CAfile: /etc/pki/tls/certs/ca-bundle.crt
              CApath: none
            * NSS error -12190 (SSL_ERROR_PROTOCOL_VERSION_ALERT)
            * Peer reports incompatible or unsupported protocol version.
            * Closing connection 0
            curl: (35) Peer reports incompatible or unsupported protocol version.
        • good response:
          • $ curl -v -I -X GET https://github.com/meetecho/janus-gateway/
            * About to connect() to github.com port 443 (#0)
            *   Trying 192.30.253.112...
            * Connected to github.com (192.30.253.112) port 443 (#0)
            * Initializing NSS with certpath: sql:/etc/pki/nssdb
            *   CAfile: /etc/pki/tls/certs/ca-bundle.crt
              CApath: none
            * SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
            * Server certificate:
            *       subject: CN=github.com,O="GitHub, Inc.",L=San Francisco,ST=California,C=US,postalCode=94107,STREET="88 Colin P Kelly, Jr Street",serialNumber=5157550,incorporationState=Delaware,incorporationCountry=US,businessCategory=Private Organization
            *       start date: Mar 10 00:00:00 2016 GMT
            *       expire date: May 17 12:00:00 2018 GMT
            *       common name: github.com
            *       issuer: CN=DigiCert SHA2 Extended Validation Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US
            > GET /meetecho/janus-gateway/ HTTP/1.1
            > User-Agent: curl/7.29.0
            > Host: github.com
            > Accept: */*
            >
            < HTTP/1.1 200 OK
            ...
      • Solució / Solution
        • update nss (3.19 -> 3.28):
          • CentOS
            • sudo yum install nss
  • Pujar un projecte a un servidor central / Import a project into a central server
    • on server (user connected via ssh), create the repository:
      • $ cd /opt/git
        $ mkdir project.git
        $ cd project.git
        $ git --bare init [--shared=group]
      • shared for group members:
        • git config core.sharedRepository true
        • chgrp unix_project_group -R /opt/git/project.git/
        • find /opt/git/project.git/ -type d -exec chmod 2770 {} +
        • find /opt/git/project.git/ -type f -exec chmod660 {} +
    • on client computer with the original code:
      • $ cd myproject
        $ git init
        $ echo -e "*.pyc\n*~\n.project\n.pydevproject" > .gitignore
        $ git add .
        $ git commit -m 'initial commit'
        $ git remote add origin git@gitserver:/opt/git/project.git
        $ git push origin master
    • on other client computer:
      • $ git clone git@gitserver:/opt/git/project.git
        $ cd project
        $ vim README
        $ git commit -am 'fix for the README file'
        $ git push origin master
  • backup

    • config copied all branches to local working branch usable as local (working) git usable as origin git sync with original size typical usage
      git clone remote_repo_url.git local_repo [core]
              repositoryformatversion = 0
              filemode = true
              bare = false
              logallrefupdates = true
      [remote "origin"]
              url = remote_repo_url.git
              fetch = +refs/heads/*:refs/remotes/origin/*
      [branch "master"]
              remote = origin
              merge = refs/heads/master
      all refs (?) master (HEAD) yes
      git fetch size of repo (.git) + size of working branch
      working developer
      git clone --bare remote_repo_url.git local_repo.git [core]
              repositoryformatversion = 0
              filemode = true
              bare = true
      [remote "origin"]
              url = remote_repo_url.git
      all refs

      no
      yes, but not in sync with the original one
      (not possible)
      size of repo
      git clone --mirror remote_repo_url.git local_repo [core]
              repositoryformatversion = 0
              filemode = true
              bare = true
      [remote "origin"]
              url = remote_repo_url
              fetch = +refs/*:refs/*
              mirror = true
      all refs

      no
      when up to date, identical to the original one
      • git remote update
      • git --git-dir project.git remote update
      size of repo to copy an entire repo to a new git server
      git bundle create local_bundle_file --all


      no
      no -
      size of repo create a single file from a local git repo (--all: backup)
      git copy







    • ...
    • Backup a GitHub repository
    • Git Repository Backup
    • Fully backup a git repo?
    • What's the difference between git clone --mirror and git clone --bare
    • git bundle
      • create a bundle file (--all: with all heads) from inside a local git repo
        • git bundle create reponame.bundle --all
      • incremental
        • (see: man git bundle)
      • inspect:
        • git bundle list-heads reponame.bundle
      • regenerate a git repo from a bundle file:
        • git clone [-b master] reponame.bundle reponame_from_bundle
        • git clone --bare reponame.bundle reponame_from_bundle
    • git clone --mirror
      • ...
    • Passos / Steps
      • from a computer with access to the origin git
        • first time: create a mirror and a bundle file from it
          • git clone --mirror git@some.origin/reponame.git /path/to/reponame.git
          • cd /path/to/reponame.git
          • git bundle create /path/to/backups/reponame.bundle --all
        • next times (periodically): update the mirror and create a bundle file from it
          • git --git-dir /path/to/reponame.git remote update
          • cd /path/to/reponame.git
          • git bundle create /path/to/backups/reponame.bundle --all
  • bare
  • pujar des de local a servidor remot (p.ex. GitLab)
    • Git global setup:
      • git config --global user.name "My Name"
      • git config --global user.email "myusername@toto.org"
    • Create a new repository:
      • git clone git@gitlab.com:mygroup/myproject.git
      • cd myproject
      • touch README.md
      • git add README.md
      • git commit -m "add README"
      • git push -u origin master
    • Push an existing folder:
      • cd existing_folder
      • git init
      • git remote add origin git@gitlab.com:mygroup/myproject.git
      • git add .
      • git commit -m "Initial commit"
      • git push -u origin master
    • Push an existing Git repository:
      • cd existing_repo
      • git remote rename origin old-origin
      • git remote add origin git@gitlab.com:mygroup/myproject.git
      • git push -u origin --all
      • git push -u origin --tags
  • GitHub / GitLab
  • GUI
  • info
    • git status
      • do not show untracked files:
        • git status -uno
    • git remote -v
      • project_name=$(git remote -v | head -n1 | awk '{print $2}' | sed -e 's,.*:\(.*/\)\?,,' -e 's/\.git$//')
    • git remote show [remote-name]
    • git show
      • git describe --tags --long --abbrev=7 | xargs git show -s --format=format:"%C(yellow)%h|%C(red)%ai|%C(blue)%an|%C(green)%d %C(reset)%s"
      • git describe --tags --long --abbrev=7 | xargs git show -s --format=format:"%h | %ai | %an | %d %s"
      • git_date=$(git describe --tags --long --abbrev=7 | xargs git show -s --format=format:"%aI")
    • git show-ref
    • git describe
      • git describe --tags --long --abbrev=7
    • git branch -a
      • git_branch=$(git branch | grep \* | awk '{print $2}' | tr -d '(')
    • git log
      • options
        • --oneline: one line per commit
        • --decorate: add HEAD, branch, tag information
        • --graph: print as a graph
        • --all: print all commits (not only until HEAD)
      • examples
        • logs until HEAD:
          • git log --oneline --decorate --graph
          • git log --pretty=oneline
        • all logs:
          • git log --oneline --decorate --graph --all
        • with dates and authors:
          • git log --pretty=format:'%C(yellow)%h|%C(red)%ad|%C(blue)%an|%C(green)%d %C(reset)%s' --date=short --graph --all
    • git reflog
    • Inclusió de la informació del git en el codi font / Include git info in source files:
    • list files
    • git blame <filename>
      • show who modified lines in filename
    • git bisect
      • Use binary search to find the commit that introduced a bug
  • Change log
  • build a local repository (fetch) and a working copy (...) from a remote repository:
    • git clone [--depth=...] nom_usuari@origin_server:/full/path/to/repository.git
    • git clone [--depth=...] nom_usuari@origin_server:/full/path/to/repository.git <local_repository_name>
    • des d'un git en un altre directori local:
      • git clone /full/path/to/repository.git
      • git clone /full/path/to/repository
    • branca específica (branch_name) en un directori diferent (repository-branch_name):
      • git clone -b branch_name nom_usuari@origin_server:/full/path/to/repository.git repository-branch_name
    • Problemes / Problems
      • fatal: '/home/git/toto.git' does not appear to be a git repository
        fatal: The remote end hung up unexpectedly
        • Solució / Solution
          • make sure that user/group has the right permissions for all the subdirectories. For instance, if all the users from a given group must have write access to the origin repository:
            • chmod g+wX -R /home/git/toto.git
    • only a specific directory (dir_in_project) inside a project:
      • git init ~/my_dir
      • cd ~/my_dir
      • git remote add -m branch_name origin https://github.com/user/project.git
      • git config core.sparsecheckout true
      • echo dir_in_project >> .git/info/sparse-checkout
      • git pull origin branch_name
      • git checkout branch_name
  • commit to local repository
    • option 1:
      1. add selected modified files to stage:
        • git add fitxer1 fitxer2
      2. commit files that are on stage:
        • git commit -m "comentari"
    • option 2:
      1. add all modified files to satge ans commit them in a single step:
        • git commit -a -m "comentari"
    • modify comment:
  • diferències / differences
    • entre les modificacions locals i el repositori (per exemple, abans de fer l'add) / between local modifications and repo (e.g. before making add)
      • git diff toto_file | kompare -
      • git difftool -d -t kompare
      • git difftool -d -t meld
    • entre dues branques / between two branches:
    • entre dues versions del mateix fitxer:
    • entre dues version de dos fitxers diferents:
      • git diff <revision_1>:<file_1> <revision_2>:<file_2>
      • git difftool revision_1:file_1 revision_2:file_2
  • sync with remote
    • 3.5 Git Branching - Remote Branches
    • Syncing a fork (GitHub)
    • How to keep two Git repositories in sync
      • setup
        • if your primary_repo is not bare, you may want to checkout every remote branch to convert them to local
        • git clone --mirror https://primary_repo_url/primary_repo.git
        • cd primary_repo.git
        • git remote add --mirror=fetch secondary https://secondary_repo_url/secondary_repo.git
      • sync primary -> secondary
        • git fetch origin
        • git push secondary --all
      • sync secondary -> primary
        • git fetch secondary
        • git push origin
      • sync primary <-> secondary
        • mkdir ../workdir
        • git fetch origin
        • git --work-tree=../workdir/ checkout branch_name file_name1
        • git fetch secondary
        • git --work-tree=../workdir/ checkout branch_name file_name2
        • git push secondary
        • git push origin
    • show the remotes:
      • git remote -v
    • remove the remote "origin"
      • git remote remove origin
      • git remote remove <remote_name>
    • add a new remote (default to "origin"):
      • git remote add origin remote_user@remote_server.org:/home/user/toto.git
      • git remote add <remote_name> remote_user@remote_server.org:/home/user/toto.git
    • check remote changes:
    • get the remote (default to "origin") changes into the local repository (e.g. to get new branches), without merging:
      • git fetch
      • git fetch <remote_name>
      • all remotes:
        • git fetch --all
    • pull (= git fetch + git merge FETCH_HEAD) the remote changes to local repository:
    • discard local changes
    • push the local repository to a remote (default to "origin"):
      • git push
      • git push <remote_name>
      • push only a branch
        • git push origin +<branch_name>
        • git push <remote_name> <branch>
        • git push <remote_name> <local_branch>:<remote_branch>
      • replace a remote branch by local version of the branch (e.g. after a squash)
        • git push --force origin <branch_name>
        • alternative:
          • git push origin :<branch_name> # to delete remote branch
          • git push origin <branch_name> # to push the local branch
    • Problemes / Problems
  • change the remote origin (e.g. to GitLab):
    • git remote -v
    • git remote remove origin
    • git remote add origin git@gitlab.com:<your_group>/<your_project>.git
    • git branch --set-upstream-to=origin/master master
    • git pull
  • get a given branch or commit
    • git checkout master
    • git checkout remotes/git-svn
    • git checkout c8a1
  • ignore
    • gitignore
    • gitignore.io (create .gitignore file for a lot of languages/frameworks)
    • user
      • $HOME/.config/git/ignore
    • repository
      • .gitignore
    • exemples / examples:
      • *.pyc
  • submodules
  • revert / reset
    • revert will add new commits
    • reset will not add new commits
    • Undo commit
      • not pushed yet (all local commits will be discarded):
        • git reset --hard origin/<branch_name>
      • already pushed:
        • git revert ...
        • only last commit:
          • git revert HEAD
          • git push
        • last two commits:
          • git revert HEAD~1
          • git push
        • ...
    • Undoing Merges
      • local:
        • git reset --hard <hash_of_commit_previous_to_merge>
      • local and remote:
        • git revert -m 1 <hash_of_merge_commit>
        • redo merge
          • git revert <hash_of_first_revert>
    • Rolling back changes with revert
    • reset remote branch
      • to the same commit as in local
        • Resetting remote to a certain commit
        • steps
          • you may need to temporarily configure repo to accept forced push:
            • GitLab
              • Settings -> Repository -> Protected Branches
                • master: Allowed to force push
          • then, from local at the commit of your branch (e.g. master) you want the remote (e.g. origin) to be reset to:
            • git push --force origin <commit_sha>:master
  • branch
    • Git - Branches in a nutshell
    • clone a given branch
      • git clone -b branch_name nom_usuari@origin_server:/full/path/to/repository.git repository-branch_name
    • list all local branches
      • git branch
    • list all available (local and remote) branches
      • git branch -a
      • sort by date
        • git branch -v --sort=committerdate
        • git branch -a -v --sort=committerdate --no-merged
        • git for-each-ref --sort=-committerdate refs/heads/
    • get current branch
      • git rev-parse --abbrev-ref HEAD
      • git symbolic-ref --short HEAD
    • branch management
      • git branch
      • git branch -v
      • git branch --merged
      • git branch --no-merged
      • git branch -v --sort=committerdate --no-merged
    • create a new branch:
      • git branch <branch_name>
    • switch to the new branch:
      • git checkout <branch_name>
    • create a new branch and switch to it:
      • git checkout -b <branch_name>
    • create a local branch based on a remote one (a previous fetch was done) and switch to it:
      • git checkout <branch_name>
      • git checkout --track <remote_name>/<branch_name>
      • git checkout -b <local_branch_name> <remote_name>/<remote_branch_name>
    • rename a local branch (*)
      • git branch -m <old_branch_name> <new_branch_name>
    • rename a remote branch (*)
      • git branch -m <old_branch_name> <new_branch_name>
      • git push origin :<old_branch_name>
      • git push --set-upstream origin <new_branch_name>
      • other users:
        • git fetch origin --prune
    • upstream (connect to/track a remote branch)
      • set the upstream:
        • git branch -u <remote_name>/<remote_branch_name>
        • git branch --set-upstream-to=<remote_name>/<remote_branch_name>
      • get the upstream:
        • git branch -vv
      • delete the upstream:
        • git ...
    • push a local branch
      • git push origin <branch_name>
      • undo a push (recently done)
        • git reset --hard HEAD~1
        • git push --force
    • get new branches from origin
      • git fetch
    • merge master into your branch
      • git checkout <branch_name>
      • git merge --no-ff master
      • Abort merge
        • git reset --merge
    • merge your branch into master
      • git checkout master
      • git merge --no-ff <branch_name>
    • discard local merge, not pushed yet
    • dry-run merge (Is there a git-merge --dry-run option?)
      1. git merge --no-commit --no-ff <branch_name>
      2. git status -uno
      3. git merge --abort
    • revert / undo a merge
    • conflicts
      • solve conflicts
        • manually, or
        • git mergetool
      • git add <file_with_resolved_conflicts>
      • git status
      • git commit -m ...
    • delete branch
      • git branch -d <branch_name>
      • to force deletion:
        • git branch -D <branch_name>
      • delete branch in origin
    • rebase branch (sense canviar-ne el nom / without changing name)
      • git checkout my_branch
      • git rebase master
      • git push --force-with-lease origin my_branch
      • other users should remove their local versions of the branch and checkout the rebased one:
        • git branch -D my_branch
        • git fetch
        • git checkout my_branch
    • rebase branch (canviant-ne el nom / changing name)
      • git checkout my_branch
      • git rebase master
      • git branch -m my_branch my_branch_rebased
      • git branch --unset-upstream my_branch_rebased
      • git push --set-upstream origin my_branch_rebased
      • other users
        • git fetch origin --prune
  • squash
  • tag
    • Git - Tagging
    • Semantic versioning 2.0.0
    • crea una etiqueta / create a tag:
      • git tag -a nom_tag [-m "my comments"]
      • lightweight
        • git tag lw_nom_tag
      • git push origin nom_tag
    • etiqueta un commit anterior / tag a previous commit:
      • git log --pretty=oneline
        • 9fceb02...
      • git tag -a v1.2 9fceb02
    • llista d'etiquetes / list of tags:
      • git tag
      • amb els comentaris:
        • git tag -n
    • detalls sobre una etiqueta / details about a tag
      • git show nom_tag
    • puja a origin
      • una etiqueta
        • git push origin nom_tag
      • totes les etiquetes
        • git push origin --tags
    • afegeix un comentari a una etiqueta existent / add a comment to an existing tag:
      • git tag -f existing_tag existing_tag -m "my comments"
    • esborra una etiqueta / delete a tag:
      • local
        • git tag -d old_tag
      • origin
        • git push --delete origin old_tag
    • reanomena una etiqueta / rename old_tag -> new_tag:
      • git tag new_tag old_tag
      • git tag -d old_tag
      • git push origin new_tag
    • get
  • cherry-pick
    • Aplicar un commit a otra rama con git cherry-pick
    • apply changes from a hotfix to preproduction branch:
      1. git checkout branch_with_hotfix
      2. git log --pretty=oneline
        • note the commit_id of the commit you want to apply to preproduction branch
      3. git checkout preproduction
      4. git cherry-pick <commit_id>
  • patch
    • 5.3 Distributed Git - Maintaining a Project
    • Option 1: to be applied with classical patch
      • Creació / Creation
        • git diff -p v1.0.0 >0001.patch
      • Aplicació / Application
        • patch -p1 <0001.patch
    • Option 2: to be applied to a git repo
      • Creació / Creation
        • diferències entre el git local (amb els commits fets) i l'origin:
      • Aplicació / Application
        • git apply 0001-toto-description.patch
        • git am ...
      • Desfer l'aplicació / Undo application
        • git apply -R 0001-toto-description.patch
  • archive
  • git - svn
    • 9.1 Git and Other Systems - Git as a Client
    • Git and Subversion
    • git-svn(1)
    • Howto Use Git and Svn Together
    • git-svn tutorial
    • Git Diff between HEAD and SVN Master
    • Bitbucket
    • Exemples / Examples
      • rèplica de tot el repositori (s'hi pot estar una bona estona):
        • git svn clone svn://svn.code.sf.net/p/gpac/code/ [-T trunk -b branches -t tags] [local_name]
        • you can replace "-T trunk -b branches -t tags" by the equivalent, shorter one "-s"
        • només una part de la història:
          • git svn clone -s -r 4000:HEAD svn://svn.code.sf.net/p/gpac/code/
      • baixa només la darrera versió de trunk:
        • primera vegada / first time
          • cd /path/to/; mkdir gpac; cd gpac
          • git svn init svn://svn.code.sf.net/p/gpac/code/trunk/gpac
          • git svn fetch -rHEAD (or specific revision, obtained with "svn log svn://svn.code.sf.net/p/gpac/code/trunk/gpac")
          • git svn clone -rHEAD svn://svn.code.sf.net/p/gpac/code/trunk/gpac
          • or a range of revisions (from r4000 to HEAD)
            • git svn clone -r 4000:HEAD svn://svn.code.sf.net/p/gpac/code/trunk/gpac
      • actualitza el git a partir de l'svn / update git from svn:
        • git svn rebase
      • des d'un altre ordinador, sincronitza cap a aquest nou git creat / attach another client computer to this newly created git
        • git clone user@server:/path/to/gpac.git
        • o bé, des del matiex ordinador, en un altre directori / or, from the same computer, on another directory:
          • git clone /path/to/gpac/
      • a l'ordinador que sincronitza l'svn, mira les diferències que hi ha entre el git local (master) (amb els commits fets) i la versió que s'ha baixat de l'svn remot (remotes/git-svn):
        • comprova les branques existents
          • git branch -a
        • git diff remotes/git-svn..
        • crea un patch amb aquestes diferències:
          • git format-patch remotes/git-svn
    • Migració / Migration svn -> git
      • 8.2 Git and Other Systems - Migrating to Git
      • Passos / Steps
        1. Optional: get the authors from svn history, and edit the resulting users.txt file:
          • svn log --xml | grep -P "^<author" | sort -u | perl -pe 's/<author>(.*?)<\/author>/$1 = /' > users.txt
        2. Clone the remote svn to a local git (as before):
          • git svn clone svn://server/remote_project_name [--authors-file=users.txt] --no-metadata local_project_name
        3. post-import cleanup (for branches and tags)
          • ...
        4. Add a remote server:
          • git remote add origin your_login_name@remote_git_server:/path/to/project_name.git
        5. On the remote server, create the repository
        6. from your local computer push to it:
          • git push origin --all

Grafana

  • Instal·lació / Installation
    • Dependències / Dependencies
      • Mageia
        • urpmi ...
    • Get Grafana
      • tar
        • wget https://dl.grafana.com/oss/release/grafana-6.5.3.linux-amd64.tar.gz
        • tar -zxvf grafana-6.5.3.linux-amd64.tar.gz
      • rpm
        • wget https://dl.grafana.com/oss/release/grafana-6.5.3-1.x86_64.rpm
        • Mageia (not working: needs freetype)
          • urpmi grafana-6.5.3-1.x86_64.rpm
        • ...
    • Start server
      • sudo ...grafana-6.5.3/bin/grafana-server
  • Ús / Usage
    • http://localhost:3000/
    • admin / admin (només la primera vegada / only the first time)
    • Data Source Dashboard

      InfluxDB
      • URL: http://localhost:8086
      • Database: home_db
      Query: InfluxDB
      • A
        • FROM default temperature WHERE machine = unit42
        • SELECT field(external) mean()
        • GROUP BY time($_interval) fill(null)
        • FORMAT AS Time series
        • ALIAS BY unit42_external
      • B
        • FROM default temperature WHERE machine = unit42
        • SELECT field(internal) mean()
        • GROUP BY time($_interval) fill(null)
        • FORMAT AS Time series
        • ALIAS BY unit42_internal


      InfluxDB
      • URL: http://localhost:8086
      • Database: sensors



Calendaris / Calendars

apropos

  • makewhatis

Matlab

  • gcf = figure( 'Position', [0 0 mida_x mida_y] );
    ...
    axis( [0 255 0 Inf] );
    set( gcf, 'PaperPositionMode', 'auto' );
    print( '-r72', '-dtiff', 'toto.tif' );

C / C++

  • Temps / Time
    • include <time.h>
    • time_t tHoraActualUTC;
    • time( &tHoraActualUTC ); // get present time
-> time_t tm str
time_t
(sec from 1 jan 1970)
- gmtime
localtime ctime
tm
(struct)
timegm (gnu c)
_mkgmtime (ms visual)
- asctime
mktime (ansi)
timelocal (gnu c)

str
getdate
strptime
strftime
-

NO fa la conversió a hora local
fa la conversió a hora local

Cygwin

Postfix (servidor de correu / email server)

  • Instal·lació / Installation
    • CentOS
      • sudo yum install postfix
  • Configuració / Configuration
    • MSA
      Mail Submission Agent
      MTA
      Mail Transfer Agent
      MDA
      Mail Delivery Agent
      Postfix smtpd (server) Postfix smtpd (SMTP server: receiving)
      Postfix smtp (SMTP+LMTP client: sending) dovecot, cyrus
      /etc/postfix/master.cf
      /etc/postfix/main.cf
      (sudo postconf -e ...)
      /etc/postfix/main.cf
      (sudo postconf -e ...)

      Enable port 587:
      • submission inet n       -       n       -       -       smtpd
          -o syslog_name=postfix/submission
          -o smtpd_tls_security_level=encrypt
          -o smtpd_sasl_auth_enable=yes
          -o smtpd_reject_unlisted_recipient=no
          -o smtpd_client_restrictions=$mua_client_restrictions
          -o smtpd_helo_restrictions=$mua_helo_restrictions
          -o smtpd_sender_restrictions=$mua_sender_restrictions
          -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
          -o milter_macro_daemon_name=ORIGINATING
      • # network interfaces that listen
        inet_interfaces
        = localhost, 192.168.1.100
      • # trusted networks that can send messages
        mynetworks = 192.168.1.0/24, 127.0.0.0/8
      • # domain name for this email server
        mydomain = example.org
      • # host name of the system
        myhostname = mail.example.org
      • # domain for locally-posted email
        myorigin = $mydomain
      • # this server is destination for emails with this domain
        mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
      • # destination domains this server can relay to
        relay_domains =
      • home_mailbox = Maildir/


      SASL: cyrus
      • ...
      SASL: dovecot
      • smtpd_sasl_auth_enable = yes
      • broken_sasl_auth_clients = yes
      • smtpd_sasl_type = dovecot
      • smtpd_sasl_path = private/auth
      • smtpd_sasl_security_options = noanonymous
      • smtpd_sasl_local_domain =
      • smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
      SASL (when relaying: connection to a remote STMP for submission):
      • smtp_sasl_auth_enable = yes
      • smtp_tls_security_level = encrypt
      • smtp_sasl_tls_security_options = noanonymous
      • relayhost = [mail.isp.example]
        # Alternative form:
        # relayhost = [mail.isp.example]:submission
      • smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd


      certificates (server):
      • self signed test certificates (including key) can be created with OpenSSL: "cd /etc/postfix/; make -f /etc/pki/tls/certs/Makefile mail.example.org.pem"
        • smtpd_tls_cert_file = /etc/postfix/mail.example.org.pem
        • smtpd_tls_key_file = $smtpd_tls_cert_file
      • Let's Encrypt certificates:
        • smtpd_tls_cert_file = /etc/letsencrypt/live/mail.example.org/fullchain.pem
        • smtpd_tls_key_file = /etc/letsencrypt/live/mail.example.org/privkey.pem
      STARTTLS:
      • smtpd_tls_security_level = may
      TLS (server):
      • smtpd_use_tls = yes
      • smtpd_tls_loglevel = 1
      • smtpd_tls_received_header = yes
      • #smtpd_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
      • smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination

      TLS (client) (connection to destination MTA; e.g. if not secure, Gmail will mark message as non secure):
      • smtp_use_tls (obsolete since Postfix 2.3)
      • smtp_tls_security_level = may
      • smtp_tls_note_starttls_offer = yes
      • smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt # see also: ca-root-nss.crt



      Virtual maps
      • virtual_alias_domains = $mydomain
      • virtual_alias_maps = hash:/etc/postfix/virtual



      /etc/postfix/virtual
      • postmaster@example.org root
        root@example.org root
        info@exampe.org info
      • sudo postmap /etc/postfix/virtual

    • Postfix Standard Configuration Examples
    • Test configuration
      • postconf
    • Django + Postfix
    • Postfix rate limiting – Politeness goes a long way
    • CentOS 5
    • Port
      • Enable port 587 (submission), that will enable STARTTLS on 250 responses to EHLO request
        • /etc/postfix/master.cf
          • submission inet n       -       n       -       -       smtpd
              -o syslog_name=postfix/submission
              -o smtpd_tls_security_level=encrypt
              -o smtpd_sasl_auth_enable=yes
              -o smtpd_reject_unlisted_recipient=no
              -o smtpd_client_restrictions=$mua_client_restrictions
              -o smtpd_helo_restrictions=$mua_helo_restrictions
              -o smtpd_sender_restrictions=$mua_sender_restrictions
              -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
              -o milter_macro_daemon_name=ORIGINATING
    • Seguretat / Security
      • Info
      • Let's Encrypt
      • STARTTLS
        • Problemes / Problems
          • warning: TLS library problem: 5294:error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol:s23_srvr.c:647:
            • Solució / Solution
              • telnet/nc does not allow sending non-encrypted text once STARTTLS has been invoked
              • use openssl s_client instead
      • Autenticació / Authentication
        • SASL - Simple Authentication and Security Layer
          • Postfix SASL Howto
          • supported SASL implementations:
            • postconf -a
          • Cyrus SASL
            • Instal·lació / Installation
              • CentOS
                • sudo yum install cyrus-sasl
                • systemctl enable saslauthd.service
                • systemctl start saslauthd.service
          • Dovecot SASL
            • Instal·lació / Installation
            • Configuració / Configuration
              • Basic configuration
                • Authentication (users and passwords)
                  • Example from real user, with password stored as plain text (do not use it in real deployments):
                    • $ echo "$USER:{PLAIN}password:$UID:$(id -g)::$HOME" > users
                    • sudo mv users /etc/dovecot/
                  • Add non-system users with encrypted passwords
                    • Password Schemes (How To Safely Store A Password)
                    • check availability of encryption schemes:
                      • doveadm pw -l
                    • encrypt with SHA256-CRYPT:
                      • $ doveadm pw -s SHA256-CRYPT -p my_password
                        {SHA512-CRYPT}$6$...
                    • echo "$USER:{SHA512-CRYPT}$6$...:$UID:$(id -g)::$HOME" > /etc/dovecot/users
                  • sudo chown root.root /etc/dovecot/users; sudo chmod 600 /etc/dovecot/users
                  • /etc/dovecot/conf.d/10-auth.conf
                    • # Remove '#' to use passwd-file:
                      !include auth-passwdfile.conf.ext
                  • check:
                    • doveconf -n passdb userdb
              • /etc/dovecot/conf.d/10-master.conf (or under directory included by file specified when running: doveconf -n | head -n1)
                • service auth {
                  ...
                  # Postfix smtp-auth
                  unix_listener /var/spool/postfix/private/auth {
                  mode = 0660
                  # Assuming the default Postfix user and group
                  user = postfix
                  group = postfix
                  }
                  ...
                  }

                  # Outlook Express and Windows Mail works only with LOGIN mechanism, not the standard PLAIN:
                  auth_mechanisms = plain login
            • Prova / Test
              • Testing SASL authentication in the Postfix SMTP Server (postfix.org)
              • encode username and password in base64 (if password starts with a digit, and bash version >=2.3, check that you are using four zeros):
                • $ echo -ne '\0000username\0000password' | base64 <username_and_password_in_base64>
                • check decoding:
                  • $ echo -ne <username_and_password_in_base64> | base64 -d usernamepassword
              • $ openssl s_client -connect mail.example.org:587 -starttls smtp
                ...
                250 DSN
                AUTH PLAIN <username_and_password_in_base64>
              • Problemes / Problems
                • dovecot: auth-worker(5017): Error: passwd-file: open(/etc/dovecot/users) failed: Permission denied
    • non-relayed (local Postfix acts as a server: smtpd_...)
      • (feu servir el fitxer /etc/postfix/main.cf predeterminat / use the default /etc/postfix/main.cf file)
      • el camp "from" es crearà a partir de:
        • `whoami`@`hostname`
      • seguretat / security
      • usuaris / users
      • accessible des de fora / accessible from outside
        • inet_interfaces = ...
    • relayed (local Postfix acts as a client: smtp_...)
    • Debug
      • telnet localhost 25
        • 220 hostname.local ESMTP Postfix
      • mailq
      • /var/log/maillog
  • Client

Dovecot (servidor IMAP)

MySQL / MariaDB

  • Instal·lació / Iinstallation
    • Mageia
      • urpmi mysql mysql-MariaDB
      • # urpmi mariadb
    • Ubuntu
    • CentOS
      • yum install mariadb-server
    • # TMPDIR=/var/tmp mysql_install_db
    • # chmod 755 -R /var/lib/mysql
    • check that:
      • installation is ok (no errors about mysql user or group)
    • start the service
      • Mageia
        • systemctl enable mysqld.service
        • systemctl start mysqld.service
        • old way
          • service mysqld start
      • Ubuntu
        • sudo service mysql start
      • CentOS
        • systemctl enable mariadb.service
        • systemctl start mariadb.service
    • (cal?) # mysql_upgrade
    • check that it is working:
      • mysql [-h localhost -u root]
      • Note: "mysql -h 127.0.0.1 -u root" will not work
    • Establiu la contrasenya de root / Set the root password
    • Problemes / Problems
      • només s'hi pot connectar des de superusuari. Des d'usuari, apareix l'error "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)"
        • Solució / Solution:
          • # chmod 755 -R /var/lib/mysql
  • Set the root password (How to reset the root password) by using one of the following methods:
    1. mysql_secure_installation
    2. Command line (recommended by MariaDB after running mysql_install_db):
      • # /usr/bin/mysqladmin -u root password ['new-password']
      • # /usr/bin/mysqladmin -u root -p -h localhost password ['new-password']
      • # service mysqld restart
      • Check that it is working when logged as a regular user:
        • $ mysql -u root -p
    3. Use mysql-workbench
    4. Use mysql-administrator
    5. $ mysql -u root
      • mysql> UPDATE mysql.user SET password = password('new_password') WHERE user = 'root';
        mysql> FLUSH PRIVILEGES;
  • Afegir usuaris / Add users
    • Adding users
    • mysql -u root -p -h localhost mysql
      • CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
    • Creació d'una base de dades i un usuari:
      • mysql -u root -p -h localhost
        • CREATE DATABASE IF NOT EXISTS toto_db;
          GRANT ALL ON toto_db.* TO 'usuari'@'localhost' IDENTIFIED BY 'contrasenya';
          FLUSH PRIVILEGES;
          exit;
        • CREATE DATABASE IF NOT EXISTS toto_db;
          GRANT ALL ON toto_db.* TO 'usuari'@'%' IDENTIFIED BY 'contrasenya';
          FLUSH PRIVILEGES;
          exit;
  • Bolcat des d'un fitxer / Dump from file
  • Execució de comandes SQL en línia (o des d'un script) / Execution of on-lin SQL commands (or inside a script):
    • How to feed mysql queries from bash
    • Opció 1: using EOF:
      • mysql -u root -p mysql <<EOF
        CREATE USER 'usuari'@'localhost' IDENTIFIED BY 'contrasenya';
        EOF
      • mysql -u root -p > toto.txt <<EOF
        use toto_db;
        select * from toto_table;
        EOF
    • Opció 2: auxiliary file
      • mysql --host=localhost --user=user --password=password [database_name] < commands.sql
    • Opcions / Options
      • -s / --silent
      • -N / --skip-column-names
  • Time Zone Tables
  • Admin (GUI)
    • mysql-workbench
      • urpmi mysql-workbench
      • Set the root password:
        • New connection:
          • Connection Name: your_label
          • Connection Method: Local Socket/Pipe
          • Socket/Pipe Path: (leave empty)
          • Username: root
          • Password / Store in Keychain...: your_password
          • Default Schema: (leave empty)
      • Problemes / Problems
        • "pure virtual method called"
          • Solution:
            • ...
    • phpMyAdmin
    • mysql-administrator
      • urpmi mysql-administrator
      • Set the root password:
        • mysql-administrator
        • Stored connection / Save this connection...: your_label
        • Server hostname: localhost
        • Username: root
        • Password: (empty)
        • Connect
        • User Administration / root : New password / Apply changes
  • Accés remot / Remote access
    • server (IP address: server_ip_address):
      • /etc/my.cnf
        • comment "skip-networking"
        • ? bind-address
      • grant privileges for a user (user_with_remote_privileges) from a remote location:
        • from command line (user_with_remote_privileges is mythtv):
          • mysql -u root -p
          • mysql> grant all on mythconverg.* to mythtv@"%" identified by "mythtv";
          • mysql> flush privileges;
        • (?) from mysql-workbench:
          • Server administration:
            • Security / Users and privileges
              • Server Access Management
                • Select user: user_with_remote_privileges
                • Login name: user_with_remote_privileges
                • Limit connectivity to hosts matching: % (for any host)
              • Schema Privileges
                • Select user: user_with_remote_privileges
                • Add entry...
      • service mysqld restart
    • client (IP address: client_ip_address):
      • mysql -h server_ip_address -u user_with_remote_privileges -p
  • Logs
  • Problemes / Problems
  • Esborrar totes les bases de dades i eliminar la contrasenya de root:
    • rm -rf /var/lib/mysql
    • service mysqld restart
  • Esborrar mysql / Removing mysql
    • urpme mysql mariadb
    • this will not remove all the data (root password...). To completely remove mysql:
      • # rm -rf /var/lib/mysql
  • Causes of Access denied Errors
  • Configuration for:
  • Client (GUI)
    • sqlgui
      • urpmi sqlgui libsqlguimysql
      • ln -s /usr/lib/libsqlguimysql-0.1.1.so /usr/lib/libsqlguimysql.so
  • Backup
    • mysqldump database_name -u root -p > database_name.sql
    • mysqldump --all-databases -u root -p > all_databases.sql
    • cron backup
      • /var/spool/cron
        • 0 23 * * * /root/backup_base_dades.sh
      • /root/backup_base_dades.sh
        • #!/bin/bash
          DB_BACKUP_DIR="/var/export/backup"
          DB_USER="root"
          DB_PASSWD="******"
          DATE="`date '+%Y%m%d_%H%M'`"
          mysqldump -u$DB_USER -p$DB_PASSWD timetracker > $DB_BACKUP_DIR/backup_timetracker_$DATE.sql
          mysqldump -u$DB_USER -p$DB_PASSWD wikidb > $DB_BACKUP_DIR/backup_wikidb_$DATE.sql
          echo "$DATE: Backup done" > /tmp/backup_base_dades.txt
          mail -s "[backup] Backup base de dades" $EMAIL < /tmp/backup_base_dades.txt
    • backup from mysql-administrator (mabackup)
    • backup from mysql-workbench
  • Restore

Bugzilla

  • MySQL
  • Instal·lació / Installation
    • Mageia
      • urpmi apache-mpm-prefork postfix perl-DBD-mysql
      • [urpmi bugzilla-contrib eclipse-bugzilla]
      • [urpmi apache-mod_perl perl-GDGraph perl-Template-GD perl-Chart perl-PatchReader perl-Image-Magick perl-HTML-Scrubber perl-Apache-DBI perl-DBD-Pg perl-MIME-tools perl-Email-MIME-Attachment-Stripper perl-Email-Reply interdiff]
      • [urpmi 'perl(Authen::Radius)' 'perl(SOAP::Lite)' 'perl(JSON::RPC)' 'perl(JSON::XS)' 'perl(Test::Taint)' 'perl(TheSchwartz)' 'perl(Daemon::Generic)' 'perl(Math::Random::Secure)']
      • urpmi bugzilla
    • Ubuntu
      • sudo apt-get install liblist-moreutils-perl libdatetime-perl libtemplate-perl libemail-send-perl libemail-mime-perl liburi-perl libmath-random-isaac-perl
      • optional:
        • apt-get install lib...-perl
      • wget http://ftp.mozilla.org/pub/mozilla.org/webtools/bugzilla-4.4.4.tar.gz
      • sudo tar --directory /usr/local -xvzf bugzilla-4.4.4.tar.gz
  • Configuració / Configuration
    • Option 1: new bugzilla
      • run config:
        • Mageia
          • /usr/share/bugzilla/bin/checksetup.pl
        • Ubuntu
          • sudo /usr/local/bugzilla-4.4.4/checksetup.pl
      • configure mysql for bugzilla
        • add user 'bugs' with password xxxxx (specified with $db_pass in localconfig):
          • mysql -u root -p
          • mysql> GRANT SELECT, INSERT,
            UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES,
            CREATE TEMPORARY TABLES, DROP, REFERENCES ON bugs.*
            TO bugs@localhost IDENTIFIED BY 'xxxxx';
            mysql> FLUSH PRIVILEGES;
        • edit config file:
          • Mageia
            • /etc/bugzilla/localconfig
              • set $db_pass xxxxx
          • Ubuntu
            • /usr/local/bugzilla-4.4.4/localconfig
              • set $db_pass xxxxx
                $webservergroup = 'www-data';
        • run config again:
          • Mageia
            • /usr/share/bugzilla/bin/checksetup.pl
          • Ubuntu
            • sudo /usr/local/bugzilla-4.4.4/checksetup.pl
    • Option 2: from existing bugzilla
      • On previous machine: backup
        • mysqldump bugs -u root -p > bugs_$(date '+%Y%m%d_%H%M').sql
      • On new machine: restore
    • Apache configuration
      • Bugzilla using Apache
      • Mageia (Apache 2.4)
        • (config file /etc/httpd/conf/sites.d/bugzilla.conf already supplied by rpm package):
          • # Bugzilla Apache configuration
            Alias /bugzilla/data /var/lib/bugzilla/
            Alias /bugzilla /usr/share/bugzilla/www

            <Directory /usr/share/bugzilla/www>
                Require all granted

                Options ExecCGI
                DirectoryIndex index.cgi
                AddHandler cgi-script .cgi .pl
            </Directory>

            # The dot files must be accessible to the public webdot server
            # The png files locally created locally must be accessible
            <Directory /var/lib/bugzilla/webdot>
                <FilesMatch \.dot$>
                    Require host research.att.com
                </FilesMatch>

                <FilesMatch \.png$>
                    Require all granted
                </FilesMatch>
            </Directory>
      • Ubuntu (Apache 2.4)
        • /etc/apache2/sites-available/bugzilla.conf
          • Alias /bugzilla /usr/local/bugzilla-4.4.4

            <Directory
            /usr/local/bugzilla-4.4.4>
               
            Require all granted
                Options ExecCGI
                DirectoryIndex index.cgi
                AddHandler cgi-script .cgi .pl

            </Directory>
        • sudo a2ensite bugzilla
        • sudo a2enmod cgi
        • sudo service apache2 reload
      • Problemes / Problems
        • Service Unavailable. The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
          • Solution
            • sudo service apache2 restart
    • Mail server configuration
    • LDAP configuration
  • Usage:

Scmbug

  • CVS
  • Bugzilla
  • Scmbug
    • instal·lació dels paquets necessaris (exemple per a MandrivaLinux):
      • urpmi docbook-style-dsssl-doc perl-XML-Simple perl-Mail-Sendmail
    • correspondència entre usuaris de cvs i usuaris de bugzilla:
      • /etc/scmbug/daemon.conf
      • userlist => {enabled => 1, values => {'usuari' => 'usuari@domini.org'}}
    • inici del servei:
      • temporalment: service scmbug-server restart
      • permanentment: chkconfig scmbug-server on
    • enganxa l'scmbug entre cvs i bugzilla:
      • scm_install_glue --scm=CVS --product=nom_modul --repository=/usr/local/cvsroot --bug=1 --daemon=127.0.0.1 --binary-paths=/usr/bin
    • edita algunes preferències:
      • chmod 644 /usr/local/cvsroot/CVSROOT/etc/scmbug/glue.conf
      • /usr/local/cvsroot/CVSROOT/etc/scmbug/glue.conf 
      • presence_of_bugs_ids => {value => 'optional' }
      • valid_bug_owner => {enabled => 0}
      • log_regex => '[Bb][Uu][Gg].*?:(.*)'

Eclipse

Inno Setup

  • Execució MSI:
    • [Run]
      Filename "msiexec.exe"; Parameters: "/qb+ /i ""{pf}\toto.msi"""; Flags: runascurrentserver shellexec waituntilterminated;

NTP (Network Time Protocol)

  • UNIX / Linux
    • Data / Date
    • Quick HOWTO : Ch24 : The NTP Server
    • client (no funcionarà si el servei ntpd està funcionant, perquè ocupa el port) (maybe you need to open the NTP port: 123)
      • force set time:
        • sudo systemctl stop ntpd.service sudo ntpd -gq sudo systemctl start ntpd.service
        • sudo service ntp stop
          sudo ntpd -gq
          sudo service ntp start
      • ntpdate (deprecated: use ntpd -gq instead)
        • Installation:
          • urpmi ntpdate
          • apt-get install ...
        • Usage
          • ntpdate -u europe.pool.ntp.org (amb l'opció -u sí que funcionarà quan el servei ntpd està en marxa / use -u option to force update when ntpd service is running)
          • ntpdate -q europe.pool.ntp.org (just query)
      • KDE adjust time: automatically
      • CentOS 8
        • dnf install chrony
        • sudo systemctl status chronyd.service
        • Check clock sync:
          • sudo dnf install ntpstat
          • ntpstat
    • client / server (nom_servidor)
      • /etc/ntp.conf (/etc/chrony.conf)
        • server nom_servidor iburst (ex: aries.salle.url.edu)
      • service ntpd start / systemctl start ntpd.service
      • systemctl enable ntpd.service
      • comproveu que el port és accessible des dels clients / check that port is accessible from clients
        • [solved] ntp reachable but rejected
          • Open port 123 (udp, tcp):
            • iptables -I INPUT -p tcp -m multiport --dports 123 -m comment --comment "ntp incoming (tcp)" -j ACCEPT
              iptables -I INPUT -p udp -m multiport --dports 123 -m comment --comment "ntp incoming (udp)" -j ACCEPT
      • ntpq (standard NTP query program)
        • list of peers:
          • ntpq -p
        • interactive format command (-c)
          • list of peers and their status:
            • ntpq -c peers
          • list of association identifiers:
            • ntpq -c assoc
        • nom_servidor no serà vàlid fins que no surti un * quan se'l pregunta amb ntpq -p nom_servidor / nom_servidor will not be valid until a * appears before it when calling ntpq -p nom_servidor
  • MS Windows XP, 2003
    • client / server
      • [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters]
      • "NtpServer"="aries.salle.url.edu,0x1"
      • "Type"="NTP"
      • [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient]
      • "Enabled"=dword:00000001
      • "SpecialPollInterval"=dword:00000708 (cada 1800s es connecta al servidor / connected to server every 1800s)
    • server
      • [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer]
      • "Enabled"=dword:00000001

UUID

  • UNIX
    • urpmi libext2fs-devel (libuuid-devel) (libossp_uuid-devel)
    • #include <uuid/uuid.h>
    • uuid_generate( uu );
    • needed lib: -luuid
  • MS Windows
    • #inlcude <rpc.h>
    • UuidCreate(&uu);
    • needed lib: Rpcrt4.lib

Microsoft IIS (Internet Information Server)

MS Visual Web Services

  • Check that your web service is running:
    • http://localhost/<your_web_service>/<your_web_service>.asmx
  • "Server Application Unavailable" (when trying to access web services with .net 2.0):
    • uninstall .net 3.0
  • "Failed to access iis metabase". Solution:
    • WINDOWS\Microsoft.NET\Framework\vX.X.XXXXX\aspnet_regiis -i
  • "The process account used to run ASP.NET must have read access to the IIS metabase"
    • aspnet_regiis -ga <WindowsUserAccount>
  • Others:
    • aspnet_regiis -ua
    • aspnet_regiis -i -enable
  • "Parser Error Message: Unrecognized configuration section 'connectionStrings'" / "Server Error in '/<your_web_service>' Application, Configuration Error"
    • Check that your web service is using the right ASP version:
    • Start / Control Panel / Administrative Tools / Computer Management / Services and Applications / Internet Information Services / Web sites / Default Web Site
    • <your_web_service>: Properties / ASP.NET tab / ASP.NET version: <the_needed_version_for_your_web_service>
  • To install NET framework from Microsoft:
  • Verify that the ASPNET user have writing permissions in the wanted directories:
    • Properties / Security / Add / Advanced options / Search now
    • if Security tab is not present:
      • Tools / Folder options / View / (don't use) Simple file sharing
  • ASP tab not present
  • Virtual units (subst) do not work for user ASPNET.
  • Needed files for deployment of a web service in a computer without MS Visual installed (to be put under C:\Inetpub\wwwroot\<your_web_service>\bin\):
    • developed with MS Visual 2005:
      • Release
        • ...\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT\
          • msvcp80.dll
          • msvcr80.dll
          • Microsoft.VC80.CRT.manifest
        • ...\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.MFC\
          • mfc80.dll
          • Microsoft.VC80.MFC.manifest
      • Debug
        • ...\Microsoft Visual Studio 8\VC\redist\Debug_NonRedist\x86\Microsoft.VC80.DebugCRT\
          • msvcp80d.dll
          • msvcr80d.dll
          • Microsoft.VC80.DebugCRT.manifest
        • ...\Microsoft Visual Studio 8\VC\redist\Debug_NonRedist\x86\Microsoft.VC80.DebugMFC\
          • mfc80d.dll
          • Microsoft.VC80.DebugMFC.manifest
  • Security issues (accessing network drives)

Toggle keybord layout in MS Windows

  • Control Panel / Regional and Language Options / Languages / Details
  • select the language and then Add
  • add a keyboard
  • Language bar: select all options

KDE

  • Font antialiasing
    • KDE control centre: Fonts / Use anti-aliasing / Enabled / Style: Complete
  • Menú / Menu
    • kmenuedit
    • /etc/xdg/menus/
    • /etc/xdg/kde4/menus/
  • Auto start of applications/scripts:
    • Configure desktop -> Advanced ->  Autostart
    • applications
      • ~/.config/autostart/*.desktop
    • scripts
      • ~/.kde4/Autostart/*.desktop
  • Netbook / HTPC

Escriptori remot / Remote dektop

  • rdesktop
    • rdesktop -g 1024x768 -k es remote_server -r disk:C=/
    • Per a accedir a la sessió remota ja iniciada ("-0"):
      • rdesktop -0 -g 1024x768 -k es remote_server -r disk:C=/
  • Citrix
    • Citrix Workspace App
      • Download Citrix Workspace App
      • Instal·lació / Install
        • Dependències / Dependencies
          • Mageia 9
            • (no hi ha dependències)
          • Mageia 7
            • urpmi libxpm4 libsm6 libxmu6 libxext6
        • From rpm (ICAClient, ctxusb)
          • sudo rpm -ivh --nodeps ICAClientWeb-rhel-20.9.0.15-0.x86_64.rpm ctxusb-20.9.0.15-1.x86_64.rpm
          • it will be installed in:
            • /opt/Citrix/ICAClient/
        • From tar
          • tar xvf linuxx64-20.9.0.15.tar.gz
            ./setupwfc
          • by default, it will be installed in:
            • ~/ICAClient/linuxx64/
      • Ús / Usage
        • Citrix Workspace app for Linux Command Reference
        • serveis / services
          • ICAClientWeb
            • sudo systemctl status ctxlogd.service
            • sudo systemctl status ctxcwalogd.service
            • Problemes / Problems
              • ctxlogd.service: Start operation timed out. Terminating.
              • Solució / Solution
                • modify /etc/rc.d/init.d/ctxlogd so as it does not use start_daemon, which, in Mageia 7, does not support -p option:
                  • # If /lib/lsb/init-functions is present use the LSB init fuctions.
                    if [ -r "$LSB_INIT_FUNCTIONS" ]; then
                        . "$LSB_INIT_FUNCTIONS"
                        INITLIB="$LSB_INIT_FUNCTIONS"
                    fi
                    INITLIB="NOT_FOUND"
                • or manually call:
                  • /opt/Citrix/ICAClient/util/ctxlogd
          • ctxusb
            • sudo systemctl status ctxusbd.service
            • config
              • /opt/Citrix/ICAClient/usb.conf
                • # DENY:  class=0b # Smartcard
              • ...
        • ~/ICAClient/linuxx64/wfica -icaroot ~/ICAClient/linuxx64 toto.ica /opt/Citrix/ICAClient/wfica -icaroot /opt/Citrix/ICAClient toto.ica
          • Problemes / Problems
            • corrupted double-linked list
              Avortat (s'ha bolcat la memòria)
            • malloc_consolidate(): invalid chunk size
              Avortat (s'ha bolcat la memòria)
        • Navegador / Browser

rsync

  • setup an rsync server (to be used as rsync daemon):
    • /etc/xinetd.d/rsync
  • syntax (man rsync)

    remote shell (one :)
    rsync daemon (two ::)
    pull
    rsync [OPTION...] [USER@]HOST:SRC... [DEST]
    rsync [OPTION...] [USER@]HOST::SRC... [DEST]
    push
    rsync [OPTION...] SRC... [USER@]HOST:DEST
    rsync [OPTION...] SRC... [USER@]HOST::DEST
  • src/dest
    (-r) SRC DEST
    sense barra final/ without trailing bar si és un directori, agafarà  el directori i els fitxers que conté si el directori existeix, ho posarà tot a dins; si no existeix, el crearà i ho posarà tot a dins
    amb barra final / with trailing bar si és un directori, agafarà els fitxers que conté si el directori existeix, ho posarà tot a dins; si no existeix, el crearà i ho posarà tot a dins
  • Exemples
    • rsync -avvr toto cesc@synologynas.local::homes/cesc/titi
      • src dst
        • toto/
          • primer.txt
          • segon.txt
        • homes/cesc/
          • titi/
            • toto/
              • primer.txt
              • segon.txt
    • rsync -avvr toto/ cesc@synologynas.local::homes/cesc/titi
      • src
        dst
        • toto/
          • primer.txt
          • segon.txt
        • homes/cesc/
          • titi/
            • primer.txt
            • segon.txt
  • Problemes amb l'horari d'estiu / Problems with daylight-savings time (DST)
  • examples:
    • opcions
      • --dry-run
      • -a archive mode; equals -rlptgoD (no -H,-A,-X)
        • -r, --recursive    recurse into directories
        • -l, --links        copy symlinks as symlinks
        • -p, --perms        preserve permissions
        • -t, --times        preserve modification times
        • -g, --group        preserve group
        • -o, --owner        preserve owner (super-user only)
        • -D                 same as --devices --specials
      • -A
      • -H
      • -X
      • --delete                 delete extraneous files from dest dirs
        • els fitxers que hi ha a dest però no a src s'esborraran de dest; però aquesta opció cal posar-la explícitament
        • sembla que Synology Shared Folder Sync l'activa sempre
      • ...
    • list of shared modules (rsync daemon):
      • rsync cesc@diskstation.local::
        • només apareixeran els directoris compartits des de Control Panel -> Shared Folders
      • rsync cesc@synologynas.local::
      • rsync cesc@diskstation.local::photo
      • rsync cesc@synologynas.local::photo
    • list of remote own (/home/cesc/) directories (remote shell):
      • rsync cesc@diskstation.local:
    • from smartphone (mounted at /media/6636-3133) to local directory:
      • rsync -avvr /media/6636-3133/DCIM/ ~/Imatges/HTC_Magic/
      • rsync -avvr /media/.../DCIM/ ~/Imatges/HTC_One_X/
    • from video camera (mounted at /media/disk or /run/media/cesc/disk/, vfat) to local directory:
      • rsync [--modify-window=3601] -avvr /media/disk/ ~/Vídeos/Sony/
      • rsync --modify-window=3601 -avvr /run/media/cesc/disk/ ~/Vídeos/Sony2/
    • from SD card (mounted at /run/media/cesc/9016-4EF8) to local directory:
      • rsync --modify-window=3601 -avvr /run/media/cesc/9016-4EF8/ ~/Imatges/Nikon_S31/
    • from SD card (mounted at /run/media/cesc/9016-4EF8) to Synology NAS:
      • rsync --modify-window=3601 -avvr /run/media/cesc/9016-4EF8/ admin@diskstation.home::photo/album_1/sd1/
    • from local directory to Synology NAS (diskstation.local, 192.168.0.50):
      • rsync -avvr ~/Imatges/HTC_Magic admin@diskstation.local::photo
      • rsync -avvr ~/Imatges/ admin@diskstation.local::photo
      • rsync -avvr ~/Vídeos/ admin@diskstation.local::video
      • rsync -avvr ~/Vídeos/Sony2/ admin@diskstation.local::video/Sony2/
      • rsync -avvr /home/cesc/Documents/ cesc@diskstation.local::homes/cesc/Documents/
    • from local directory to external drive:
      • rsync -avvr /home/cesc/Documents /media/disc/copia_seguretat/
    • exclusió de fitxers / exclusion of files:
      • rsync --exclude='*.o' ...
    • exclusió de directoris / exclusion of directories:
      • rsync --exclude='bin' ...
    • preserva els enllaços / preserve links:
      • rsync -l ...
    • llistat de fitxers modificats
    • ssh en un port específic / on a specific remote ssh port 8023:
      • rsync -avvr dir_local --rsh='ssh -p8023' usuari_remot@adreca_servidor:/dir_remot_pare/
      • per a fer-ho sempre
        • ~/.ssh/config
          • Host etiqueta_per_a_servidor
              HostName adreca_servidor
              Port 8023
        • rsync -avvr dir_local usuari_remot@etiqueta_per_a_servidor:/dir_remot_pare/
    • ssh amb un certificat (-e, --rsh són equivalents) (nota: el camí cap al certificat .pem ha de ser absolut)
      • rsync -avvr -e 'ssh -i /home/cesc/.ssh/keys/my_key.pem' dir_local usuari_remot@adreca_servidor:/dir_remot .
    • rsync amb sudo remot
      • Getting files from remote server that need sudo
      • Pulling Read restricted files from a remote system with rsync and sudo
      • Server
        • /etc/sudoers.d/usuari_remot
          • usuari_remot ALL=(ALL) NOPASSWD:ALL
            # no need for "-t" when accessing via ssh
            Defaults:usuari_remot !requiretty
      • Client
        • rsync -avvr -e 'ssh -i /home/cesc/.ssh/keys/my_key.pem' --rsync-path='sudo rsync' usuari_remot@adreca_servidor:/etc/dir_remot .

ImageMagick

  • Instal·lació / Installation
    • Mageia
      • urpmi ...
    • CentOS
      • sudo yum install ...
  • Features
    • -list format
    • -list interlace
  • Info (-format)
    • identify -format '%wx%h' filename
    • identify -format '%[exif:orientation]' filename
    • identify -verbose filename
  • Python
  • Resize
    • convert input_filename -scale 120x90 output_filename
  • YUV
  • Reduce the number of colours (useful, e.g. for images from a scanner):
    • convert toto.pnm -colors 4 toto.png
  • Convert alpha transparency in png (generate an RGBA image, suitable e.g. for Snowmix)
  • Convert to pdf
    • convert toto.png toto.pdf
    • they can then be joined with pdftk
  • Create a BGRA image (e.g. for Snowmix)
    • which convert && convert -depth 8 -size 1280x720 canvas:black black_1280x720.bgra
    • convert -depth 8 -size 1280x720 canvas:green green_1280x720.bgra
  • Convert to raw BGRA (e.g. for Snowmix)
    • convert toto.png toto.bgra
  • Display a BGRA image:
    • display -size 1280x720 -depth 8 BGRA:green_1280x720.bgra
    • ...
  • PNG




    • convert to this format using:
      create using:


      file gimp channels convert (ImageMagick) gimp python PIL
      PNG8
      no transparency PNG image data, 320 x 180, 8-bit colormap, non-interlaced Indexat -alpha remove PNG8:image_wot_png8.png
      • Imatge -> Mode -> Indexat...
      # pip install pillow
      from PIL import Image, ImageDraw

      image = Image.new('P', size=(320, 180), color=(155, 0, 0))
      d = ImageDraw.Draw(image)
      d.ellipse((20, 20, 160, 160), fill=(255, 255, 255))
      image.save("imatge_png8.png", format='png')
      1 indexed colour is transparent PNG image data, 320 x 180, 8-bit colormap, non-interlaced Indexat, Alfa -transparent '#FFFFFF' PNG8:image_wt_png8.png
      • Imatge -> Mode -> Indexat...
      • Capes -> Transparència -> Afegeix canal alfa
      • Capes -> Transparència -> Color a alfa
      # pip install pillow
      from PIL import Image, ImageDraw

      image = Image.new('P', size=(320, 180), color=(155, 0, 0))
      d = ImageDraw.Draw(image)
      d.ellipse((20, 20, 160, 160), fill=(255, 255, 255))
      #image = image.convert('P', palette=Image.ADAPTIVE, colors=2)
      # index 0 will be transparent
      # save palette with 1 bit (2 colours)
      image.save("imatge_png8a.png", format='png', transparency=0, bits=1)
      PNG24
      no transparency PNG image data, 320 x 180, 8-bit/color RGB, non-interlaced Vermell, Verd, Blau -alpha remove PNG24:image_wot_png24.png
      • Imatge -> Mode -> RGB
      # pip install pillow
      from PIL import Image, ImageDraw

      image = Image.new('RGB', size=(320, 180), color=(155, 0, 0))
      d = ImageDraw.Draw(image)
      d.ellipse((20, 20, 160, 160), fill=(255, 255, 255))
      image.save("imatge_png24.png", format='png')
      1 RGB colour is transparent PNG image data, 320 x 180, 8-bit/color RGB, non-interlaced Vermell, Verd, Blau, Alfa -transparent '#FFFFFF' PNG24:image_wt_png24.png
      • Imatge -> Mode -> RGB
      • Capes -> Transparència -> Afegeix canal alfa
      • Capes -> Transparència -> Color a alfa
      # pip install pillow
      from PIL import Image, ImageDraw

      image = Image.new('RGB', size=(320, 180), color=(155, 0, 0))
      d = ImageDraw.Draw(image)
      d.ellipse((20, 20, 160, 160), fill=(255, 255, 255))
      # colour (155,0,0) will be transparent
      image.save("imatge_png24a.png", format='png', transparency=(155,0,0))
      PNG32 gradual transparency PNG image data, 320 x 180, 8-bit/color RGBA, non-interlaced Vermell, Verd, Blau, Alfa ... -compose copy-opacity -composite PNG32:image_png32.png
      • Imatge -> Mode -> RGB
      • Capes -> Transparència -> Afegeix canal alfa
      # pip install pillow
      from PIL import Image, ImageDraw

      image = Image.new('RGBA', size=(320, 180), color=(155, 0, 0, 128))
      d = ImageDraw.Draw(image)
      d.ellipse((20, 20, 160, 160), fill=(255, 255, 255))
      image.save("imatge_png32.png", format='png')

HTML parsing

  • Python
    • BeautifulSoup 4
    • BeautifulSoup 3
      • urpmi python-beautifulsoup
      • import BeautifulSoup                             # To get everything
        from BeautifulSoup import BeautifulSoup          # For processing HTML
        import urllib

        url="http://xxx/toto.html"
        txt = urllib.urlopen(url).read()  #Pull in the url

        soup = BeautifulSoup(txt)

        allTags = soup.findAll('h3')
        for node in allTags:
            print node.string
  • PHP

Expresions regulars / Regular expressions

  • Perl regular expressions
  • Regular expressions in bash
  • Regular expression (wp)
  • Regular Expression Flavor Comparison
  • Online regex tester and debugger: PHP, PCRE, Python and JavaScript (101)
  • Python regular expressions
  • Literal character
  • Exemples / Examples
    • awk
    • Java
    • Parsing URLs
      • RFC 3986 Appendix B
      • Faster and cleaner way to parse Parameters from URL in javascript/jQuery?
        • http://usuari:contrasenya@example.com:8080/path/to/file;parameters?a=b&c=d#section
        • ^(?:([^:/?#.]+):)?(?://(?:([^/?#]*)@)?([\\w\\d\\-\\u0100-\\uffff.%]*)(?::([0-9]+))?)?([^?#]+)?(?:\\?([^#]*))?(?:#(.*))?$
        • example
          RFC 3986 regex
          regular expression
          regexp group name
          javascript: location.
          Python urllib.parse
          bash

          ^
          ^





          http:
          (([^:/?#]+):)?
          (?:([^:/?#.]+):)? protocol protocol (includes ":")

          scheme

          scheme=${url%//*}


          (?:





          //usuari
          (//([^/?#]*))?
          //(?:([^/?#]*)@)? user


          netloc
          username
          url_wo_scheme=${url#*//}
          domain=${url_wo_scheme%%/*}

          :contrasenya@



          password
          example.com
          ([\\w\\d\\-\\u0100-\\uffff.%]*) hostname hostname
          host
          hostname
          :8080
          (?::([0-9]+))? port

          port


          )?





          /path/to/file
          ([^?#]*)
          ([^?#]+)? pathname pathname

          path

          path=${url_wo_scheme##$domain}
          ;parameters





          params


          ?a=b&c=d
          (\?([^#]*))?
          (?:\\?([^#]*))? search search

          query


          #section
          (#(.*))?
          (?:#(.*))? hash hash

          fragment



          $ $





    • dvbsnoop
  • Character classes
    [abc]
    any one character between brackets
    [^abc]
    any one character not between brackets
    .
    any character except newline
    \w
    word character
    \W
    non word character
    \s
    whitespace character
    \S
    non whitespace character
    \d
    digit
    \D
    non digit
  • Anchors
    • ^
      beginning
      $
      end
      \b

      \B

  • Repetition (specified aftter the character)
    • 0
      1
      more
      ?

      *

      +
    • n
      more
      m
      {n}


      {n,}

      {n,m}
    • ??
      non-greedy (stops at first occurrence)
      *?
      +?
      {}?
  • Grouping
    (...)
    all characters in specified order must match. Use (?:...) if you only want to match a group of characters but you do not want to keep them
    |
    separator between groups of characters. E.g.: (dev|pre|pro)
    \n

  • Extended regular expressions (Regex lookahead, lookbehind and atomic groups)
    (?#...)


    (?:...) matches, but does not return the content ("...")

    (?=...) positive lookahead

    (?!...) negative lookahead
    grep -P 'echo.*date(?!.*log_path)' toto.sh
    (?<=...) positive lookbehind
    (?<!...) negative lookbehind
    (?>...) atomic group

Substitució / Replacement

Base64



bash Python Javascript
encoding non url safe echo -n "toto" | base64 base64.b64encode(b"toto")
url safe echo -n "toto" | base64 | tr '+' '-' | tr '/' '_' base64.urlsafe_b64encode(b"toto")
decoding non url safe echo -n "dG90bw==" | base64 -d base64.b64decode(b"dG90bw==")
url safe echo -n "dG90bw==" | tr '-' '+' | tr '_' '/' | base64 -d base64.urlsafe_b64decode(b"dG90bw==")
  • ...

Tasques / Tasks

  • crontab
  • incron(incrond, incrontab)
    • config
      • tasca
        • /path/to/be/watched/ IN_CLOSE_WRITE /path/to/tasca.sh $@ $# $%
          ...
    • script
      • tasca.sh
        • #!/bin/bash
          ...
          directori=$1
          nom_fitxer=$2
          esdeveniment=$3
          ...
    • start service
      • #echo root > /etc/incron.deny
        #service incrond start
        $incrontab tasca

Data / Date

Telnet

  • See also: nc / netcat
  • Instal·lació / Installation
    • Mageia
      • urpmi netkit-telnet
    • CentOS
      • sudo yum install telnet
  • Utilització / Usage
    • escape characters:
      • ^] = Ctrl+]
      • ^@ = Ctrl+@
    • Exemple / Example: RadioDNS
  • Automate interactive session
    • Automating telnet session using bash scripts
      • /usr/bin/expect
        • urpmi expect expect-examples
          • /usr/share/doc/expect-examples/
        • telnet.sh
          • #!/usr/bin/expect
            set timeout 20
            set hostName [lindex $argv 0]
            set port [lindex $argv 1]
            set password [lindex $argv 2]

            spawn telnet $hostName $port
            expect "Password:"
            send "$password\r";

            send "...\r";

            sleep 2
            send "logout\r";
        • telnet.sh host_name port password
      • {echo "command1"; echo "command2"; sleep 2; } | telnet localhost 4212

OpenSSH

  • Instal·lació / Installation

    • server
      client

      installation
      service firewall
      CentOS
      yum install openssh-server systemctl [enable,start,status,stop] sshd.service


      Cygwin



      Mageia dnf install openssh-server systemctl [enable,start,status,stop] sshd.service /etc/shorewall/rules.drakx
      • ACCEPT  net     fw      tcp     22      -

      Ubuntu sudo apt-get install openssh-server


  • Default port: 22
  • Especificació dels usuaris autoritzats / Specify allowed users (Step 5):
    • /etc/ssh/ssh_config
      • AllowUsers ...
  • Change port (from default 22 to 10022)
    • server
      • sshd
        • /etc/ssh/sshd_config
          • Port 10022
      • sshd-xinetd
        • /etc/xinetd.d/sshd-xinetd
          • port = 10022
      • obrir el port 10022 al tallafoc
    • client
      • ssh -p 10022 username@server
  • Muntatge d'un sistema de fitxers remot en un directori local / Mount remote filesystem in a local directory:
    • urpmi sshfs-fuse
    • mkdir /mnt/local_dir/
    • sshfs remote_user@remote_address:/remote_dir /mnt/local_dir/ -o uid=local_user_numerical_id -o gid=local_group_numerical_id
  • Cyphers
    • SSH: How to disable weak ciphers?
      • sshd -T | grep ciphers | sed -e "s/\(3des-cbc\|aes128-cbc\|aes192-cbc\|aes256-cbc\|arcfour\|arcfour128\|arcfour256\|blowfish-cbc\|cast128-cbc\|rijndael-cbc@lysator.liu.se\)\,\?//g" >>/etc/ssh/sshd_config
      • echo "ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com" >>/etc/ssh/sshd_config
  • OpenSSL
  • Parell de claus / Key pairs:


    storage

    generation server
    client
    server pair
    (ssh-server) /etc/ssh/ssh_host_rsa_key
    ~/.ssh/known_hosts
    [client pair] ssh-keygen via ssh-copy-id:
    • ~username/.ssh/authorized_keys
    • ~/.ssh/id_rsa
    • any other location specified by ssh-keygen -f filename

  • Autencicació sense contrasenya / Password-less authentication (optional):
    • server:
      • install ssh server
      • /etc/ssh/sshd_config
        • PubkeyAuthentication yes
        • # only pair of keys is allowed:
          PasswordAuthentication no
    • setup from client:
      • if you do not have the pair of keys, generate them:
        • ssh-keygen -t rsa -C id_for_remote_server_name -f ~/.ssh/keys/id_for_remote_server_name.pem
          • this will generate:
            • ~/.ssh/keys/id_for_remote_server_name.pem
            • ~/.ssh/keys/id_for_remote_server_name.pem.pub
        • if you generared the pair with openssl (remote_server.pem), extract the public key and convert it to pub (PKCS8) format (id_rsa_remote_server.pub):
          1. openssl rsa -in remote_server_name.pem -out remote_server_name.public.pem -outform PEM -pubout
          2. ssh-keygen -i -f remote_server_name.public.pem -m PKCS8 > id_rsa_remote_server_name.pub

      • copy the public part (id_for_remote_server_name.pem.pub) to the remote server. Use one of the following:
        • Option A:
          • on remote server, enable password authentication:
            • /etc/ssh/sshd_config
              • PasswordAuthentication yes
            • sudo systemctl restart sshd.service
          • on local server:
            • ssh-copy-id -i ~/.ssh/keys/id_for_remote_server_name.pem.pub username@remoteserver
          • on remote server, disable password authentication:
            • /etc/ssh/sshd_config
              • PasswordAuthentication no
            • sudo systemctl restart sshd.service
        • Option B:
          • from remote server, manually paste the content of remote_server_name.pem.pub to the authorized keys file of the user you will use in further ssh connections:
            • /home/myuser/.ssh/authorized_keys
              • ssh-rsa ... id_for_remote_server_name
      • this will create a line in the remotehost file ~username/.ssh/authorized_keys,  with the  following content:
        • ssh-rsa AAA... id_for_remote_server_name
        • but it can be completed as (SSH configuration tricks):
          • command="program" ssh-dsa AAAABtce9euch… user@example.com
    • connection from client:
  • Control version with SSH
    • Subversion with SSH
    • Bitbucket / GitLab (git) with SSH
      • Use the SSH protocol with Bitbucket Cloud
      • Set up SSH for Git and Mercurial on Mac OSX/Linux
      • Configure multiple SSH identities for GitBash, Mac OSX, & Linux
      • Simple setup
        • Create a key pair (or get the one generated by e.g. weblate)
          • ssh-keygen -f ~/.ssh/keys/gitlab-user_i-id_from_work -t ed25519
        • ~/.ssh/config
          • # GitLab.com server
            Host gitlab.com
            RSAAuthentication yes
            IdentityFile ~/.ssh/keys/gitlab-user
            _i-id_from_work
        • git clone git@gitlab.com:accountname_i/repo_a.git
      • Complete setup
        • identity
          Bitbucket account / GitLab user
          git remote
          name
          .ssh/config account account can access to repositories

          each identity has a key pair;
          an identity replaces accountname/password, and must be unique in Bitbucket/GitLab;
          an account can have several identities
          must register the identity keys non-own repositories (e.g. a team) must grant permissions to the account, but should not register key pairs

          bitbucket-account_i-id_from_home
          Host bb-aci-id1
               HostName bitbucket.org
               IdentityFile ~/.ssh/keys/bitbucket-account_i-id_from_home
          accountname_i accountname_i/repo_a.git accountname_j/repo_d.git teamname_k/repo_m.git
          git@bb-aci-id1:accountname_i/repo_a.git git@bb-aci-id1:accountname_j/repo_d.git git@bb-aci-id1:teamname_k/repo_m.git
          bitbucket-account_i-id_from_work Host bb-aci-id2
               HostName bitbucket.org
               IdentityFile ~/.ssh/keys/bitbucket-account_i-id_from_work
          git@bb-aci-id2:accountname_i/repo_a.git git@bb-aci-id2:accountname_j/repo_d.git git@bb-aci-id2:teamname_k/repo_m.git
          bitbucket-account_ii-id_from_home Host bb-0acii-id1
               HostName bitbucket.org
               IdentityFile ~/.ssh/keys/bitbucket-account_ii-id_from_home
          accountname_ii accountname_ii/repo_b.git accountname_jj/repo_e.git teamname_kk/repo_n.git git@bb-acii-id1:accountname_ii/repo_b.git git@bb-acii-id1:accountname_jj/repo_e.git git@bb-acii-id1:teamname_kk/repo_n.git
          bitbucket-account_ii-id_from_production_server Host bb-acii-id2
               HostName bitbucket.org
               IdentityFile ~/.ssh/keys/bitbucket-account_ii-id_from_production_server
          git@bb-acii-id2:accountname_ii/repo_b.git git@bb-acii-id2:accountname_jj/repo_e.git git@bb-acii-id2:teamname_kk/repo_m.git
        • Steps
          1. Create key pairs (maybe several for each account in Bitbucket; you don't need to create a key pair to access to a team account: just use one of your key pair):
            • Bitbucket
              • ssh-keygen -f ~/.ssh/keys/bitbucket-account_i-id_from_home -t ed25519 -C "Bitbucket: identity to login as accountname_i, from home"
              • ssh-keygen -f ~/.ssh/keys/bitbucket-account_i-id_from_work -t ed25519 -C "Bitbucket: identity to login as accountname_i, from work"
              • ssh-keygen -f ~/.ssh/keys/bitbucket-account_ii-id_from_home -t ed25519 -C "Bitbucket: identity to login as accountname_ii, from home"
              • ssh-keygen -f ~/.ssh/keys/bitbucket-account_ii-id_from_production_server -t ed25519 -C "Bitbucket: identity to login as accountname_ii, from work"
            • GitHub
              • ssh-keygen -f gitlab-account_i-id_from_home -t ed25519 -C "your_email@example.com"
              • ssh-keygen -f gitlab-account_i-id_from_home -t rsa -b 4096 -C "your_email@example.com"
            • GitLab
              • ssh-keygen -f gitlab-account_i-id_from_home -t ed25519 -C "user@example.org" -b 4096
              • ...
          2. ~/.ssh/config
            • Bitbucket
              • Host bb-aci-id1
                     HostName bitbucket.org
                     IdentityFile ~/.ssh/keys/bitbucket-account_i-id_from_home

                Host bb-aci-id2
                     HostName bitbucket.org
                     IdentityFile ~/.ssh/keys/bitbucket-account_i-id_from_work
              • Host bb-acii-id1
                     HostName bitbucket.org
                     IdentityFile ~/.ssh/keys/bitbucket-account_ii-id_from_home

                Host bb-acii-id2
                     HostName bitbucket.org
                     IdentityFile ~/.ssh/keys/bitbucket-account_ii-id_from_production_server
            • GitHub
              • Host gh-aci-id1
                     HostName github.com
                     IdentityFile~/.ssh/keys/github-account_i-id_from_home
                Host gh-aci-id2
                     HostName github.com
                     IdentityFile~/.ssh/keys/github-account_i-id_from_work
            • GitLab
              • Host gl-aci-id1
                     HostName gitlab.com
                     IdentityFile ~/.ssh/keys/gitlab-account_i-id_from_home
                Host gl-aci-id2
                     HostName gitlab.com
                     IdentityFile~/.ssh/keys/gitlab-account_i-id_from_work
              • ...
          3. Add public keys to accounts:
            • Bitbucket (web interface Settings: SECURITY / SSH Keys):
              • xclip -selection clipboard < ~/.ssh/keys/...:
                • into accountname_i:
                  • bitbucket-account_i-id_from_home.pub
                  • bitbucket-account_i-id_from_work.pub
                • into accountname_ii:
                  • bitbucket-account_ii-id_from_home.pub
                  • bitbucket-account_ii-id_from_production_server.pub
            • GitHub
              • User -> Settings -> SSH and PGP keys
              • Title: github-account_i-id_from_home
              • Key: (xclip -selection clipboard < ~/.ssh/keys/github-account_i-id_from_home.pub)
            • GitLab (Group -> Members)
              • Profile settings -> SSH Keys
              • xclip -selection clipboard < ~/.ssh/keys/gitlab-account_i-id_from_home.pub
                • into accountname_i:
                  • gitlab-account_i-id_from_home.pub
                  • gitlab-account_i-id_from_work.pub
                • into accountname_ii:
                  • gitlab-account_ii-id_from_home.pub
                  • gitlab-account_ii-id_from_work.pub
          4. Clone repo:
            • git clone git@gl-aci-id1:accountname_i/repo_a.git
          5. Change repository configuration
            • ~/src/repo_a/.git/config
              • url = git@bb-aci-id1:accountname_i/repo_a.git
            • ~/src/repo_b/.git/config
              • url = git@bb-acii-id1:accountname_ii/repo_b.git
  • Shh! OpenSSH Secrets Here
    • Password-less SSH logins
  • ssh-agent (ssh password caching)
  • X11 forwarding (abans DISPLAY / fomerly DISPLAY)
    • How to forward X over SSH from Ubuntu machine?
    • servidor ssh / ssh server (remote)
      • CentOS
        • sudo yum install xorg-x11-xauth
      • /etc/ssh/sshd_config
        • X11Forwarding yes
    • client ssh (local)
      • ssh -X nom_servidor_ssh
      • No cal establir la variable d'entorn DISPLAY / No need to specify environment variable DISPLAY
      • Resolució de problemes / Problem resolution
        • al servidor / in server
          • ssh -X nom_servidor_ssh
            • X11 forwarding request failed on channel 0
            • Solució / Solution
              • ssh -v -X nom_servidor_ssh
                • debug1: Requesting X11 forwarding with authentication spoofing.
                  debug1: Remote: No xauth program; cannot forward with spoofing.
              • Install xauth:
                • CentOS
                  • sudo yum install xorg-x11-xauth
        • al client / in client
          • (run a program with gui, e.g. xterm)
            • X11 forwarding is disabled to avoid man-in-the-middle attacks.
            • libGL error: unable to load driver: swrast_dri.so
              libGL error: failed to load driver: swrast
              • Solució / Solution
                • export LIBGL_DEBUG=verbose; xterm
                  • libGL: OpenDriver: trying /usr/lib64/dri/tls/swrast_dri.so
                    ...
                • CentOS
                  • sudo yum provides /usr/lib64/dri/tls/swrast_dri.so
                  • sudo yum install mesa-dri-drivers
  • Redireccionament d'àudio / Audio forwarding
    • How to carry audio over SSH?
    • PulseAudio
      • PulseAudio over network
      • Network audio with PulseAudio made (somewhat) easy
      • X11 forwarding over SSH & Pulseaudio

      • local sink (has audio hardware)
        remote source (does not have audio hardware)
        dependencies
        sudo urpmi ...
        • sudo yum install pulseaudio-utils
        • if you are going to use gstreamer, it must contain pulseaudio:
          • gst-inspect-1.0 | grep pulse
        configure PulseAudio (/etc/pulse/default.pa)
        load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/24 auth-anonymous=1

        restart PulseAudio systemctl --user restart pulseaudio.socket pulseaudio.service
        check that tcp module is loaded
        pacmd list-modules | grep module-native-protocol-tcp

        set  PulseAudio remote server pax11publish -e -S <sink_ip_address>
        connect to remote
        ssh -X <remote_user>@<remote_source_ip_address>

        check audio server
        • pavucontrol (urpmi pavucontrol)
        • xprop -root PULSE_SERVER (yum install xorg-x11-utils)
          • <sink_ip_address>
        • pavucontrol (yum install pavucontrol)
        play file containing audio

        • ffplay ...
        • gst-launch-1.0 -v audiotestsrc wave=5 ! audioconvert ! volume volume=0.2 ! pulsesink
        • gst-launch-1.0  playbin uri=file:/path/to/bbb.mp4
        • mplayer ...
      • NOTE: if using VirtualBox, do not activate audio device in remote virtual machine
      • (needed?) al servidor / on server
        • paprefs
          • Servidor de xarxa: Habilita l'accés a la xarxa per als dispositius de so locals
            • sembla que no funciona; editeu /etc/pulse/default.pa i afegiu-hi: load-module module-native-protocol-tcp auth-ip-acl...
    • Enabling audio in VirtualBox and using Alsa (has lipsync issues)
      • al client / on client (vm)
        • CentOS
          • sudo yum install alsa-utils alsa-firmware alsa-lib alsa-oss
        • sudo usermod -a -G audio my_user_in_vm
        • alsamixer
          • increase volume
  • LDAP
  • Problemes / Problems

Logs

Synology (NAS)

Iomega NAS

  • Iomega Storage Manager
    • urpmi libjpeg62 libupnp3
    • export LD_LIBRARY_PATH=/usr/bin/Iomega\ Storage\ Manager/lib/

Xiaomi Band

  • Temes / Themes
    • Descàrrega / Download
    • Change Mi Band 4 Theme!
      • Download
        • AmazfitBipTools_Mi4_0.0.2.zip
          • WINEPREFIX=~/.win_32 WINEARCH=win32 wine WatchFace.exe
            • WatchFace.exe unpacks and packs Amazfit Bip downloadable watch faces and resource files.

              Usage examples:
                WatchFace.exe watchface.bin   - unpacks watchface images and config
                WatchFace.exe watchface.json  - packs config and referenced images to bin file
                WatchFace.exe mili_chaohu.res - unpacks resource file images
                WatchFace.exe mili_chaohu     - packs folder content to res file
        • template.bin
      • Passos / Steps
        1. Descarregueu-vos el fitxer de les utilitats:
          1. si no el teniu, creeu un directori: mkdir ~/src
          2. des del navegador, aneu a: https://fwd.duc1607.ooo/mi-band-4-theme, i descarregueu-vos AmazfitBipTools_Mi4_0.0.2.zip a ~/src
          3. aneu al directori on l'heu desat i descomprimiu-lo: 
            1. cd ~/src
            2. unzip AmazfitBipTools_Mi4_0.0.2.zip
            3. cd AmazfitBipTools_Mi4_0.0.2
        2. Descarregueu-vos un fitxer .bin que servirà com a base (p.ex. mario_odyssey_06-37039-e65bd5a5ee.bin), a ~/src/AmazfitBipTools_Mi4_0.0.2/mario_odyssey_06-37039-e65bd5a5ee.bin
        3. Descomprimiu-lo:
          • WINEPREFIX=~/.win_32 WINEARCH=win32 wine WatchFace.exe mario_odyssey_06-37039-e65bd5a5ee.bin
        4. Aneu a la nova carpeta mario_odyssey_06-37039-e65bd5a5ee:
          • cd mario_odyssey_06-37039-e65bd5a5ee
        5. Modifiqueu les imatges que vulgueu, per exemple la imatge de fons, 0000.png (PNG image data, 8-bit/color RGBA, non-interlaced)
          • Gimp
            • Fitxer / Obre...
              • la nova imatge que voleu posar al rellotge
            • Imatge / Escala la imatge...
              • Amplada: 120
              • Alçada: 240
              • Resolució X: 96 píxels/in
              • Resolució Y: 96 píxels/in
            • Capa / Transparència / Afegeix canal alfa
            • Imatge / Mode / Indexat
            • Fitxer / Exporta com a...
              • 0000.png
          • Dimensions
            • Background: 120x240
            • ...
        6. Opcionalment, modifiqueu el fitxer json: ~/src/AmazfitBipTools_Mi4_0.0.2/mario_odyssey_06-37039-e65bd5a5ee/mario_odyssey_06-37039-e65bd5a5ee.json
        7. Empaqueteu de nou el directori:
          • cd ~/src/AmazfitBipTools_Mi4_0.0.2
          • WINEPREFIX=~/.win_32 WINEARCH=win32 wine WatchFace.exe mario_odyssey_06-37039-e65bd5a5ee/mario_odyssey_06-37039-e65bd5a5ee.json
          • us generarà un nou fitxer: mario_odyssey_06-37039-e65bd5a5ee/mario_odyssey_06-37039-e65bd5a5ee_packed.bin
        8. Connecteu el telèfon Android a l'ordinador, amb un cable USB (haureu de donar permís des del telèfon a la connexió per USB per a desenvolupadors)
        9. Trobeu quin directori de l'aplicació MiFit voldreu sobreescriure amb el nou bin, fent servir l'eina adb:
          1. ~/Android/Sdk/platform-tools/adb devices
          2. ~/Android/Sdk/platform-tools/adb shell
            • cd /storage/sdcard0/Android/data/com.xiaomi.hm.health/files/watch_skin_local/
            • ls -l
              • trieu algun d'aquests directoris, per exemple: mrrfZikKuBb7MXFrNKu8VyHE0lLXKRcnO0xCyJ0w
            • exit
        10. Poseu aquest fitxer, fent servir ADB, dins d'un directori de MiFit  al vostre dispositiu Android (/storage/sdcard0/Android/data/com.xiaomi.hm.health/files/watch_skin_local/):
          1. cd ~/src/AmazfitBipTools_Mi4_0.0.2/mario_odyssey_06-37039-e65bd5a5ee
          2. ~/Android/Sdk/platform-tools/adb push mario_odyssey_06-37039-e65bd5a5ee_packed.bin /storage/sdcard0/Android/data/com.xiaomi.hm.health/files/watch_skin_local/mrrfZikKuBb7MXFrNKu8VyHE0lLXKRcnO0xCyJ0w
        11. Des de MiFit, instal·leu el tema com faríeu habitualment
        12. ...
    • amazfitbip/tools

TimeTracker

  • User guide
  • Installation (Installation instuctions, Upgrade instructions, Ubuntu installation)
    • Dependencies
      • Install MySQL and set the root password
      • urpmi task-lamp-php
      • urpmi apache-mod_php php-pear php-pear-DB php-mbstring [php-smarty php-mysql php-pear-MDB2_Driver_mysql]
    • download:
    • unzip -d /var/www anuko_time_tracker.zip
    • Information about version, changelog, troubleshooting:
      • timetracker/readme.txt
    • chmod 777 WEB-INF/templates_c
    • Configure Timetracker:
      • cd /var/www/timetracker/WEB-INF/; cp config.php.dist config.php
      • /var/www/timetracker/WEB-INF/config.php
        • define("DSN",'mysql://tt_user:tt_password@localhost/timetracker');
        • define("APP_NAME",'timetracker');
        • define('MAIL_SMTP_HOST', 'smtp.your_server.com');
    • Configure Apache (may not be needed for Ubuntu):
      • /etc/httpd/conf/webapps.d/timetracker.conf
        • Alias /timetracker /var/www/timetracker
          <Directory "/var/www/timetracker">
            Order allow,deny
            Allow from All
          </Directory>
      • /etc/httpd/conf/httpd.conf
        • <Directory "/var/www/timetracker">
              Options -Indexes FollowSymLinks MultiViews
              AllowOverride None
              Order allow,deny
              Allow from all
          </Directory>
    • For a first time installation:
      • mysql -u root -p
        • CREATE DATABASE timetracker;
        • GRANT ALL ON timetracker.* TO 'tt_user'@'localhost' IDENTIFIED BY 'tt_password';
        • FLUSH PRIVILEGES;
        • exit;
      • mysql -u root -p -D timetracker < mysql.sql
      • Check that database is working
        • mysql -u tt_user -p
          • > password: tt_password
          • > use timetracker;
          • > show tables;
      • http://localhost/timetracker/dbinstall.php
        • Create
    • For an upgrade (and restore from backup):
      • mysql -u root -p
        • GRANT ALL ON timetracker.* TO 'tt_user'@'localhost' IDENTIFIED BY 'tt_password';
        • FLUSH PRIVILEGES;
        • exit;
      • mysql -v -v -v -u root -p < backup_timetracker.sql
      • Check that database is working
        • mysql -u tt_user -p
          • > password: tt_password
          • > use timetracker;
          • > show tables;
      • http://localhost/timetracker/dbinstall.php
        • Update:
          • sequentially click all Update buttons, from your_old_version up to 1.3.3
          • if you are not sure about what your_old_version is, click on ALL Update buttons, starting from the very first Update button
  • Upgrade
  • Timeout
    • /etc/php.ini
      • session.gc_maxlifetime=28800
    • /usr/lib/php/maxlifetime (used in /etc/cron.d/php)
      • max=28800
  • Problems
    • Activate PHP display errors
    • Check readme.txt: BLANK PAGES IN ANUKO TIME TRACKER
    • "The server encountered an internal error and was unable to complete your request. Error message:
      The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script."

Kimai

  • Install
    • urpmi php-pdo_mysql
    • mysql -u root -p
      • CREATE DATABASE kimaidb;
    • /etc/httpd/conf/webapps.d/kimai.conf
      • Alias /kimai /var/www/kimai_0.9.0.1082
        <Directory "/var/www/kimai_0.9.0.1082">
          Order allow,deny
          Allow from All
        </Directory>
  • chown apache.apache -R /var/www/kimai_0.9.0.1082/compile
  • chown apache.apache -R /var/www/kimai_0.9.0.1082/extensions
  • chown apache.apache -R /var/www/kimai_0.9.0.1082/temporary
  • open browser:
    • http://localhost/kimai
  • default user: admin/changeme

Weblate

  • Descàrrega / Download
    • git
  • Quick setup guide
    • Serving static files
    • Weblate with GitLab as OAuth provider
    • Django
    • Dependències / Dependencies
      • Mageia
        • urpmi ...
      • CentOS
        • sudo yum install gcc libxml2-devel libxslt-devel libjpeg-devel
      • Pip
        • virtualenv env
        • source env/bin/activate
        • pip install psycopg2 uwsgi
        • pip install python-social-auth
          • to avoid error "No module named social.apps.django_apps"
        • pip install -r requirements.txt
        • pip install --upgrade pip
        • pip install -r requirements-optional.txt
          • Additional dependencies:
            • for tesserocr
              • CentOS
                • sudo yum install tesserocr-devel
    • Download
      • git clone https://github.com/nijel/weblate.git
    • Setup
      • cd weblate
      • cp weblate/settings_example.py weblate/settings.py
      • settings.py
        • ...
      • ./manage.py migrate
      • ./manage.py createsuperuser
      • ./scripts/generate-locales
        • Problemes / Problems
          • *** Git <https://git-scm.com/> is too old! ***
            Installed version 1.8.3.1, required 1.8.5
            • Solució / Solution
              • Install a newer version of git (CentOS)
      • ./manage.py runserver 0.0.0.0:8000
  • Problemes / Problems
    • Git conflicts
      • ssh ...
      • cd /var/lib/weblate/data/vcs/<my_project>/<my_component>/
      • sudo su django
      • git status
      • Web GUI:
        • (?) Rebase
    • Fresh installation: ERROR: accounts.VerifiedEmail.social: (fields.E300) #1405
      • accounts.VerifiedEmail.social: (fields.E300) Field defines a relation with model 'UserSocialAuth', which is either not installed, or is abstract.
    • Error 500
    • When creating a component:
      • admin:
        • fatal: There is no merge to abort (MERGE_HEAD missing). (128)
      • /var/log/messages
        • ERROR my_project/my_component: failed merge on repo: fatal: ambiguous argument '@': unknown revision or path not in the working tree.
          Use '--' to separate paths from revisions, like this:
          'git <command> [<revision>...] -- [<file>...]' (128)
          • Produced by:
            • cd my_project/my_component
            • git log -n 1 --format=format:%H @
            • e.g. with CentOS and git 1.8.3.1
            • working fine with git 2.7.4 (Mageia)
          • Solution. One of the following
            • upgrade git
            • sed -i "s/'log', '-n', '1', '--format=format:%H', '@'/'log', '-n', '1', '--format=format:%H', 'HEAD'/" weblate/weblate/trans/vcs.py
    • (when debugging from Eclipse) OperationalError: no such table: trans_project
      • Solution
        • Do not use sqlite3
    • "Android String Resource" not present in File Format list
    • Hierachical JSON files are flattened
      • Weblate and i18next json files
        • Solució / Solution
          • cd /var/lib/weblate/scripts/
          • wget https://gist.githubusercontent.com/saily/f8a9f72c6b064d51f09040d66e981240/raw/5bcb059b5ff0339584745b7bfc707d6adc79e2a8/json_restore_hierarchy
          • chmod +x json_restore_hierarchy
          • settings.py
            • PRE_COMMIT_SCRIPTS = (
              '/var/lib/weblate/scripts/json_restore_hierarchy',
              )
          • sudo systemctl restart emperor.uwsgi.service
          • Admin -> Components -> MyComponent
            • Pre-commit script: json_restore_hierarchy
  • Usage
    • admin
      • SSH (http://<weblate>/admin/ssh/)
        • Public SSH key
          • stored in .../weblate/data/ssh/
            • id_rsa
            • id_rsa.pub
          • this is the id that will be used in git transactions; you need to add id_rsa.pub as a valid public key (identity) associated to your account in your git origin (e.g. GitLab)
        • Server key
          • stored in .../weblate/data/ssh/known-hosts
          • Add server key: gitlab.com
      • Project (http://<weblate>/admin/trans/)
        • Component
          • Repository URL: git@gitlab.com:my_group/my_project.git
          • Push repository URL: git@gitlab.com:my_group/my_project.git


          • Django
            AngularJS 2
            Android
            Source code repository:
            git@gitlab.com:my_group/my_project.git


            Repository push URL:
            git@gitlab.com:my_group/my_project.git


            Repository branch:
            master



            File mask:

            locale/*/LC_MESSAGES/django.po
            src/locale/messages.*.xlf
            app/src/main/res/values-*/strings.xml
            Monolingual base language file:


            src/messages.xlf app/src/main/res/values/strings.xml
            File format:

            Gettext PO file
            XLIFF translation file
            Android String Resource
            New translation:




  • Weblate and GitLab

DNS server

  • Info
    • ...
  • Eines / Tools
  • Prerequisites
    • make sure the hostname contains a full name and domain
  • Firewall
  • Bind
    • Installation
    • Configuration
      • /etc/named.conf
        • zone "." IN {
                  type hint;
                  file "named.ca";
          };
      • caching-nameserver
        • /etc/named.rfc1912.zones
          • zone "localhost" IN {
                    type master;
                    file "named.localhost";
                    allow-update { none; };
            };
            ...
      • /var/named/
        • named.ca
        • named.localhost
        • ...
      • rdnc
        • Key generation:
          • dnssec-keygen -a hmac-md5 -b <bit-length> -n HOST <key-file-name>
        • configuration
          /etc/named.conf
          /etc/rndc.conf
          key "rndc-key" {
                  algorithm hmac-md5;
                  secret "...";
          };
          controls {
                inet 127.0.0.1 port 953
                        allow { 127.0.0.1; } keys { "rndc-key"; };
          };

          options {
                  default-key "rndc-key";
                  default-server 127.0.0.1;
                  default-port 953;
          };

        • command line options
    • Check
      • dig @localhost localhost
      • dig @localhost toto.org

VPN

  • Servidor / Server
  • Client

    • command setting file

      vpn-start ... /etc/sysconfig/network-scripts/vpn.d/
      SSL openvpn nom_openvpn openvpn/nom_openvpn.conf
      IPSec vpnc nom_vpnc vpnc/nom_vpnc.conf
    • MCC (Mageia)
      • Xarxa i Internet -> Configura una connexió VPN per a l'accés a una xarxa segura
        • Cisco VPN Concentrator
        • OpenVPN
    • vpn-start (part of initscripts package)
      • openvpn (for connection to OpenVPN servers)
      • vpnc (for connection to Cisco servers)
    • PPTP
    • L2TP over IPsec (Cisco)
      • /etc/sysconfig/network-scripts/vpn.d/vpnc/nom_vpn_cisco.conf
        • IPSec gateway x.x.x.x
          IPSec ID nom_grup
          IPSec secret contrasenya_grup
          Xauth username nom_usuari
          Xauth password contrasenya_usuari
        • Note: it may be necessary to put the same value on nom_grup and nom_usuari; contrasenya_grup and contrasenya_usuari
      • # vpn-start vpnc nom_vpn_cisco
      • it calls vpnc
      • to debug:
        • /usr/sbin/vpnc /etc/sysconfig/network-scripts/vpn.d/vpnc/toto.conf --pid-file /var/run/vpnc-toto.pid --debug 2 --no-detach
      • Problemes / Problems:
        • vpnc[xxxx]: HMAC mismatch in ESP mode
          • Solució / Solution
            • use the latest svn version:
              • urpmi libgnutls-devel lib64gcrypt-devel
              • svn checkout http://svn.unix-ag.uni-kl.de/vpnc/trunk/ vpnc
              • cd vpnc
              • make
              • # make install
          • Solució / Solution
    • OpenVPN (SSL)
      • urpmi openvpn
      • /etc/sysconfig/network-scripts/vpn.d/openvpn/nom_openvpn.conf
        • client
          remote myremote.example.org 443
          capath /etc/pki/tls/rootcerts
          auth-user-pass nom_openvpn.txt
          ns-cert-type server
      • /etc/sysconfig/network-scripts/vpn.d/openvpn/nom_openvpn.txt
        • myname
          mypassword
      • chmod 400 /etc/sysconfig/network-scripts/vpn.d/openvpn/credentials.txt
      • # vpn-start openvpn nom_openvpn
      • it calls openvpn
      • to debug:
        • openvpn --config /etc/sysconfig/network-scripts/vpn.d/openvpn/nom_openvpn.conf ...
      • Problemes / Problems
    • PPP + SSL
      • openfortivpn
        • Instal·lació des de codi font / Installation from source code
          • Dependències / Dependencies
            • Mageia
              • sudo urpmi git gcc automake autoconf openssl-devel make pkg-config ppp
          • Passos / Steps
            1. cd ~src
            2. git clone https://github.com/adrienverge/openfortivpn.git
            3. cd openfortivpn
            4. ./autogen.sh
            5. ./configure --sysconfdir=/etc
            6. make
            7. sudo make install
        • Ús / Usage
          • sense fitxer de configuració
            • openfortivpn -v vpn-gateway:10443 --username=foo --password=bar --trusted-cert xxx
          • amb fitxer de configuració
            • /etc/openfortivpn/myconfig
              • host = vpn-gateway
                port = 10443
                username = foo
                password = bar
                # the value of xxx will be given as an advice the first time you run openfortivpn without it
                trusted-cert = xxx
            • openfortivpn -v -c /etc/openfortivpn/myconfig
        • Problemes / Problems
          • no es troben les pàgines web (perquè es fa servir el servidor DNS habitual, i no el nou, subministrat pel servidor VPN)
            • Solució / Solution
              • cal obrir el navegador després d'haver establert la VPN; no abans
              • cal canviar l'ordre en l'escriptura al fitxer /etc/resolv.conf, per a donar preferència als nous valors (la interfície ppp* ha de tenir preferència sobre les altres):
                • /etc/resolvconf/interface-order
                  • # interface-order(5)
                    lo.inet6
                    lo.inet
                    lo.@(dnsmasq|pdnsd)
                    lo.!(pdns|pdns-recursor)
                    lo
                    tun*
                    tap*
                    ppp*
                    em+([0-9])?(_+([0-9]))*
                    p+([0-9])p+([0-9])?(_+([0-9]))*
                    *
          • Cal deshabilitar el tallafoc
            • quins ports? De moment: tot, sense tallafoc
      • openfortigui
        • Instal·lació / Installation
          • Dependències / Dependencies 
            • Mageia
              • sudo urpmi git gcc automake autoconf openssl-devel make pkg-config ppp
          • Passos / Steps
            1. cd ~src
            2. git clone https://github.com/theinvisible/openfortigui.git
            3. cd openfortigui && git submodule init && git submodule update
            4. qmake && make -j4
            5. sudo ./openfortigui
        • Ús / Usage
          • ...

DHCP

  • urpmi dhcp-server
  • urpmi drakwizard-base drakwizard (MCC)
  • Manpage of dhcp.conf (fr)
  • MCC: Serveis de xarxa -> Configura DHCP
  • /etc/dhcpd.conf
    • DHCPD_INTERFACE = "eth1";
    • ddns-update-style none;
      subnet 192.168.0.0 netmask 255.255.255.0 {
              # default gateway
              option routers 192.168.0.1;
              option subnet-mask 255.255.255.0;

              option domain-name "domain.org";

              # Seting up an ip address is better here
              option domain-name-servers ns.domain.org;
              option nis-domain "domain.org";

              range dynamic-bootp 192.168.0.128 192.168.0.254;
              default-lease-time 21600;
              max-lease-time 43200;

              # we want the nameserver to appear at a fixed address
              host ns {
                      next-server fixed.domain.org;
                      hardware ethernet 12:34:56:78:AB:CD;
                      fixed-address 192.168.0.10;
              }
      }
  • service dhcpd start
  • LDAP
  • PXE

PXE

  • PXE boot on Mandriva
  • MediaMVP PXE config
  • PXE on VirtualBox
  • PXE Documentation: HOWTO setup a PXE 2.x server under Linux
  • urpmi tftp-server
  • /etc/dhcpd.conf
    • ddns-update-style none;
      subnet 192.168.1.0 netmask 255.255.255.0 {
      # default gateway
      option routers 192.168.1.12;
      option subnet-mask 255.255.255.0;

      option domain-name "xarxacasa.net";
      option domain-name-servers 192.168.1.12;

      range dynamic-bootp 192.168.1.21 192.168.1.253;
      default-lease-time 43200;
      max-lease-time 21600;

      host mvp1 {
      hardware ethernet 00:0d:fe:00:6c:39;
      fixed-address 192.168.1.30;
      filename "dongle.bin";
      }
      }
    • # for explanation in french go to : http://www.delafond.org/traducmanfr/man/man5/dhcpd.conf.5.html
      ddns-update-style none;
      allow booting;
      allow bootp;

      # Your dhcp server is not master on your network !
      #not authoritative;
      # Your dhcpd server is master on your network !
      authoritative;
      #not authoritative;

      #Interface where dhcpd is active
      DHCPD_INTERFACE = "eth1";

      # Definition of PXE-specific options
      # Code 1: Multicast IP address of bootfile
      # Code 2: UDP port that client should monitor for MTFTP responses
      # Code 3: UDP port that MTFTP servers are using to listen for MTFTP requests
      # Code 4: Number of secondes a client must listen for activity before trying
      #         to start a new MTFTP transfer
      # Code 5: Number of secondes a client must listen before trying to restart
      #         a MTFTP transfer

      # define Option for the PXE class
      option space PXE;
      option PXE.mtftp-ip code 1 = ip-address;
      option PXE.mtftp-cport code 2 = unsigned integer 16;
      option PXE.mtftp-sport code 3 = unsigned integer 16;
      option PXE.mtftp-tmout code 4 = unsigned integer 8;
      option PXE.mtftp-delay code 5 = unsigned integer 8;
      option PXE.discovery-control code 6 = unsigned integer 8;
      option PXE.discovery-mcast-addr code 7 = ip-address;

      #Define options for pxelinux
      option space pxelinux;
      option pxelinux.magic      code 208 = string;
      option pxelinux.configfile code 209 = text;
      option pxelinux.pathprefix code 210 = text;
      option pxelinux.reboottime code 211 = unsigned integer 32;
      site-option-space "pxelinux";
      # These lines should be customized to your setup
      #option pxelinux.configfile "configs/common";
      #option pxelinux.pathprefix "/pxelinux/files/";
      #filename "/pxelinux/pxelinux.bin";

      option pxelinux.magic f1:00:74:7e;
      option pxelinux.reboottime 30;
      #if exists dhcp-parameter-request-list {
              # Always send the PXELINUX options
      #       append dhcp-parameter-request-list 208, 209, 210, 211;
      #       append dhcp-parameter-request-list 208,211;
      #                                       }

      #Class that determine the options for Etherboot 5.x requests
      class "Etherboot" {

      #if The vendor-class-identifier equal Etherboot-5.0
      match if substring (option vendor-class-identifier, 0, 9) = "Etherboot";

      # filename define the file retrieve by the client, there nbgrub
      # our tftp is chrooted so is just the path to the file
      filename "/etherboot/nbgrub";

      #Used by etherboot to detect a valid pxe dhcp server
      option vendor-encapsulated-options 3c:09:45:74:68:65:72:62:6f:6f:74:ff;

      # Set the  "vendor-class-identifier" field to "PXEClient" in dhcp answer       
      # if this field is not set the pxe client will ignore the answer !
      option vendor-class-identifier "Etherboot";

      vendor-option-space PXE;
      option PXE.mtftp-ip 0.0.0.0;

      # IP of you TFTP server
      next-server 172.16.14.90;
      }


      # create the Class PXE
      class "PXE" {
      # if the "vendor-class-identifier" is set to "PXEClient" in the client dhcp request
      match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
       
      # filename define the file retrieve by the client, there pxelinux.0
      # our tftp is chrooted so is just the path to the file
      # If you prefer use grub, use pxegrub compiled for your ethernet card.
      #filename "/PXEClient/pxegrub";
      filename "/X86PC/linux/linux.0";

      # Set the  "vendor-class-identifier" field to "PXEClient" in dhcp answer
      # if this field is not set the pxe client will ignore the answer !
      option vendor-class-identifier "PXEClient";

                                       
      vendor-option-space PXE;
      option PXE.mtftp-ip 0.0.0.0;

      # IP of you TFTP server
      next-server 172.16.14.90;
      }

      # the class know exist just for deny the response to other DHCP request
      class "known" {
        match hardware;
        one-lease-per-client on;
        ddns-updates on;
        ddns-domainname = "";
        option domain-name "";
        option domain-name-servers  172.16.14.90;  
        ddns-hostname = pick-first-value(ddns-hostname, option host-name);
        option fqdn.no-client-update on;
        set vendor_class_identifier = option vendor-class-identifier;
      }

      # TAG: COMPUTER_LIST_BEGIN
      #host compute9{
      #    hardware ethernet 00:02:b3:3f:7e:b7;
      #    fixed-address compute9;
      # TAG: COMPUTER_LIST_END

      #  subnet 192.168.200.0 netmask 255.255.255.0 {
      subnet 172.16.14.0 netmask 255.255.255.0 {
        option subnet-mask 255.255.255.0;
        option routers 172.16.14.1;
        default-lease-time 28800;
        max-lease-time 86400;
        option domain-name "";
        option domain-name-servers  172.16.14.90;
        next-server 172.16.14.90;
        
          pool {
             range 172.16.14.129 172.16.14.254;
      #       deny members of "PXE";
      #       deny members of "Etherboot";
              }

      #   pool {
      #     range 192.168.200.200 192.168.200.254;
      # give an address of the the pool for PXE client and deny the other
      #allow members of "PXE";
      #deny members of "known";
      #allow members of "Etherboot";
      #        }
      }

gPXE

iPXE

VTigerCRM

  • Installation with LAMP
    • Cómo instalar y configurar vtiger CRM 5.0.x.
    • Install Apache
      • urpmi apache
    • Download and deploy VTiger (or checkout svn version)
    • Config PHP
      • urpmi apache-mod_php php-gd php-imap php-openssl php-curl php-mysql php-iconv
      • /etc/php.ini
        • allow_call_time_pass_reference = On
          error_reporting = ... E_WARNING & ~E_NOTICE
          safe_mode = Off
          display_errors = On
          file_uploads = On
          max_execution_time = 600
          memory_limit = 64M
          log_errors = Off
          output_buffering = On
          register_globals = Off
          short_open_tag = On
    • Config Apache
      • cd /var/www
      • chmod -R 775 vtigercrm
      • chown -R apache.apache vtigercrm
      • Create/etc/httpd/conf/webapps.d/vtigercrm.conf
        • Alias /vtigercrm /var/www/vtigercrm
          <Directory "/var/www/vtigercrm">
            Order allow,deny
            Allow from All
          </Directory>

          <Directory "/var/www/vtigercrm/bin">
            Order allow,deny
            Deny from All
          </Directory>
      • service httpd restart
    • Config MySQL
      • Assegureu-vos que heu establert la contrasenya de root / Make sure that root password has been set
      • Add database (vtigercrm540) and user (vtigeradmin):
        • mysql -u root -p
        • mysql> create database vtigercrm540;
        • mysql> grant all privileges on vtigercrm540.* to vtigeradmin@"localhost" identified by "some_password";
    • Config VTiger
      • Open http://localhost/vtigercrm
        • Database information:
          • Host name: localhost
          • User name: vtigeradmin
          • Database name: vtigercrm540
          • (disable) Create database
          • (?) Populate database with demo data
        • Espereu uns minuts... / Wait for some minutes...
  • Installation from SVN
  • Utilització / Usage
  • Problemes / Problems
    • Lead import blank page
    • PHP Warning:  Unknown: 1 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query() in Unknown on line 0
      • Solució / Solution
        • make sure that on /etc/php.ini you have the mysql.trace_mode set to off (not on):
          • mysql.trace_mode = Off
    • SMTP mail not working (5.4)

WebDAV

  • Apache WebDAV configuration
  • How To Set Up WebDAV With Apache2 On Mandriva 2009.1
  • How to set up WebDAV with Apache2 on Debian Etch
  • Servidor / Server
    • urpmi apache-mod_dav
    • mkdir -p /var/www/toto
    • chown apache:apache /var/www/toto
    • Add user test_user:
      • htpasswd -c /var/www/passwd.dav test_user
    • httpd.conf:
      • LoadModule dav_module modules/mod_dav.so
        LoadModule dav_fs_module modules/mod_dav_fs.so
        LoadModule dav_lock_module modules/mod_dav_lock.so
        Alias /toto /var/www/toto
        <Location /toto>
        Dav on
        AuthType Basic
        AuthName "toto_webdav"
        AuthUserFile /var/www/passwd.dav
        Require valid-user
        </Location>
        <Directory "/var/www/toto">
        Options -Indexes MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
        </Directory>
    • service httpd restart
  • Client
    • cadaver
      • urpmi cadaver
      • cadaver http://webdav_server/toto/
    • Nautilus
      • dav://webdav_server/toto/
    • Dolphin
      • webdav://server[:8080]/toto
    • Windows browser
      • \\server[:8080]\toto
    • davfs2
      • Instal·lació / Installation
        • Mageia
          • urpmi davfs2
        • Ubuntu
          • sudo apt-get install davfs2
      • /etc/fstab
        • # from Mageia
          http://webdav_server/toto/ /mnt/http davfs2 defaults 0 0
        • # from Ubuntu
          http://webdav_server/toto/ /mnt/http davfs defaults 0 0
      • /etc/davfs2/davfs2.conf
        • man davfs2.conf
      • /etc/davfs2/secrets
        • /mnt/http nom_ususari contrasenya
      • Problemes / Problems
    • fusedav

Wiki (mediawiki)

  • WikiMatrix
  • Instal·lació de Mediawiki 1.16.5 (/usr/share/doc/mediawiki-1.16.5/INSTALL):
    • urpmi mediawiki (/usr/share/doc/mediawiki/README.urpmi)
    • mediawiki-create /var/www/mediawiki
    • ln -s /usr/share/mediawiki/skins /var/www/mediawiki
    • /etc/httpd/conf/webapps.d/mediawiki.conf:
      • Alias /mediawiki /var/www/mediawiki
        <Directory "/var/www/mediawiki">
          Order allow,deny
          Allow from All
        </Directory>

        <Directory "/var/www/mediawiki/bin">
          Order allow,deny
          Deny from All
        </Directory>
    • /etc/httpd/conf/httpd.conf
      • <Directory "/var/www/mediawiki">
            Options -Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            Allow from all
        </Directory>
    • Check that MySQL is running
    • service httpd restart
    • open http://server_address/mediawiki/
      • Use superuser account: yes
      • prefix: mw_
    • cd /var/www/mediawiki/config; mv LocalSettings.php ..
    • Logo:
      • cp logotip.png /var/www/mediawiki/
      • LocalSettings.php
        • $wgLogo = "/mediawiki/logotip.png";
  • Upgrade to 1.16.5 (/usr/share/doc/mediawiki-1.16.5/UPGRADE, /usr/share/doc/mediawiki/README.urpmi)
    • mysql -u root -p < backup_mediawiki.sql
    • cp -pr /tmp/backup/var/www/mediawiki /var/www
    • cd /var/www/mediawiki
    • [cp LocalSettings.php LocalSettings.php.bo]
    • rm -f /var/www/mediawiki/{index.php,api.php,opensearch_desc.php}
      mediawiki-create /var/www/mediawiki
      rm -rf /var/www/mediawiki/config/
    • modify LocalSettings.php
      • if( defined( 'MW_INSTALL_PATH' ) ) {
            $IPLOCAL = MW_INSTALL_PATH;
        } else {
            $IPLOCAL = dirname( __FILE__ );
        }

        $IP = '/usr/share/mediawiki';
      • require_once( "$IPLOCAL/extensions/..."
    • cp AdminSettings.sample AdminSettings.php
    • modify AdminSettings.php:
      • $wgDBadminuser      = 'wgDBuser';
        $wgDBadminpassword  = 'wgDBpassword';
    • modify LocalSettings.php (*)
      • ## $wgDBTableOptions = "TYPE=InnoDB";
        $wgDBTableOptions = "ENGINE=InnoDB";
      • temporarilly modify:
        • $wgDBuser="root" (to have permissions to create new tables)
    • Modify /usr/sbin/mediawiki-updateall
      • #mw-createinstance "$path"
    • mediawiki-updateall (performs an update.php to each instance in /etc/mediawiki/instances)
    • Check that the user $wgDBuser (usually wikiuser) with password $wgDBpassword has access to database $wgDBname (usually wikidb) (all variables in LocalSettings.php.bo):
      • mysql -u wgDBuser -p
  • Instal·lació de Mediawiki (Cómo instalar MediaWiki en Mandriva Linux)
    1. urpmi mediawiki wget http://download.wikimedia.org/mediawiki/1.13/mediawiki-1.13.3.tar.gz (mediawiki-1.15.1-1mdv2010.0.noarch.rpm)
    2. /etc/httpd/conf/webapps.d/mediawiki.conf:
      • Alias /mediawiki /var/www/mediawiki
        <Directory "/var/www/mediawiki">
          Order allow,deny
          Allow from All
        </Directory>

        <Directory "/var/www/mediawiki/bin">
          Order allow,deny
          Deny from All
        </Directory>
    3. Check that MySQL is running
    4. open http://server_address/mediawiki/
      • Use superuser account: yes
      • prefix: mw_
    5. mv /var/www/mediawiki/config/LocalSettings.php /var/www/mediawiki/
    6. Open http://localhost/mediawiki/index.php
  • Upgrade Mediawiki
    • ssh user@server
    • cd /var/www/mediawiki/
    • mv LocalSettings.php LocalSettings.php.old
    • firefox -no-remote http://server_address/mediawiki/config/index.html
      • Use superuser account
      • prefix: mw_
  • PHP debug
  • Servidor de correu / Mail server
  • Llengües
  • Configuració / Configuration
    • Alphabetical list of parameters
    • /var/www/mediawiki/LocalSettings.php
      • if( defined( 'MW_INSTALL_PATH' ) ) {
            $IPLOCAL = MW_INSTALL_PATH;
        } else {
            $IPLOCAL = dirname( __FILE__ );
        }

        $wgExtraNamespaces = array(
                   100 => "NewName1",
                   101 => "NewName1_Discussion",
                   102 => "NewName2",
                   103 => "NewName2_Discussion",
                   );

        # no es permeten edicions anònimes
        $wgGroupPermissions['*']['edit'] = false;

        # extensions de fitxers que es poden pujar
        $wgFileExtensions = array_merge($wgFileExtensions, array('doc', 'xls','mpp', 'pdf', 'svg', 'zip'));

        #<math>
        $wgUseTeX = true;

        #permet el protocol file://
        $wgUrlProtocols[] = "file:";

        # per a debugar
        $wgShowExceptionDetails = true;

        # permet referències a imatges externes
        $wgAllowExternalImages = true;
  • Usuaris / Users
  • Aplicacions
    • mwlib (Python) (PediaPress)
      • urpmi python-setuptools libpython-devel gcc-c++ python-imaging libxslt-devel python-reportlab python-pygments 
      • easy_install mwlib
      • easy_install mwlib.rl (per a generar pdf) (readme.txt)
      • Problems:
      • Examples
        • mw-render --list-writers
        • mw-render --config=http://localhost/mediawiki/ --writer=rl --output=./p.pdf Pàgina_Principal
      • Configuració
        • pdf
          • /usr/lib/python2.x/site-packages/mwlib.rl-0.aa.bb-py2.x.egg/mwlib/rl/pdfstyles.py
            • titlepagefooter = _(u'Peu de pàgina del títol')
            • pagefooter = _(u'Peu de pàgina')
            • show_creation_date = False
            • show_article_attribution = False (without "Article Sources and Contributors" and "Image Sources, Licenses and Contributors" sections)
        • odf
          • /usr/lib/python2.x/site-packages/mwlib-0.cc.dd-py2.x-linux-i686.egg/mwlib/odfstyles.py
  • Plantilles / Templates
  • Extensions
    • Collection / Pdf Writer (es necessita mwlib, mwlib.rl) (readme.txt)
      • Help
      • mw-serve -i localhost(engega el servidor mwlib per a ser accedit des de l'API de mediawiki) (el nom del servidor, en aquest cas localhost, ha de ser coherent amb el valor indicat a$wgCollectionMWServeURL)
        • per a fer-ho de forma automàtica quan engega l'ordinador:
      • urpmi php-curl
      • cd /var/www/mediawiki/extensions
      • svn co http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/Collection
      • /var/www/mediawiki/LocalSettings.php
        • require_once("$IP/extensions/Collection/Collection.php");
        • $wgCollectionMWServeURL = "http://localhost:8899";
        • $wgCollectionFormats = array(
                     'rl' => 'PDF',
                     'odf' => 'ODT',
                 );
      • open port: 8899/tcp
      • /var/www/mediawiki/skins/MonoBook.php
        • <?php
          if(isset($GLOBALS['wgSpecialPages']['Book'])) {
          Collection::printPortlet();
          }
          ?>
      • Hauríeu de veure una nova capseta a l'esquerra, sobre la capseta "eines", anomenada "create a book". Si no es veu, buideu la memòria cau del vostre navegador
      • Comprovació:
        • wget "http://localhost/mediawiki/index.php?title=Especial:Book/render_article/&arttitle=Pàgina_principal&oldid=2&writer=rl"
        • wget "http://localhost/mediawiki/index.php?title=Especial:Book/render_article/&arttitle=Pàgina_principal&oldid=2&writer=odf"
        • Si hi ha error del tipus 500, verifiqueu
          • tail /var/log/httpd/error_log
      • Problems
        • Fatal error: Unsupported operand types in .../extensions/Collection/Collection.php on line 192
          • Solution:
            • get a previous version:
              • svn co -r 79875 http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/Collection/
    • Bibwiki (*) (*)
      • urpmi php-mbstring
      • Download the latest image (0.99e-rc1)
      • Afegiu les entrades a 'ca' al fitxer Bibwiki.i18n.php (copieu-les de 'en')
        • haureu d'accedir a la pàgina especial: mediawiki/index.php/Especial:Bibliography
      • cp BibwikiSettings.Default.php BibwikiSettings.php
      • Settings: /var/www/mediawiki/extensions/<bibwiki_path>/BibwikiSettings.php (copy BibwikiSettings.Default.php)
        • $wgBibPath = '/var/www/mediawiki/bib';
        • $wgDefaultBib = 'my.bib';
        • Export
          • urpmi tetex (/usr/bin/bibtex)
          • Exporting via BibTeX
          • $wgEnableExport = true;
          • $wgBibTeXExecutable = '/usr/bin/bibtex';
          • $wgTempDir = '/tmp';
          • $wgBibStyles = array('plain', 'abbrv','ieeetr'); (styles available under /usr/share/texmf/bibtex/bst or /usr/share/texmf-dist/bibtex/bst/base/)
      • Afegir / Add InProceedings:
        • Bibwiki.body.php:
          • elseif ($wgRequest->getVal("type") == "InProceedings") {
                                   $wgOut->addHTML("@".$wgRequest->getVal("type")."{*,\n");
                                   $wgOut->addHTML('author = '.$wgValueDelimLeft.$wgValueDelimRight.','."\n");
                                   $wgOut->addHTML('title = '.$wgTitleDelimLeft.$wgTitleDelimRight.','."\n");
                                   $wgOut->addHTML('titleaddon = '.$wgTitleDelimLeft.$wgTitleDelimRight.','."\n");
                                   $wgOut->addHTML('booktitle = '.$wgTitleDelimLeft.$wgTitleDelimRight.','."\n");
                                   $wgOut->addHTML('year = '.$wgValueDelimLeft.$wgValueDelimRight.','."\n");
                                   $wgOut->addHTML('pages = '.$wgValueDelimLeft.$wgValueDelimRight.','."\n");
                                   $wgOut->addHTML('address = '.$wgValueDelimLeft.$wgValueDelimRight.','."\n");
                                   $wgOut->addHTML('note = '.$wgValueDelimLeft.$wgValueDelimRight.','."\n");
                                   $wgOut->addHTML('keywords = '.$wgValueDelimLeft.$this->mFilter.$wgValueDelimRight.','."\n");
                                   $wgOut->addHTML('bibdate = '.$wgValueDelimLeft.strftime($wgDateTimeFormat,time()).$wgValueDelimRight.",\n");
                                   $wgOut->addHTML("}");
                           }
          • print('<li><a href="'.Bibliography::getLocalURL(array('view='.$wgRequest->getVal("view"), 'action=new', 'type=InProceedings', $bibquery, $keywordquery)).'">'.wfMsg('bibwiki_inproceedings').'</a></li>');
        • Bibwiki.i18n.php, for each language:
          • "bibwiki_inproceedings" => "Inproceedings",
      • Problemes / Problems
        • The style file: plain.bst
          I couldn't open database file toto.bib
        • "Program doesn't seem to be BibTeX. Check the output and $wgBibTeXExecutable in BibwikiSettings.php.
          Output of the program:
          I couldn't open file name `/tmp/bibexport.blg'"
          • Solution:
            • /usr/share/texmf/web2c/texmf.cnf (*)
              • openout_any = a
        • Problems with accents at exported text.
          • Solution: modify /var/www/mediawiki/extensions/Bibwiki-0.99d/Bblfile.php
            • elseif ($cmd == "'" and $arg != "" and stristr('aeiouy', $arg) !== false)
                          return '&'.$arg.'acute;';
              elseif ($cmd == "`" and $arg != "" and stristr('aeiouy', $arg) !== false)
                          return '&'.$arg.'grave;';
        • "Too many commas in name..."
          • Solution: modify the entry so as there is the word "and" to separate author names.
        • "No es troba la pàgina especial que busqueu"
          • comproveu el nom en català (sota l'apartat 'ca') que figura a Bibwiki.i18n.php
          • proveu amb mediawiki/index.php/Especial:Bibliography
    • Cite (references as footnotes)
    • Cerca / Search
      • SphinxSearch
        • urpmi sphinx
        • download SphinxSearch-0.6.1 to /tmp/SphinxSearch-0.6.1
          • sphinx.conf
            • sql_user =... (same as in LocalSettings.php)
            • sql_pas = ... (same as in LocalSettings.php)
            • sql_db = ... (same as in LocalSettings.php)
            • check sql_query sql_query_info (prefix coherent with $wgDBprefix in LocalSettings.php)
            • morphology    = stem_ca (?)
          • mkdir /var/data/ /var/data/sphinx 
          • sphinx-indexer --config sphinx.conf --all
          • search --config sphinx.conf "paraula"
          • crontab -e:
            • tototototot
        • mkdir /var/www/mediawiki/extensions/SphinxSearch
        • cp /usr/share/doc/sphinx/api/sphinxapi.php /var/www/mediawiki/extensions/SphinxSearch
        • cd /var/www/mediawiki/extensions/SphinxSearch
        • svn export http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/ExtensionFunctions.php
        • mv /tmp/SphinxSearch-0.6.1/sphinx.conf /etc/sphinx/
        • cp /tmp/SphinxSearch-0.6.1/* /var/www/mediawiki/extensions/SphinxSearch/
        • service sphinx-searchd restart
        • LocalSettings.conf
          • require_once( "$IP/extensions/SphinxSearch/SphinxSearch.php" );
        • minus sign:
    • Editors WYSIWYG
    • Semantic mediawiki
  • math / LATeX
    • urpmi make ocaml
    • cd mediawiki/math
    • make
  • Edició / Edition

Wordpress

Zotero

http://www.francescpinyol.cat/utilitats.html
Darrera modificació: 28 de febrer de 2024 / Last update: 28th February 2024

Cap a casa / Back home.