Memcachedb & logs

Well, the memcachedb again ate whole sshd with infinite log.xxxxxxsomething files.

After a lot of digging around, found this memcachedb-guide-1.0. It appeared that memcachedb has db_archive command to purge all un-needed logs!

Just create a following file somewhere, e.g. /root/memcachedb_rotate_logs:

db_archive
quit

and add following to crontab to rotate memcachedb logs hourly:

0 * * * * /usr/bin/telnet localhost 21201 < /root/memcachedb_rotate_logs

(fix port number if needed).

Redmine rack initscript

Seems like the only normal way to run redmine is with rack

 
ruby script/server -e production
 

and this simple initscript:

 
#!/bin/bash
### BEGIN INIT INFO
# Provides:          redmine
# Required-Start:    $local_fs $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Redmine issue tracker
### END INIT INFO
 
case "$1" in
    start)
      cd /var/www/redmine/
      /usr/bin/ruby script/server -d -e production
    ;;
    stop)
      kill -9 `ps aux | grep "ruby script/server" | awk '{ print $2 }' | head -n 1`
    ;;
esac
 

mograil / passenger sucks beyond understanding

Bash: how to copy permissions recursively

Imagine you were copying an, eg, virtual server from /server to /newserver, and messed permissions in /etc; thre's a way to copy permissions with this simple script:

 
#!/bin/bash
 
source=$1
target=$2
 
echo "Copy files from $source to $target"
 
cd $source
files=`find $source`
 
for file in $files
do
  #this is some bash voodoo - string part replacement
  targetFile=$target${file#$source}
  #stat command can accept -c parameter and return data in needed format
  #where %u and %g are numeric user/group ids, and %a - octal permissions
  permissions=`stat -c%a $file`
  ownership=`stat -c%u:%g $file`
  echo $targetFile to $ownership $permissions
  chmod $permissions $targetFile
  chown $ownership $targetFile
done
 

invoke this like

 
./permissions.sh /server/etc /newserver/etc
 

change %u:%g to %U:%G if you prefer string id's (www-data:www-data) more than numeric (0:0)

ActiveMQ initscript

A quick'n'dirty ActiveMQ initscript, if activemq extracted to /opt/activemq.
Enable with

update-rc.d activemq defaults

, LSB-tags present.

 
#! /bin/sh
### BEGIN INIT INFO
# Provides:          activemq
# Required-Start:    $local_fs $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# ActiveMQ message broker
### END INIT INFO
 
case "$1" in
  start)
          /opt/activemq/bin/activemq start > /dev/null
          if [ $? -eq 0 ]
          then
                  echo "Started ok!"
          else
                  echo "Start error, try /opt/activemq/bin/activemq start"
          fi
          ;;
  stop)
          /opt/activemq/bin/activemq stop > /dev/null
          if [ $? -eq 0 ]
          then
                  echo "Stopped ok!"
          else
                  echo "Stop error, try /opt/activemq/bin/activemq stop"
          fi
          ;;
  status)
    if [ `/opt/activemq/bin/activemq list | grep "Connection refused" | wc -l` -eq 0 ]
    then
      echo "Running and connected, web-interface on port 8161"
    else
      echo "Not running or connection refused"
    fi
    ;;
  restart)
    echo "Stopping..."
    /opt/activemq/bin/activemq stop > /dev/null
    echo "Starting..."
    /opt/activemq/bin/activemq start > /dev/null
    if [ `/opt/activemq/bin/activemq list | grep "Connection refused" | wc -l` -eq 0 ]
    then
      echo "Running and connected, web-interface on port 8161"
    else
      echo "Not running or connection refused"
    fi
    ;;
  *)
          echo "Usage: $0 start|stop|status|restart" >&2
          exit 3
          ;;
esac
 

Gitosis setup step-by-step

Just to remember how to setup this )
Via scie.nti.st

Put your admin key in /tmp/id_rsa.pub

 
apt-get install gitosis
sudo adduser \
    --system \
    --shell /bin/sh \
    --gecos 'git version control' \
    --group \
    --disabled-password \
    --home /var/git \
    git
sudo -H -u git gitosis-init < /tmp/id_rsa.pub
 

fetch admin

 
git clone git@YOUR_SERVER_HOSTNAME:gitosis-admin.git
cd gitosis-admin
 

config file cheat sheet:

 
[group officeworkers]
members = john ken barbie
writable = repo1
readonly = repo2 repo3
 

...and just add/commit/push admin.

Hp-setup

Инсталляция принтера Canon в Linux:
- фтыкаешь
- линукс такой "ааааа! принтер! вкусне сладке принтер!"
- работаешь

Инсталляция принтера HP в Linux:
- фтыкаешь
- ничего
- перефтыкаешь
- определяется, но не работает
- запускаешь hp-setup
- виснет
- запускаешь kdesudo hp-setup
- виснет на next
- через полчаса предлагает лениво скачать дравер
- думаешь качет? фуй, оно полчаса рисует окно с лицензией
- временем на две сигареты инсталлится
- принтер жалобно мигает лампочками
- может быть печатает