JerzySeweryn

personal notes

Maven deploy with ftp

in

vim ~/.m2/settings.xml

add

  <settings>
    ...
    <servers>
      <server>
        <id>ftp-repository</id>
        <username>user</username>
        <password>pass</password>
      </server>
    </servers>
  </settings>

in project file:

vim pom.xml

add

  ...
  </dependencies>
  ...
  <distributionManagement>
   <repository>
   <id>ftp-repository</id>
   <url>ftp://ftpServerA.com</url>
   </repository>
  </distributionManagement>
  ...
  <build>
      <extensions>
        <extension>
          <groupId>org.apache.maven.wagon</groupId>
          <artifactId>wagon-ftp</artifactId>
          <version>1.0-alpha-6</version>
        </extension>
      </extensions>
  </build>
  ...
mvn deploy

link: http://maven.apache.org/plugins/maven-deploy-plugin/examples/deploy-ftp.html

Ssh keys authorization

  // generujemy swój klucz ssh
  ssh-keygen
  //na wszystkie pytania odpowiadamy enterem
  //wynik otrzymujemy w:
  ~/.ssh$ ls -al
  id_rsa // klucz prywatny
  id_rsa.pub // klucz publiczny
  //kompiujemy klucz publiczny na serwer
  scp ~/.ssh/id_rsa.pub remoteuser@remotehost:~/
  //dopisujemy go kluczy na serwerze
  cat id_rsa.pub >> ~/.ssh/authorized_keys
  //usuwamy plik na serwerze
  rm id_rsa.pub
  //włączamy autoryzację po kluczach w
  sudo vim /etc/ssh/sshd_config
  RSAAuthentication yes
  PubkeyAuthentication yes
  //restartujemy ssh na serwerze
  /etc/init.d/ssh reload
  //teraz logując się po ssh na serwer nie będzie pytania o hasło ;-)
  

Screen tips

* Uruchamimay program w screen.

screen -S torrent rtorrent
screen <opcje> <parametry> <nazwa programu>

* Wyście ze screen’a:

  ctrl + a, d

* Powrót do screen’a:

  screen -x torrent

* Lista screen’nów:

  screen -list

* Powrót do screen’a z listy:

  screen -x 31234

* Po uruchomieniu pierwszego screen’a jesteśmy w konsoli 0;
* Aby otrzymać następną konsolę w screen’ie robimy:

  ctrl + a, c

* Przełączamy się między konsolami przy pomocy:

  ctrl + a, #
  // # - oznacza numer konsoli

* Aby usunąć konsolę:

  exit

Adobe AIR automatic updates

main Application:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="checkForAppUpdate()">
     <mx:Script>
          <![CDATA[
               import air.update.events.UpdateEvent;
               import air.update.ApplicationUpdaterUI;
               private var appUpdater:ApplicationUpdaterUI = new ApplicationUpdaterUI;
               // checks to see if an updated version of the app is up.
               private function checkForAppUpdate():void
               {
                    appUpdater.configurationFile = new File(app:/updateConfig.xml);
                    appUpdater.isCheckForUpdateVisible = false;
                    appUpdater.initialize();
                    appUpdater.addEventListener(UpdateEvent.INITIALIZED, onUpdate);
                    appUpdater.addEventListener(ErrorEvent.ERROR, onError);
               }
               // if there's an error to the update show an alert
               private function onError(event:ErrorEvent):void
               {
                    Alert.show(event.toString());
               }
               // check to see if updated is needed
               private function onUpdate(event:UpdateEvent):void
               {
                    appUpdater.checkNow();
               }
          ]]>
     </mx:Script>
</mx:WindowedApplication>

* updateConfig.xml (with your src, compiled at build):

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns="http://ns.adobe.com/air/framework/update/configuration/1.0">
<url>http://somewhereOnTheInternet.com/aDirectory/aDirectory/appUpdate.xml</url>
<delay>0.5</delay>
<defaultUI>
          <dialog name="checkForUpdate" visible="false" />
          <dialog name="downloadUpdate" visible="false" />
          <dialog name="downloadProgress" visible="false" />
          <dialog name="installUpdate" visible="false" />
          <dialog name="fileUpdate" visible="false" />
          <dialog name="unexpectedError" visible="true" />
     </defaultUI>
</configuration>

Delay is per day. .5 is half day, .02 = half an hour.

appUpdate.xml (to be placed somewhere on your site):

<?xml version="1.0" encoding="utf-8"?>
     <update xmlns="http://ns.adobe.com/air/framework/update/description/1.0">
          <version>v1.0</version>
          <url>http://somewhereOnTheInternet.com/aDirectory/aDirectory/myApplication.air</url>
          <description>
               <![CDATA[
               This is where your description goes.
               ]]>
          </description>
     </update>

link: http://forums.adobe.com/thread/483482

