Posts Tagged ‘remote’

fastest way to get git server

September 17th, 2009 Comments off

I was searching for a fast and easy way to setup git server, and I found one, but I was not fully happy with it, so lets have a look on another way:

ssh -C "mkdir -p repos/library2.git; cd repos/library2.git; git --bare init"
git clone
cd library2/
touch test.txt
git add .
git commit -a -m "1st"
git push origin master

This is good way to keep Your private repo, just as central repo or backup, no packages needed, just git on both sides

The same can be done on local filesystem like shared storage(nfs or smb):

cd /remote
mkdir test.git
cd test.git/
git --bare init
git clone /remote/test.git/
cd test/
touch test.txt
git add .
git commit -a -m "1st"
git push origin master

From now on it will be working by simply calling “git pull” and “git push”.

Categories: Hosting, Linux Tags: , ,

easy capistrano remote invocation

May 6th, 2009 Comments off

Today I was coding just for fun … and wrote my own Capistrano script for deployment, during this I have found great way to invoke remote tasks.

The method is easy, add following code to your config/deploy.rb file:

set :sudo_call, ''
desc 'makes remote/rake calls to be executed with sudo'
task :use_sudo do
  set :sudo_call, 'sudo'

desc 'run rake task'
task :rake do
  ARGV.values_at('rake')+1,-1)).each do |task|
    run "cd #{current_path}; #{sudo_call} RAILS_ENV=production rake #{task}"

desc 'run remote command'
task :remote do
  run "cd #{current_path}; #{sudo_call} RAILS_ENV=production #{command*' '}"

desc 'run specified rails code on server'
task :runner do
  run "cd #{current_path}; RAILS_ENV=production script/runner '#{command*' '}'"

Now try your new tool with following commands:

cap rake db:migrate
cap use_sudo rake db:migrate
cap remote "tail -n 10 log/production.log"
cap use_sudo remote cat /etc/passwd
cap runner p User.all
cap runner "User.all.each{ |u| p u }"

In the third call I have used parentheses to hide “-n” form Capistrano, because it is its parameter, to see whole list of Capistrano parameters call it with “cap –help”. For the last command I have used parentheses again because now it contained bash special characters.

Did You liked this post or maybe not, vote on it at dzone.

Categories: Development, Linux Tags: , , , ,