Set up together Thunderbird, Google Calendar, Remember The Milk

Manage Google Calendar and Remember The Milk in Mozilla Thunderbird.

Install this plugings:

Lightning Plugin for Thunderbird: http://www.mozilla.org/projects/calendar/lightning/

Google Calendar Provider: https://addons.mozilla.org/en-US/thunderbird/addon/4631

RTM: https://addons.mozilla.org/en-US/sunbird/addon/7125

more info about Google Calendar and Mozilla Thunderbird: http://ubuntuforums.org/showthread.php?t=540330

Instalacja Redmine with Apache, Ruby Enterprise, Phusion Passenger

wget http://rubyforge.org/frs/download.php/57098/ruby-enterprise_1.8.6-20090520_i386.deb
wget http://rubyforge.org/frs/download.php/56909/redmine-0.8.4.tar.gz

sudo apt-get install apache
sudo apt-get install  build-essential apache2-prefork-dev libapr1-dev

sudo dpkg -i ruby-enterprise_1.8.6-20090520_i386.deb

sudo -i
export PATH=/opt/ruby-enterprise/bin:$PATH
passenger-install-apache2-module

Tworzymy plik /etc/apache2/mods-available/passenger.load o treści:

LoadModule passenger_module /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.2/ext/apache2/mod_passenger.so

oraz /etc/apache2/mods-available/passenger.conf o treści:

PassengerRoot /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.2
PassengerRuby /opt/ruby-enterprise/bin/ruby

a potem aktywujemy stworzone moduły przez

sudo a2enmod passenger
1
Instalacja redmine
1
$ cd /apps
$ sudo tar xzvf ~/redmine-0.8.4.tar.gz
$ sudo ln -s redmine-0.8.4 redmine
$ sudo chown -R www-ruby.www-ruby redmine/public redmine/log redmine/config

Tworzymy bazę danych i jej właściciela

$ sudo -u postgres createuser \ --no-superuser --no-createdb --no-createrole --pwprompt \ redmine $ sudo -u postgres createdb \ --encoding utf-8 --owner redmine redmine "Redmine"

Weryfikujemy poprawność składni dat:

$ psql --user redmine redmine redmine=> SHOW DATESTYLE;

i jeśli wyjdzie coś innego niż ISO, MDY, robimy:

redmine=> ALTER DATABASE "redmine" SET datestyle="ISO,MDY";

W katalogu redmine/config edytujemy database.yml, które może wyglądać tak:

production: adapter: postgresql database: redmine host: localhost username: redmine password: hasloPodanePrzyCreateUser encoding: utf8
1
a także email.yml:
1
production: delivery_method: :smtp smtp_settings: address: firmowy.serwer.smtp port: 25 domain: nasza.firma.pl # authentication: :login # user_name: user_smtp # password: haslo_smtp

Stworzenie lub upgrade bazy danych
Po prostu

$ cd /apps/redmine $ rake db:migrate RAILS_ENV="production"

Jeżeli jest to nowa instalacja, odpalamy także:

$ rake redmine:load_default_data RAILS_ENV="production"

Wersje Redmine nowsze niż 0.8.* (tj. w tej chwili trunk) wymagają też

$ rake config/initializers/session_store.rb

Standardowo tworzymy /etc/apache2/sites-available/redmine, np.

    NameVirtualHost *:9090

      ServerName nasz.serwer:9090
      ServerAdmin "Jan.Kowalski@firma.com"
      DocumentRoot /apps/redmine/public

      ErrorLog /var/log/apache2/redmine-error.log
      LogLevel info

po czym aktywujemy wirtualny serwer przez

$ sudo a2ensite redmine

Musimy też poprawić lub usunąć plik redmine/public/.htaccess! W domyślnej formie odpowiada on uruchamianiu aplikacji przez cgi lub FastCGI, działaniu w Phusion Passengerze znajdujące się tam dyrektywy Rewrite najzwyczajniej szkodzą (błędy 404 przy próbie używania aplikacji). Jeśli nie chcemy usuwać .htaccess, trzeba przynajmniej zakomentować - jak niżej - regułki

#RewriteRule ^$ index [QSA] #RewriteRule ^([^.]+)$ $1.html [QSA]

Ustawienia dla wirtualnych hostów aby project.wlasnaDomena.com.pl redmine.wlasnaDomena.com.pl były skierowne na ip:

NameVirtualHost 192.168.4.2
<virtualhost>
  ServerName remine.domenaA.com
  ServerAdmin "Jan.Kowalski@firma.com"
  DocumentRoot /home/login/apps/redmine/public

  ErrorLog /var/log/apache2/redmine-error.log
  LogLevel info
</virtualhost>
<virtualhost>
  DocumentRoot /home/login/apps/proj
  ServerName myproj.domenaB.com
</virtualhost>
$ sudo invoke-rc.d apache2 restart